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
Ken Werner b28335b5a5 Fix inline assembly.
Remove the third colon if the clobber list is not present.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-06-30 12:36:44 +02:00
Arun Sharma e09f9701ff Handle register nums > 16 on x86_64
gcc generates them when using ms-abi. Support disabled by
default since it increases the cache footprint of the library.
2011-06-18 20:48:49 -07:00
Joel Brobecker 7d43108f9c No libunwind-generic.so if configured with --disable-shared
Installing a libunwind that was configured with --disable-shared
results in a broken libunwind-generic.so link. This patch avoids
this broken link.
2011-06-18 19:50:39 -07:00
Joel Brobecker ea7160a841 Remove unintended semi-colon in os-hpux.c fun definition
Probably a copy/paste error... This showed up on ia64-hpux.
2011-06-18 19:50:35 -07:00
Joel Brobecker 8d991d9258 Fix call to maps_next in _UPT_get_dyn_info_list_addr.c
A previous change reduced the number of arguments that this function
tasks, but one call at least did not get updated, resulting in a build
failure on ia64-linux.  This patch fixes it.
2011-06-18 19:50:31 -07:00
Joel Brobecker e003e44a37 Check for <sys/ptrace.h> before including it
On ia64-hpux version 11.31, <sys/ptrace.h> has been removed.
This patch adds a configure check for this header file, and only
includes <sys/ptrace.h> if it exists.
2011-06-18 19:50:28 -07:00
Lassi Tuura d2525ec936 Use single level hash table for fast trace. 2011-05-06 22:09:07 -07:00
Lassi Tuura 5c2cade264 Inline access to initial register values as it's known to be safe. 2011-05-06 20:19:36 -07:00
Ken Werner 36511d3d1f Add support for handling signal frames on ARM Linux.
This patch add support for resuming at a certain stack frame even if signal
frames are involved. For restoring the registers the trampoline (sigreturn)
is used. RT and non-RT signal frames are handled for both >=2.6.18 and
<2.6.18 kernels.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-05-03 20:18:40 +02:00
Ken Werner 9533ea1a6a Add support for RT signal frame detection on ARM.
This patch adds a few more patterns to the check that detects if the IP
points to a sigreturn sequence.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-05-03 20:18:33 +02:00
Ken Werner 1e10c2931d Add initial support for local unw_resume on ARM Linux.
Provides basic support for resuming execution at a certain stack frame.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-04-21 17:25:42 +02:00
Lassi Tuura ae5c1f2adf Performance optimisations for fast trace.
Insert static branch prediction predicates in useful places and avoid
unnecessary code in the hottest paths. Bypass unnecessary indirect
calls, in particular to access_mem(), when known to be safe.
2011-04-17 20:34:38 -07:00
Arun Sharma e2962af9d3 Implement a cheaper getcontext()
Since the fast unwinding code path doesn't need the full context,
a faster target dependent getcontext is implemented.

Signed-off-by: Lassi Tuura <lat@cern.ch>
2011-04-05 22:07:05 -07:00
Arun Sharma 15f182828d Use __thread instead of pthread_getspecific() 2011-04-05 22:06:51 -07:00
Ken Werner fd21d07fe4 Create a generic and local variant of the extbl parser.
In order to have the DWARF_* macros working properly a generic and a local
variant of the ex_tables.c have been created.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-04-05 20:59:10 -07:00
Lassi Tuura 5f38f35d5d Drop a call frame in tdep_trace and avoid a call to unw_step.
Dropping the extra frame for unw_backtrace itself using unw_step is
approximately 15% slower than skipping the frame in tdep_trace.  So
drop the frame in the latter, and make the function a private
implementation detail for libunwind, not an exported interface.

Also moves unw_getcontext call back into unw_backtrace to avoid an
extra call frame in case slow_backtrace does not get inlined into
unw_backtrace.
2011-04-01 00:00:39 -07:00
Lassi Tuura 50bc12afba Export unw_backtrace() and alias backtrace() to it. 2011-04-01 00:00:33 -07:00
Arun Sharma 2f9b04e9c2 Mark slow_backtrace() ALWAYS_INLINE
Also fix Makefile.am so remote unwinding tests such Gtest-trace
don't link with the local unwind library (libunwind.a).
2011-03-31 22:58:07 -07:00
Lassi Tuura 3b9fd99cb7 Assign copyright as requested by the author. 2011-03-25 00:20:49 -07:00
Lassi Tuura f1ea02be58 Reset 'used' to zero after expanding frame cache hash table. 2011-03-25 00:20:48 -07:00
Arun Sharma 7ff83c051e Fix up compilation and test failures 2011-03-24 23:32:25 -07:00
Lassi Tuura 44a14d1364 Integrate fast trace into backtrace(). 2011-03-24 22:33:55 -07: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
Lassi Tuura 28f33c8ce0 Auto-detect whether to use msync() or mincore() for address validation. 2011-03-24 21:02:28 -07:00
Ken Werner 0f9937485e ARM: Return the dwarf.cfa in case the user requests SP/R13.
Usually we don't have a valid location for the SP but we keep calculating
the value of the CFA. The ARM backend should return this value instead.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-03-24 20:44:33 -07:00
Ken Werner f053677198 Remove the ARM_EXIDX_TABLE_MALLOC code path.
Using malloc is not an option since unw_init_local and unw_step are supposed
to be async signal safe. Therefore this code path can be removed.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-03-24 20:44:33 -07:00
Ken Werner 6296ff1fb2 Remove the appname string of the ARM extbl parser.
There is no need for libunwind to set/fake a name of the elf file from which
the program header came from.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-03-24 20:44:33 -07:00
Ken Werner dcb8d0d90f Prefer to unwind using DWARF info on ARM.
DWARF expressions are more powerful than the ARM specific unwind tables.
Therefore DWARF should be the preferred unwind method.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-03-24 20:44:33 -07:00
Ken Werner fb325c895e ARM extbl cleanup.
Move code that does not necessarily need to reside in the ex_tables.h header
file into ex_tables.c. Add comments and remove unused code.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-03-24 20:44:25 -07:00
Ken Werner cf8d5e41af Have the ARM extbtl-parser operate on the DWARF model directly.
This eliminates the arm_stackframe and therefore the need to synchronize the
two models. It also clears the way for unwinding call stacks with mixed
DWARF- and extbl-frames.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-03-24 20:42:00 -07:00
Konstantin Belousov 04fc88fa31 Fix build and distribution on the FreeBSD.
Signed-off-by: Konstantin Belousov <kostikbel@gmail.com>
2011-03-24 20:41:07 -07:00
Arun Sharma 0613d4c680 Fixup trailing whitespace
Signed-off-by: Arun Sharma <asharma@fb.com>
2011-03-22 08:40:49 -07:00
Zachary T Welch 6a67154674 Use ARM-specific unwinding tables in unw_step
Uses ex_tables routines to provide a new means of unwinding the stack.
Set UNW_ARM_UNWIND_METHOD=4 to use ARM-specific unwinding tables.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-03-22 08:14:58 -07:00
Zachary T Welch ffc474b8c8 Add module for parsing ARM-specific unwind tables
Handles lookup, extracting unwind entries, and decoding the entry
using a callback mechanism.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-03-22 08:14:51 -07:00
Zachary T Welch 049e2ba1b9 Add ARM signal frame detection
Implements a check for call to sigreturn that the kernel will have
setup before jumping to the signal handler.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-03-22 08:14:45 -07:00
Zachary T Welch 6a072982dd Fix file descriptor leakage in maps_init
If mmap fails, be sure to close the maps file before returning an error.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-03-07 21:24:51 -08:00
Ken Werner 4a89b88fd3 Link libunwind-setjmp against libunwind-elf.
This prevents the linker from complaining about a missing symbol when
building the test-setjmp test case.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-03-07 21:24:51 -08:00
Arun Sharma 516304a557 Revert "Use more convenience libraries"
Breaks make check on both x86 (32 and 64 bit)

This reverts commit af88cab09f.
2011-02-01 20:37:25 -08:00
Arun Sharma a83e96cc1c Some entries in /proc/<pid>/maps are not ELF files, so add check
in elf_map_image() to ensure mapped files have a valid ELF header.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
Signed-off-by: Arun Sharma <asharma@fb.com>
2011-01-23 17:55:55 -08:00
Zachary T Welch 5007f8c794 Improve ELF valid_object() helper
Ensures the ELF header version is valid.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
2011-01-23 17:21:04 -08:00
Zachary T Welch af88cab09f Use more convenience libraries
Eliminates obfuscating variables in favor of adding files directly
to library SOURCES.  Eliminates the need for EXTRA_DIST variable.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
2010-11-29 11:29:01 -08:00
Zachary T Welch ce847afb3b Build ELF convenience libraries
Rather than building the sources directly, create a library that
gets linked statically into libunwind.la and libunwind-$(arch).la.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
2010-11-29 11:28:57 -08:00
Zachary T Welch 02dd6c468a Use noinst_HEADERS for distributing .h files
Header files should be listed in a HEADERS automake declaration
rather than in the SOURCES.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
2010-11-29 11:28:54 -08:00
Zachary T Welch 9de666d141 Simplify DWARF source handling
Build DWARF source files into automake convenience libraries to
eliminate duplication in arch-dependent library build rules.
Adds a configure-time check to determine whether to use them.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
2010-11-29 11:28:51 -08:00
Zachary T Welch b07829bedd Simplify LIBRARIES and LTLIBRARIES automake rules
Use automake's '+=' to eliminate obfuscation.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
2010-11-29 11:28:47 -08:00
Zachary T Welch 64a827603c Simplify libunwind_setjmp automake rules
Eliminate redundant listing of libunwind_setjmp source files by
using automake's '+=' operator.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
2010-11-29 11:28:44 -08:00
Zachary T Welch 651e9bb4fd Add MAINTAINERCLEANFILES to Makefile.am files.
Ensures 'make maintainer-clean' removes files generated by autotools.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
2010-11-08 09:06:09 -08:00
Zachary T Welch cf6a998796 Fix memory leak in ARM unw_create_addr_space()
Frees newly created address space memory in the event of a failure
caused by an endian mismatch.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
2010-11-08 09:03:34 -08:00
Sven Neumann 7909c71e5d [PATCH] Add files to EXTRA_DIST so that 'make dist' works again 2010-08-04 14:26:39 -07:00
Arun Sharma 99e60be5a4 Fix the page boundary crossing bug.
Signed-off-by: Jason Evans <jasone@canonware.com>
2010-06-08 14:44:07 -07:00
Konstantin Belousov b3757e7792 Restore the linking when --enable-debug-frame is not specified 2010-05-29 01:07:40 +03:00
Arun Sharma 00aed9631b Add an experimental and optional frame chain unwinding for ARM
The environment variable UNW_ARM_UNWIND_METHOD controls the unwind method.

1 - debug_frame unwinding
2 - frame chain unwinding,
3 - 1 & 2 (default))

