[Lldb-commits] [lldb] [NFC][lldb] Extract Do{Dis}EnableBreakpoint into helper functions (PR #191136)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 9 01:52:42 PDT 2026


================
@@ -3267,6 +3267,97 @@ size_t ProcessGDBRemote::PutSTDIN(const char *src, size_t src_len,
   return 0;
 }
 
+/// Enable a single breakpoint site by trying Z0 (software), then Z1
+/// (hardware), then manual memory write as a last resort.
+static llvm::Error DoEnableBreakpointSite(ProcessGDBRemote &proc,
+                                          BreakpointSite &bp_site) {
+  Log *log = GetLog(GDBRLog::Breakpoints);
+  const addr_t addr = bp_site.GetLoadAddress();
+  const size_t bp_op_size = proc.GetSoftwareBreakpointTrapOpcode(&bp_site);
+  auto &gdb_comm = proc.GetGDBRemote();
+
+  // SupportsGDBStoppointPacket always returns true unless a previously sent
+  // packet failed. As such, query the function before AND after sending the
+  // packet.
+  if (gdb_comm.SupportsGDBStoppointPacket(eBreakpointSoftware) &&
+      !bp_site.HardwareRequired()) {
+    uint8_t error_no = gdb_comm.SendGDBStoppointTypePacket(
+        eBreakpointSoftware, true, addr, bp_op_size,
+        proc.GetInterruptTimeout());
+    if (error_no == 0) {
+      bp_site.SetEnabled(true);
+      bp_site.SetType(BreakpointSite::eExternal);
+      return llvm::Error::success();
+    }
+    if (gdb_comm.SupportsGDBStoppointPacket(eBreakpointSoftware)) {
+      if (error_no != UINT8_MAX)
+        return llvm::createStringErrorV(
+            "error: {0} sending the breakpoint request", error_no);
+      return llvm::createStringError("error sending the breakpoint request");
+    }
+    LLDB_LOGF(log, "Software breakpoints are unsupported");
----------------
JDevlieghere wrote:

```suggestion
    LLDB_LOG(log, "Software breakpoints are unsupported");
```

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


More information about the lldb-commits mailing list