jarin created this revision. jarin added a reviewer: labath. jarin added a project: LLDB. Herald added a subscriber: JDevlieghere. Herald added a project: All. jarin requested review of this revision. Herald added a subscriber: lldb-commits.
Currently, lldb's unwinder ignores cfi_restore opcodes for registers that are not set in the first row of the unwinding info. This prevents unwinding of failed assertion in Chrome/v8 (https://github.com/v8/v8). The attached test is an x64 copy of v8's function that failed to unwind correctly. This patch changes handling of cfi_restore to reset the location if the first unwind table row does not map the restored register. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D153043 Files: lldb/source/Symbol/DWARFCallFrameInfo.cpp lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test Index: lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test =================================================================== --- /dev/null +++ lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test @@ -0,0 +1,21 @@ +# Test restoring of register values. + +# UNSUPPORTED: system-windows +# REQUIRES: target-x86_64, native + +# RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind-abort.s -o %t +# RUN: %lldb %t -s %s -o exit | FileCheck %s + +process launch +# CHECK: stop reason = signal SIGTRAP + +thread backtrace +# CHECK: frame #0: {{.*}}`asm_main + 23 +# CHECK: frame #1: {{.*}}`main + {{.*}} + +target modules show-unwind -n asm_main +# CHECK: eh_frame UnwindPlan: +# CHECK: row[0]: 0: CFA=rsp +8 => rip=[CFA-8] +# CHECK: row[1]: 14: CFA=rsp+16 => rbp=[CFA-16] rip=[CFA-8] +# CHECK: row[2]: 17: CFA=rbp+16 => rbp=[CFA-16] rip=[CFA-8] +# CHECK: row[3]: 22: CFA=rsp +8 => rip=[CFA-8] Index: lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s =================================================================== --- /dev/null +++ lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s @@ -0,0 +1,25 @@ + .text + .globl asm_main +asm_main: + .cfi_startproc + cmpb $0x0, g_hard_abort(%rip) + jne .L + + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + callq abort +.L: + .cfi_def_cfa 7, 8 + .cfi_restore 6 + int3 + ud2 + .cfi_endproc + + .data + .globl g_hard_abort +g_hard_abort: + .byte 1 + .size g_hard_abort, 1 \ No newline at end of file Index: lldb/source/Symbol/DWARFCallFrameInfo.cpp =================================================================== --- lldb/source/Symbol/DWARFCallFrameInfo.cpp +++ lldb/source/Symbol/DWARFCallFrameInfo.cpp @@ -674,6 +674,8 @@ unwind_plan.GetRowAtIndex(0)->GetRegisterInfo(reg_num, reg_location)) row->SetRegisterInfo(reg_num, reg_location); + else + row->RemoveRegisterInfo(reg_num); break; } }
Index: lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test =================================================================== --- /dev/null +++ lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test @@ -0,0 +1,21 @@ +# Test restoring of register values. + +# UNSUPPORTED: system-windows +# REQUIRES: target-x86_64, native + +# RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind-abort.s -o %t +# RUN: %lldb %t -s %s -o exit | FileCheck %s + +process launch +# CHECK: stop reason = signal SIGTRAP + +thread backtrace +# CHECK: frame #0: {{.*}}`asm_main + 23 +# CHECK: frame #1: {{.*}}`main + {{.*}} + +target modules show-unwind -n asm_main +# CHECK: eh_frame UnwindPlan: +# CHECK: row[0]: 0: CFA=rsp +8 => rip=[CFA-8] +# CHECK: row[1]: 14: CFA=rsp+16 => rbp=[CFA-16] rip=[CFA-8] +# CHECK: row[2]: 17: CFA=rbp+16 => rbp=[CFA-16] rip=[CFA-8] +# CHECK: row[3]: 22: CFA=rsp +8 => rip=[CFA-8] Index: lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s =================================================================== --- /dev/null +++ lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s @@ -0,0 +1,25 @@ + .text + .globl asm_main +asm_main: + .cfi_startproc + cmpb $0x0, g_hard_abort(%rip) + jne .L + + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + callq abort +.L: + .cfi_def_cfa 7, 8 + .cfi_restore 6 + int3 + ud2 + .cfi_endproc + + .data + .globl g_hard_abort +g_hard_abort: + .byte 1 + .size g_hard_abort, 1 \ No newline at end of file Index: lldb/source/Symbol/DWARFCallFrameInfo.cpp =================================================================== --- lldb/source/Symbol/DWARFCallFrameInfo.cpp +++ lldb/source/Symbol/DWARFCallFrameInfo.cpp @@ -674,6 +674,8 @@ unwind_plan.GetRowAtIndex(0)->GetRegisterInfo(reg_num, reg_location)) row->SetRegisterInfo(reg_num, reg_location); + else + row->RemoveRegisterInfo(reg_num); break; } }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits