[Lldb-commits] [lldb] r361758 - FuncUnwinders: prefer debug_frame over eh_frame

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon May 27 04:53:24 PDT 2019


Author: labath
Date: Mon May 27 04:53:24 2019
New Revision: 361758

URL: http://llvm.org/viewvc/llvm-project?rev=361758&view=rev
Log:
FuncUnwinders: prefer debug_frame over eh_frame

The two sections usually contain the same information, and we rarely
have both kinds of entries for a single function. However, in theory the
debug_frame plan can be more complete, whereas eh_frame is only required
to be correct at places where exceptions can be thrown.

Reviewers: jasonmolenda, clayborg

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D62374

Added:
    lldb/trunk/lit/Unwind/Inputs/prefer-debug-over-eh-frame.s
    lldb/trunk/lit/Unwind/prefer-debug-over-eh-frame.test
Modified:
    lldb/trunk/source/Symbol/FuncUnwinders.cpp

Added: lldb/trunk/lit/Unwind/Inputs/prefer-debug-over-eh-frame.s
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Unwind/Inputs/prefer-debug-over-eh-frame.s?rev=361758&view=auto
==============================================================================
--- lldb/trunk/lit/Unwind/Inputs/prefer-debug-over-eh-frame.s (added)
+++ lldb/trunk/lit/Unwind/Inputs/prefer-debug-over-eh-frame.s Mon May 27 04:53:24 2019
@@ -0,0 +1,38 @@
+        .cfi_sections .eh_frame, .debug_frame
+        .text
+        .globl  bar
+bar:
+        .cfi_startproc
+        leal    (%edi, %edi), %eax
+        ret
+        .cfi_endproc
+
+        .globl  foo
+foo:
+        .cfi_startproc
+        pushq   %rbp
+        .cfi_def_cfa_offset 16
+        .cfi_offset %rbp, -16
+        movq    %rsp, %rbp
+        .cfi_def_cfa_register %rbp
+        call    bar
+        addl    $1, %eax
+        popq    %rbp
+        ret
+        .cfi_endproc
+
+        .globl  asm_main
+asm_main:
+        .cfi_startproc
+        pushq   %rbp
+        .cfi_def_cfa_offset 16
+        .cfi_offset 6, -16
+        movq    %rsp, %rbp
+        .cfi_def_cfa_register 6
+        movl    $47, %edi
+
+        call foo
+        popq    %rbp
+        .cfi_def_cfa 7, 8
+        ret
+        .cfi_endproc

Added: lldb/trunk/lit/Unwind/prefer-debug-over-eh-frame.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Unwind/prefer-debug-over-eh-frame.test?rev=361758&view=auto
==============================================================================
--- lldb/trunk/lit/Unwind/prefer-debug-over-eh-frame.test (added)
+++ lldb/trunk/lit/Unwind/prefer-debug-over-eh-frame.test Mon May 27 04:53:24 2019
@@ -0,0 +1,23 @@
+# Test that we prefer debug_frame over eh_frame unwind plans. They usually
+# contain the same information, and we rarely have both kinds of entries for a
+# single function. However, in theory the debug_frame plan can be more complete,
+# whereas eh_frame is only required to be correct at places where exceptions can
+# be thrown.
+
+# UNSUPPORTED: system-windows
+# REQUIRES: target-x86_64, native
+
+# RUN: %clang %p/Inputs/call-asm.c %p/Inputs/prefer-debug-over-eh-frame.s -o %t
+# RUN: %lldb %t -s %s -o exit | FileCheck %s
+
+breakpoint set -n bar
+# CHECK: Breakpoint 1: where = {{.*}}`bar
+
+process launch
+# CHECK: stop reason = breakpoint 1.1
+
+target modules show-unwind -n foo
+# CHECK: Asynchronous (not restricted to call-sites) UnwindPlan is 'DWARF CFI plus augmentation from assembly parsing'
+# CHECK: Synchronous (restricted to call-sites) UnwindPlan is 'DWARF CFI'
+# CHECK: eh_frame UnwindPlan:
+# CHECK: debug_frame UnwindPlan:

Modified: lldb/trunk/source/Symbol/FuncUnwinders.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/FuncUnwinders.cpp?rev=361758&r1=361757&r2=361758&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/FuncUnwinders.cpp (original)
+++ lldb/trunk/source/Symbol/FuncUnwinders.cpp Mon May 27 04:53:24 2019
@@ -60,10 +60,10 @@ UnwindPlanSP FuncUnwinders::GetUnwindPla
 
   if (UnwindPlanSP plan_sp = GetSymbolFileUnwindPlan(thread))
     return plan_sp;
-  if (UnwindPlanSP plan_sp = GetEHFrameUnwindPlan(target))
-    return plan_sp;
   if (UnwindPlanSP plan_sp = GetDebugFrameUnwindPlan(target))
     return plan_sp;
+  if (UnwindPlanSP plan_sp = GetEHFrameUnwindPlan(target))
+    return plan_sp;
   if (UnwindPlanSP plan_sp = GetCompactUnwindUnwindPlan(target))
     return plan_sp;
   if (UnwindPlanSP plan_sp = GetArmUnwindUnwindPlan(target))
@@ -362,10 +362,10 @@ UnwindPlanSP FuncUnwinders::GetUnwindPla
 
   if (UnwindPlanSP plan_sp = GetSymbolFileUnwindPlan(thread))
     return plan_sp;
-  if (UnwindPlanSP plan_sp = GetEHFrameAugmentedUnwindPlan(target, thread))
-    return plan_sp;
   if (UnwindPlanSP plan_sp = GetDebugFrameAugmentedUnwindPlan(target, thread))
     return plan_sp;
+  if (UnwindPlanSP plan_sp = GetEHFrameAugmentedUnwindPlan(target, thread))
+    return plan_sp;
 
   return assembly_sp;
 }




More information about the lldb-commits mailing list