// location said we should stop. But that's better than not running
// all the callbacks.
- // There's one other complication here. We may have run an async
- // breakpoint callback that said we should stop. We only want to
- // override that if another breakpoint action says we shouldn't
- // stop. If nobody else has an opinion, then we should stop if the
- // async callback says we should. An example of this is the async
- // shared library load notification breakpoint and the setting
- // stop-on-sharedlibrary-events.
- // We'll keep the async value in async_should_stop, and track whether
- // anyone said we should NOT stop in actually_said_continue.
- bool async_should_stop = false;
- if (m_should_stop_is_valid)
- async_should_stop = m_should_stop;
- bool actually_said_continue = false;
-
m_should_stop = false;
// We don't select threads as we go through them testing breakpoint
bool precondition_result =
bp_loc_sp->GetBreakpoint().EvaluatePrecondition(context);
- if (!precondition_result) {
- actually_said_continue = true;
+ if (!precondition_result)
continue;
- }
+
// Next run the condition for the breakpoint. If that says we
// should stop, then we'll run the callback for the breakpoint. If
// the callback says we shouldn't stop that will win.
// the condition fails. We've already bumped it by the time
// we get here, so undo the bump:
bp_loc_sp->UndoBumpHitCount();
- actually_said_continue = true;
continue;
}
}
if (callback_says_stop && auto_continue_says_stop)
m_should_stop = true;
- else
- actually_said_continue = true;
-
// If we are going to stop for this breakpoint, then remove the
// breakpoint.
// here.
if (HasTargetRunSinceMe()) {
m_should_stop = false;
- actually_said_continue = true;
break;
}
}
- // At this point if nobody actually told us to continue, we should
- // give the async breakpoint callback a chance to weigh in:
- if (!actually_said_continue && !m_should_stop) {
- m_should_stop = async_should_stop;
- }
}
// We've figured out what this stop wants to do, so mark it as valid so
// we don't compute it again.
+++ /dev/null
-""" Test that stop-on-sharedlibrary-events works and cooperates with breakpoints. """
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-class TestStopOnSharedlibraryEvents(TestBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- @skipIfRemote
- @skipIfWindows
- @no_debug_info_test
- def test_stopping_breakpoints(self):
- self.do_test()
-
- def test_auto_continue(self):
- def auto_continue(bkpt):
- bkpt.SetAutoContinue(True)
- self.do_test(auto_continue)
-
- def test_failing_condition(self):
- def condition(bkpt):
- bkpt.SetCondition("1 == 2")
- self.do_test(condition)
-
- def test_continue_callback(self):
- def bkpt_callback(bkpt):
- bkpt.SetScriptCallbackBody("return False")
- self.do_test(bkpt_callback)
-
- def do_test(self, bkpt_modifier = None):
- self.build()
- main_spec = lldb.SBFileSpec("main.cpp")
- # Launch and stop before the dlopen call.
- target, process, _, _ = lldbutil.run_to_source_breakpoint(self,
- "// Set a breakpoint here", main_spec)
-
- # Now turn on shared library events, continue and make sure we stop for the event.
- self.runCmd("settings set target.process.stop-on-sharedlibrary-events 1")
- self.addTearDownHook(lambda: self.runCmd(
- "settings set target.process.stop-on-sharedlibrary-events 0"))
-
- # Since I don't know how to check that we are at the "right place" to stop for
- # shared library events, make an breakpoint after the load is done and
- # make sure we don't stop there:
- backstop_bkpt_1 = target.BreakpointCreateBySourceRegex("Set another here - we should not hit this one", main_spec)
- self.assertGreater(backstop_bkpt_1.GetNumLocations(), 0, "Set our second breakpoint")
-
- process.Continue()
- self.assertEqual(process.GetState(), lldb.eStateStopped, "We didn't stop for the load")
- self.assertEqual(backstop_bkpt_1.GetHitCount(), 0, "Hit our backstop breakpoint")
-
- # We should be stopped after the library is loaded, check that:
- found_it = False
- for module in target.modules:
- if module.file.basename.find("load_a") > -1:
- found_it = True
- break
- self.assertTrue(found_it, "Found the loaded module.")
-
- # Now capture the place where we stopped so we can set a breakpoint and make
- # sure the breakpoint there works correctly:
- load_address = process.GetSelectedThread().frames[0].addr
- load_bkpt = target.BreakpointCreateBySBAddress(load_address)
- self.assertGreater(load_bkpt.GetNumLocations(), 0, "Set the load breakpoint")
-
- backstop_bkpt_1.SetEnabled(False)
-
- backstop_bkpt_2 = target.BreakpointCreateBySourceRegex("Set a third here - we should not hit this one", main_spec)
- self.assertGreater(backstop_bkpt_2.GetNumLocations(), 0, "Set our third breakpoint")
-
- if bkpt_modifier == None:
- process.Continue()
- self.assertEqual(process.GetState(), lldb.eStateStopped, "We didn't stop for the load")
- self.assertEqual(backstop_bkpt_2.GetHitCount(), 0, "Hit our backstop breakpoint")
-
- thread = process.GetSelectedThread()
- self.assertEqual(thread.stop_reason, lldb.eStopReasonBreakpoint, "We attributed the stop to the breakpoint")
- self.assertEqual(thread.GetStopReasonDataCount(), 2, "Only hit one breakpoint")
- bkpt_no = thread.GetStopReasonDataAtIndex(0)
- self.assertEqual(bkpt_no, load_bkpt.id, "We hit our breakpoint at the load address")
- else:
- bkpt_modifier(load_bkpt)
- process.Continue()
- self.assertEqual(process.GetState(), lldb.eStateStopped, "We didn't stop")
- thread = process.GetSelectedThread()
- self.assertEqual(thread.stop_reason, lldb.eStopReasonBreakpoint, "We didn't hit some breakpoint")
- self.assertEqual(thread.GetStopReasonDataCount(), 2, "Only hit one breakpoint")
- bkpt_no = thread.GetStopReasonDataAtIndex(0)
- self.assertEqual(bkpt_no, backstop_bkpt_2.id, "We continued to the right breakpoint")
-
-
-
-
-