forked from OSchip/llvm-project
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. llvm-svn: 115899
This commit is contained in:
parent
1958cefd69
commit
0ed37c9615
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -164,6 +164,64 @@ def CMD_MSG(str, exe):
|
|||
else:
|
||||
return "'%s' compares successfully" % str
|
||||
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue