1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-06-25 02:41:45 +02:00
Commit graph

1740 commits

Author SHA1 Message Date
Tommi Rantala 90d7baea35 Remove free() NULL pointer checks in load_debug_frame() error path
Just pass potentially NULL pointers to free() in the error path in
load_debug_frame(). Saved 40 bytes of code in libunwind.so on ARM -O2
thumb build at the expense of slightly slower execution.
2012-09-04 14:58:24 +03:00
Tommi Rantala a745ac2f60 PPC: return failure from the unw_get_proc_info() stub
Stop pretending that unw_get_proc_info() works on PPC, and instead give
an error back to the caller. As far as I can tell, none of the libunwind
tests clear out the `unw_proc_info_t' before passing it to
unw_get_proc_info(), so they would end up working on garbage data.
2012-09-04 13:26:13 +03:00
Tommi Rantala 8f94f1e6c0 PPC: add missing debug level in Debug() calls in Gstep.c
ppc32/Gstep.c:116: warning: comparison between pointer and integer
ppc32/Gstep.c:116: warning: comparison with string literal results in unspecified behavior
ppc32/Gstep.c:116: warning: initialization makes integer from pointer without a cast
ppc32/Gstep.c:116: warning: passing argument 2 of 'fprintf' makes pointer from integer without a cast
/usr/powerpc-linux-gnu/include/stdio.h:333: note: expected 'const char *__restrict__' but argument is of type 'int'
2012-09-04 13:26:13 +03:00
Tommi Rantala 7feb6b8575 HPPA: fix common_init() bitrot
Fix bitrot in HPPA common_init(). This has only been compile tested.

hppa/init.h: In function 'common_init':
hppa/init.h:33: error: 'struct cursor' has no member named 'ip_loc'
hppa/init.h:33: warning: implicit declaration of function 'HPPA_REG_LOC'
hppa/init.h:34: error: 'struct cursor' has no member named 'sp_loc'
hppa/init.h:36: warning: implicit declaration of function 'hppa_get'
hppa/init.h:36: error: 'struct cursor' has no member named 'ip_loc'
hppa/init.h:36: error: 'struct cursor' has no member named 'ip'
hppa/init.h:40: error: 'struct cursor' has no member named 'sp'
2012-09-04 13:26:13 +03:00
Tommi Rantala 7e5cab6dac Add missing newline to debug message in _UCD_access_reg_linux.c 2012-08-21 23:04:07 +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
Tommi Rantala 5738bac171 ARM: fix with-signal-frame local unw_resume()
Make sure that the `sigcontext_addr' cursor member is pointing to the
`struct sigcontext' as expected in arm_local_resume().
2012-08-21 22:33:56 +03:00
Tommi Rantala 14fc15928b ARM: fix non-signal-frame local unw_resume() due to compiler optimization cleverness
When cross-compiling libunwind with optimizations (-O1 or higher),
gcc-4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) optimizes away the memory
writes prior to the inline asm() statement in arm_local_resume() in the
non-signal-frame path, causing the `regs' array to be only allocated on
the stack, but not populated. This means that we are restoring garbage
to the registers.

As suggested in the GCC docs, add a fixed size input memory constraint
for the array content. This is enough to get the desired code to be
generated.

Adding __builtin_unreachable() to the point that we should never reach
was also in itself enough to inhibit the optimization. It also reduces
the function size by a few instructions.
2012-08-21 22:33:56 +03:00
Tommi Rantala 5fef17c05d Fix memory leaks in unw_create_addr_space() wrong-endian error paths
Check the endianness earlier in unw_create_addr_space() on all
architectures to avoid leaking the dynamically allocated address space
struct.

