1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-08 10:18:13 +01:00
Commit graph

383 commits

Author SHA1 Message Date
Filip Nyback
e1804829ca Add fast stack trace on ARM.
Port of the fast stack trace feature to ARM.
2014-07-30 14:25:14 +03:00
Tim Deegan
4eb880e1b5 Implement DWARF DW_CFA_val_expression for x86_64
Ubuntu's libc-bin (2.15-0ubuntu20.2) on x86_64 uses DW_CFA_val_expression
in describing the pthread spinlock operations __lll_unlock_wake() and
__lll_lock_wait().  libunwind 1.1 doesn't understand that opcode and
so backtraces from those operations are truncated.

This changeset adds basic support for it, by adding a new type to
dwarf_loc_t that describes the register's actual contents rather than
its location.  I've only implemented the new type for x86_64, and
stubbed it out for all other architectures -- it looks like a lot
of that code is duplicated so oughtn't to be that hard, but I don't
have test cases for them.

Tested that DW_CFA_val_expression works on x86_64 (by using
https://code.google.com/p/gperftools/ on a lock-heavy program).
Build-tested on x86, x86_64 and arm.  The unit tests don't pass for me
on any of those archs, but this cset doesn't break anything that was
passing before.

Signed-off-by: Tim Deegan <tjd@phlegethon.org>
2014-02-08 20:19:20 -08:00
Ulrich Weigand
da0b1a146f Support powerpc64le-linux platform
This patch adds support for the powerpc64le-linux platform.  It consists
of two main features:

- Support little-endian byte order
  This is done via a "big_endian" member of struct unw_addr_space,
  which is evaluated by common code via the dwarf_is_big_endian
  macro, and also in endian-aware code in unw_is_signal_frame.

- Support the ELFv2 ABI
  This is done via an "abi" member of struct unw_addr_space.  This
  is currently only needed in tdep_get_func_addr, since the ELFv2
  ABI does not use function descriptors.

Both new members are initialized in unw_create_addr_space and
ppc64_local_addr_space_init, following the mips precedent.

Since ppc32 and ppc64 now no longer share the unw_create_addr_space
implementation, the file is duplicated from the ppc directory into
ppc32/ppc64.

Tested on powerpc64-linux and powerpc64le-linux.  Support on LE
seems to be as good as existing BE support; I have not attempted to
fix the existing shortcomings of PPC support that already cause a
number to tests to fail due to unimplemented features.

Signed-off-by: Ulrich Weigand <uweigand@de.ibm.com>
2013-12-27 07:09:06 -08:00
Arun Sharma
85ce920cff Use adaptive mutexes when available. 2013-11-17 20:33:33 -08:00
Matt Fischer
eac65dc9b8 Add basic support for the QNX operating system
This change adds some special cases to allow libunwind to compile
for QNX.

* QNX's copy of <elf.h> and <link.h> reside in sys/ instead.  To deal
  with this, an AC_CHECK_HEADERS() was added to check for the files
  in both locations.
* Similarly, QNX does not have <endian.h>.  In cases where the file is
  not found, logic was added to refer to QNX-specific macros to determine
  endianness.
* The QCC compiler, which is a wrapper around GCC, cannot handle some
  standard GCC options.  Therefore, logic was added to check for QCC,
  and when it is found, to suppress the use of -lgcc, and to express the
  option -nostartfiles as -Wc,-nostartfiles instead, which is correctly
  passed on to the underlying GCC.
* Finally, the support file os-qnx.c was added, patterned after the existing
  os-*.c files.  Only local image lookup is currently supported (see the
  comments for more information), but this is sufficient for QNX, since
  ptrace is not supported there anyway, and that is the only case where the
  function is required to do remote image lookup.

Change-Id: Ie7934f94a7317bdde59335f2acd4c3a97c0384c1
2013-05-13 10:50:17 -05:00
Yvan Roux
ac6c0a6535 [PATCH] AArch64 port. 2013-05-11 09:20:28 -06:00
Dave Lerner
becfc23123 Fix the UNW_TDEP_CURSOR_LEN for ppc32 to fix assert failure
When libunwind is built for a ppc32 target, for example the yocto distro
for qemuppc, and configured with options --enable-debug-frame and
--enable-debug, then the shortfall in the size of the 'opaque' member
of the unw_cursor_t type throws an assert in mi_init().

The calculations for the ppc32 target size of UNW_TDEP_CURSOR_LEN in
the comment block based on the register count plus overhead sum to 280
words. However, that value is not reflected in the ppc32 header, which
defines the size as 200.  Fixing the ppc32 header value to 280 makes the
unw_cursor_t type larger than struct cursor type and the assert tests
true at run-time in mi_init().

Signed-off-by Dave Lerner <dave.lerner@windriver.com>
2013-04-13 11:47:18 -07:00
Ladislav Michl
10b064ffe9 Support building with older compilers.
Add a check for __builtin_unreachable.
2012-11-24 21:37:07 -08:00
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
e0653f9e3a Define and use `WEAK' 2012-09-28 14:51:21 +03:00
Tommi Rantala
e3e49dc28a Define and use `NOINLINE' 2012-09-28 14:51:19 +03:00
Tommi Rantala
ee8df26288 Constify `dwarf_to_unw_regnum_map' 2012-09-28 14:50:03 +03:00
Tommi Rantala
fca254a9b4 IA64: give prototype for `ia64_find_unwind_table()'
src/ptrace/_UPT_find_proc_info.c: In function 'get_unwind_info':
src/ptrace/_UPT_find_proc_info.c:67: warning: implicit declaration of function 'ia64_find_unwind_table'
2012-09-28 14:50:03 +03:00
Tommi Rantala
8d5b1aeeff SuperH port
Add support for the 32bit SuperH architecture running Linux.
Specifically, support is added for SH4, and support for earlier SH
versions and to the 64bit SH5 are left out. This was tested in qemu with
a little-endian SH4 debian image & GCC 4.7 cross compiler.
2012-09-28 14:50:03 +03:00
Tommi Rantala
79c2c254a7 MIPS coredump support
Add MIPS support to the coredump library. Explicit support for the MIPS
program counter register is added so that we can start backtracing from
the program counter value we read from a core dump. The PC register
support was not strictly required for local backtracing, and we will in
fact just plug the return address to the PC register in getcontext().

I have only tested the 32bit "OABI" paths.
2012-09-28 14:50:03 +03:00
Tommi Rantala
5d0f376b08 Invert tdep_init() flag logic
Invert the flag that signals that tdep_init() was called, to move the
symbol from data to BSS.
2012-09-28 14:06:07 +03:00
Tommi Rantala
c2d6f85a0a Use __sync builtin atomics on all architectures if available
We can use the __sync builtin atomics also on other architectures than
IA64. GCC 4.7 documentation notes that these builtins are ``legacy'' --
adding support for the newer GCC __atomic atomics should be fairly easy.
2012-09-28 14:06:04 +03:00
Tommi Rantala
9a3565ddc1 Simplify `sos_alloc()' implementation
Instead of maintaining a pointer to the `sos_memory' array, maintain an
index that tells the next free position. When atomic operations are
available, the allocation boils down to a single fetch-and-add
operation.
2012-09-28 13:52:22 +03:00
Tommi Rantala
26fc1563fb Align `sos_memory' to MAX_ALIGN
We give aligned pointers from the `sos_memory' array, so any non-aligned
bytes are only wasted.
2012-09-28 13:52:22 +03:00
Tommi Rantala
0aa60f4f15 Remove unneeded atomic_ops.h' inclusion in dwarf.h' 2012-09-28 13:52:21 +03:00
Tommi Rantala
dc680c0b52 Pull attribute macros from libunwind_i.h' to new header compiler.h'
Pull attribute macros from `libunwind_i.h' to new header `compiler.h',
to allow the macros to also be used in the tests.
2012-09-28 13:52:21 +03:00
Tommi Rantala
c2f7574187 Rename and share `ALIGN' macro from _UCD_internal.h
Rename the `ALIGN' macro to `UNW_ALIGN', and move it from
`_UCD_internal.h' to `libunwind_i.h' so that we can share it with the
mempool code. `ALIGN' was clashing with system headers on FreeBSD:

In file included from src/coredump/_UCD_access_reg_freebsd.c:26:
src/coredump/_UCD_internal.h:102:1: warning: "ALIGN" redefined
In file included from /usr/include/sys/param.h:115,
                 from src/coredump/_UCD_lib.h:52,
                 from src/coredump/_UCD_access_reg_freebsd.c:24:
/usr/include/machine/param.h:79:1: warning: this is the location of the previous definition
2012-09-05 14:02:36 +03:00
Tommi Rantala
a15874f2cb Annotate unused argument in mark_as_used() to avoid -Wextra compiler noise
include/libunwind_i.h: In function 'mark_as_used':
include/libunwind_i.h:187:39: warning: unused parameter 'v' [-Wunused-parameter]
2012-09-04 12:59:11 +03:00
Tommi Rantala
18c26d4a7e Place `inline' at beginning of declaration of invalidate_edi()
../include/libunwind_i.h:319:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
2012-08-21 22:33:57 +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
6a5da54b8a Allow for architecture specific dwarf_to_unw_regnum()
For a few of the supported architectures we can use one-to-one mapping
from the dwarf to the libunwind register numbers. Allow the
architectures to define their own dwarf_to_unw_regnum() macro to do this
easily.
2012-08-21 22:30:46 +03:00
Tommi Rantala
d139d7e78e HPPA: include mempool.h' in libunwind_i.h'
dwarf/Gfde.c: In function '_Uhppa_dwarf_extract_proc_info_from_fde':
dwarf/Gfde.c:335: warning: implicit declaration of function 'mempool_alloc'
2012-08-20 08:46:46 +03:00
Tommi Rantala
d1e4614995 HPPA: add `global_cache' member to unw_addr_space struct
dwarf/Gparser.c: In function 'get_rs_cache':
dwarf/Gparser.c:522: error: 'struct unw_addr_space' has no member named 'global_cache'
2012-08-20 08:46:46 +03:00
Tommi Rantala
971216f8d4 HPPA: fix tdep_put_unwind_info() macro
In file included from mi/Lput_dynamic_unwind_info.c:4:
mi/Gput_dynamic_unwind_info.c:48:40: error: macro "tdep_put_unwind_info" passed 3 arguments, but takes just 2
2012-08-20 08:46:46 +03: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
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
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
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
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
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
Konstantin Belousov
29b32cf142 Fix silly mistakes in the definitions related to the FreeBSD offsets in
jmpbuf on x86.
2012-02-05 11:39:19 +02:00
Arun Sharma
d20df8b318 Fix up the breakage when host != target 2011-10-31 22:33:47 -07:00
Ken Werner
91494b732b Define GNU and processor specific values for the Phdr p_type field
Define GNU and processor specific values for the Phdr p_type field in case
they aren't defined by <elf.h> already.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-10-29 17:12:43 -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
Ken Werner
2c865b6ed3 Include <sys/mman.h> to have MAP_ANONYMOUS defined
This change prevents libunwind_i.h from using a self-defined MAP_ANONYMOUS and
therefore avoids collisions in case the system header gets pulled in later.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-10-29 17:12:42 -07:00
Ken Werner
c01ea3f6d6 Have dwarf.h include pthread.h
This is required for the pthread_mutex_t type that is beeing used in the
dwarf_rs_cache structure.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-10-15 23:10:28 -07:00
Arun Sharma
3bf76e8d19 Installed include files can't include config.h
config.h is not copied to $DESTDIR after make install. ms-abi users
will need to manually define it for now.
2011-09-05 10:47:13 -07: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
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