1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-06-29 20:51:44 +02:00
Commit graph

81 commits

Author SHA1 Message Date
Ken Werner 059676cb00 Prevent the use of struct dl_phdr_info outside of dl_iterate_phdr
Since the dl_iterate_phdr is required for local unwinding only the use of
struct dl_phdr_info can be eliminated in case libunwind gets compiled for
remote unwinding. This enhances libunwinds portability to targets that
don't provide any dl_iterate_phdr functionality.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-10-29 17:12:43 -07:00
Ken Werner 0fed502a81 UNW_REMOTE_ONLY fixes
Exclude <link.h> because it is only required for local unwinding when
iterating over the program headers.

Have the following DWARF related functions available in case of
UNW_REMOTE_ONLY because they are used by libunwind-ptrace:
  dwarf_find_debug_frame
  locate_debug_info
  find_binary_for_address
  load_debug_frame
  debug_frame_tab_new
  debug_frame_tab_append
  debug_frame_tab_shrink
  debug_frame_tab_compare

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-10-29 17:12:43 -07:00
Ken Werner 545023c207 Rework the lookup of the ARM specific unwind info
Implement routines for finding the proc_info and searching the unwind table
for the ARM backend.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-08-15 20:12:54 +02:00
Ken Werner 0b9f591823 Make the dwarf dl_iterate_phdr callback available within libunwind.
Rename the dwarf dl_iterate_phdr callback routine and the callback_data
structure to dwarf_callback and dwarf_callback_data. Make it available
within libunwind by declaring the two at the dwarf.h header file.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-08-15 20:12:54 +02:00
Lassi Tuura 9e98f15e9a Fast back-trace for x86_64 for only collecting the call stack.
Adds new function to perform a pure stack walk without unwinding,
functionally similar to backtrace() but accelerated by an address
attribute cache the caller maintains across calls.
2011-03-24 22:33:17 -07:00
Arun Sharma 46e10c5abe Support .debug_frame based unwinding in _UPTi_find_unwind_table()
Signed-off-by: Andris Zeila <andris.zeila@accenture.com>
2010-05-26 19:25:41 -07:00
Arun Sharma 546463d1e7 Factor out and export dwarf_find_debug_frame() function
Signed-off-by: Andris Zeila <andris.zeila@accenture.com>
2010-05-26 19:21:30 -07:00
Arun Sharma b115ab645a Ignore separate debug files which contain a .gnu_debuglink section.
Current implementation fails to find separate debug symbols when
.gnu_debuglink is set to the same name of the target ELF basename
(e.g. "libc.so.6" for /lib/libc.so.6). This patch fixes this by ignoring
separate debug files that contain a .gnu_debuglink section.

It also fixes a small typo in a related Debug() line.

Signed-off-by: Andris Zeila <andris.zeila@accenture.com>
2010-05-15 11:57:35 -07:00
Lassi Tuura a9dce3c06e During the stack unwinding process, the return address points to
the instruction after the call for a normal frame. libunwind uses
IP-1 to lookup unwind information. However, this is not necessary for
interrupted frames such as signal frames (or interrupt frames) in
the kernel context.

This patch handles both cases correctly.

Based on work by Mark Wielaard <mwielaard@redhat.com>
2010-04-24 19:16:09 -07:00
Lassi Tuura 4c553ceb2c Identify end-of-stack by undefined return address location. 2010-04-24 17:18:31 -07:00
Lassi Tuura dac2d001af Identify signal frames by augmentation attribute. 2010-04-24 17:18:26 -07:00
Lassi Tuura 250382c56d Use wider format when printing addresses in debug format. 2010-04-24 17:18:19 -07:00
Arun Sharma 7bd264e292 Fix up what looks like an unintentional semi colon.
Thanks to Lassi Tuura for noticing it.
2010-03-23 10:37:21 -07:00
Paul Pluzhnikov 9626d66019 Fix a race condition in dwarf unwinding.
Original code was accessing rs_cache memory without holding a lock
in some cases. If there was sufficient cache pressure, entry being
accessed may be overwritten by another thread, resulting in a data
race.

