[Lldb-commits] [lldb] [lldb] Step over non-lldb breakpoints (PR #190622)

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 7 23:11:12 PDT 2026


================
@@ -82,6 +83,42 @@ 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.
+    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, Address(pc), bytes_at_pc);
+  auto platform_opcode =
+      platform_sp->SoftwareTrapOpcodeBytes(target.GetArchitecture(), size_hint);
+
+  if (auto *arch_plugin = target.GetArchitecturePlugin();
+      arch_plugin &&
----------------
jasonmolenda wrote:

I think a more common idiom here would be like
```
if ((Architecture *arch_plugin = target.GetArchitecturePlugin()) && arch_plug->...
```

I didn't comment on it in other places in the patch, like just above, but I avoid using `auto` for simple types - it makes the code harder for people to read in the future, without assistance from a fancy editor that can determine the actual types and show them.  When it's a complex return value like an stl iterator or a lambda, the actual return type is longer and harder to read and I can understand the use of auto, but for simple types like this, I think it just reduces readability.

https://github.com/llvm/llvm-project/pull/190622


More information about the lldb-commits mailing list