Convert a few more tests to use run_to_source_breakpoint.
llvm-svn: 307943
This commit is contained in:
parent
30bac79162
commit
61949c9f6f
|
@ -23,32 +23,8 @@ class UnwindFromExpressionTest(TestBase):
|
|||
def build_and_run_to_bkpt(self):
|
||||
self.build()
|
||||
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
# Create the breakpoint.
|
||||
breakpoint = target.BreakpointCreateBySourceRegex(
|
||||
"// Set a breakpoint here to get started", self.main_spec)
|
||||
self.assertTrue(breakpoint, VALID_BREAKPOINT)
|
||||
|
||||
# Launch the process, and do not stop at the entry point.
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
|
||||
if not process:
|
||||
self.fail("SBTarget.LaunchProcess() failed")
|
||||
|
||||
if process.GetState() != lldb.eStateStopped:
|
||||
self.fail("Process should be in the 'stopped' state, "
|
||||
"instead the actual state is: '%s'" %
|
||||
lldbutil.state_type_to_str(process.GetState()))
|
||||
|
||||
self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(
|
||||
process, breakpoint)
|
||||
self.assertIsNotNone(
|
||||
self.thread, "Expected one thread to be stopped at the breakpoint")
|
||||
(target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
|
||||
"// Set a breakpoint here to get started", self.main_spec)
|
||||
|
||||
# Next set a breakpoint in this function, set up Expression options to stop on
|
||||
# breakpoint hits, and call the function.
|
||||
|
|
|
@ -30,46 +30,13 @@ class BadAddressBreakpointTestCase(TestBase):
|
|||
|
||||
def address_breakpoints(self):
|
||||
"""Test that breakpoints set on a bad address say they are bad."""
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
|
||||
# Create a target by the debugger.
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
# Now create a breakpoint on main.c by name 'c'.
|
||||
breakpoint = target.BreakpointCreateBySourceRegex(
|
||||
"Set a breakpoint here", lldb.SBFileSpec("main.c"))
|
||||
self.assertTrue(breakpoint and
|
||||
breakpoint.GetNumLocations() == 1,
|
||||
VALID_BREAKPOINT)
|
||||
|
||||
# Get the breakpoint location from breakpoint after we verified that,
|
||||
# indeed, it has one location.
|
||||
location = breakpoint.GetLocationAtIndex(0)
|
||||
self.assertTrue(location and
|
||||
location.IsEnabled(),
|
||||
VALID_BREAKPOINT_LOCATION)
|
||||
|
||||
launch_info = lldb.SBLaunchInfo(None)
|
||||
|
||||
error = lldb.SBError()
|
||||
|
||||
process = target.Launch(launch_info, error)
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
# Did we hit our breakpoint?
|
||||
from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
|
||||
threads = get_threads_stopped_at_breakpoint(process, breakpoint)
|
||||
self.assertTrue(
|
||||
len(threads) == 1,
|
||||
"There should be a thread stopped at our breakpoint")
|
||||
|
||||
# The hit count for the breakpoint should be 1.
|
||||
self.assertTrue(breakpoint.GetHitCount() == 1)
|
||||
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
|
||||
"Set a breakpoint here", lldb.SBFileSpec("main.c"))
|
||||
|
||||
# Now see if we can read from 0. If I can't do that, I don't have a good way to know
|
||||
# what an illegal address is...
|
||||
error.Clear()
|
||||
error = lldb.SBError()
|
||||
|
||||
ptr = process.ReadPointerFromMemory(0x0, error)
|
||||
|
||||
|
|
|
@ -18,29 +18,9 @@ class ConsecutiveBreakpointsTestCase(TestBase):
|
|||
|
||||
def prepare_test(self):
|
||||
self.build()
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
|
||||
# Create a target by the debugger.
|
||||
self.target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(self.target, VALID_TARGET)
|
||||
|
||||
breakpoint1 = self.target.BreakpointCreateBySourceRegex(
|
||||
"Set breakpoint here", lldb.SBFileSpec("main.cpp"))
|
||||
self.assertTrue(
|
||||
breakpoint1 and breakpoint1.GetNumLocations() == 1,
|
||||
VALID_BREAKPOINT)
|
||||
|
||||
# Now launch the process, and do not stop at entry point.
|
||||
self.process = self.target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertIsNotNone(self.process, PROCESS_IS_VALID)
|
||||
|
||||
# We should be stopped at the first breakpoint
|
||||
self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(
|
||||
self.process, breakpoint1)
|
||||
self.assertIsNotNone(
|
||||
self.thread,
|
||||
"Expected one thread to be stopped at breakpoint 1")
|
||||
(self.target, self.process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(
|
||||
self, "Set breakpoint here", lldb.SBFileSpec("main.cpp"))
|
||||
|
||||
# Set breakpoint to the next instruction
|
||||
frame = self.thread.GetFrameAtIndex(0)
|
||||
|
|
Loading…
Reference in New Issue