Skip to content

[Dexter] Adapt to upcoming lldb stepping behavior #108127

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

Conversation

jasonmolenda
Copy link
Collaborator

lldb will change how it reports stop reasons around breakpoints in the near future. I landed an earlier version of this change and noticed debuginfo test failures on the CI bots due to the changes. I'm addressing the issues found by CI at
#105594 and will re-land once I've done all of them.

Currently, when lldb stops at a breakpoint instruction -- but has not yet executed the instruction -- it will overwrite the thread's Stop Reason with "breakpoint-hit". This caused bugs when the original stop reason was important to the user - for instance, a watchpoint on an AArch64 system where we have to instruction-step past the watchpoint to find the new value. Normally we would instruction step, fetch the new value, then report the user that a watchpoint has been hit with the old and new values. But if the instruction after this access is a breakpoint site, we overwrite the "watchpoint hit" stop reason (and related actions) with "breakpoint hit".

dexter sets breakpoints on all source lines, then steps line-to-line, hitting the breakpoints. But with this new behavior, we see two steps per source line: The first step gets us to the start of the next line, with a "step completed" stop reason. Then we step again and we execute the breakpoint instruction, stop with the pc the same, and report "breakpoint hit". Now we can step a second time and move past the breakpoint.

I've changed the step method in LLDB.py to check if we step to a breakpoint site but have a "step completed" stop reason -- in which case we have this new breakpoint behavior, and we need to step a second time to actually hit the breakpoint like the debuginfo tests expect.

lldb will change how it reports stop reasons around breakpoints in
the near future.  I landed an earlier version of this change and
noticed debuginfo test failures on the CI bots due to the changes.
I'm addressing the issues found by CI at
llvm#105594 and will re-land
once I've done all of them.

Currently, when lldb stops at a breakpoint instruction -- but has
not yet executed the instruction -- it will overwrite the thread's
Stop Reason with "breakpoint-hit".  This caused bugs when the
original stop reason was important to the user - for instance, a
watchpoint on an AArch64 system where we have to instruction-step
past the watchpoint to find the new value.  Normally we would
instruction step, fetch the new value, then report the user that a
watchpoint has been hit with the old and new values.  But if the
instruction after this access is a breakpoint site, we overwrite
the "watchpoint hit" stop reason (and related actions) with "breakpoint
hit".

dexter sets breakpoints on all source lines, then steps line-to-line,
hitting the breakpoints.  But with this new behavior, we see two
steps per source line:  The first step gets us to the start of the
next line, with a "step completed" stop reason.  Then we step again
and we execute the breakpoint instruction, stop with the pc the
same, and report "breakpoint hit".  Now we can step a second time
and move past the breakpoint.

I've changed the `step` method in LLDB.py to check if we step to a
breakpoint site but have a "step completed" stop reason -- in which
case we have this new breakpoint behavior, and we need to step a
second time to actually hit the breakpoint like the debuginfo tests
expect.
@jasonmolenda
Copy link
Collaborator Author

I've never looked at/touched the debuginfo tests / dexter before, I'm not sure who is best to ask to review this change. I'm open to feedback, I know the comment is a bit long but I wanted to be clear what this was doing. I wanted to have Dexter work with old or new lldb's equally but people will slowly forget the old lldb behavior.

Copy link
Contributor

@SLTozer SLTozer left a comment

Choose a reason for hiding this comment

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

Looks like a sensible way to solve the problem, thanks for this! Just so I understand correctly, in cases where we set breakpoints but exclusively advance using go(), as with the ConditionalController, the change in LLDB's behaviour will have no effect - is that correct?

@jasonmolenda
Copy link
Collaborator Author

Looks like a sensible way to solve the problem, thanks for this! Just so I understand correctly, in cases where we set breakpoints but exclusively advance using go(), as with the ConditionalController, the change in LLDB's behaviour will have no effect - is that correct?

The lldb go method does SBProcess.Continue(). If we are moving between the breakpoints with Continues, the behavior is the same as it was before. We execute until we hit the breakpoint instruction, and then when we resume the thread (step/continue/etc), the breakpoint is silently stepped past before execution is resumed. The issue I'm fixing in this PR only comes up because the step stops on the breakpoint instruction that hasn't been executed yet. I did run the dexter tests on my desktop with the stepping change and they passed, we'll see what happens when it hits the CI bots but I think this is sufficient. Thanks!

