1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-09-19 04:12:51 +02:00
Commit graph

3101 commits

Author SHA1 Message Date
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
39b8398159 Flush icache with __builtin___clear_cache() in tests when compiling with GCC
When compiling with GCC, use the builtin instruction cache flushing
mechanism in all tests where it is needed.

Quoting GCC docs: ''If the target does not require instruction cache
flushes, __builtin___clear_cache has no effect. Otherwise either
instructions are emitted in-line to clear the instruction cache or a
call to the __clear_cache function in libgcc is made.''.
2012-08-21 22:33:56 +03:00
Tommi Rantala
5fedf3407c Avoid -Wunused-value warning in tests/Gtest-exc.c
Gtest-exc.c: In function 'a':
Gtest-exc.c💯15: warning: value computed is not used [-Wunused-value]
2012-08-21 22:33:56 +03:00
Tommi Rantala
5b55e556ca test-resume-sig-rt: test unw_resume() in presence of "realtime" signal frame
Introduce a new test case that is derived from test-resume-sig, but
using the SA_SIGINFO sigaction() flag. This case is referred in the
linux kernel sources as "realtime" signal handler, and is handled
differently in the kernel on many architectures and in libunwind as
well.
2012-08-21 22:33:56 +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
ff0c6ccf6b Remove unneeded length modifier from suppressed match in sscanf() format in tests/crasher.c
GCC is complaining about the `%*jx' match in sscanf() format string.
Replace it with `%*x'; sscanf() will identically match an unsigned
hexadecimal integer without the length modifier.

crasher.c: In function 'write_maps':
crasher.c:30:9: warning: use of assignment suppression and length modifier together in gnu_scanf format [-Wformat]
2012-08-21 22:30:47 +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
9a6d921230 Fix plain return from main() in tests/test-async-sig.c
test-async-sig.c: In function 'main':
test-async-sig.c:185:4: warning: 'return' with no value, in function returning non-void [-Wreturn-type]
2012-08-21 22:30:46 +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
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
Tommi Rantala
56f07a8e55 Stop using nonportable echo arguments in tests
echo arguments are not portable, so use printf when we need to print
tabs or newlines.
2012-08-21 22:30:46 +03:00
Tommi Rantala
96cc0e8316 Run autoupdate' to stop using obsoleted macros in configure.in' 2012-08-21 22:30:46 +03:00
Tommi Rantala
757c81cca9 Update .gitignore 2012-08-21 22:30:46 +03:00
Tommi Rantala
f42a8de0fa Annotate unused parameters in tests
Compiling the tests with -Wextra results to lots of warnings for unused
parameters. Annotate these cases with the `unused' attribute to avoid
the warnings.
2012-08-21 22:30:46 +03:00
Tommi Rantala
47a99b6f00 Eliminate unused parameters in tests 2012-08-21 22:30:41 +03:00
Tommi Rantala
6f374ccb5a Ignore _fbss, _fdata, _ftext and _gp symbols on MIPS 2012-08-20 08:46:47 +03:00
Tommi Rantala
a63c209fed Add PPC namespace checking
PPC is the only architecture that has the get_func_addr() symbol
exported, so add specific checks for this architecture.
2012-08-20 08:46: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
Arun Sharma
201bb8733d Use libtool to build libunwind-ptrace 2012-08-18 12:41:21 -07:00
Konstantin Belousov
04c77cced4 Fix for test suite build in the separate directory.
Avoid manually coding the rule to build crasher, instead fuddle
the compiler so that even -O2 optimization does not eliminate call
to b().

First, put calls to both a() and b() in the b() into non-tail-recursive
position. Second, as recommended in gcc manual, use asm volatile("");
to prevent further prevent inlining, besides attribute((noinline).
And third, call b() by alias, which current gcc optimizer cannot see
through.

Also, do not dereference NULL in a, and mark the memory access as volatile.
[ Minor portability improvements: asharma@fb.com ]
2012-08-11 22:02:55 -07:00
Arun Sharma
538f63d796 Fix test-ptrace in automated mode
Tested via:
./test-ptrace
./test-ptrace -v /bin/ls /usr
2012-08-11 21:21:54 -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
4ab9e5dd10 MiniDebugInfo test: tests/run-coredump-unwind-mdi
Test that creates MiniDebugInfo-containing binary and then checks if it
can recover the procedure names from its coredump.

Signed-off-by: Martin Milata <mmilata@redhat.com>
2012-08-10 15:29:03 +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
2dbc26dde8 Make coredump test also test unw_get_proc_name
Signed-off-by: Martin Milata <mmilata@redhat.com>
2012-08-08 13:54:05 +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
707b1dba99 Fix a SIGSEGV in test-ptrace.c
./test-ptrace -v resulted in a SIGSEGV.
2012-08-04 18:06:07 -07:00
Arun Sharma
32202619c4 Fix a test failure
The test contains hints to users of unw_backtrace() and friends
on how to ensure correctness in a multi-threaded program
2012-08-04 17:58:24 -07:00
Arun Sharma
814bd79fb1 Fix some compiler warnings 2012-08-04 12:48:56 -07:00
Tommi Rantala
5e854a4103 Fix typo in unw_get_proc_name documentation 2012-07-31 22:52:32 +03:00
Tommi Rantala
4bf1b71952 Use unw_context_t instead of ucontext_t in tests/Gtest-trace.c and tests/Gtest-bt.c
At least on ARM unw_context_t and ucontext_t are not the same types, so
use unw_context_t.

See also commit 24112f6d9b ("Fix some test
failures on x86_64 on distros with small default stacks.")

Gtest-trace.c: In function 'do_backtrace':
Gtest-trace.c:66:3: warning: initialization from incompatible pointer type [enabled by default]
Gtest-trace.c:67:3: warning: passing argument 2 of '_Uarm_init_local' from incompatible pointer type [enabled by default]
../include/libunwind-common.h:239:1: note: expected 'struct unw_context_t *' but argument is of type 'struct ucontext_t *'

Gtest-bt.c: In function 'do_backtrace':
Gtest-bt.c:65:3: warning: initialization from incompatible pointer type [enabled by default]
Gtest-bt.c:66:3: warning: passing argument 2 of '_Uarm_init_local' from incompatible pointer type [enabled by default]
../include/libunwind-common.h:239:1: note: expected 'struct unw_context_t *' but argument is of type 'struct ucontext_t *'
2012-07-31 16:21:15 +03:00
Tommi Rantala
9158e522db Fix IP vs. PC confusion in tests on ARM
The intention in the test cases is to print the "instruction pointer"
value at certain places, and on ARM we will want to get the Program
Counter in these cases. IP is a scratch register, and not very
interesting.
2012-07-31 16:21:15 +03: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
Tommi Rantala
a06f189baf Rip out AC_TYPE_SIGNAL and sighandler_t check
AC_TYPE_SIGNAL is an obsolete autoconf macro, and we were not using
sighandler_t or RETSIGTYPE for anything anyways.
2012-07-31 15:01:02 +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
Konstantin Belousov
0f6c8313b7 Port crasher to FreeBSD. 2012-06-23 11:39:18 -07:00
Arun Sharma
21266608cc Allow --enable-debug=no
Signed-off-by: David Lee <live4thee@gmail.com>
2012-06-11 21:44:02 -07:00
Martin Milata
0f9a540c8c coredump: add test
Program test-coredump-unwind was modified to map backing files based on
virtual addresses instead of segment numbers.

The crasher.c is a program that essentially calls some functions and
then writes to invalid address causing a crash. Before that, it detects
which executables are mapped to which virtual addresses and writes this
information to a file suitable for consumption by test-coredump-unwind.
The mapping information is obtained form /proc/self/maps, so currently
it only works on linux.

The test itself is a shell script, which first runs the program and then
runs test-coredump-unwind on the resulting core and address space
map file to check whether the stack trace obtained from the dump roughly
corresponds to what it should look like.

Signed-off-by: Martin Milata <mmilata@redhat.com>
2012-05-31 11:00:40 +02:00
Konstantin Belousov
61a173763e Fix test build on FreeBSD. 2012-05-24 12:45:23 +03:00