diff options
-rw-r--r-- | lldb/include/lldb/API/SBTarget.h | 12 | ||||
-rw-r--r-- | lldb/scripts/lldb.swig | 1 | ||||
-rw-r--r-- | lldb/source/API/SBTarget.cpp | 26 | ||||
-rw-r--r-- | lldb/test/class_types/TestClassTypes.py | 46 | ||||
-rwxr-xr-x | lldb/test/dotest.py | 4 | ||||
-rw-r--r-- | lldb/test/lldbtest.py | 65 |
6 files changed, 129 insertions, 25 deletions
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 3bd2f079d0c..ae20e216851 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -57,12 +57,12 @@ public: // DEPRECATED in favor of the function below that contains an SBError as the // last parameter. - lldb::SBProcess - LaunchProcess (char const **argv, - char const **envp, - const char *tty, - uint32_t launch_flags, // See lldb::LaunchFlags - bool stop_at_entry); +// lldb::SBProcess +// LaunchProcess (char const **argv, +// char const **envp, +// const char *tty, +// uint32_t launch_flags, // See lldb::LaunchFlags +// bool stop_at_entry); lldb::SBProcess LaunchProcess (char const **argv, diff --git a/lldb/scripts/lldb.swig b/lldb/scripts/lldb.swig index a02bd65c56f..a7cfc840555 100644 --- a/lldb/scripts/lldb.swig +++ b/lldb/scripts/lldb.swig @@ -134,6 +134,7 @@ typedef int32_t break_id_t; typedef lldb::SBStringList SBStringList; typedef lldb::RegisterKind RegisterKind; const RegisterKind kNumRegisterKinds = lldb::kNumRegisterKinds ; +typedef int StateType; typedef int StopReason; diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 087b7dfafb1..860dae7aa92 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -119,19 +119,19 @@ SBTarget::CreateProcess () } -SBProcess -SBTarget::LaunchProcess -( - char const **argv, - char const **envp, - const char *tty, - uint32_t launch_flags, - bool stop_at_entry -) -{ - SBError sb_error; - return LaunchProcess (argv, envp, tty, launch_flags, stop_at_entry, sb_error); -} +// SBProcess +// SBTarget::LaunchProcess +// ( +// char const **argv, +// char const **envp, +// const char *tty, +// uint32_t launch_flags, +// bool stop_at_entry +// ) +// { +// SBError sb_error; +// return LaunchProcess (argv, envp, tty, launch_flags, stop_at_entry, sb_error); +// } SBProcess diff --git a/lldb/test/class_types/TestClassTypes.py b/lldb/test/class_types/TestClassTypes.py index 4d352b6b5e1..adc183d9ace 100644 --- a/lldb/test/class_types/TestClassTypes.py +++ b/lldb/test/class_types/TestClassTypes.py @@ -3,6 +3,7 @@ import os, time import unittest2 import lldb +import lldbutil from lldbtest import * class ClassTypesTestCase(TestBase): @@ -56,6 +57,13 @@ class ClassTypesTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) + # The test suite sometimes shows that the process has exited without stopping. + # + # CC=clang ./dotest.py -v -t class_types + # ... + # Process 76604 exited with status = 0 (0x00000000) + self.runCmd("process status") + # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, substrs = ['state is Stopped', @@ -92,15 +100,43 @@ class ClassTypesTestCase(TestBase): self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) # Verify the breakpoint just created. - self.expect("breakpoint list", BREAKPOINT_CREATED, - substrs = ['main.cpp:93']) + self.expect(repr(breakpoint), BREAKPOINT_CREATED, exe=False, + substrs = ['main.cpp', + '93']) - self.runCmd("run", RUN_SUCCEEDED) + # Now launch the process, and do not stop at entry point. + rc = lldb.SBError() + self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False, rc) + #self.breakAfterLaunch(self.process, "C::C(int, int, int)") - self.runCmd("thread backtrace") + if not rc.Success() or not self.process.IsValid(): + self.fail("SBTarget.LaunchProcess() failed") + + if self.process.GetState() != StateTypeEnum("Stopped"): + self.fail("Process should be in the 'Stopped' state, " + "instead the actual state is: '%s'" % + StateTypeString(self.process.GetState())) + + # The stop reason of the thread should be breakpoint. + thread = self.process.GetThreadAtIndex(0) + + self.expect(StopReasonString(thread.GetStopReason()), + STOPPED_DUE_TO_BREAKPOINT, exe=False, + startstr = "Breakpoint") + + # The filename of frame #0 should be 'main.cpp' and the line number + # should be 93. + self.expect("%s:%d" % (lldbutil.GetFilenames(thread)[0], + lldbutil.GetLineNumbers(thread)[0]), + "Break correctly at main.cpp:93", exe=False, + startstr = "main.cpp:") + ### clang compiled code reported main.cpp:94? + ### startstr = "main.cpp:93") # We should be stopped on the breakpoint with a hit count of 1. - self.assertTrue(breakpoint.GetHitCount() == 1) + self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) + + self.process.Continue() def class_types_expr_parser(self): """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" diff --git a/lldb/test/dotest.py b/lldb/test/dotest.py index 804b6769372..25a7e450b50 100755 --- a/lldb/test/dotest.py +++ b/lldb/test/dotest.py @@ -99,6 +99,7 @@ where options: -p : specify a regexp filename pattern for inclusion in the test suite -t : trace lldb command execution and result -v : do verbose mode of unittest framework +-w : insert some wait time (currently 0.5 sec) between consecutive test cases and: args : specify a list of directory names to search for python Test*.py scripts @@ -191,6 +192,9 @@ def parseOptionsAndInitTestdirs(): elif sys.argv[index].startswith('-v'): verbose = 2 index += 1 + elif sys.argv[index].startswith('-w'): + os.environ["LLDB_WAIT_BETWEEN_TEST_CASES"] = 'YES' + index += 1 else: print "Unknown option: ", sys.argv[index] usage() diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index 2713971cc07..d361f47c78c 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -167,6 +167,64 @@ def CMD_MSG(str, exe): # # Returns the enum from the input string. # +def StateTypeEnum(string): + if string == "Invalid": + return 0 + elif string == "Unloaded": + return 1 + elif string == "Attaching": + return 2 + elif string == "Launching": + return 3 + elif string == "Stopped": + return 4 + elif string == "Running": + return 5 + elif string == "Stepping": + return 6 + elif string == "Crashed": + return 7 + elif string == "Detached": + return 8 + elif string == "Exited": + return 9 + elif string == "Suspended": + return 10 + else: + raise Exception("Unknown stateType string") + +# +# Returns the stateType string given an enum. +# +def StateTypeString(enum): + if enum == 0: + return "Invalid" + elif enum == 1: + return "Unloaded" + elif enum == 2: + return "Attaching" + elif enum == 3: + return "Launching" + elif enum == 4: + return "Stopped" + elif enum == 5: + return "Running" + elif enum == 6: + return "Stepping" + elif enum == 7: + return "Crashed" + elif enum == 8: + return "Detached" + elif enum == 9: + return "Exited" + elif enum == 10: + return "Suspended" + else: + raise Exception("Unknown stopReason enum") + +# +# Returns the enum from the input string. +# def StopReasonEnum(string): if string == "Invalid": return 0 @@ -354,6 +412,10 @@ class TestBase(unittest2.TestCase): #import traceback #traceback.print_stack() + if ("LLDB_WAIT_BETWEEN_TEST_CASES" in os.environ and + os.environ["LLDB_WAIT_BETWEEN_TEST_CASES"] == 'YES'): + time.sleep(0.5) + if "LLDB_MAX_LAUNCH_COUNT" in os.environ: self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"]) @@ -401,8 +463,9 @@ class TestBase(unittest2.TestCase): if self.runStarted: self.runCmd("process kill", PROCESS_KILLED, check=False) elif self.process and self.process.IsValid(): - rc = self.process.Kill() + rc = self.invoke(self.process, "Kill") self.assertTrue(rc.Success(), PROCESS_KILLED) + del self.process del self.dbg |