@jasonmolenda jasonmolenda merged commit 93e45a6 into llvm:main Sep 11, 2024
7 checks passed
@jasonmolenda jasonmolenda deleted the dexter-update-for-upcoming-lldb-stepping-behavior branch September 11, 2024 23:09
jasonmolenda added a commit to jasonmolenda/llvm-project that referenced this pull request Feb 13, 2025
lldb will change how it reports stop reasons around breakpoints in the
near future. I landed an earlier version of this change and noticed
debuginfo test failures on the CI bots due to the changes. I'm
addressing the issues found by CI at
llvm#105594 and will re-land once
I've done all of them.

Currently, when lldb stops at a breakpoint instruction -- but has not
yet executed the instruction -- it will overwrite the thread's Stop
Reason with "breakpoint-hit". This caused bugs when the original stop
reason was important to the user - for instance, a watchpoint on an
AArch64 system where we have to instruction-step past the watchpoint to
find the new value. Normally we would instruction step, fetch the new
value, then report the user that a watchpoint has been hit with the old
and new values. But if the instruction after this access is a breakpoint
site, we overwrite the "watchpoint hit" stop reason (and related
actions) with "breakpoint hit".

dexter sets breakpoints on all source lines, then steps line-to-line,
hitting the breakpoints. But with this new behavior, we see two steps
per source line: The first step gets us to the start of the next line,
with a "step completed" stop reason. Then we step again and we execute
the breakpoint instruction, stop with the pc the same, and report
"breakpoint hit". Now we can step a second time and move past the
breakpoint.

I've changed the `step` method in LLDB.py to check if we step to a
breakpoint site but have a "step completed" stop reason -- in which case
we have this new breakpoint behavior, and we need to step a second time
to actually hit the breakpoint like the debuginfo tests expect.

(cherry picked from commit 93e45a6)
jasonmolenda added a commit to jasonmolenda/llvm-project that referenced this pull request Mar 29, 2025
lldb will change how it reports stop reasons around breakpoints in the
near future. I landed an earlier version of this change and noticed
debuginfo test failures on the CI bots due to the changes. I'm
addressing the issues found by CI at
llvm#105594 and will re-land once
I've done all of them.

Currently, when lldb stops at a breakpoint instruction -- but has not
yet executed the instruction -- it will overwrite the thread's Stop
Reason with "breakpoint-hit". This caused bugs when the original stop
reason was important to the user - for instance, a watchpoint on an
AArch64 system where we have to instruction-step past the watchpoint to
find the new value. Normally we would instruction step, fetch the new
value, then report the user that a watchpoint has been hit with the old
and new values. But if the instruction after this access is a breakpoint
site, we overwrite the "watchpoint hit" stop reason (and related
actions) with "breakpoint hit".

dexter sets breakpoints on all source lines, then steps line-to-line,
hitting the breakpoints. But with this new behavior, we see two steps
per source line: The first step gets us to the start of the next line,
with a "step completed" stop reason. Then we step again and we execute
the breakpoint instruction, stop with the pc the same, and report
"breakpoint hit". Now we can step a second time and move past the
breakpoint.

I've changed the `step` method in LLDB.py to check if we step to a
breakpoint site but have a "step completed" stop reason -- in which case
we have this new breakpoint behavior, and we need to step a second time
to actually hit the breakpoint like the debuginfo tests expect.

(cherry picked from commit 93e45a6)
jasonmolenda added a commit to jasonmolenda/llvm-project that referenced this pull request Apr 8, 2025
lldb will change how it reports stop reasons around breakpoints in the
near future. I landed an earlier version of this change and noticed
debuginfo test failures on the CI bots due to the changes. I'm
addressing the issues found by CI at
llvm#105594 and will re-land once
I've done all of them.

Currently, when lldb stops at a breakpoint instruction -- but has not
yet executed the instruction -- it will overwrite the thread's Stop
Reason with "breakpoint-hit". This caused bugs when the original stop
reason was important to the user - for instance, a watchpoint on an
AArch64 system where we have to instruction-step past the watchpoint to
find the new value. Normally we would instruction step, fetch the new
value, then report the user that a watchpoint has been hit with the old
and new values. But if the instruction after this access is a breakpoint
site, we overwrite the "watchpoint hit" stop reason (and related
actions) with "breakpoint hit".

dexter sets breakpoints on all source lines, then steps line-to-line,
hitting the breakpoints. But with this new behavior, we see two steps
per source line: The first step gets us to the start of the next line,
with a "step completed" stop reason. Then we step again and we execute
the breakpoint instruction, stop with the pc the same, and report
"breakpoint hit". Now we can step a second time and move past the
breakpoint.

I've changed the `step` method in LLDB.py to check if we step to a
breakpoint site but have a "step completed" stop reason -- in which case
we have this new breakpoint behavior, and we need to step a second time
to actually hit the breakpoint like the debuginfo tests expect.

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

Successfully merging this pull request may close these issues.

2 participants