strace-k.test is failed on i386 GNU/Linux. I inspect the reason and it seems that libunwind does not have enough ability to unwinding the stack when pc is at [vdso]. However, I think stacktrace feature is still useful even on i386 GNU/Linux. So this patch relaxes the pass condition of strace-k.test test case.
Background: It seems that call convention at vdso on i386 linux is different from explanations on widely available texts. Generally $ebp + 4 points return address for the current frame. libunwind may use this convention for unwinding. However, this convention is not applicable at vdso on i386 linux. Gdb may know the convention used in the vdso. I run a program extended from stack-fcall.c under gdb. Call sequence of extended stack-fcall.c is main -> f0 -> f1 -> f2 -> getpid -> sysenter@[vdso]. Following gdb session is stopped just after sysenter@[vdso]. With where command of gdb, the call sequence is printed. However, with unwinding manually, in other words tracking $ebp, the addresses of f2 and getpid are not found. f1, f0 and main can be unwined well. ---- GDB SESSION ---- (gdb) stepi 0xb7fff424 in __kernel_vsyscall () (gdb) disass Dump of assembler code for function __kernel_vsyscall: 0xb7fff414 <+0>: push %ecx 0xb7fff415 <+1>: push %edx 0xb7fff416 <+2>: push %ebp 0xb7fff417 <+3>: mov %esp,%ebp 0xb7fff419 <+5>: sysenter 0xb7fff41b <+7>: nop 0xb7fff41c <+8>: nop 0xb7fff41d <+9>: nop 0xb7fff41e <+10>: nop 0xb7fff41f <+11>: nop 0xb7fff420 <+12>: nop 0xb7fff421 <+13>: nop 0xb7fff422 <+14>: int $0x80 => 0xb7fff424 <+16>: pop %ebp 0xb7fff425 <+17>: pop %edx 0xb7fff426 <+18>: pop %ecx 0xb7fff427 <+19>: ret End of assembler dump. (gdb) print/x *(void **)($ebp + 4) $57 = 0x8048457 (gdb) where #0 0xb7fff424 in __kernel_vsyscall () #1 0x47636fde in getpid () from /lib/libc.so.6 #2 0x0804843d in f2 (i=1) at stack-fcall.c:9 #3 0x08048457 in f1 (i=1) at stack-fcall.c:15 #4 0x08048471 in f0 (i=1) at stack-fcall.c:21 #5 0x0804848e in main (argc=1, argv=0xbffff534) at stack-fcall.c:27 ---- GDB SESSION ---- How the test case is relaxed: Though two frames on the stack are lost, I think stacktrace feature is useful. So I decide to relax the pass condition of test case. * tests/stack-fcall.c (f2): New function. (f1): Call f2. Added one more function call. * tests/strace-k.test: check the output of test target with matching two patterns. The test is passed when the output matches one of them. One is "getpid f2 f1 f0 main". This is strict pattern we used before. "f1 f0 main" is the new relaxed pattern. Reference: https://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.5/2.5.67/2.5.67-mm3/broken-out/vsyscall-unwinding.patch This patch may explains the call convention in vdso of i386. Signed-off-by: Masatake YAMATO <yam...@redhat.com> --- tests/stack-fcall.c | 8 +++++++- tests/strace-k.test | 7 +++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/stack-fcall.c b/tests/stack-fcall.c index 1c66fef..b49014a 100644 --- a/tests/stack-fcall.c +++ b/tests/stack-fcall.c @@ -3,12 +3,18 @@ /* Use "volatile" to avoid compiler optimization. */ -int f1(int i) +int f2(int i) { static pid_t (* volatile g)(void) = getpid; return g() + i; } +int f1(int i) +{ + static int (* volatile g)(int) = f2; + return g(i) + i; +} + int f0(volatile int i) { static int (* volatile g)(int) = f1; diff --git a/tests/strace-k.test b/tests/strace-k.test index 3845c8c..eae0a71 100755 --- a/tests/strace-k.test +++ b/tests/strace-k.test @@ -23,11 +23,14 @@ $STRACE $args > $LOG 2>&1 || { fail_ "$STRACE $args failed" } -expected='getpid f1 f0 main ' +expected_x86_64='getpid f2 f1 f0 main ' +expected_i386='f1 f0 main ' result=$(sed -n '1,/(main+0x[a-f0-9]\+) .*/ s/^.*(\([^+]\+\)+0x[a-f0-9]\+) .*/\1/p' $LOG | tr '\n' ' ') -test "$result" = "$expected" || { +test "$result" = "$expected_x86_64" || +test "$result" = "$expected_i386" || +{ cat $LOG echo "expected: \"$expected\"" echo "result: \"$result\"" -- 1.9.0 ------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems _______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel