[Lldb-commits] [lldb] [lldb] Allow forks to occur in expression evaluation (PR #184815)

Philip DePetro via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 15 12:02:38 PDT 2026


================
@@ -6045,11 +6045,27 @@ CommandObject *ProcessGDBRemote::GetPluginCommandObject() {
   return m_command_sp.get();
 }
 
-void ProcessGDBRemote::DidForkSwitchSoftwareBreakpoints(bool enable) {
-  GetBreakpointSiteList().ForEach([this, enable](BreakpointSite *bp_site) {
+void ProcessGDBRemote::DidForkSwitchSoftwareBreakpoints(
+    bool enable, bool is_expression_fork) {
+  Log *log = GetLog(GDBRLog::Process);
+  bool is_expr = !enable && is_expression_fork;
+
+  GetBreakpointSiteList().ForEach([this, enable, is_expr,
+                                   log](BreakpointSite *bp_site) {
     if (bp_site->IsEnabled() &&
         (bp_site->GetType() == BreakpointSite::eSoftware ||
          bp_site->GetType() == BreakpointSite::eExternal)) {
+      // During expression evaluation, retain internal breakpoints (e.g. the
+      // _start return trap) in the forked child so it dies deterministically
+      // on SIGTRAP rather than executing _start with a corrupted stack.
+      if (is_expr && bp_site->IsInternal()) {
----------------
pdepetro wrote:

Does this look better: https://github.com/llvm/llvm-project/pull/184815/changes#diff-e98d8a60b203d4f4725c6b245166287194a3f5af9eac6954b84640ccb83fdb81R6052-R6074

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


More information about the lldb-commits mailing list