[Lldb-commits] [lldb] r115899 - in /lldb/trunk: include/lldb/API/SBTarget.h scripts/lldb.swig source/API/SBTarget.cpp test/class_types/TestClassTypes.py test/dotest.py test/lldbtest.py
Johnny Chen
johnny.chen at apple.com
Wed Oct 6 19:04:14 PDT 2010
Author: johnny
Date: Wed Oct 6 21:04:14 2010
New Revision: 115899
URL: http://llvm.org/viewvc/llvm-project?rev=115899&view=rev
Log:
o SBtarget.cpp/.h:
Temporarily commenting out the deprecated LaunchProcess() method.
SWIG is not able to handle the overloaded functions.
o dotest.py/lldbtest.py:
Add an '-w' option to insert some wait time between consecutive test cases.
o TestClassTypes.py:
Make the breakpoint_creation_by_filespec_python() test method more robust and
more descriptive by printing out a more insightful assert message.
o lldb.swig: Coaches swig to treat StateType as an int type, instead of a C++ class.
Modified:
lldb/trunk/include/lldb/API/SBTarget.h
lldb/trunk/scripts/lldb.swig
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/test/class_types/TestClassTypes.py
lldb/trunk/test/dotest.py
lldb/trunk/test/lldbtest.py
Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=115899&r1=115898&r2=115899&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Wed Oct 6 21:04:14 2010
@@ -57,12 +57,12 @@
// 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,
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=115899&r1=115898&r2=115899&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Wed Oct 6 21:04:14 2010
@@ -134,6 +134,7 @@
typedef lldb::SBStringList SBStringList;
typedef lldb::RegisterKind RegisterKind;
const RegisterKind kNumRegisterKinds = lldb::kNumRegisterKinds ;
+typedef int StateType;
typedef int StopReason;
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=115899&r1=115898&r2=115899&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Wed Oct 6 21:04:14 2010
@@ -119,19 +119,19 @@
}
-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
Modified: lldb/trunk/test/class_types/TestClassTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=115899&r1=115898&r2=115899&view=diff
==============================================================================
--- lldb/trunk/test/class_types/TestClassTypes.py (original)
+++ lldb/trunk/test/class_types/TestClassTypes.py Wed Oct 6 21:04:14 2010
@@ -3,6 +3,7 @@
import os, time
import unittest2
import lldb
+import lldbutil
from lldbtest import *
class ClassTypesTestCase(TestBase):
@@ -56,6 +57,13 @@
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 @@
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'])
+
+ # 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)")
+
+ 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()))
- self.runCmd("run", RUN_SUCCEEDED)
+ # The stop reason of the thread should be breakpoint.
+ thread = self.process.GetThreadAtIndex(0)
- self.runCmd("thread backtrace")
+ 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."""
Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=115899&r1=115898&r2=115899&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Wed Oct 6 21:04:14 2010
@@ -99,6 +99,7 @@
-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 @@
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()
Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=115899&r1=115898&r2=115899&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Wed Oct 6 21:04:14 2010
@@ -167,6 +167,64 @@
#
# 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 @@
#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 @@
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
More information about the lldb-commits
mailing list