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

33 commits

Author SHA1 Message Date
Tommi Rantala 890e23eb9d Prefer NULL over zero 2012-09-28 14:51:21 +03:00
Tommi Rantala 7d471b1440 Define and use `CONST_ATTR' 2012-09-28 14:51:21 +03:00
Tommi Rantala e61c6f69c3 Fix function name duplication in Debug() output
Fix function name duplication in Debug() output that was caused by
manually prepending the debug message with the function name.
2012-08-21 23:04:07 +03:00
Jiri Olsa 69e300e8f6 dwarf: Get correct return from expression evaluation
Currently the expression evaluation always succeeds,
and possible error is not propagated to the caller.

The ',' operator makes the condition always return 0.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Tested-by: Paul Pluzhnikov <ppluzhnikov@google.com>
2012-04-16 07:13:54 -07:00
Arun Sharma 5e59e93d04 dwarf: introduce a valid bit for dwarf_reg_state_t
Without this, cache_match() returns true when (ip == 0).
2012-03-25 18:33:40 -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
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
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
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
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 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 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 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 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
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
homeip.net!davidm 642607dbaa Cast register indices of type unw_word_t to (unsigned int) before
printing them.  Avoids compiler-warning for 64-bit targets.

(apply_reg_state): Handle the special case where the stack-pointer
	plays the role of the CFA and the stack-pointer hasn't
	been saved.  This is based on a patch by Max Asbock.

(Logical change 1.253)
2004-08-20 11:23:15 +00:00
homeip.net!davidm aae368ace2 Drop DWARF-parsing debug prints from level 16 to 15.
(Logical change 1.248)
2004-08-19 12:26:11 +00:00
homeip.net!davidm 88160e0f66 Rename: src/dwarf/Gparser-dwarf.c -> src/dwarf/Gparser.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm 3f9d2e9c5c Initial revision 2004-08-17 15:34:28 +00:00