summaryrefslogtreecommitdiff
path: root/libdwfl/frame_unwind.c
Commit message (Collapse)AuthorAgeFilesLines
* libdwfl: Handle unwind frame when the return address register isn't set.Mark Wielaard2018-04-131-16/+30
| | | | | | | | | | | | | | | | When we have unwound the frame and then cannot set the return address we wouldn't set any error. That meant that a dwfl_thread_getframes () call could end in an error, but without any dwfl_errno set, producing the "no error" error message. If we cannot set the return address at the end of unwinding the frame that means that either the return address register is bogus (error), or that the return address is undefined (end of the call stack). This fixes the run-backtrace-native-biarch.sh testcase for me on an i386 on x86_64 setup with gcc 7.2.1 and glibc 2.17. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Use fallthrough attribute.Joshua Watt2018-02-101-1/+1
| | | | | | | | | | | | | | | Use __attribute__ ((fallthrough)) to indicate switch case fall through instead of a comment. This ensures that the fallthrough warning is not triggered even if the file is pre-processed (hence stripping the comments) before it is compiled. The actual fallback implementation is hidden behind a FALLBACK macro in case the compiler doesn't support it. Finally, the -Wimplict-fallthrough warning was upgraded to only allow the attribute to satisfy it; a comment alone is no longer sufficient. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
* Clean up linux-specific system includesUlf Hermann2017-04-261-1/+0
| | | | | | We only include them where we actually need them and only on linux. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* lib: Provide MAX and MIN in system.hAkihiko Odaki2016-10-121-4/+1
| | | | | | | | | | This change also creates a new header file libeu.h to provide the prototypes for the function of libeu. That hides the definition of function crc32, which can conflict with zlib, from libelf. It also prevents mistakes to refer those functions from a component which doesn't link with libeu, such as libelf. Signed-off-by: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
* libdwfl: Don't crash on out of memory when frame unwinding.Mark Wielaard2016-02-221-5/+18
| | | | | | | new_unwound didn't check whether malloc was successful. Check that we could allocate memory before use and return DWFL_E_NOMEM otherwise. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: make the unwinder aware of the backend defined ra_offset.Jose E. Marchesi2016-01-031-1/+8
| | | | | | | | | Ebl backends can define an offset that must be applied to the value of the "return address register" defined in the CFI ABI information. This patch makes the unwinder to use that offset when reading the RA CFI register. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
* Move nested functions in frame_unwind.c.Chih-Hung Hsieh2015-11-031-73/+90
| | | | | | | | * Nested functions 'pop' and 'push' in libdwfl/frame_unwind.c are moved to file scope. Used local variables are passed in struct eval_stack. Signed-off-by: Chih-Hung Hsieh <chh@google.com>
* libdwfl: Replace abs with llabs for int64_t values.Chih-Hung Hsieh2015-09-091-1/+1
| | | | | Signed-off-by: Chih-Hung Hsieh <chh@google.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libebl: Add ebl_func_addr_mask plus ARM backend implementation.Mark Wielaard2014-06-221-1/+5
| | | | | | | | | | | | | | The ARM EABI says that the zero bit of function symbol st_value indicates whether the symbol points to a THUMB or ARM function. Also the return value address in an unwind will contain the same extra bit to indicate whether to return to a regular ARM or THUMB function. Add a new ebl function to mask off such bits and turn a function value into a function address so that we get the actual value that a function symbol or return address points to. It isn't easily possible to reuse the existing ebl_resolve_sym_value for this purpose, so we end up with another hook that can be used from dwfl_module_getsym, handle_cfi and elflint. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: __libdwfl_frame_reg_[gs]et use uint64_t when checking bits.Mark Wielaard2014-04-241-2/+2
| | | | | | | Found by gcc -fsanitize=undefined while running the backtrace-core-ppc test. runtime error: shift exponent 45 is too large for 32-bit type 'unsigned int' Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: Only skip reset of return register for non-CIE-return regno (ppc64).elfutils-0.158Mark Wielaard2014-01-051-2/+3
| | | | | | | | | | | | | For PPC64 we skip resetting the return register if it is already set. This is because on PPC64 there are two DWARF registers numbers that can represent the same register. Setting the return address again confuses the unwinder. But we do want to reset it if the register number (non-translated by the ppc64 ebl) is equal to the actual register number as set in the CIE as return address. This happens on older toolchains in .debug_frame where the return address is set to 108, but the ebl abi_cfi also sets register number 65. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: Make sure to set the CFI return register only once (for ppc64).Mark Wielaard2013-12-251-2/+25
| | | | | | | | On PPC64 there are two DWARF registers numbers that can represent the same register. If that register is the CIE return register then we only want to set it once. The second setting will confuse the unwinder. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* unwinder: s390 and s390xJan Kratochvil2013-12-181-9/+84
| | | | Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* Fix forgotten call of ebl_dwarf_to_regno.Jan Kratochvil2013-12-171-1/+1
| | | | Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* libdwfl: Fix various frame related memory leaks.Mark Wielaard2013-12-161-0/+1
| | | | | | | | | | The result of dwarf_cfi_addrframe should have been freed when done. Dwfl_Module cached the reloc_info and the eh_cfi it which also should have been released when disposing of the module. Reported-by: Masatake YAMATO <yamato@redhat.com> Tested-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* unwinder: ppc and ppc64Jan Kratochvil2013-12-151-0/+4
| | | | Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* Unwinder for x86*.Jan Kratochvil2013-11-071-0/+617
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>