llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Charles Zablit (charles-zablit)

<details>
<summary>Changes</summary>

`NativeProcessWindows::OnDebugException` forwarded `STATUS_BREAKPOINT` 
exceptions, which returned `ExceptionResult::SendToApplication` on first chance.

On Windows an unhandled `STATUS_BREAKPOINT` is fatal to the process. Programs 
containing explicit `int3`, `__debugbreak()`, or `__builtin_debugtrap()` were 
killed when hitting the instruction and the subsequent user `continue` had 
nothing to resume.

This patch mirrors the `ProcessWindows` plugin handling of 
`EXCEPTION_BREAKPOINT`. It fixes all shell `Register/*-read.test` / 
`*-write.test` cases and several expression side-effect tests in `check-lldb` 
with `LLDB_USE_LLDB_SERVER=1`.

---
Full diff: https://github.com/llvm/llvm-project/pull/197669.diff


1 Files Affected:

- (modified) 
lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp (+12-1) 


``````````diff
diff --git 
a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
index c5698b1a8368d..3e546bbd7d10a 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -564,7 +564,18 @@ NativeProcessWindows::OnDebugException(bool first_chance,
       return ExceptionResult::BreakInDebugger;
     }
 
-    [[fallthrough]];
+    // Any remaining STATUS_BREAKPOINT is a breakpoint instruction in the
+    // program's own code (e.g. `__debugbreak()` or `__builtin_debugtrap()`).
+    // Stop the debugger and let the user decide what to do.
+    std::string desc =
+        formatv("Exception {0} encountered at address {1}",
+                llvm::format_hex(record.GetExceptionCode(), 8),
+                llvm::format_hex(record.GetExceptionAddress(), 8))
+            .str();
+    StopThread(record.GetThreadID(), StopReason::eStopReasonException,
+               std::move(desc));
+    SetState(eStateStopped, true);
+    return ExceptionResult::MaskException;
   default:
     LLDB_LOG(log,
              "Debugger thread reported exception {0:x} at address {1:x} "

``````````

</details>


https://github.com/llvm/llvm-project/pull/197669
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to