Signed-off-by: Andris Zeila <andris.zeila@accenture.com>
2010-05-26 19:28:44 -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
Konstantin Belousov 298e575f2c Fix freebsd build 2010-05-17 21:57:59 +03:00
Arun Sharma 8ee7b1762e Add ip argument to _UPTi_find_unwind_table.
Signed-off-by: Andris Zeila <andris.zeila@accenture.com>
2010-05-15 12:15:49 -07:00
Arun Sharma 1787a2fd28 Add path and pathlen arguments to tdep_get_elf_image()
Signed-off-by: Andris Zeila <andris.zeila@accenture.com>
2010-05-15 12:14:09 -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
Arun Sharma 66b7335ff3 Adds missing register offsets for ARM
Signed-off-by: Andris Zeila <andris.zeila@accenture.com>
2010-05-15 11:56:37 -07:00
Konstantin Belousov e1493dc011 Merge branch 'master' into freebsd 2010-05-03 17:59:50 +03:00
Arun Sharma aa3bb307a3 Fix merge errors 2010-05-03 07:47:41 -07:00
Konstantin Belousov c84005e9c8 Add unwind annotations for freebsd/x86 getcontext.S.
Rearrange the code to put the slow branch out of main body,
and pinch the fixed amount of stack space to be able to annotate
the code.
2010-05-02 17:06:24 +03:00
Konstantin Belousov b73c618a31 Merge branch 'master' into freebsd 2010-05-02 16:29:02 +03:00
Arun Sharma 0176c4f723 Merge commit 'fdc534ccb05d1e6c0438345d292203343a811701' 2010-04-28 17:27:38 -07:00
Arun Sharma fdc534ccb0 Silence a compiler warning 2010-04-28 16:38:27 -07:00
Arun Sharma 215afa30b7 Add unwind descriptors to getcontext.S 2010-04-28 16:32:30 -07:00
Arun Sharma c140d8598d Undo commit f252f5ff4e for now.
Seems to introduce a couple of test breakages.
2010-04-25 09:44:59 -07:00
Arun Sharma d3c4bc4295 Fix a compiler warning 2010-04-25 09:24:40 -07:00
Lassi Tuura 045c55b2a2 Be conservative in all pointer derefrences by default.
Since most people can't completely control their compile or runtime
environment, it becomes hard to ensure that unwind data is perfect.
2010-04-24 19:24:49 -07:00
Lassi Tuura d4fbc8326a Detect end of stack in x86-64 rbp-based walk. 2010-04-24 19:22:08 -07:00
Lassi Tuura 92cc7fd78a Remove obsolete code for 'old way' of handling x86-64 signal frames. 2010-04-24 19:21:52 -07:00
Lassi Tuura f252f5ff4e Recognise and unwind through PLT. 2010-04-24 19:21:26 -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
Konstantin Belousov 58f290e1ce Add config.h. 2010-04-21 15:43:05 +03:00
Konstantin Belousov 2709abc883 msync() also may be called on unaligned address. 2010-04-21 15:33:37 +03:00
Konstantin Belousov 4454413242 Account for possible unaligned access. 2010-04-21 15:18:02 +03:00
Konstantin Belousov ee99dbec87 Use mincore instead of msync when available 2010-04-20 17:45:18 +03:00
Konstantin Belousov 75b76d1f45 Save FPU context for i386. 2010-04-17 00:18:33 +03:00
Konstantin Belousov b1c68e060c Arrange the FreeBSD ucontext offset definitions in ascending order. 2010-04-17 00:17:58 +03:00
Giuseppe Scrivano a67654e86f [PATCH] Reduce scope of the eh_frame_end local variable 2010-04-14 12:11:29 -07:00
Arun Sharma 1d9c5a356d Fix compiler warnings on x86_64 Linux 2010-04-14 12:01:37 -07:00
Arun Sharma 5a70fab451 Fix compiler warnings on x86 Linux 2010-04-14 18:54:20 -07:00
Konstantin Belousov 127acf8e97 Use correct offset name and value for ucontext offset in struct sigframe 2010-04-14 12:15:05 +03:00
Konstantin Belousov 0d311ea161 Add abort() after sigreturn calls 2010-04-14 12:10:34 +03:00
Konstantin Belousov 34b064bf22 Fix typo. 2010-04-14 12:10:14 +03:00
Konstantin Belousov 1e77c66a51 Fix FreeBSD/x86_64 sigcontext restore 2010-04-14 12:04:28 +03:00
Konstantin Belousov 61f4345a9e Fix an issue where len was too short for sysctl to recieve the process
vm map.
2010-04-13 15:33:11 +03:00
Konstantin Belousov 02d0cb6f71 Do not save FPU context on x86 for now; XMM save area must be 16-bytes aligned 2010-04-13 14:20:22 +03:00
Konstantin Belousov ae7eebb839 Separate getcontext implementation for x86 2010-04-13 14:11:39 +03:00
Konstantin Belousov 66e49bdd41 Save %eax for i386 2010-04-13 13:55:23 +03:00
Konstantin Belousov 5a7407dd94 Merge branch 'master' into freebsd 2010-04-12 22:34:24 +03:00
Arun Sharma c2d78041cc GCC compatibility on x86 for C++ exception handling 2010-04-12 12:08:43 -07:00
Giuseppe Scrivano eb8857a324 Silence a compiler warning 2010-04-12 10:45:31 -07:00
Konstantin Belousov 843190597c Remove unneeded include.
Noted by:	Arun Sharma
2010-04-11 22:07:31 +03:00
Konstantin Belousov 21f0e90ce8 Rework 69001646fa, store sigframe address into sigcontext_addr. 2010-04-11 22:01:08 +03:00
Konstantin Belousov 42bc15c72c Provide proper register offsets in the gregset for FreeBSD/i386 2010-04-11 19:18:07 +03:00
Konstantin Belousov f10f851916 Add slightly more debug output 2010-04-11 14:59:36 +03:00
Konstantin Belousov e33fa9f73c Ditch using the libutil, it is not async-signal safe. 2010-04-11 14:36:24 +03:00
Konstantin Belousov 69001646fa Store the ucontext_t pointer to properly handle resume across signal frames. 2010-04-11 13:48:14 +03:00
Konstantin Belousov f01a043712 Convince gcc that x86_64_sigreturn cannot return, as declared. 2010-04-11 13:47:28 +03:00
Konstantin Belousov a688d6c4c9 Remove unused variable. 2010-04-10 18:51:17 +03:00
Konstantin Belousov dd1c7b6c1a Declare mxcsr as XMM 2010-04-10 18:48:35 +03:00
Konstantin Belousov 53f7e650e0 For FreeBSD/i386, add real offset values for FPU context fields. 2010-04-10 18:48:16 +03:00
Konstantin Belousov 6f7b335e89 Add my copyrights to several files that contain essential modifications 2010-04-10 01:42:26 +03:00
Konstantin Belousov 9fe75c7d93 Save FPU state when saving context. For XMM-capable CPUs only (for now). 2010-04-10 00:47:08 +03:00
Konstantin Belousov 117ccd246d Move all XMM offsets into one place. 2010-04-10 00:46:51 +03:00
Konstantin Belousov f6546e27ed Implement the base code to fetch x86/xmm state on x86. Offsets to be filled. 2010-04-10 00:40:39 +03:00
Konstantin Belousov 2c50c95cde Correct arguments for Debug().
Shut up warning by using the cast.
2010-04-10 00:38:54 +03:00
Arun Sharma d1676f192e Fix warnings on 32 bit x86 2010-04-08 03:12:05 -07:00
Arun Sharma caa6095aec Fix compile errors on Linux 2010-04-07 19:59:06 -07:00
Konstantin Belousov 979af4502f Move local_resume to os-specific file. 2010-04-05 23:00:27 +03:00
Konstantin Belousov 0dbeeeb08d Move uc_addr to os-specific file 2010-04-05 22:42:23 +03:00
Konstantin Belousov 79d012348d Move get_scratch_loc() to os-specific file. 2010-04-05 22:22:55 +03:00
Konstantin Belousov aeee03dd74 Reduce diffs to master 2010-04-05 16:28:46 +03:00
Konstantin Belousov ccc0ae665b More move of osdep code. 2010-04-05 16:25:36 +03:00
Konstantin Belousov a40641f326 Trim spaces 2010-04-05 16:25:20 +03:00
Konstantin Belousov fd88f41818 Merge remote branch 'origin/master' into freebsd
Conflicts:
	src/x86/Gis_signal_frame.c
	src/x86/Gstep.c
	src/x86_64/Gis_signal_frame.c
	src/x86_64/Gstep.c
