[Lldb-commits] [lldb] r307287 - Working through testcases, converting to run_to_source_breakpoint.

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 6 11:06:25 PDT 2017


Author: jingham
Date: Thu Jul  6 11:06:25 2017
New Revision: 307287

URL: http://llvm.org/viewvc/llvm-project?rev=307287&view=rev
Log:
Working through testcases, converting to run_to_source_breakpoint.

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py?rev=307287&r1=307286&r2=307287&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py Thu Jul  6 11:06:25 2017
@@ -32,26 +32,9 @@ class Issue11581TestCase(TestBase):
         """valobj.AddressOf() should return correct values."""
         self.build()
 
-        exe = os.path.join(os.getcwd(), "a.out")
-
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target, VALID_TARGET)
-
-        breakpoint = target.BreakpointCreateBySourceRegex(
-            'Set breakpoint here.', lldb.SBFileSpec("main.cpp", False))
-
-        process = target.LaunchSimple(
-            None, None, self.get_process_working_directory())
-        self.assertTrue(process, "Created a process.")
-        self.assertTrue(
-            process.GetState() == lldb.eStateStopped,
-            "Stopped it too.")
-
-        thread_list = lldbutil.get_threads_stopped_at_breakpoint(
-            process, breakpoint)
-        self.assertTrue(len(thread_list) == 1)
-        thread = thread_list[0]
-
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, 
+                                              'Set breakpoint here.', 
+                                              lldb.SBFileSpec("main.cpp", False))
         self.runCmd("command script import --allow-reload s11588.py")
         self.runCmd(
             "type synthetic add --python-class s11588.Issue11581SyntheticProvider StgClosure")

Modified: lldb/trunk/packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py?rev=307287&r1=307286&r2=307287&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py Thu Jul  6 11:06:25 2017
@@ -30,32 +30,8 @@ class TestMacros(TestBase):
         src_file_spec = lldb.SBFileSpec(src_file)
         self.assertTrue(src_file_spec.IsValid(), "Main source file")
 
-        # Get the path of the executable
-        cwd = os.getcwd()
-        exe_file = "a.out"
-        exe_path = os.path.join(cwd, exe_file)
-
-        # Load the executable
-        target = self.dbg.CreateTarget(exe_path)
-        self.assertTrue(target.IsValid(), VALID_TARGET)
-
-        # Set breakpoints
-        bp1 = target.BreakpointCreateBySourceRegex("Break here", src_file_spec)
-        self.assertTrue(
-            bp1.IsValid() and bp1.GetNumLocations() >= 1,
-            VALID_BREAKPOINT)
-
-        # Launch the process
-        process = target.LaunchSimple(
-            None, None, self.get_process_working_directory())
-        self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
-
-        # Get the thread of the process
-        self.assertTrue(
-            process.GetState() == lldb.eStateStopped,
-            PROCESS_STOPPED)
-        thread = lldbutil.get_stopped_thread(
-            process, lldb.eStopReasonBreakpoint)
+        (target, process, thread, bp1) = lldbutil.run_to_source_breakpoint(
+            self, "Break here", src_file_spec)
 
         # Get frame for current thread
         frame = thread.GetSelectedFrame()

Modified: lldb/trunk/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py?rev=307287&r1=307286&r2=307287&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py Thu Jul  6 11:06:25 2017
@@ -37,25 +37,10 @@ class ExprOptionsTestCase(TestBase):
         # Set debugger into synchronous mode
         self.dbg.SetAsync(False)
 
-        # Create a target by the debugger.
-        target = self.dbg.CreateTarget(self.exe)
-        self.assertTrue(target, VALID_TARGET)
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+            self, '// breakpoint_in_main', self.main_source_spec)
 
-        # Set breakpoints inside main.
-        breakpoint = target.BreakpointCreateBySourceRegex(
-            '// breakpoint_in_main', self.main_source_spec)
-        self.assertTrue(breakpoint)
-
-        # Now launch the process, and do not stop at entry point.
-        process = target.LaunchSimple(
-            None, None, self.get_process_working_directory())
-        self.assertTrue(process, PROCESS_IS_VALID)
-
-        threads = lldbutil.get_threads_stopped_at_breakpoint(
-            process, breakpoint)
-        self.assertEqual(len(threads), 1)
-
-        frame = threads[0].GetFrameAtIndex(0)
+        frame = thread.GetFrameAtIndex(0)
         options = lldb.SBExpressionOptions()
 
         # test --language on C++ expression using the SB API's

Modified: lldb/trunk/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py?rev=307287&r1=307286&r2=307287&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py Thu Jul  6 11:06:25 2017
@@ -31,17 +31,10 @@ class SaveJITObjectsTestCase(TestBase):
         src_file = "main.c"
         src_file_spec = lldb.SBFileSpec(src_file)
   
-        exe_path = os.path.join(os.getcwd(), "a.out")
-        target = self.dbg.CreateTarget(exe_path)
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+            self, "break", src_file_spec)
 
-        breakpoint = target.BreakpointCreateBySourceRegex(
-            "break", src_file_spec)
-
-        process = target.LaunchSimple(None, None,
-                                      self.get_process_working_directory())
-
-        thread = process.GetSelectedThread()
-        frame = thread.GetSelectedFrame()
+        frame = thread.frames[0]
 
         cleanJITFiles()
         frame.EvaluateExpression("(void*)malloc(0x1)")

Modified: lldb/trunk/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py?rev=307287&r1=307286&r2=307287&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py Thu Jul  6 11:06:25 2017
@@ -25,36 +25,14 @@ class ExprCommandWithTimeoutsTestCase(Te
     @expectedFlakeyFreeBSD("llvm.org/pr19605")
     @expectedFailureAll(
         oslist=[
-            "windows",
-            "macosx"],
+            "windows"],
         bugnumber="llvm.org/pr21765")
     def test(self):
         """Test calling std::String member function."""
         self.build()
 
-        exe_name = "a.out"
-        exe = os.path.join(os.getcwd(), exe_name)
-
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target, VALID_TARGET)
-
-        breakpoint = target.BreakpointCreateBySourceRegex(
-            'stop here in main.', self.main_source_spec)
-        self.assertTrue(breakpoint, VALID_BREAKPOINT)
-        self.runCmd("breakpoint list")
-
-        # Launch the process, and do not stop at the entry point.
-        process = target.LaunchSimple(
-            None, None, self.get_process_working_directory())
-
-        self.assertTrue(process, PROCESS_IS_VALID)
-
-        # Frame #0 should be on self.step_out_of_malloc.
-        threads = lldbutil.get_threads_stopped_at_breakpoint(
-            process, breakpoint)
-
-        self.assertTrue(len(threads) == 1)
-        thread = threads[0]
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+            self, 'stop here in main.', self.main_source_spec)
 
         # First set the timeout too short, and make sure we fail.
         options = lldb.SBExpressionOptions()




More information about the lldb-commits mailing list