This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Move breakpoint hit reset code to Target::CleanupProcess
ClosedPublic

Authored by labath on Sep 29 2022, 7:50 AM.

Details

Summary

This ensures it is run regardless of the method we use to initiate the
session (previous version did not handle connects), and it is the same
place that is used for resetting watchpoints.

Diff Detail

Event Timeline

labath created this revision.Sep 29 2022, 7:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2022, 7:50 AM
labath requested review of this revision.Sep 29 2022, 7:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2022, 7:50 AM

If there's some guarantee that Target::CreateProcess HAS to be the way that a process is created, then this is fine. Is there such a guarantee - the function is pretty trivial so somebody might be tempted to do the work in some other place but miss the breakpoint resetting.

I'm not sure what kind of guarantees are you looking for. m_process_sp is a private member of the Target class, so it's not like just anyone can come in and change it. There's no way to stop code from inside the Target class from changing it without going through the CreateProcess method, but the same can be said about the calls to WillXXX methods in the process class.

jingham added a comment.EditedSep 30 2022, 10:07 AM

The WillXXX have the virtue that they are at least self-documenting "Before you do XXX this will be called." As it stands somebody working on Target could be forgiven for thinking Target::CreateProcess was just a convenience method, and redo it somewhere inline forgetting the breakpoint resetting. If we are going to require CreateProcess as the only way to do this, we should at least state that somewhere.

labath updated this revision to Diff 464700.Oct 3 2022, 8:42 AM

use CleanupProcess instead

labath retitled this revision from [lldb] Move breakpoint hit reset code to Target::CreateProcess to [lldb] Move breakpoint hit reset code to Target::CleanupProcess.Oct 3 2022, 8:42 AM
labath edited the summary of this revision. (Show Details)

Here's an even better idea. I've now doing it in Target::CleanupProcess, right next to the code for resetting watchpoint hit counts.

That seems fine. I think it's useful to be able to see breakpoint hit counts up to the point where you start a new process. From looking at the code, it looks like putting the clear in CleanupProcess will do that. If you agree this is useful, can you add to the test that the hit count is still 1 between process.Kill and connecting to the new process? Other than that this seems fine.

labath updated this revision to Diff 465012.Oct 4 2022, 7:51 AM

Check breakpoint hit counts after termination

labath added a comment.Oct 4 2022, 7:52 AM

That seems fine. I think it's useful to be able to see breakpoint hit counts up to the point where you start a new process. From looking at the code, it looks like putting the clear in CleanupProcess will do that. If you agree this is useful, can you add to the test that the hit count is still 1 between process.Kill and connecting to the new process?

That makes sense to me. I've added the extra check.

This revision was not accepted when it landed; it landed in state Needs Review.Oct 6 2022, 8:19 AM
This revision was automatically updated to reflect the committed changes.