[Lldb-commits] [lldb] 08c4a67 - [lldb] Move breakpoint hit reset code to Target::CleanupProcess
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 6 08:19:10 PDT 2022
Author: Pavel Labath
Date: 2022-10-06T17:18:51+02:00
New Revision: 08c4a6795ac40f14d8a4385d28bc4f266ba895f1
URL: https://github.com/llvm/llvm-project/commit/08c4a6795ac40f14d8a4385d28bc4f266ba895f1
DIFF: https://github.com/llvm/llvm-project/commit/08c4a6795ac40f14d8a4385d28bc4f266ba895f1.diff
LOG: [lldb] Move breakpoint hit reset code to Target::CleanupProcess
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.
Differential Revision: https://reviews.llvm.org/D134882
Added:
Modified:
lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp
lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
Removed:
################################################################################
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 1a9befdfcb0ce..bbc5cb87f86f6 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -2761,18 +2761,15 @@ ListenerSP ProcessAttachInfo::GetListenerForProcess(Debugger &debugger) {
}
Status Process::WillLaunch(Module *module) {
- GetTarget().ResetBreakpointHitCounts();
return DoWillLaunch(module);
}
Status Process::WillAttachToProcessWithID(lldb::pid_t pid) {
- GetTarget().ResetBreakpointHitCounts();
return DoWillAttachToProcessWithID(pid);
}
Status Process::WillAttachToProcessWithName(const char *process_name,
bool wait_for_launch) {
- GetTarget().ResetBreakpointHitCounts();
return DoWillAttachToProcessWithName(process_name, wait_for_launch);
}
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 27c58cb6e2e16..c567407757e39 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -177,6 +177,7 @@ void Target::CleanupProcess() {
// clean up needs some help from the process.
m_breakpoint_list.ClearAllBreakpointSites();
m_internal_breakpoint_list.ClearAllBreakpointSites();
+ ResetBreakpointHitCounts();
// Disable watchpoints just on the debugger side.
std::unique_lock<std::recursive_mutex> lock;
this->GetWatchpointList().GetListMutex(lock);
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py b/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
index 1e0a519f420fa..191eda5cfecbc 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
@@ -63,3 +63,57 @@ def test_process_connect_async(self):
self.dbg.GetSelectedTarget().GetProcess().Kill()
lldbutil.expect_state_changes(self, self.dbg.GetListener(),
self.process(), [lldb.eStateExited])
+ def test_breakpoint_count(self):
+ """
+ Test that breakpoint count gets reset for each new connection.
+ """
+ class MyResponder(MockGDBServerResponder):
+
+ def __init__(self):
+ super().__init__()
+ self.continued = False
+
+ def qfThreadInfo(self):
+ return "m47"
+
+ def qsThreadInfo(self):
+ return "l"
+
+ def setBreakpoint(self, packet):
+ return "OK"
+
+ def readRegister(self, reg):
+ # Pretend we're at the breakpoint after we've been resumed.
+ return "3412000000000000" if self.continued else "4747000000000000"
+
+ def cont(self):
+ self.continued = True
+ return "T05thread=47;reason:breakpoint"
+
+ # Connect to the first process and set our breakpoint.
+ self.server.responder = MyResponder()
+ target = self.createTarget("a.yaml")
+ process = self.connect(target)
+
+ bkpt = target.BreakpointCreateByAddress(0x1234)
+ self.assertTrue(bkpt.IsValid())
+ self.assertEqual(bkpt.GetNumLocations(), 1)
+
+ # "continue" the process. It should hit our breakpoint.
+ process.Continue()
+ self.assertState(process.GetState(), lldb.eStateStopped)
+ self.assertEqual(bkpt.GetHitCount(), 1)
+
+ # Now kill it. The breakpoint should still show a hit count of one.
+ process.Kill()
+ self.server.stop()
+ self.assertEqual(bkpt.GetHitCount(), 1)
+
+ # Start over, and reconnect.
+ self.server = MockGDBServer(self.server_socket_class())
+ self.server.start()
+
+ process = self.connect(target)
+
+ # The hit count should be reset.
+ self.assertEqual(bkpt.GetHitCount(), 0)
More information about the lldb-commits
mailing list