llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Felipe de Azevedo Piovezan (felipepiovezan) <details> <summary>Changes</summary> Breakpoints should never be delayed on a running process, as they can immediately affect program execution. --- Full diff: https://github.com/llvm/llvm-project/pull/198747.diff 4 Files Affected: - (modified) lldb/source/Target/Process.cpp (+3) - (added) lldb/test/API/functionalities/breakpoint/breakpoint_while_running/Makefile (+3) - (added) lldb/test/API/functionalities/breakpoint/breakpoint_while_running/TestBreakpointWhileRunning.py (+26) - (added) lldb/test/API/functionalities/breakpoint/breakpoint_while_running/main.c (+8) ``````````diff diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index d0711bb36ebff..6467671e2d2ca 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1601,6 +1601,9 @@ Status Process::DisableBreakpointSiteByID(lldb::user_id_t break_id) { llvm::Error Process::ExecuteBreakpointSiteAction(BreakpointSite &site, BreakpointAction action, bool do_it_now) { + // Breakpoints immediately affect running processes, so do not delay them. + do_it_now |= IsRunning(); + if (do_it_now) if (llvm::Error E = FlushDelayedBreakpoints()) LLDB_LOG_ERROR( diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_while_running/Makefile b/lldb/test/API/functionalities/breakpoint/breakpoint_while_running/Makefile new file mode 100644 index 0000000000000..10495940055b6 --- /dev/null +++ b/lldb/test/API/functionalities/breakpoint/breakpoint_while_running/Makefile @@ -0,0 +1,3 @@ +C_SOURCES := main.c + +include Makefile.rules diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_while_running/TestBreakpointWhileRunning.py b/lldb/test/API/functionalities/breakpoint/breakpoint_while_running/TestBreakpointWhileRunning.py new file mode 100644 index 0000000000000..b478be689a46d --- /dev/null +++ b/lldb/test/API/functionalities/breakpoint/breakpoint_while_running/TestBreakpointWhileRunning.py @@ -0,0 +1,26 @@ +""" +Test inserting a breakpoint while inferior is executing. +""" + +import lldb +from lldbsuite.test.lldbtest import TestBase +from lldbsuite.test import lldbutil + + +class BreakpointWhileRunning(TestBase): + NO_DEBUG_INFO_TESTCASE = True + + def test_breakpoint_while_running(self): + self.build() + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, "main", lldb.SBFileSpec("main.c") + ) + + self.dbg.SetAsync(True) + listener = self.dbg.GetListener() + self.runCmd("break delete --force") + self.runCmd("continue") + lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning]) + self.runCmd("break set --source-pattern-regexp 'break here'") + lldbutil.expect_state_changes(self, listener, process, [lldb.eStateStopped]) + self.runCmd("process status") diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_while_running/main.c b/lldb/test/API/functionalities/breakpoint/breakpoint_while_running/main.c new file mode 100644 index 0000000000000..ff22dc074854d --- /dev/null +++ b/lldb/test/API/functionalities/breakpoint/breakpoint_while_running/main.c @@ -0,0 +1,8 @@ +#include <unistd.h> + +int main() +{ + int count = 100; + while (count--) + sleep (1); // break here +} `````````` </details> https://github.com/llvm/llvm-project/pull/198747 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