We now make a thread local copy of the data, before releasing the
lock. If we end up supporting UNW_CACHE_PER_THREAD properly
in the future, this memcpy should be unnecessary.
2009-11-24 15:18:48 -08:00
Paul Pluzhnikov 2648a77f04 Simplify control flow
Greetings,

Attached patch gets rid of additional unnecessary branch (rs_get_cache
can not return NULL unless caching_policy is UNW_CACHE_NONE), gets rid of
goto's, and makes apply_reg_state (major CPU consumer) execute with cache
lock not held (before the patch, apply_reg_state was called with lock held
for newly-inserted entries, but not for found-in-cache entries).

Tested on Linux/x86_64 with no regressions.

Thanks,
--
Paul Pluzhnikov
2009-11-20 12:04:13 -08:00
Paul Pluzhnikov f958b9dc4f Get rid of some bogus checks.
Greetings,

Attached patch is rather on the obvious side:
- rs1 can't be NULL since it's assigned on previous line
- rs_new never returns NULL, and if it ever did, we'd crash on memcpy that
  preceeds the NULL check.

Tested on Linux/x86_64 with no regressions.

Thanks,
--
Paul Pluzhnikov
2009-11-20 11:40:05 -08:00
Arun Sharma d7089547e2 Fix a warning message on i386
Without this, we may be accessing data beyond the array bounds.
2009-10-23 22:38:11 -07:00
Arun Sharma 491d576529 Fix compiler warnings on x86_64 2009-10-16 14:01:50 -07:00
Paul Pluzhnikov b56375e76a Reduce stack use and apply CONFIG_DEBUG_FRAME to more code.
Currently, libunwind allocates several PATH_MAX entries on stack, while
trying to find a binary via /proc/.../maps.

However stack space may be at premium (especially when sigaltstack is used),
and PATH_MAX on Linux is 4096, while SIGSTKSZ is only 8192 on x86.

Attached patch eliminates multiple PATH_MAX stack allocations, and simplifies
code in maps_next, at the cost of being unable to do anything if we can't
mmap one page. It appears to me that under such low-memory conditions,
libunwind will fail shortly elsewhere anyway.

This patch also disables more of debug_frame-handling code when
CONFIG_DEBUG_FRAME is undefined.

Tested on Linux/x86_64 with and without CONFIG_DEBUG_FRAME, no regressions.
2009-10-07 12:51:03 -07:00
Paul Pluzhnikov fc2934aade Make the remaining sigprocmask calls conditional on --enable-block-signals 2009-09-29 23:14:50 -07:00
Paul Pluzhnikov 839db77b7b Wait if there is contention on the cache
The behavior on wait vs abort unwind depends on the locking primitive
chosen by the user. This makes the API consistent and independent of
the locking primitive.
2009-09-25 09:38:55 -07:00
Paul Pluzhnikov 84d4150668 Allow caller to block signals.
Greetings,

We use libunwind just for stack traces (I suspect many others do as well).

The use pattern is:

GetStackTrace(void** result, int max_depth)
{
...
  unw_getcontext(&uc);
  unw_init_local(&cursor, &uc);

  while (n < max_depth) {
    if (unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *) &ip) < 0) {
      break;
    }
    result[n++] = ip;
    if (unw_step(&cursor) <= 0) {
      break;
    }
  }

Given this usage, it is quite convenient for us to block signals (or
prevent signal handlers from re-entering libunwind by other means) at the
"top level", which makes most of the sigprocmask calls performed by
libunwind itself unneccessary.

The second patch in this series adds a configure option which removes most
of the sigprocmask calls.

Attached patch is a preliminary for it -- consolidating all of the
"sigprocmask; mutex_lock;" sequences into lock_acquire and "mutex_unlock;
sigprocmask;" sequences into lock_release.

Thanks,
--
Paul Pluzhnikov

commit 402d15b123d54a7669db7cf17a76dd315094e472
Author: Paul Pluzhnikov <ppluzhnikov@google.com>
Date:   Mon Sep 21 10:18:28 2009 -0700

    Replace "sigprocmask + mutext_lock" with a single lock_acquire.
    Likewise, replace "mutext_unlock + sigprocmask" with lock_release.