2010-04-05 16:14:50 +03:00
Arun Sharma 8e53e62db9 Refactor os specific code for x86 (both 32 and 64 bit).
Move Linux specific code into ${arch}/Gos-linux.c
2010-04-04 16:46:13 -07:00
Konstantin Belousov 980ccffe9e Merge remote branch 'origin/master' into freebsd
Conflicts:
	src/x86/Gis_signal_frame.c
2010-04-04 12:44:10 +03:00
Arun Sharma 2b7ca45acc Fix handling of SA_SIGINFO frames on 32 bit x86
Submitted by: Arne de Bruijn <mail@arnedebruijn.nl>
2010-04-03 16:49:18 -07:00
Konstantin Belousov bd2798805a Reformat os-freebsd.c. 2010-04-03 23:29:28 +03:00
Konstantin Belousov 5715d912f4 Make setjmp/longjmp work at least on FreeBSD/amd64.
FreeBSD-supplied setjmp() saves incremented stack pointer into jmpbuf.

I have no idea whether siglongjmp ever worked on amd64, since
UNW_NUM_EH_REGS == 2 and abort at siglongjmp.c:81 is firing.
2010-04-03 19:02:43 +03:00
Konstantin Belousov 31ece3eaa1 Fix setcontext for amd64 freebsd 2010-04-03 18:28:31 +03:00
Konstantin Belousov 9bb9c972e6 Merge with origin/master 2010-03-31 16:01:38 +03:00
Arun Sharma 6203f1cd0f Cleanup a mapped elf image.
Without this, we end up with mmap leaks. Thanks to Humberto Abdelnur
for suggesting this.
2010-03-26 15:54:14 -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
Konstantin Belousov 8a75ba971a Signal trampoline on amd64 for ia32 is special. 2010-03-13 21:26:50 +02:00
Konstantin Belousov e51429280b Handle error return from is_signal_frame 2010-03-13 20:31:12 +02:00
Konstantin Belousov e9cd30040e Move x86 porting further. 2010-03-13 20:28:12 +02:00
Konstantin Belousov 71c4161247 Remove extra empty line 2010-03-13 18:33:22 +02:00
Arun Sharma f8a15e9679 Fix a couple of test breakages on x86_64
setcontext() now restores the signal mask. Also remove a check
in the test that doesn't seem to be valid.
2010-03-10 22:52:12 -08:00
Konstantin Belousov a6b23dcb0c Add partial implementation for is_signal_frame for i386. 2010-03-11 00:50:40 +02:00
Konstantin Belousov 54f8b2fdbe Fill real offsets for freebsd 2010-03-11 00:02:24 +02:00
Konstantin Belousov 47dcc89457 Remove unneeded braces 2010-03-10 23:51:59 +02:00
Konstantin Belousov bb41eba56c FreeBSD/i386 port. get/setcontext need further work 2010-03-09 18:01:25 +02:00
Konstantin Belousov 9f79621a29 Enough for now for ptrace backend 2010-03-08 20:55:50 +02:00
Konstantin Belousov 752ce15c4f Preliminary version of freebsd syscall unwinder 2010-03-08 19:45:54 +02:00
Konstantin Belousov c1b1c10cfc Fix memory leak on error 2010-03-08 18:48:27 +02:00
Konstantin Belousov 89e1df2d32 Fix _UI_siglongjmp_cont name 2010-03-08 15:55:29 +02:00
Konstantin Belousov 0f1c0f5f66 Fix resume. 2010-03-08 15:51:39 +02:00
Konstantin Belousov 43ed5b3e56 Add required assembler magic. 2010-03-08 00:57:50 +02:00
Konstantin Belousov 5f5b1a5daa tdep_get_elf_image should be public 2010-03-08 00:52:26 +02:00
Konstantin Belousov 093855f12a Remove unneeded includes of sys/types.h 2010-03-08 00:25:22 +02:00
Konstantin Belousov 53095e6b3e Code for resume 2010-03-07 23:43:07 +02:00
Konstantin Belousov c64723835c Support walk over freebsd sigframes 2010-03-07 21:53:01 +02:00
Konstantin Belousov d0d5f9979b Correct rsp offset 2010-03-07 21:20:43 +02:00
Konstantin Belousov efd0655ff4 Silence warning about symbol redefinition. 2010-03-07 17:27:41 +02:00
Konstantin Belousov d7eea91448 Cast caddr_t argument for ptrace 2010-03-07 12:27:03 +02:00
Konstantin Belousov 200147d0f2 Handle fpu state 2010-03-06 23:22:46 +02:00
Konstantin Belousov 62218e10eb Provide proper offsets for gregs in freebsd ucontext. Note that fp regs are not handled. 2010-03-06 22:33:11 +02:00
Konstantin Belousov 63ae8ca894 Correct assignments, remove unneeded includes. 2010-03-06 22:32:11 +02:00
Konstantin Belousov 4de09a9c15 Implement freebsd-specific vm walker. 2010-03-06 18:53:27 +02:00
Konstantin Belousov 81f2de0083 Add implementation of unw_is_signal_frame for freebsd. 2010-03-06 18:08:44 +02:00
Konstantin Belousov 1ba7599250 Add FreeBSD stub. 2010-03-06 17:54:51 +02:00
Konstantin Belousov 2646e0fde8 Add freebsd stub 2010-03-06 17:51:00 +02:00
Konstantin Belousov 3eabce18b1 Include sys/types.h when needed. 2010-03-06 16:43:39 +02:00
Konstantin Belousov 29c110265f _NSIG. 2010-03-06 16:43:18 +02:00
Konstantin Belousov c7ffca11ae FreeBSD way to name registers. 2010-03-06 16:35:32 +02:00
Konstantin Belousov 78cb28b4a6 PT_CONTINUE. 2010-03-06 16:20:47 +02:00
Konstantin Belousov d4a4ddd23d Provide access to the general regs on FreeBSD. 2010-03-06 16:17:21 +02:00
Konstantin Belousov cf6ae3548f Code to read/write user memory on FreeBSD 2010-03-06 15:04:56 +02:00
Konstantin Belousov d11456ffbf Code to read/write fpregs on FreeBSD 2010-03-06 14:55:11 +02:00
Konstantin Belousov 905034ce72 Initial attempt at the build infrastructure for FreeBSD. 2010-03-06 00:41:37 +02:00
Arun Sharma 3468a6b33d Change MS_SYNC to MS_ASYNC
Hopefully this makes the address validation a bit cheaper.
2010-02-23 10:35:47 -08:00
Stefan Demharter 752076789f Be gcc compatible for C++ exceptions on 32 bit platforms. 2010-02-21 22:45:08 -08:00
Arun Sharma 5a1d3c6fd7 Remove bogus check on scan_string which is guaranteed to fail every time. 2010-02-21 22:35:26 -08:00
Paul Pluzhnikov 54752e0df0 Implement getcontext for x86
Greetings,

Attached patch implements getcontext for x86.

Motivation is the same as:
http://lists.nongnu.org/archive/html/libunwind-devel/2008-06/msg00009.html

This also fixes check-name-space on x86.

Tested on Linux/86 with no new failures.

Thanks,
--
Paul Pluzhnikov
2009-12-23 09:59:52 -08:00
Paul Pluzhnikov 0cf76ed0b5 Check for NULL when validating addresses
This is rather on the obvious side.

While doing strace on an executable using libunwind, I noticed a
lot of:

  msync(0, 1, MS_SYNC) = -1 ENOMEM (Cannot allocate memory)

Since we know that the first page isn't mapped (or at least doesn't
contain the data we are looking for), we can eliminate all such
msync calls.

Tested on Linux/x86_64 with no regressions.
2009-12-01 13:59:45 -08: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 4b8404d153 Remove the special casing of ia64 for GetIPInfo()
This rule (no IP adjustment on ia64) may be correct for locating the right FDE.

Unfortunately the same adjusted/unadjusted return address is being used also by
__gxx_personality_v0() to locate the right call-site (the try {} block) for
unwinding.  And this case is already sensitive for off-by-one PC values.
Unlike the FDE location where the function prologue + epilogue make it immune
against off-by-one PC calculations.

Therefore suggesting to unify it with non-ia64 case.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
2009-04-24 11:10:08 -07:00
Arun Sharma 6aec15799d Fix ppc32 build.
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
2009-04-13 11:44:45 -07:00
Arun Sharma 40afb6667d Use a shorter path for include
This should've been a part of: 2fce54102c
2009-04-13 10:57:21 -07:00
Arun Sharma 2fce54102c Implement _Unwind_GetIPInfo() as required by the C++ ABI
Provide a special implementation for ia64, because the unwind
information is such that an IP adjustment is not necessary before
looking up unwind info.

