diff options
| author | Mark Wielaard <[email protected]> | 2016-08-25 17:17:23 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2016-08-25 21:02:11 +0200 |
| commit | 9008499a5276c45b37bc0adb47e7ad227e6ba2a9 (patch) | |
| tree | 1bc5f04f83f072d4107a1d93bdfa395d42dadbee /tests/backtrace-child.c | |
| parent | 324cc566974470090ed4a86f38afafe231501320 (diff) | |
tests: Simplify backtrace-native tests. Drop raise jmp patching for x86_64.
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]>
Diffstat (limited to 'tests/backtrace-child.c')
| -rw-r--r-- | tests/backtrace-child.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/backtrace-child.c b/tests/backtrace-child.c index 40e7b32d..cf4547ca 100644 --- a/tests/backtrace-child.c +++ b/tests/backtrace-child.c @@ -1,5 +1,5 @@ /* Test child for parent backtrace test. - Copyright (C) 2013 Red Hat, Inc. + Copyright (C) 2013, 2016 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -19,7 +19,8 @@ --ptraceme will call ptrace (PTRACE_TRACEME) in the two threads. --gencore will call abort () at its end. Main thread will signal SIGUSR2. Other thread will signal SIGUSR1. - On x86_64 only: + There used to be a difference between x86_64 and other architectures. + To test getting a signal at the very first instruction of a function: PC will get changed to function 'jmp' by backtrace.c function prepare_thread. Then SIGUSR2 will be signalled to backtrace-child which will invoke function sigusr2. @@ -66,8 +67,17 @@ # 5 0xf77c1a48 - 1 start # 6 0xf77699da - 1 start_thread # 7 0xf769bbfe - 1 __clone + + But the raise jmp patching was unreliable. It depends on the CFI for the raise() + function in glibc to be the same as for the jmp() function. This is not always + the case. Some newer glibc versions rewrote raise() and now the CFA is calculated + differently. So we disable raise jmp patching everywhere. */ +#ifdef __x86_64__ +/* #define RAISE_JMP_PATCHING 1 */ +#endif + #include <config.h> #include <assert.h> #include <stdlib.h> @@ -130,7 +140,7 @@ dummy1 (void) asm volatile (""); } -#ifdef __x86_64__ +#ifdef RAISE_JMP_PATCHING static NOINLINE_NOCLONE USED void jmp (void) { @@ -157,7 +167,7 @@ stdarg (int f UNUSED, ...) assert (errno == 0); assert (l == 0); } -#ifdef __x86_64__ +#ifdef RAISE_JMP_PATCHING if (! gencore) { /* Execution will get PC patched into function jmp. */ |