2009-09-25 09:35:31 -07:00
Arun Sharma 9607c6407c Fixup CONFIG_DEBUG_FRAME support. 2009-03-17 19:08:58 -07:00
Arun Sharma ec53de82ec [PATCH] Avoiding name conflict with the GNU-specific dprintf in stdio.h
Signed-off-by: Yang Zhang <yaaang@gmail.com>
2009-03-16 21:37:11 -07:00
Arun Sharma a2c27a4ab7 Make .debug_frame support optional.
Because these code paths use malloc and stdio, they could
cause deadlocks when we try to unwind stack from inside malloc.
2009-03-16 21:21:58 -07:00
Daniel Jacobowitz 3842dac733 Add initial ARM and MIPS support. To support this, also enable the
reading of .debug_frame sections (used in lieu of .eh_frame sections
when they're not available).
2008-02-04 17:16:37 -07:00
Mark Wielaard 5ed2da2a40 [DWARF] Fix error return.
* src/dwarf/Gfde.c (dwarf_extract_proc_info_from_fde):
	  Return -UNW_ENOMEM.
2008-02-04 16:31:34 -07:00
Arun Sharma 55fe524775 Cleanup the hash() function copied from ia64
Fixes the compiler warning on x86-32.

Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-08-16 15:43:49 -06:00
Arun Sharma a5d0c1f8b7 Remove HAVE___THREAD. This was never tested.
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-08-16 15:41:32 -06:00
Arun Sharma 11ea1275bd [dwarf] The sword() function in Gexpr.c doesn't do what's intended.
Yes, it casts to signed, but then converts right back to
unsigned via the return type.  Fixed thus.

Signed-off-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-07-26 22:12:10 -06:00
Arun Sharma 58888a5060 (dwarf_find_save_locs): Also apply register-state after parsing the FDE 2006-07-26 21:55:09 -06:00
Arun Sharma 4312719cbc [dwarf] Need to guard against multiple threads accessing the rs cache.
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-07-26 21:44:38 -06:00
Arun Sharma c5dc3c150a [dwarf] Allow return address column to differ from function to function.
Signed-off-by: Andrey Veskov <Andrey.Veskov@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-07-26 21:29:50 -06:00
Arun Sharma 60b7af702a (dwarf_find_save_locs): Add a comment.
Now that dwarf_find_save_locs() not just finds the save-locations but
also updates the cursor-state, document this fact (the function really
is misnamed now).
2006-07-26 21:25:37 -06:00
Arun Sharma 3dfde7a3f0 (dwarf_find_save_locs): put_unwind_info() is not needed in the cached case. 2006-07-26 21:23:30 -06:00
Arun Sharma 00db7f752a Implement a ip -> dwarf_reg_state cache.
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-07-26 21:18:49 -06:00
hp.com!davidm d9e100753f Include "libunwind_i.h" instead of "tdep.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm b7adf160ee Include "dwarf_i.h" instead of "dwarf.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm df3d6af467 Don't include <string.h>.
Include "libunwind_i.h" instead of "tdep.h".

(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm 9fac7579ee Don't include <string.h> and "tdep.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm 03ba50ccaa Don't include <stdlib.h> and <string.h>.
Include "libunwind_i.h" instead of "tdep.h".

(Logical change 1.294)
2005-05-20 09:48:08 +00:00
mostang.com!davidm 9bc79a618b Rename: src/dwarf/dwarf-eh.h -> include/dwarf-eh.h
}(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm 1f5ac0f5bd Adjust for sigset_t to intrmask_t renaming.
2004/11/17 02:43:39-08:00 mostang.com!davidm
(struct callback_data): New structure.
(linear_search): New function.
(callback): Convert to getting auxiliary info passed via a pointer to
	a callback_data structure, rather than an unw_dyn_info_t
	structure.
	Keep track of the maximum load address in max_load_addr.
	If an object doesn't have a binary search-table, fall back
	on a linear search.
(dwarf_find_proc_info): Fill in callback-data structure before calling
	dl_iterate_phdr().  Upon returning, check whether
	cb_data.single_fde is set and, if so, return directly, without
	searching the DWARF unwind-table.
(dwarf_search_unwind_table): Adjust for renaming of
	dwarf_parse_fde() to dwarf_extract_proc_info_from_fde().
	If IP doesn't fall into the IP-range of the FDE-entry found
	by the search, return UNW_ENOINFO.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm 46b7b8196c (is_cie_id): New function.
(parse_cie): Adjust for moving DWARF2 extra-info from
	unw_dyn_dwarf_fde_info_t to dwarf_cie_info.
	Add support for `S' augmentation ("special frames").
(dwarf_extract_proc_info_from_fde): Rename frm dwarf_parse_fde().
	Convert to returning data via dwarf_cie_info rather than
	unw_dyn-dwarf_fde_info_t.  Allow 0-length FDE since those
	can be used to indicate the end of the FDE-table.  Return
	the end of the FDE via *ADDRP.  Ignore CIEs (we may pick them
	up during linear searches through the FDE-table).
	Fill in the unwind-info only if really needed.  When needed,
	return the info via a dynamically allocated dwarf_cie_info
	structure.  Add support for `S' augmentation (ABI/tag pairs).

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm c14371409a (fetch_proc_info): Decrement IP before searching for dynamic/static
unwind-info, since DWARF expects us to do so (unlikey for ia64,
	where we are guaranteed that the (return) IP points to the
	correct unwind-info).

2004/11/17 02:43:39-08:00 mostang.com!davidm
(run_cfi_program): Switch over to using dwarf_cie_info instead of
	unw_dyn_dwarf_fde_info_t.
(fetch_proc_info): Clear c->pi before filling it in.
(put_unwind_info): If we got non-dynamic unwind-info, free it
	via a call to mempool_free().
(parse_fde): Switch over to using dwarf_cie_info instead of
	unw_dyn_dwarf_fde_info_t.
(apply_reg_state): Drop accessees to c->cfa_is_sp.

2004/10/25 17:38:51+02:00 homeip.net!davidm
Fix typo: DW_CFA_CFA_expression -> DW_CFA_expression.

2004/10/21 11:15:44+02:00 homeip.net!davidm
Auto merged

2004/10/21 11:15:12+02:00 homeip.net!davidm
(run_cfi_program): Add missing newline in Debug statement.
(apply_reg_state): It was wrong to do a dwarf_get() on the CFA-location
	returned by eval_location_expr().  Instead, we must make sure
	we're dealing with a memory-location and, if so, just extract
	the memory address as the CFA.
	Also, update c->cfa only _after_ the other frame-state has
	been updated.  This seems to be necessary for correct parsing
	of the sigtramp unwind info.  Not sure yet this is 100% correct,
	but it gets us through Gtest-resume-sig.

2004/10/19 23:24:56-07:00 mostang.com!davidm
(run_cfi_program): Fix typos in Debug statements.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm 4502aa0ff2 (dwarf_read_encoded_pointer): Implement simply by calling
dwarf_read_encoded_pointer_inlined().

2004/11/17 02:43:39-08:00 mostang.com!davidm
(dwarf_read_encoded_pointer): Declare proc-info-pointer argument
	as "const".

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm 3239e7db60 (dwarf_cie_info_pool): New variable.
(dwarf_init): Initialize dwarf_cie_info_pool.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
homeip.net!davidm bb03dca33e Add Debug statement for return-value.
2004/10/19 23:15:02-07:00 mostang.com!davidm
(update_frame_state): Take additional argument "prev_cfa".
	When we detect a NULL-frame, debug-print the IP and the CFA
	so we know where things went wrong.
(dwarf_step): Get "prev_cfa" before we call dwarf_find_save_locs(),
	since update_frame_state() doesn't actually update
	the CFA.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
homeip.net!davidm 670399d357 (pop): Returning the right element does help...
(pick): Likewise.
(dwarf_eval_expr): Fix "while" conditional so we see all operators.
	Fix DW_OP_litN typo: "opcode = DW_OP_lit0" to
	"opcode - DW_OP_lit0".
	Add lots of Debug() statements so we can see what's going
	on.  Debug level 15 will show just entry/return values.
	Debug level 16 shows all operators.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
com[davidm]!marky 271f706944 dwarf: fix local & remote table lookup
(Logical change 1.256)
2004-08-24 08:19:00 +00:00