This was already fixed for ARM in commit cf6a998796 ("Fix memory leak
in ARM unw_create_addr_space()"). Move the endianness check also on ARM
to avoid malloc() & free() in the error case.
2012-08-21 22:33:29 +03:00
Tommi Rantala 2d750952a5 Use constants for ELF magic bytes in _UCD_create.c 2012-08-21 22:30:47 +03:00
Tommi Rantala 7b81113721 MIPS: implement dwarf_to_unw_regnum() macro without table 2012-08-21 22:30:46 +03:00
Tommi Rantala 1dc66bd181 ARM: implement dwarf_to_unw_regnum() macro without table 2012-08-21 22:30:46 +03:00
Tommi Rantala 54a096a5af PPC: do not export dwarf_to_unw_regnum_map
dwarf_to_unw_regnum_map is internal to libunwind, and should not be
exported.
2012-08-21 22:30:46 +03:00
Tommi Rantala 80fc285599 MIPS: fix symbol naming for mips_lock', mips_local_resume', and `mips_local_addr_space_init'
Properly export the symbol names also on MIPS. `make check' was
complaining:

src/.libs/libunwind.a(Linit.o): In function `mips_local_addr_space_init':
src/mips/Ginit.c:183: multiple definition of `mips_local_addr_space_init'
../src/.libs/libunwind-mips.a(Ginit.o):src/mips/Ginit.c:183: first defined here

src/.libs/libunwind.a(Lglobal.o): In function `_ULmips_init':
src/mips/Gglobal.c:42: multiple definition of `mips_lock'
../src/.libs/libunwind-mips.a(Gglobal.o):src/mips/Gglobal.c:42: first defined here

collect2: ld returned 1 exit status
2012-08-21 22:30:46 +03:00
Arun Sharma 201bb8733d Use libtool to build libunwind-ptrace 2012-08-18 12:41:21 -07:00
Martin Milata 3d5e6c1ddd Search MiniDebugInfo for procedure names
After searching the normal symbol table, look if the binary contains
.gnu_debugdata section. If it does, run LZMA decompression on it, load
the resulting ELF image into memory and call lookup_symbol() on it
again.

lookup_symbol() is modified so that it takes min_dist as a parameter and
only returns a symbol when it finds one that is closer than indicated by
the parameter.

Signed-off-by: Martin Milata <mmilata@redhat.com>
2012-08-10 15:29:07 +02:00
Martin Milata 71c1fffc35 Refactor parts of elfxx.c to allow reusing code
Signed-off-by: Martin Milata <mmilata@redhat.com>
2012-08-10 15:29:07 +02:00
Martin Milata 7d5a197021 Add liblzma detection to configure script
Signed-off-by: Martin Milata <mmilata@redhat.com>
2012-08-10 15:07:49 +02:00
Martin Milata e11a6a4fdf Fix incorrect return code of unw_get_proc_name
The code for symbol lookup (elfxx.c:lookup_symbol) works by iterating
over symbol tables while maintaing the symbol closest to the supplied
instruction pointer. Whenever this search encountered symbol that was
longer than result buffer, the function returned -UNW_ENOMEM even though
the final symbol wasn't too long.

Signed-off-by: Martin Milata <mmilata@redhat.com>
2012-08-06 20:12:38 +02:00
Arun Sharma 814bd79fb1 Fix some compiler warnings 2012-08-04 12:48:56 -07:00
Tommi Rantala a26f1eac22 IA64: `ent' needed conditionally in Gtables.c
ia64/Gtables.c: In function '_ULia64_search_unwind_table':
ia64/Gtables.c:258: warning: unused variable 'ent'
2012-07-31 16:21:15 +03:00
Tommi Rantala 0fecf13d10 Fix --enable-debug-frame build
dwarf/Gfind_unwind_table.c: In function '_Ux86_dwarf_find_unwind_table':
dwarf/Gfind_unwind_table.c:223:46: error: 'struct elf_dyn_info' has no member named 'edi'
2012-07-31 16:21:15 +03:00
Tommi Rantala 5d36914c9b IA64: use tdep_find_unwind_table() in coredump lib
Fixup commit d93d96ad83 ("Fix compilation
on IA64"), and replace the dwarf_find_unwind_table() call with
tdep_find_unwind_table().

Fixes linkage error on IA64:
../src/.libs/libunwind-coredump.so: undefined reference to `dwarf_find_unwind_table'
2012-07-31 16:21:15 +03:00
Tommi Rantala 354b3fd45b Allow IA64 cross-compilation
Change the way we generate the cursor header files, so that we do not
need to invoke IA64 binaries, which would fail when cross-compiling
libunwind.

Adopt the strategy used in the Linux kernel build system, and parse our
annotated offset information from the assembler file produced by the
compiler.
2012-07-31 16:03:53 +03:00
Martin Milata de28c51e63 Build libunwind-coredump using libtool
So that it builds shared/pic library that can be linked with other
libraries.

Signed-off-by: Martin Milata <mmilata@redhat.com>
2012-07-04 17:01:44 -07:00
Martin Milata d93d96ad83 Fix compilation on IA64
- Add tdep macro for {dwarf,ia64}_find_unwind_table so that ia64
   doesn't try to use dwarf code.
 - Fix extraneous #if.
 - Fix mistyped filename in Makefile.am.
 - Link ia64-specific tests with correct libraries.

Signed-off-by: Martin Milata <mmilata@redhat.com>
2012-05-23 20:52:28 -07:00
Arun Sharma fa5409387c Merge branch 'coredump2' of https://github.com/adsharma/libunwind
Conflicts:
	src/ptrace/_UPT_find_proc_info.c
2012-05-23 20:51:50 -07:00
Arun Sharma dd297ea92e Revert "x86_64: unbreak test-ptrace"
This reverts commit c9c5a40be1.
dwarf_get() returns 0 on success. We should continue unwinding
in that case.

TBD: investigate test-ptrace failure on some platforms.
2012-05-18 15:24:02 -07:00
Arun Sharma c9c5a40be1 x86_64: unbreak test-ptrace
If dwarf_get returns 0 (indicating the end of call chain), we should
not override the return value to 1. This may result in the caller
continuing to unwind and getting spurious errors.
2012-05-16 07:49:30 -07:00
Konstantin Belousov 1a6ea3da60 freebsd: Fix boundary conditions for non-dwarf walker on x86_64.
In the commit d04dc94cc2, the check for
dwarf.ip == 0 was removed from non-dwarf walker in x86_64 version of
unw_step(). Apparently this broke the detection of the end of frame
chain when NULL %rbp is specified, because the case just marked
dwarf.ip as 0. Explicitly set ret to 0 to indicate the end of
iteration.
2012-05-14 23:18:00 -07:00
Konstantin Belousov 3bb74aae3d freebsd: Account for the possible ERESTART handling of the syscalls. 2012-05-14 23:07:52 -07:00
Konstantin Belousov 5f440b4af2 freebsd: Workaround for old FreeBSD kernels
Older kernels interpret the pid argument of the process information
sysctls as pid only. If libunwind UPT consumer passed tid to _UPT_create,
tdep_get_elf_image() returns error due to sysctls failure. Provide a
slow workaround by searching for a process owning the supplied tid if
sysctl returned ESRCH.
2012-05-14 23:07:52 -07:00
Konstantin Belousov f8858bacca freebsd: Fix logic error
When encountered vm map entry is not backed by a vnode, continue search
for matching entry instead of aborting the loop.
2012-05-14 23:07:51 -07:00
Konstantin Belousov 0fac4c8109 freebsd: Consistently use symbolic name UNW_EUNSPEC for errors 2012-05-14 23:07:51 -07: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 cbc66b62c0 mips: fix a linker error
Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
2012-04-09 19:48:49 -07:00
Arun Sharma 9507a9b501 ia64: move ia64 specific code out of dwarf
We still need to fixup the callers to pick dwarf_find_unwind_table
vs ia64_find_unwind_table in a target dependent way.
2012-03-29 11:35:26 -07:00
Arun Sharma bc056ffc9f coredump: update license to be the same as rest of libunwind
Per Denys Vlasenko <dvlasenk@redhat.com>:

Sure. It's a trivial file, I don't mind if you use
whatever license you like on it :)
2012-03-26 19:07:58 -07:00
Alexander Larsson edcc521a0e Add helper macros for pointer arithmetics
ALIGN lets you align pointers and STRUCT_MEMBER lets you get
structure members at a specific offset.

