Skip to content

[lldb] Set the stop reason when receiving swbreak/hwbreak #108518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

jasonmolenda
Copy link
Collaborator

xusheng added support for swbreak/hwbreak a month ago, and no special support was needed in ProcessGDBRemote when they're received because lldb already marks a thread as having hit a breakpoint when it stops at a breakpoint site. However, with changes I am working on, we need to know the real stop reason a thread stopped or the breakpoint hit will not be recognized.

This is similar to how lldb processes the "watch/rwatch/awatch" keys in a thread stop packet -- we set the reason to watchpoint, and these set it to breakpoint so we set the stop reason correctly later in these methods.

xusheng added support for swbreak/hwbreak a month ago, and no special
support was needed in ProcessGDBRemote when they're received because
lldb already marks a thread as having hit a breakpoint when it stops
at a breakpoint site.  However, with changes I am working on,
we need to know the real stop reason a thread stopped or the breakpoint
hit will not be recognized.

This is similar to how lldb processes the "watch/rwatch/awatch" keys in
a thread stop packet -- we set the `reason` to `watchpoint`, and these
set it to `breakpoint` so we set the stop reason correctly later in
these methods.
@llvmbot
Copy link
Member

llvmbot commented Sep 13, 2024

@llvm/pr-subscribers-lldb

Author: Jason Molenda (jasonmolenda)

Changes

xusheng added support for swbreak/hwbreak a month ago, and no special support was needed in ProcessGDBRemote when they're received because lldb already marks a thread as having hit a breakpoint when it stops at a breakpoint site. However, with changes I am working on, we need to know the real stop reason a thread stopped or the breakpoint hit will not be recognized.

This is similar to how lldb processes the "watch/rwatch/awatch" keys in a thread stop packet -- we set the reason to watchpoint, and these set it to breakpoint so we set the stop reason correctly later in these methods.


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

1 Files Affected:

  • (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+2)
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 5eaf9ce2a302aa..271ff61a7188a6 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2317,6 +2317,8 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
         StreamString ostr;
         ostr.Printf("%" PRIu64, wp_addr);
         description = std::string(ostr.GetString());
+      } else if (key.compare("swbreak") == 0 || key.compare("hwbreak") == 0) {
+        reason = "breakpoint";
       } else if (key.compare("library") == 0) {
         auto error = LoadModules();
         if (error) {

@jasonmolenda
Copy link
Collaborator Author

jasonmolenda commented Sep 13, 2024

This is the follow up patch I alluded to in #102873 needed for my work to re-land my change to how breakpoints are handled in lldb (work in progress at #108504 ). It's the same thing we do for watchpoints just above this point, setting the reason variable to the actual stop reason so we set the thread's status correctly. There's no difference in behavior right now, but it will be important when I land my changes, if someone communicates with a stub that sends swbreak/hwbreak.

jasonmolenda added a commit to jasonmolenda/llvm-project that referenced this pull request Sep 13, 2024
Breaking this patch out into a separate PR
llvm#108518

This reverts commit 3408ce1.
Copy link
Collaborator

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still curious exactly how we end up with threads on a breakpoint that didn't execute it - #108504 (comment)

But aside from that this LGTM.

@jasonmolenda jasonmolenda merged commit 65a4d11 into llvm:main Sep 13, 2024
9 checks passed
@jasonmolenda jasonmolenda deleted the set-stop-reason-for-swbreak-hwbreak branch September 13, 2024 16:04
jasonmolenda added a commit to jasonmolenda/llvm-project that referenced this pull request Feb 13, 2025
xusheng added support for swbreak/hwbreak a month ago, and no special
support was needed in ProcessGDBRemote when they're received because
lldb already marks a thread as having hit a breakpoint when it stops at
a breakpoint site. However, with changes I am working on, we need to
know the real stop reason a thread stopped or the breakpoint hit will
not be recognized.

This is similar to how lldb processes the "watch/rwatch/awatch" keys in
a thread stop packet -- we set the `reason` to `watchpoint`, and these
set it to `breakpoint` so we set the stop reason correctly later in
these methods.

(cherry picked from commit 65a4d11)
jasonmolenda added a commit to jasonmolenda/llvm-project that referenced this pull request Mar 29, 2025
xusheng added support for swbreak/hwbreak a month ago, and no special
support was needed in ProcessGDBRemote when they're received because
lldb already marks a thread as having hit a breakpoint when it stops at
a breakpoint site. However, with changes I am working on, we need to
know the real stop reason a thread stopped or the breakpoint hit will
not be recognized.

This is similar to how lldb processes the "watch/rwatch/awatch" keys in
a thread stop packet -- we set the `reason` to `watchpoint`, and these
set it to `breakpoint` so we set the stop reason correctly later in
these methods.

(cherry picked from commit 65a4d11)
jasonmolenda added a commit to jasonmolenda/llvm-project that referenced this pull request Apr 8, 2025
xusheng added support for swbreak/hwbreak a month ago, and no special
support was needed in ProcessGDBRemote when they're received because
lldb already marks a thread as having hit a breakpoint when it stops at
a breakpoint site. However, with changes I am working on, we need to
know the real stop reason a thread stopped or the breakpoint hit will
not be recognized.

This is similar to how lldb processes the "watch/rwatch/awatch" keys in
a thread stop packet -- we set the `reason` to `watchpoint`, and these
set it to `breakpoint` so we set the stop reason correctly later in
these methods.

(cherry picked from commit 65a4d11)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants