ravitheja added a comment. Hi Jason,
Ok let me explain the scenario here, the application i.e the test function tries to abort which eventually ends up in a function present in the vdso, on the way the call flow goes through some functions in libc. Now the backtrace is done from inside of the function in the vdso, which was successful in the case of gcc and unsuccessful for clang. Before I tell you my findings, I would mention that the vdso is mapped by the kernel in to the inferiors memory and would be the same for clang or gcc. Now I found that the ebp register was not touched by the functions in the libc and the assembly unwind plan was used for the vdso for the first frame. This was successful for gcc because gcc emitted the prologue for the main function whereas clang does not. Here is the log without my patch - (lldb) log enable lldb unwind (lldb) run Process 99000 launched: '/nfs/site/disks/idb_team/raddepal/LLDB/llvm/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/a.out' (i386) th1/fr0 with pc value of 0x8048350, symbol name is '' (i386) /nfs/site/disks/idb_team/raddepal/LLDB/llvm/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/a.out: Reading EH frame info th1/fr0 0x0000000008048350: CFA=esp +4 => esp=CFA+0 eip=[CFA-4] th1/fr0 CFA is 0xffffd4d4: Register esp (7) contents are 0xffffd4d0, offset is 4 th1/fr0 initialized frame current pc is 0x8048350 cfa is 0xffffd4d4 using assembly insn profiling UnwindPlan th1/fr0 supplying caller's saved eip (8)'s location using assembly insn profiling UnwindPlan th1/fr0 supplying caller's register eip (8) from the stack, saved at CFA plus offset -4 [saved at 0xffffd4d0] th1/fr1 pc = 0x1 th1/fr0 supplying caller's register ebp (6) from the live RegisterContext at frame 0 th1/fr1 fp = 0x0 th1/fr0 supplying caller's saved esp (7)'s location using assembly insn profiling UnwindPlan th1/fr0 supplying caller's register esp (7), value is CFA plus offset 0 [value is 0xffffd4d4] th1/fr1 sp = 0xffffd4d4 th1/fr1 this frame has a pc of 0x0 th1/fr0 supplying caller's saved eip (8)'s location, cached th1/fr0 Got an invalid CFA register value - reg ebp (6), value 0x0 th1/fr0 failed to get cfa with fallback unwindplan Frame 1 invalid RegisterContext for this frame, stopping stack walk th1 Unwind of this thread is complete. th1/fr0 with pc value of 0xf7fd9d80, symbol name is '__kernel_vsyscall' (i386) [vdso](0x00000000f7fd9000): Reading EH frame info th1/fr0 0x00000000f7fd9d75: CFA=ebp+16 => ebp=[CFA-16] esp=CFA+0 eip=[CFA-4] th1/fr0 Got an invalid CFA register value - reg ebp (6), value 0x0 th1/fr0 could not read CFA register for this frame. th1 Unwind of this thread is complete. Process 99000 stopped - thread #1: tid = 99000, 0xf7fd9d80 [vdso]`__kernel_vsyscall + 16, name = 'a.out', stop reason = signal SIGABRT frame #0: 0xf7fd9d80 [vdso]`__kernel_vsyscall + 16 [vdso]`__kernel_vsyscall: -> 0xf7fd9d80 <+16>: popl %ebp 0xf7fd9d81 <+17>: popl %edx 0xf7fd9d82 <+18>: popl %ecx 0xf7fd9d83 <+19>: retl (lldb) disassemble [vdso]`__kernel_vsyscall: 0xf7fd9d70 <+0>: pushl %ecx 0xf7fd9d71 <+1>: pushl %edx 0xf7fd9d72 <+2>: pushl %ebp 0xf7fd9d73 <+3>: movl %esp, %ebp 0xf7fd9d75 <+5>: sysenter 0xf7fd9d77 <+7>: nop 0xf7fd9d78 <+8>: nop 0xf7fd9d79 <+9>: nop 0xf7fd9d7a <+10>: nop 0xf7fd9d7b <+11>: nop 0xf7fd9d7c <+12>: nop 0xf7fd9d7d <+13>: nop 0xf7fd9d7e <+14>: int $0x80 -> 0xf7fd9d80 <+16>: popl %ebp 0xf7fd9d81 <+17>: popl %edx 0xf7fd9d82 <+18>: popl %ecx 0xf7fd9d83 <+19>: retl After the patch -> (lldb) log enable lldb unwind (lldb) run Process 99000 launched: '/nfs/site/disks/idb_team/raddepal/LLDB/llvm/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/a.out' (i386) th1/fr0 with pc value of 0x8048350, symbol name is '' (i386) /nfs/site/disks/idb_team/raddepal/LLDB/llvm/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/a.out: Reading EH frame info th1/fr0 0x0000000008048350: CFA=esp +4 => esp=CFA+0 eip=[CFA-4] th1/fr0 CFA is 0xffffd4d4: Register esp (7) contents are 0xffffd4d0, offset is 4 th1/fr0 initialized frame current pc is 0x8048350 cfa is 0xffffd4d4 using assembly insn profiling UnwindPlan th1/fr0 supplying caller's saved eip (8)'s location using assembly insn profiling UnwindPlan th1/fr0 supplying caller's register eip (8) from the stack, saved at CFA plus offset -4 [saved at 0xffffd4d0] th1/fr1 pc = 0x1 th1/fr0 supplying caller's register ebp (6) from the live RegisterContext at frame 0 th1/fr1 fp = 0x0 th1/fr0 supplying caller's saved esp (7)'s location using assembly insn profiling UnwindPlan th1/fr0 supplying caller's register esp (7), value is CFA plus offset 0 [value is 0xffffd4d4] th1/fr1 sp = 0xffffd4d4 th1/fr1 this frame has a pc of 0x0 th1/fr0 supplying caller's saved eip (8)'s location, cached th1/fr0 Got an invalid CFA register value - reg ebp (6), value 0x0 th1/fr0 failed to get cfa with fallback unwindplan Frame 1 invalid RegisterContext for this frame, stopping stack walk th1 Unwind of this thread is complete. th1/fr0 with pc value of 0xf7fd9d80, symbol name is '__kernel_vsyscall' (i386) [vdso](0x00000000f7fd9000): Reading EH frame info th1/fr0 0x00000000f7fd9d75: CFA=ebp+16 => ebp=[CFA-16] esp=CFA+0 eip=[CFA-4] th1/fr0 Got an invalid CFA register value - reg ebp (6), value 0x0 th1/fr0 could not read CFA register for this frame. th1 Unwind of this thread is complete. Process 99000 stopped - thread #1: tid = 99000, 0xf7fd9d80 [vdso]`__kernel_vsyscall + 16, name = 'a.out', stop reason = signal SIGABRT frame #0: 0xf7fd9d80 [vdso]`__kernel_vsyscall + 16 [vdso]`__kernel_vsyscall: -> 0xf7fd9d80 <+16>: popl %ebp 0xf7fd9d81 <+17>: popl %edx 0xf7fd9d82 <+18>: popl %ecx 0xf7fd9d83 <+19>: retl (lldb) disassemble [vdso]`__kernel_vsyscall: 0xf7fd9d70 <+0>: pushl %ecx 0xf7fd9d71 <+1>: pushl %edx 0xf7fd9d72 <+2>: pushl %ebp 0xf7fd9d73 <+3>: movl %esp, %ebp 0xf7fd9d75 <+5>: sysenter 0xf7fd9d77 <+7>: nop 0xf7fd9d78 <+8>: nop 0xf7fd9d79 <+9>: nop 0xf7fd9d7a <+10>: nop 0xf7fd9d7b <+11>: nop 0xf7fd9d7c <+12>: nop 0xf7fd9d7d <+13>: nop 0xf7fd9d7e <+14>: int $0x80 -> 0xf7fd9d80 <+16>: popl %ebp 0xf7fd9d81 <+17>: popl %edx 0xf7fd9d82 <+18>: popl %ecx 0xf7fd9d83 <+19>: retl (lldb) log enable lldb unwind (lldb) run Process 113600 launched: '/nfs/site/disks/idb_team/raddepal/LLDB/llvm/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/a.out' (i386) th1/fr0 with pc value of 0x8048350, symbol name is '' (i386) /nfs/site/disks/idb_team/raddepal/LLDB/llvm/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/a.out: Reading EH frame info th1/fr0 0x0000000008048350: CFA=esp +4 => esp=CFA+0 eip=[CFA-4] th1/fr0 CFA is 0xffffd4d4: Register esp (7) contents are 0xffffd4d0, offset is 4 th1/fr0 initialized frame current pc is 0x8048350 cfa is 0xffffd4d4 using assembly insn profiling UnwindPlan th1/fr0 supplying caller's saved eip (8)'s location using assembly insn profiling UnwindPlan th1/fr0 supplying caller's register eip (8) from the stack, saved at CFA plus offset -4 [saved at 0xffffd4d0] th1/fr1 pc = 0x1 th1/fr0 supplying caller's register ebp (6) from the live RegisterContext at frame 0 th1/fr1 fp = 0x0 th1/fr0 supplying caller's saved esp (7)'s location using assembly insn profiling UnwindPlan th1/fr0 supplying caller's register esp (7), value is CFA plus offset 0 [value is 0xffffd4d4] th1/fr1 sp = 0xffffd4d4 th1/fr1 this frame has a pc of 0x0 th1/fr0 supplying caller's saved eip (8)'s location, cached th1/fr0 Got an invalid CFA register value - reg ebp (6), value 0x0 th1/fr0 failed to get cfa with fallback unwindplan Frame 1 invalid RegisterContext for this frame, stopping stack walk th1 Unwind of this thread is complete. th1/fr0 with pc value of 0xf7fd9d80, symbol name is '__kernel_vsyscall' (i386) [vdso](0x00000000f7fd9000): Reading EH frame info th1/fr0 0x00000000f7fd9d75: CFA=ebp+16 => ebp=[CFA-16] esp=CFA+0 eip=[CFA-4] th1/fr0 Got an invalid CFA register value - reg ebp (6), value 0x0 th1/fr0 supplying caller's saved eip (8)'s location using assembly insn profiling UnwindPlan th1/fr0 supplying caller's register eip (8) from the stack, saved at CFA plus offset -4 [saved at 0xfffffffffffffffb] th1/fr0 CFA is 0xffffd2d4: Register esp (7) contents are 0xffffd2c4, offset is 16 th1/fr0 requested caller's saved PC but this UnwindPlan uses a RA reg; getting eip (8) instead th1/fr0 supplying caller's saved eip (8)'s location using eh_frame CFI UnwindPlan th1/fr0 supplying caller's register eip (8) from the stack, saved at CFA plus offset -4 [saved at 0xffffd2d0] th1/fr0 trying to unwind from this function with the UnwindPlan 'eh_frame CFI' because UnwindPlan 'assembly insn profiling' failed. th1/fr0 initialized frame current pc is 0xf7fd9d80 cfa is 0xffffd2d4 using eh_frame CFI UnwindPlan th1/fr0 supplying caller's saved eip (8)'s location, cached th1/fr1 pc = 0xf7e40607 th1/fr0 supplying caller's saved ebp (6)'s location using eh_frame CFI UnwindPlan th1/fr0 supplying caller's register ebp (6) from the stack, saved at CFA plus offset -16 [saved at 0xffffd2c4] th1/fr1 fp = 0x0 th1/fr0 supplying caller's stack pointer esp (7) value, computed from CFA th1/fr1 sp = 0xffffd2d4 th1/fr1 with pc value of 0xf7e40607, symbol name is 'gsignal' (i386) /lib/i386-linux-gnu/libc.so.6: Reading EH frame info th1/fr1 active row: 0x00000000f7e405c2: CFA=esp+12 => ebx=[CFA-12] edi=[CFA-8] eip=[CFA-4] th1/fr0 supplying caller's saved esp (7)'s location, cached th1/fr1 CFA is 0xffffd2e0: Register esp (7) contents are 0xffffd2d4, offset is 12 th1/fr1 m_cfa = 0xffffd2e0 th1/fr1 initialized frame current pc is 0xf7e40607 cfa is 0xffffd2e0 th1/fr0 supplying caller's saved eip (8)'s location, cached th1/fr1 requested caller's saved PC but this UnwindPlan uses a RA reg; getting eip (8) instead th1/fr1 supplying caller's saved eip (8)'s location using eh_frame CFI UnwindPlan th1/fr1 supplying caller's register eip (8) from the stack, saved at CFA plus offset -4 [saved at 0xffffd2dc] th1/fr2 pc = 0xf7e43a33 th1/fr1 no save location for ebp (6) via 'eh_frame CFI' th1/fr0 supplying caller's saved ebp (6)'s location, cached th1/fr2 fp = 0x0 th1/fr1 supplying caller's stack pointer esp (7) value, computed from CFA th1/fr2 sp = 0xffffd2e0 th1/fr2 with pc value of 0xf7e43a33, symbol name is 'abort' th1/fr2 active row: 0x00000000f7e43903: CFA=esp+304 => ebx=[CFA-12] edi=[CFA-8] eip=[CFA-4] th1/fr1 supplying caller's saved esp (7)'s location, cached th1/fr2 CFA is 0xffffd410: Register esp (7) contents are 0xffffd2e0, offset is 304 th1/fr2 m_cfa = 0xffffd410 th1/fr2 initialized frame current pc is 0xf7e43a33 cfa is 0xffffd410 th1/fr1 supplying caller's saved eip (8)'s location, cached Process 113600 stopped - thread #1: tid = 113600, 0xf7fd9d80 [vdso]`__kernel_vsyscall + 16, name = 'a.out', stop reason = signal SIGABRT frame #0: 0xf7fd9d80 [vdso]`__kernel_vsyscall + 16 [vdso]`__kernel_vsyscall: -> 0xf7fd9d80 <+16>: popl %ebp 0xf7fd9d81 <+17>: popl %edx 0xf7fd9d82 <+18>: popl %ecx 0xf7fd9d83 <+19>: retl (lldb) disassemble [vdso]`__kernel_vsyscall: 0xf7fd9d70 <+0>: pushl %ecx 0xf7fd9d71 <+1>: pushl %edx 0xf7fd9d72 <+2>: pushl %ebp 0xf7fd9d73 <+3>: movl %esp, %ebp 0xf7fd9d75 <+5>: sysenter 0xf7fd9d77 <+7>: nop 0xf7fd9d78 <+8>: nop 0xf7fd9d79 <+9>: nop 0xf7fd9d7a <+10>: nop 0xf7fd9d7b <+11>: nop 0xf7fd9d7c <+12>: nop 0xf7fd9d7d <+13>: nop 0xf7fd9d7e <+14>: int $0x80 -> 0xf7fd9d80 <+16>: popl %ebp 0xf7fd9d81 <+17>: popl %edx 0xf7fd9d82 <+18>: popl %ecx 0xf7fd9d83 <+19>: retl http://reviews.llvm.org/D15046 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits