[Lldb-commits] [lldb] 1fcd234 - [lldb/Core] Don't crash in GetSoftwareBreakpointTrapOpcode for unknown triples

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 24 09:10:50 PDT 2020


Author: Jonas Devlieghere
Date: 2020-04-24T09:10:41-07:00
New Revision: 1fcd234ac54a0bb9dcb14338db5a336d80321662

URL: https://github.com/llvm/llvm-project/commit/1fcd234ac54a0bb9dcb14338db5a336d80321662
DIFF: https://github.com/llvm/llvm-project/commit/1fcd234ac54a0bb9dcb14338db5a336d80321662.diff

LOG: [lldb/Core] Don't crash in GetSoftwareBreakpointTrapOpcode for unknown triples

This patch ensures we don't crash in GetSoftwareBreakpointTrapOpcode for
not-yet-supported architectures but rather continue with degraded
behavior.

I found the issue in the context of an invalid ArchSpec, which should be
handled further up the chain. In this patch I've also added an assert to
cover that, so we can still catch those issues.

Differential revision: https://reviews.llvm.org/D78588

Added: 
    

Modified: 
    lldb/source/Target/Platform.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 3069a363736f..3e3c476d72f8 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1822,6 +1822,7 @@ size_t Platform::ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
 size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target,
                                                  BreakpointSite *bp_site) {
   ArchSpec arch = target.GetArchitecture();
+  assert(arch.IsValid());
   const uint8_t *trap_opcode = nullptr;
   size_t trap_opcode_size = 0;
 
@@ -1918,8 +1919,7 @@ size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target,
   } break;
 
   default:
-    llvm_unreachable(
-        "Unhandled architecture in Platform::GetSoftwareBreakpointTrapOpcode");
+    return 0;
   }
 
   assert(bp_site);


        


More information about the lldb-commits mailing list