Bad things happen if libunwind only provides parts of the ABI and
the rest come from libgcc.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
2009-04-02 22:22:05 -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 ff0ae70cc3 Bad pointer validation for 32 bit x86.
This corresponds to commit 649f1fb344.

Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
2009-03-16 21:34:49 -07:00
Arun Sharma 5822fca27a Enable Intel C++ compatibility only when C++ exceptions are enabled. 2009-03-16 21:34:49 -07:00
Arun Sharma 0bce5f0016 Remove auto generated files. 2009-03-16 21:34:49 -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
David Mosberger-Tang 638302ed73 Rerun autoreconf. 2008-06-16 14:43:21 -06:00
Arun Sharma ef29eade44 This patch eliminates one system call per unwind by not using the
getcontext in libc.

Also cleanup the namespace (check-name-space passes on x86_64 now).
Replace uses of offsets.h with ucontext_i.h.
Rename _x86_64_setcontext to _Ux86_64_setcontext.

TBD: Add CFI annotations for get/setcontext.

Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2008-06-16 14:42:16 -06:00
Arun Sharma 649f1fb344 [X86-64] For local unwinding, we have a defence mechanism against
bad/missing unwind information, which could result in libunwind
dereferencing bad pointers. This mechanism is based on msync(2) system
call and significantly reduces the chances of a bad pointer
dereference in libunwind.

