[Lldb-commits] [lldb] 99d187a - Update UnwindPlan dump to list if it is a trap handler func; also Command

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 25 20:54:09 PDT 2020


Author: Jason Molenda
Date: 2020-08-25T20:53:59-07:00
New Revision: 99d187a003c9bd4bdc42c17e5563bd80f4e159e9

URL: https://github.com/llvm/llvm-project/commit/99d187a003c9bd4bdc42c17e5563bd80f4e159e9
DIFF: https://github.com/llvm/llvm-project/commit/99d187a003c9bd4bdc42c17e5563bd80f4e159e9.diff

LOG: Update UnwindPlan dump to list if it is a trap handler func; also Command

Update the "image show-unwind" command output to show if the function
being shown is listed as a user-setting or platform trap handler.

Update the individual UnwindPlan dumps to show whether the unwind plan
is registered as a trap handler.

Added: 
    

Modified: 
    lldb/source/Commands/CommandObjectTarget.cpp
    lldb/source/Symbol/UnwindPlan.cpp
    lldb/test/Shell/Minidump/Windows/arm-fp-unwind.test
    lldb/test/Shell/SymbolFile/Breakpad/stack-cfi-parsing.test
    lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test
    lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-cfi.test
    lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win.test
    lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test

Removed: 
    


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index b6af481090d7..30fdaf9ec9a2 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -3421,10 +3421,35 @@ class CommandObjectTargetModulesShowUnwind : public CommandObjectParsed {
         continue;
 
       result.GetOutputStream().Printf(
-          "UNWIND PLANS for %s`%s (start addr 0x%" PRIx64 ")\n\n",
+          "UNWIND PLANS for %s`%s (start addr 0x%" PRIx64 ")\n",
           sc.module_sp->GetPlatformFileSpec().GetFilename().AsCString(),
           funcname.AsCString(), start_addr);
 
+      Args args;
+      target->GetUserSpecifiedTrapHandlerNames(args);
+      size_t count = args.GetArgumentCount();
+      for (size_t i = 0; i < count; i++) {
+        const char *trap_func_name = args.GetArgumentAtIndex(i);
+        if (strcmp(funcname.GetCString(), trap_func_name) == 0)
+          result.GetOutputStream().Printf(
+              "This function is "
+              "treated as a trap handler function via user setting.\n");
+      }
+      PlatformSP platform_sp(target->GetPlatform());
+      if (platform_sp) {
+        const std::vector<ConstString> trap_handler_names(
+            platform_sp->GetTrapHandlerSymbolNames());
+        for (ConstString trap_name : trap_handler_names) {
+          if (trap_name == funcname) {
+            result.GetOutputStream().Printf(
+                "This function's "
+                "name is listed by the platform as a trap handler.\n");
+          }
+        }
+      }
+
+      result.GetOutputStream().Printf("\n");
+
       UnwindPlanSP non_callsite_unwind_plan =
           func_unwinders_sp->GetUnwindPlanAtNonCallSite(*target, *thread);
       if (non_callsite_unwind_plan) {

diff  --git a/lldb/source/Symbol/UnwindPlan.cpp b/lldb/source/Symbol/UnwindPlan.cpp
index e8906f38e2ff..278a79d8c0ec 100644
--- a/lldb/source/Symbol/UnwindPlan.cpp
+++ b/lldb/source/Symbol/UnwindPlan.cpp
@@ -527,6 +527,18 @@ void UnwindPlan::Dump(Stream &s, Thread *thread, lldb::addr_t base_addr) const {
     s.Printf("not specified.\n");
     break;
   }
+  s.Printf("This UnwindPlan is for a trap handler function: ");
+  switch (m_plan_is_for_signal_trap) {
+  case eLazyBoolYes:
+    s.Printf("yes.\n");
+    break;
+  case eLazyBoolNo:
+    s.Printf("no.\n");
+    break;
+  case eLazyBoolCalculate:
+    s.Printf("not specified.\n");
+    break;
+  }
   if (m_plan_valid_address_range.GetBaseAddress().IsValid() &&
       m_plan_valid_address_range.GetByteSize() > 0) {
     s.PutCString("Address range of this UnwindPlan: ");

diff  --git a/lldb/test/Shell/Minidump/Windows/arm-fp-unwind.test b/lldb/test/Shell/Minidump/Windows/arm-fp-unwind.test
index ed871ac544a8..7c056b612a4e 100644
--- a/lldb/test/Shell/Minidump/Windows/arm-fp-unwind.test
+++ b/lldb/test/Shell/Minidump/Windows/arm-fp-unwind.test
@@ -12,6 +12,7 @@ CHECK: Assembly language inspection UnwindPlan:
 CHECK-NEXT: This UnwindPlan originally sourced from EmulateInstructionARM
 CHECK-NEXT: This UnwindPlan is sourced from the compiler: no.
 CHECK-NEXT: This UnwindPlan is valid at all instruction locations: yes.
+CHECK-NEXT: This UnwindPlan is for a trap handler function: no.
 CHECK-NEXT: row[0]:    0: CFA=sp +0 =>
 CHECK-NEXT: row[1]:    4: CFA=sp +8 => fp=[CFA-8] lr=[CFA-4]
 CHECK-NEXT: row[2]:    6: CFA=fp +8 => fp=[CFA-8] lr=[CFA-4]

diff  --git a/lldb/test/Shell/SymbolFile/Breakpad/stack-cfi-parsing.test b/lldb/test/Shell/SymbolFile/Breakpad/stack-cfi-parsing.test
index dd98939aa82e..539b8096b58b 100644
--- a/lldb/test/Shell/SymbolFile/Breakpad/stack-cfi-parsing.test
+++ b/lldb/test/Shell/SymbolFile/Breakpad/stack-cfi-parsing.test
@@ -10,6 +10,7 @@ image show-unwind -n func0
 # CHECK-NEXT: This UnwindPlan originally sourced from breakpad STACK CFI
 # CHECK-NEXT: This UnwindPlan is sourced from the compiler: yes.
 # CHECK-NEXT: This UnwindPlan is valid at all instruction locations: no.
+# CHECK-NEXT: This UnwindPlan is for a trap handler function: no.
 # CHECK-NEXT: Address range of this UnwindPlan: [stack-cfi-parsing.out..module_image + 0-0x0000000000000002)
 # CHECK-NEXT: row[0]:    0: CFA=DW_OP_breg7 +0 => rbp=DW_OP_breg7 +0 rip=DW_OP_pick 0x0
 # CHECK-NEXT: row[1]:    1: CFA=DW_OP_breg7 +0 => rbx=DW_OP_breg2 +0 rbp=DW_OP_breg0 +0 rip=DW_OP_pick 0x0

diff  --git a/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test
index 1e280738900a..1c1dabec5944 100644
--- a/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test
+++ b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test
@@ -12,6 +12,7 @@ image show-unwind -n call_many
 # CHECK: This UnwindPlan originally sourced from breakpad STACK WIN
 # CHECK: This UnwindPlan is sourced from the compiler: yes.
 # CHECK: This UnwindPlan is valid at all instruction locations: no.
+# CHECK: This UnwindPlan is for a trap handler function: no.
 # CHECK: Address range of this UnwindPlan: [unwind-via-stack-win.exe..module_image + 4112-0x0000107d)
 # CHECK: row[0]:    0: CFA=RaSearch at SP+0 => esp=DW_OP_pick 0x0, DW_OP_consts +4, DW_OP_plus  eip=DW_OP_pick 0x0, DW_OP_deref
 

diff  --git a/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-cfi.test b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-cfi.test
index 62d0ef5ce598..dade708519f5 100644
--- a/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-cfi.test
+++ b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-cfi.test
@@ -12,6 +12,7 @@ image show-unwind -n bar
 # CHECK-NEXT: This UnwindPlan originally sourced from breakpad STACK CFI
 # CHECK-NEXT: This UnwindPlan is sourced from the compiler: yes.
 # CHECK-NEXT: This UnwindPlan is valid at all instruction locations: no.
+# CHECK-NEXT: This UnwindPlan is for a trap handler function: no.
 # CHECK-NEXT: Address range of this UnwindPlan: [unwind-via-stack-cfi..module_image + 1056-0x0000000000000449)
 # CHECK-NEXT: row[0]: 0: CFA=DW_OP_breg6 +0, DW_OP_deref => rbp=DW_OP_pick 0x0, DW_OP_deref rsp=DW_OP_pick 0x0, DW_OP_consts +16, DW_OP_plus rip=DW_OP_pick 0x0, DW_OP_consts +8, DW_OP_plus, DW_OP_deref
 

diff  --git a/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win.test b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win.test
index 2e4ac58c9bea..5698a4f63878 100644
--- a/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win.test
+++ b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win.test
@@ -14,6 +14,7 @@ image show-unwind -n call_many
 # CHECK: This UnwindPlan originally sourced from breakpad STACK WIN
 # CHECK: This UnwindPlan is sourced from the compiler: yes.
 # CHECK: This UnwindPlan is valid at all instruction locations: no.
+# CHECK: This UnwindPlan is for a trap handler function: no.
 # CHECK: Address range of this UnwindPlan: [unwind-via-stack-win.exe..module_image + 4112-0x0000107d)
 # CHECK: row[0]:    0: CFA=DW_OP_breg7 +0, DW_OP_consts +80, DW_OP_plus  => esp=DW_OP_pick 0x0, DW_OP_consts +4, DW_OP_plus eip=DW_OP_pick 0x0, DW_OP_deref
 
@@ -42,6 +43,7 @@ image show-unwind -n temporary_var
 # CHECK: This UnwindPlan originally sourced from breakpad STACK WIN
 # CHECK: This UnwindPlan is sourced from the compiler: yes.
 # CHECK: This UnwindPlan is valid at all instruction locations: no.
+# CHECK: This UnwindPlan is for a trap handler function: no.
 # CHECK: Address range of this UnwindPlan: [unwind-via-stack-win.exe..module_image + 4400-0x00001134)
 # CHECK: row[0]:    0: CFA=DW_OP_breg7 +0 => esp=DW_OP_pick 0x0, DW_OP_consts +4, DW_OP_plus  eip=DW_OP_pick 0x0, DW_OP_deref
 

diff  --git a/lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test b/lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test
index b4f0cc4c402c..23133a801c27 100644
--- a/lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test
+++ b/lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test
@@ -24,3 +24,4 @@ image show-unwind -n main
 # CHECK: debug_frame UnwindPlan:
 # CHECK-NEXT: This UnwindPlan originally sourced from DWARF CFI
 # CHECK-NEXT: This UnwindPlan is sourced from the compiler: yes.
+# CHECK-NEXT: This UnwindPlan is for a trap handler function: no.


        


More information about the lldb-commits mailing list