These are useful in general, and will be needed for the coredump notes
cleanup work.
2012-03-26 19:04:01 -07:00
Alexander Larsson b1393b7e63 Clean up the elf notes handling in the coredump code
We centralize the elf notes handling code in some macros, thus
simplifying the loops over the notes and avoiding code duplication.
2012-03-26 18:59:49 -07:00
Arun Sharma 49ca8b6a3e ia64: remove references to an out of scope local
This causes problems with gcc-4.7

Signed-off-by: Joel Brobecker <brobecker@adacore.com>
2012-03-26 18:54:53 -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
Arun Sharma d04dc94cc2 dwarf: ip == 0 should't terminate unwind 2012-03-25 18:10:10 -07:00
Arun Sharma 43e5ee28c0 Demote the debug level to reduce verbosity 2012-03-25 17:44:53 -07:00
Arun Sharma 0628a9872c Whitespace cleanup 2012-03-23 22:34:42 -07:00
Alexander Larsson 0c0ea23cf2 Add support for multiple threads in core files
_UCD_select_thread() lets you select the active thread from
the core file and _UCD_get_num_threads() tells you how many there are.
2012-03-23 22:07:17 -07:00
Alexander Larsson d627481783 Break out the ifdefs for the UCD_info.prstatus type
This cleans up the code a bit and makes it easier to refer to
the prstatus type in other places.
2012-03-23 22:07:14 -07:00
Alexander Larsson b9ff650a22 Add _UCD_get_pid and _UCD_get_cursig
These let you get the pid and the current signal from the coredump.

This isn't strictly unwind related, but these are trivial to implement
as we have the info, and you almost always want these when you're
printing a backtrace from a core file.
2012-03-23 22:07:11 -07:00
Alexander Larsson adbeb79155 Fix build with --enable-debug
This just fixes a typo
2012-03-23 22:07:07 -07:00
Kostik Belousov cc7c74e691 On FreeBSD, the structure is called prstatus. 2012-03-13 18:15:39 +02:00
Kostik Belousov dc9be1a97a Implement register read for FreeBSD coredumps.
Rename _UCD_access_reg.c to _UCD_access_reg_linux.c, to have
per-OS coredump register reader.
2012-03-13 14:00:01 +02:00
Kostik Belousov 1e6959a769 Shut down compiler warning about format mismatch. 2012-03-13 13:17:07 +02:00
Kostik Belousov e8eb583450 Handle byteswap.h and endian.h inclusion. 2012-03-13 13:09:25 +02:00
Arun Sharma f0bb806ecb Move the test case to tests dir. 2012-03-12 20:11:49 -07:00
Arun Sharma 0f17b52171 Fixup regnames on x64 2012-03-12 20:11:49 -07:00
Arun Sharma b08ae72d6c Add support for unwinding coredump images
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2012-03-12 20:11:08 -07:00
Arun Sharma d276b7a961 Introduce get_proc_name_in_image()
This is similar to get_proc_name() but takes an already mapped
image.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2012-03-12 20:09:18 -07:00
Arun Sharma 6525714c27 Move some dwarf functionality from ptrace to dwarf
Move ptrace-independent code from src/ptrace/_UPT_find_proc_info.c
to src/dwarf/{G,L}find_unwind_table.c. Name this moved function
dwarf_find_unwind_table().

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2012-03-12 20:06:37 -07:00
Arun Sharma 25ee9f8172 Introduce struct elf_dyn_info
This is a common part of struct UPT_info
and struct UCD_info (to be introduced later).
Make _UPTi_find_unwind_table function operate only on this part
of struct UPT_info.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2012-03-12 20:04:19 -07:00
Arun Sharma 3d08506936 Fix undefined symbol: _Uelf64_valid_object
Without this change, we end up building libunwind-${arch}.a with
missing symbols.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
2012-02-12 19:53:38 -08:00
Konstantin Belousov 59328832f7 Provide the FreeBSD implementation for _UI_siglongjmp_cont on x86.
On FreeBSD, _NSIG is at least 128, so just pass a pointer to the
signal mask in the register.
Add my copyright.
2012-02-05 11:47:47 +02:00
Konstantin Belousov 1774384098 FreeBSD also supports PT_GNU_STACK. 2012-02-05 11:42:02 +02:00
Konstantin Belousov 29dae2171e Style. 2012-02-05 11:40:17 +02:00
Tommi Rantala 51445f61d3 ARM: fix unwind table search when IP less than first table entry
Properly return error when searching for unwind table entry for an IP
that is less than the first available table entry.
2012-02-01 07:57:15 -08:00
Tommi Rantala ec4b23bf70 ARM: fix off-by-one in exidx VFP pop
The range of VFP registers we need to pop is inclusive.
2012-01-24 20:43:55 -08:00
Tommi Rantala 458c661be7 Fix libunwind-generic.so symbolic link never being created in make install
Commit 7d43108f9c ("No
libunwind-generic.so if configured with --disable-shared") introduced a
check to avoid creating a broken libunwind-generic.so link, but the
result of the commit is that libunwind-generic.so is never created (at
least when installing to a clean directory).

We need to check for the installed libunwind-$(arch).so file,
libunwind-generic.so will be the symbolic link name.
2012-01-23 07:38:59 -08:00
Arun Sharma 52ca68c770 Fix a race condition
There is a window of time between the munmap and the tls_cache being
marked as destroyed, where there could be a bad access to memory that
has been unmapped/freed. Reorder the code a bit to close the window.

Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
2011-12-16 10:45:51 -08:00
Arun Sharma cf2f3d3b75 Correct the inverted check
Typo when manually applying the previous commit.
2011-12-02 08:35:00 -08:00
Arun Sharma 2f328202ee Fix a compiler warning
Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
2011-12-01 22:08:08 -08:00
Konstantin Belousov 2b606faa21 Fix compilation on non-glibc machines.
Commit 297d9cd07d (Fix for failing test-setjmp)
breaks non glibc systems, since __GLIBC_PREREQ is not defined there.
As a consequence, preprocessor aborts with an error.

Trying to hide __GLIBC_PREREQ under #ifdef __GLIBC would require
either code duplication, or moving the longjmp implementation into
the separate file, which is included twice. In fact, I am not sure
in any use of the __GLIBC_PREREQ at the compile time, because the
compiled code can be run on the later version of glibc.

Below is the patch, tested on FreeBSD x86/x86_64 and Scientific Linux 6.1
x86_64. I compile the code always, but keep it in under unused static
symbol. In principle, the code could be optimized out by linker.

[ Minor formatting edits: asharma@fb.com ]
2011-11-30 21:59:09 -08:00
Arun Sharma 1010880548 Address x86_64 crashes when using sigaltstack
The crashes were tracked down to f->rpb_cfa_offset being incorrect.

The problem is that {rsp,rbp}_cfa_offset only have 15 bits, but for
SIGRETURN frame they are filled with:

// src/x86_64/Gstash_frame.c

   f->cfa_reg_offset = d->cfa - c->sigcontext_addr;
   f->rbp_cfa_offset = DWARF_GET_LOC(d->loc[RBP]) - d->cfa;
   f->rsp_cfa_offset = DWARF_GET_LOC(d->loc[RSP]) - d->cfa;

The problem is that the delta here can be arbitrarily large when
sigaltstack is used, and can easily overflow the 15 and 30-bit fields.

When signal handler starts running, the stack layout is:

 ... higher addresses ...
        ucontext
 CFA->
        __restore_rt (== pretcode in rt_sigframe from
                      linux-2.6/arch/x86/include/asm/sigframe.h)
 SP ->
       ... sighandler runs on this stack.

 ... lower addresses ...

This makes it very convenient to find ucontext from the CFA.

Attached patch re-tested on Linux/x86_64, no new failures.

Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
Reviwed-by: Lassi Tuura <lat@cern.ch>
2011-11-27 18:34:38 -08:00
Paul Pluzhnikov 297d9cd07d Fix for failing test-setjmp
On Mon, Nov 14, 2011 at 5:02 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:

> P.S. test-setjmp is failing for me (before or after the patch).
> When I enable assertions (to confirm my new assertions are correct), I see:
>
>  lt-test-setjmp: ../../src/dwarf/Gparser.c:754: apply_reg_state: \
>    Assertion `rs->reg[17].where == DWARF_WHERE_EXPR' failed.
>
> which likely explains that failure.

The problem is actually two-fold:

First, the loops in {sig,}longjmp.c are "do { ... } while (unw_step() >= 0);"

But unw_step() returns 0 on reaching the end of the chain (_start),
and the loop should stop there.

The second problem is that with this commit:
  c67da0b50e
glibc obfuscates value of SP in jmp_buf, so we might as well just give up.

Patch attached.

Thanks,
--
Paul Pluzhnikov
2011-11-19 15:37:35 -08:00
Ken Werner d84e5d5d24 Call dwarf_step only if CONFIG_DEBUG_FRAME is defined
The ARM EABI does not use the .eh_frame and .eh_frame_hdr sections for unwinding. Therefore it doesn't make sense to call dwarf_step if CONFIG_DEBUG_FRAME is not defined.
2011-11-19 15:37:23 -08:00
Arun Sharma 786882ff8c Remove unused variable segbase 2011-11-12 10:02:09 -08:00
Ken Werner 1e644990c9 Only declare the start/end variables in case CONFIG_DEBUG_FRAME is defined.
Prevents compiler warnings about unused variables.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-11-12 09:47:12 -08:00
Ken Werner 25aeae9adf Fix breakage when host != target
Define the sigreturn syscall numbers instead of including on <sys/syscall.h>.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-11-03 08:24:18 -07:00
Arun Sharma d20df8b318 Fix up the breakage when host != target 2011-10-31 22:33:47 -07:00
Arun Sharma 851f14281c Fix some compiler warnings 2011-10-29 17:18:49 -07:00
Ken Werner 0eba2169fb [ARM] Add support for systems that don't support ucontext.h
Define unw_tdep_context rather than using ucontext_t in order to support
systems that lack ucontext.h. Note that POSIX.1-2008 removed getcontext,
makecontext and swapcontext from its specification.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-10-29 17:12:43 -07:00
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
Arun Sharma 0a26727ea2 Fix TLS destructor ordering problems
Glibc calls thread-specific dtors in the order in which the keys were added,
so the first dtor is the trace_cache_free() one. Then thread-specific
data for some other key is free()d, which calls into unw_backtrace(),
which uses dangling cache and munmapped cache->frames.

[ Minor rename + compiler warning fix: asharma@fb.com ]
Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
2011-10-29 17:12:36 -07:00
Arun Sharma 08077a4962 pthread_once() workaround for FreeBSD and Solaris
On FreeBSD, as well as on the Solaris < 10, weak pthread_once stub is
always exported from libc. But it does nothing, which means that if
threaded library is not loaded, then pthread_once() call do not actually
call the initializer finction. The construct
  if (likely (pthread_once != 0))
  {
    pthread_once(&trace_cache_once, &trace_cache_init_once);
then fails to initialize the trace cache on x86_64.

Work around by checking that the initializer was indeed called.
Note that this can break if libthr is loaded dynamically, but my belief
is that there is no platforms which allow dynamic loading of the threading
library.
2011-10-29 16:53:30 -07:00
Ken Werner 7f41e701e3 Have tdep_get_elf_image available in case of UNW_REMOTE_ONLY
Because it gets used by libunwind-ptrace.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-10-15 23:10:28 -07:00
Ken Werner da4743f52a Exclude arm_find_proc_info and arm_put_unwind_info in case of UNW_REMOTE_ONLY
Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-10-15 23:10:28 -07:00
Ken Werner 197571915c Change _UPTi_find_unwind_table to return an integer.
This keeps the definition on IA64 and all the other architectures in sync with
the declaration of _UPTi_find_unwind_table. This also mimics the behaviour of
what's done for local unwinding and allows the function to provide more than
one way to undwind.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-10-15 23:10:27 -07:00
Arun Sharma c4133e879b undef FORTIFY_SOURCE
It's a bit annoying to undefine at configure or compile time.

Signed-off-by: Arun Sharma <asharma@fb.com>
2011-10-15 23:10:00 -07:00
Arun f89fb17695 Fix incorrect calls to memset.
Found when compiling libunwind with clang.

Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
2011-10-02 22:43:28 -07:00
Arun Sharma 962366dace Fixup compile errors on ia64.
Suggested-by: Harald Servat <harald.servat@bsc.es>
2011-09-23 11:11:34 -07:00
Arun Sharma ac0acd06f3 Bump up the library version 2011-09-10 19:57:59 -07:00
Arun Sharma 00abb7c056 Reorder libraries in lib_LTLIBRARIES
This fixes a make install time problem.
2011-09-05 10:46:14 -07:00
Ken Werner 92327a3647 ARM: prefer to unwind using DWARF info
In case the user doesn't specify whether to unwind using the ARM specific
unwind tabler or DWARF info libunwind should prefer the latter. Since DWARF
expressions are more powerful than the ARM specific unwind tables
arm_find_proc_info is changed to check for DWARF first.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-08-29 17:58:52 +02:00
Ken Werner 912db91b05 ARM: Exit unw_step in case DWARF based unwinding was successful
Prevents unw_step from trying to unwind the stack using the ARM specific
unwind tables in case the DWARF based unwinding was successful.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-08-29 17:58:52 +02:00
Ken Werner 112c927371 ARM: Ensure unw_step returns whatever find_proc_info() returns
This allows the test-proc-info test case to pass on ARM.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-08-17 14:32:32 +00:00
Ken Werner 93e64550ac ARM: Fix return value of arm_find_proc_info
Initialize the return value with -1 in order prevent arm_find_proc_info from
returning zero. This could happen in case the environemtn variable
UNW_ARM_UNWIND_METHOD doesn't allow exidx and/or dwarf unwinding.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-08-17 14:14:48 +00:00
Ken Werner d83846f120 ARM: Initial support for remote unwinding using libunwind-ptrace
Change _UPTi_find_unwind_table to also look for the ARM specific unwind
information. Adjust the ARM unwind code to read memory using the accessor
routines.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-08-15 20:12:54 +02:00
Ken Werner b317cb4829 Change libunwind-ptrace to also look for .debug_frame if nothing found in .eh_frame.
This changes the behavior of libunwind-ptrace to what we do for local
unwinding.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-08-15 20:12:54 +02: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
Ken Werner 25f6b8295d Change address type from void* to unw_word_t.
Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-07-28 11:10:02 +00:00