================
@@ -82,6 +83,40 @@ bool StopInfo::HasTargetRunSinceMe() {
return false;
}
+void StopInfo::SkipOverTrapInstruction() {
+ Status error;
+ Log *log = GetLog(LLDBLog::Process);
+ // We don't expect to see byte sequences longer than four bytes long for
+ // any breakpoint instructions known to LLDB.
+ std::array<uint8_t, 4> bytes_at_pc = {0, 0, 0, 0};
+ auto reg_ctx_sp = GetThread()->GetRegisterContext();
+ auto process_sp = GetThread()->GetProcess();
+ addr_t pc = reg_ctx_sp->GetPC();
+ if (!process_sp->ReadMemory(pc, bytes_at_pc.data(), bytes_at_pc.size(),
+ error)) {
+ // If this fails, we simply don't handle the step-over-break logic and
+ // log the failure
+ LLDB_LOG(log, "failed to read program bytes at pc address {}, error {}",
pc,
+ error);
+ return;
+ }
+ auto &target = process_sp->GetTarget();
+ auto platform_sp = target.GetPlatform();
+ auto size_hint = platform_sp->GetTrapOpcodeSizeHint(target, pc, bytes_at_pc);
+ auto platform_opcode =
+ platform_sp->SoftwareTrapOpcodeBytes(target.GetArchitecture(),
size_hint);
+
+ if (auto *arch_plugin = target.GetArchitecturePlugin();
+ arch_plugin &&
----------------
DuncanMcBain wrote:
Yes, and it keeps the variable scoped to the body of the if. I can change it to
be more traditional, if you like, since it's quite wordy as a condition. An
early return plus storing the condition in a variable might be more readable?
```c++
auto *arch_plugin = target.GetArchitecturePlugin();
if (!arch_plugin) return;
auto is_valid_trap = arch_plugin->IsValidTrapInstruction(platform_opcode,
llvm::ArrayRef<uint8_t>(bytes_at_pc.data(), bytes_at_pc.size()
if (is_valid_trap) {
;
}
```
it would certainly reduce the indentation by a ways, which might look better on
the page. I'd be happy to do this.
https://github.com/llvm/llvm-project/pull/174348
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits