Skip to content

Commit

Permalink
[lldb/Core] Don't crash in GetSoftwareBreakpointTrapOpcode for unknow…
Browse files Browse the repository at this point in the history
…n 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
  • Loading branch information
JDevlieghere committed Apr 24, 2020
1 parent d4e7b00 commit 1fcd234
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lldb/source/Target/Platform.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -1918,8 +1919,7 @@ size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target,
} break;

default:
llvm_unreachable(
"Unhandled architecture in Platform::GetSoftwareBreakpointTrapOpcode");
return 0;
}

assert(bp_site);
Expand Down

0 comments on commit 1fcd234

Please sign in to comment.