The original idea was to turn this mechanism on only when necessary
i.e. libunwind didn't find proper unwind information for a IP.

There are a couple of problems in the current implementation.

* The flag is global and is modified without locking
* The flag isn't reset when starting a new unwind

The attached patch makes ->validate a per-thread setting by moving it
into struct cursor from unw_local_addr_space and resets it to false
when starting a new unwind. As a result, cursor->as_arg points to the
cursor itself instead of the ucontext (for the local case).

This was found to reduce the number of msync() system calls from an
application using libunwind significantly.

Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2008-06-16 14:35:53 -06:00
David Mosberger-Tang 183d28a066 Rebuild autoconf files with autoreconf. 2008-06-16 14:30:38 -06:00
Arun Sharma 8081e82ba1 Make the linking of C++ ABI related code for exceptions optional.
The default is to have it enabled.

Signed-off-by: Arun Sharma <arun.sharma@google.com>
2008-06-16 14:28:36 -06:00
Bruna Moreira 1eddefc371 [ARM] This patch add some missing bits on ARM platform.
* src/arm/unwind_i (arm_lock, arm_local_resume): Define.
 * src/ptrace/_UPT_find_proc_info.c: Handle ARM like X86 etc.
 * tests/flush-cache.S (flush_cache): Add (dummy) ARM-version.
	ARM does need executable stack, even on Linux...

Signed-off-by: Anderson Lizardo <anderson.lizardo@indt.org.br>
Signed-off-by: Bruna Moreira <bruna.moreira@indt.org.br>
2008-04-21 13:43:18 -06:00
Paul Pluzhnikov bb9d3dc689 [X86-64] Fix the pattern used to match signal frames.
The current pattern is too restrictive and doesn't work well on
modern glibcs.

Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2008-04-16 08:05:49 -06: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
David Mosberger-Tang f5cb2c52dc 2007-12-14 Mark Wielaard <mwielaard@redhat.com>
* src/mi/Gget_reg.c (unw_get_reg): Use tdep_get_ip() when
   looking for UNW_REG_IP.
2008-01-07 15:43:42 -07:00