summaryrefslogtreecommitdiffstats
path: root/tests/backtrace.c
Commit message (Collapse)AuthorAgeFilesLines
* tests: skip '(null)' symname frames in backtrace testsMark Wielaard2023-03-051-0/+8
| | | | | | | | | | | | Some setups might have some frames for unknown (null) functions in the thread backtrace. Skip these frames instead of failing immediately. * tests/backtrace.c (callback_verify): Check and skip nulls_seen. https://sourceware.org/bugzilla/show_bug.cgi?id=29176 Signed-off-by: Mark Wielaard <[email protected]>
* tests: Allow an extra pthread_kill frame in backtrace testsMark Wielaard2021-08-051-7/+54
| | | | | | | | | | | | glibc 2.34 calls pthread_kill from the raise function. Before raise directly called the (tg)kill syscall. So allow pthread_kill to be the first frame in a backtrace where raise is expected. Also change some asserts to fprintf plus abort to make it more clear why the testcase fails. https://sourceware.org/bugzilla/show_bug.cgi?id=28190 Signed-off-by: Mark Wielaard <[email protected]>
* tests: Don't printf a known NULL symname.Mark Wielaard2019-04-301-1/+1
| | | | | | | GCC9 on 32bit systems might warn about '%s' directive argument is null for symname in backtrace.c. Just check whether symname is NULL. Signed-off-by: Mark Wielaard <[email protected]>
* tests: Remove tgkill define from backtrace.cMark Wielaard2019-03-041-1/+0
| | | | | | | | tgkill is never used in the test and it might conflict with newer glibc which might define tgkill themselves (just like gettid): https://sourceware.org/bugzilla/show_bug.cgi?id=6399 Signed-off-by: Mark Wielaard <[email protected]>
* tests: Remove assert (errno == 0) from tests.Mark Wielaard2019-01-311-5/+0
| | | | | | | When a function fails it might set errno. But it isn't a guarantee that if a function succeeds that it sets errno to zero. Signed-off-by: Mark Wielaard <[email protected]>
* Consolidate error.h inclusion in system.hRoss Burton2018-07-051-1/+1
| | | | | | | | | error.h isn't standard and so isn't part of the musl C library. To easy future porting, consolidate the inclusion of error.h into system.h. https://sourceware.org/bugzilla/show_bug.cgi?id=21008 Signed-off-by: Ross Burton <[email protected]>
* 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 <[email protected]>
* Add frame pointer unwinding for aarch64 and relax backtrace testcases.Ulf Hermann2017-05-021-0/+12
| | | | | | | | | | | | | | | If we don't find any debug information for a given frame, we usually cannot unwind any further. However, the binary in question might have been compiled with frame pointers, in which case we can look up the well known frame pointer locations in the stack snapshot and use them to bridge the frames without debug information. Relax the backtrace core testcases a little by allowing a duplicate sigusr2 frame or a backtrace ending with an invalid register. Both of which can happen if the frame pointer unwinder guesses slightly wrong. Signed-off-by: Ulf Hermann <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Revert "Optionally allow unknown symbols in the backtrace tests"Mark Wielaard2017-05-021-22/+8
| | | | | | | | | | | | | | This reverts commit f9971cb422df39adea7e8c7e22689b879e39c626. Allowing no symbol resolving at all makes it too hard to see whether the test actually tests anything. But do keep "address out of range" as allowed error in check_err. This can be interpreted as DWARF not available (if end of callstack marker is missing, which it unfortunately often is missing even if CFI is available.). Signed-off-by: Mark Wielaard <[email protected]>
* Optionally allow unknown symbols in the backtrace testsUlf Hermann2017-02-141-8/+22
| | | | | | | | This is useful to test unwinding without debug information. The binaries being examined might still have frame pointers that allow us to bridge the unknown symbols. Signed-off-by: Ulf Hermann <[email protected]>
* Add GCC7 -Wimplicit-fallthrough support/fixes.Mark Wielaard2016-11-101-1/+1
| | | | | | | | | | | GCC7 will have a new -Wimplicit-fallthrough warning. It did catch one small buglet in elflint option procession. So it seems useful to enable to make sure all swatch case fallthroughs are deliberate. Add configure check to detect whether gcc support -Wimplicit-fallthrough and enable it. Add fixes and explicit fallthrough comments where necessary. Signed-off-by: Mark Wielaard <[email protected]>
* tests: Simplify backtrace-native tests. Drop raise jmp patching for x86_64.Mark Wielaard2016-08-251-18/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The backtrace-native[-biarch] testcase was a little too clever in places making it unreliable. On x86_64 we tried to make an interesting backtrace by catching the first signal and then replacing the pc with the address of the first instruction of a function. Then we would raise a new signal, through ptrace, to create a backtrace that went from a signal frame into a frame at the start of a function. That way we could check that we were trying to fetch the correct CFI for the (jmp) function even at the first instruction (normally we would substract one from the return address to get at the call address). This works as long as the CFI for the jmp() function is identical to the CFI for the raise() function that we "patched away". Unfortunately on Fedora rawhide glibc has a rewritten raise() implementation that has different CFI, in particular the CFA is calculated differently. Making the testcase fail because we cannot properly unwind from jmp(). So this special x86_64 case has been disabled (the code is still there in case we find another way to test this in a more reliable way). On Ubuntu there have been spurious testcase failures because see_exec_module found two Dwfl_Modules with the same path. This would trigger an assert. Although this might indicate some issue (maybe we are not parsing the proc/pid/map correctly?) it isn't clear that it really is a bug. Since the assert is not very helpful finding any actual bug and for the testcase it is only necessary that the first Dwfl_Module that represents the executable is found we just pick that Dwfl_Module and don't iterate through any of the others. Signed-off-by: Mark Wielaard <[email protected]>
* Reduce scope of some includesPino Toscano2015-06-271-0/+2
| | | | | | | | Use some includes only according to the #ifdef block of the respective code, or matching the fact they are Linux-only. This way, includes potentially unportable are not unconditionally used. Signed-off-by: Pino Toscano <[email protected]>
* Replace assert_perror with assertMax Filippov2015-05-051-5/+5
| | | | | | | assert_perror is a GNU extension, it's not provided by uClibc and it's only used in tests. Replace it with assert. Signed-off-by: Max Filippov <[email protected]>
* tests: Use PTRACE_GETREGS/PTRACE_SETREGS to update ripH.J. Lu2015-03-131-3/+7
| | | | | | | Use PTRACE_POKEUSER to update rip is unsupported for x32. We should use PTRACE_GETREGS/PTRACE_SETREGS to update rip. Signed-off-by: H.J. Lu <[email protected]>
* tests: ensure backtrace.c exec_dump sets jmpJosh Stone2015-02-111-1/+1
| | | | | | | | | | | | With CFLAGS='-Og -g', F21 gcc hits -Werror=maybe-uninitialized on jmp in the call "prepare_thread (pid2, jmp)". It's fine with -O2/-O0. The only way this could be unset is if the loop before ran to completion, and there's already an assert against this case. This patch initializes jmp anyway to convince gcc it's ok. Signed-off-by: Josh Stone <[email protected]>
* tests/backtrace.c (frame_callback): Error on seeing more than 16 frames.Mark Wielaard2014-06-171-0/+7
| | | | | | Don't fill up the test logs with obviously bogus frames. Signed-off-by: Mark Wielaard <[email protected]>
* tests: backtrace.c accept __libc_do_syscall as first frame symname.Mark Wielaard2014-06-171-1/+2
| | | | | | | | On some architectures (Debian armhl) system calls go through __libc_do_syscall instead of __kernel_vsyscall. Accept either of these symbol names for the first backtrace frame. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Record dwfl_attach_state error and return it on failure.Mark Wielaard2014-06-111-1/+4
| | | | | | | | | | | When dwfl_attach_state fails functions that need the process state should return the error that caused the attach to fail. Use this in the backtrace test to signal any attach failure. This makes sure that architectures that don't provide unwinder support get properly detected (and the tests SKIPs) Also don't assert when trying to attach a non-core ELF file, but return an error to indicate failure. Signed-off-by: Mark Wielaard <[email protected]>
* Unwinding is only supported on LinuxKurt Roeckx2014-04-231-0/+15
| | | | Signed-off-by: Kurt Roeckx <[email protected]>
* tests: Don't use ptrace detach stopped trick. Raise can return.Mark Wielaard2014-01-041-12/+1
| | | | | | | | | | On older kernels the ptrace detach stop trick doesn't work reliably. Just keep the child processes attached and stopped during the tests, dwfl_linux_proc_attach will handle that fine now. Also on older kernels raise would sometimes return anyway and cause a spurious assert. Just ignore it. Signed-off-by: Mark Wielaard <[email protected]>
* libdwfl: Add dwfl_core_file_attach and dwfl_linux_proc_attach.Mark Wielaard2013-12-311-0/+6
| | | | | | | | | | | | | | Rewrite __libdwfl_attach_state_for_pid and __libdwfl_attach_state_for_core as public functions and don't call them from dwfl_linux_proc_report and dwfl_core_file_report anymore. This lets the user attach state explicitly independ from how the dwfl modules have been reported. Since attaching state is an explicit action now the error can be returned directly and we don't need to keep track of process_attach_error. dwfl_linux_proc_attach lets the user can tell libdwfl whether caller takes care of ptrace attaching and stopping the threads under inspection, or whether the callback needs to take care of that and detaching again. Signed-off-by: Mark Wielaard <[email protected]>
* tests: backtrace.c only check we caught the last instruction on x86_64.Mark Wielaard2013-12-211-1/+7
| | | | | | | | | | On some architectures gcc might introduce some "padding instructions" at the end of the function (like on ppc64). So only assert we are at the last instruction of backtracegen if on x86_64 native. In theory the assert could even fail on that architectures, but in practice it doesn't and it is a nice test to have. Signed-off-by: Mark Wielaard <[email protected]>
* Tests for unwinder of x86*.Jan Kratochvil2013-12-021-0/+452
Signed-off-by: Jan Kratochvil <[email protected]>