blob: 0a4282a9284825d430169d434ddac10e0aaabf07 [file] [log] [blame]
Johnny Chena1affab2010-07-03 03:41:59 +00001"""
2LLDB module which provides the abstract base class of lldb test case.
3
4The concrete subclass can override lldbtest.TesBase in order to inherit the
5common behavior for unitest.TestCase.setUp/tearDown implemented in this file.
6
7The subclass should override the attribute mydir in order for the python runtime
8to locate the individual test cases when running as part of a large test suite
9or when running each test case as a separate python invocation.
10
11./dotest.py provides a test driver which sets up the environment to run the
12entire test suite. Users who want to run a test case on its own can specify the
13LLDB_TEST and PYTHONPATH environment variables, for example:
14
15$ export LLDB_TEST=$PWD
Johnny Chen9de4ede2010-08-31 17:42:54 +000016$ export PYTHONPATH=/Volumes/data/lldb/svn/trunk/build/Debug/LLDB.framework/Resources/Python:$LLDB_TEST:$LLDB_TEST/plugins
Johnny Chena1affab2010-07-03 03:41:59 +000017$ echo $LLDB_TEST
18/Volumes/data/lldb/svn/trunk/test
19$ echo $PYTHONPATH
Johnny Chen9de4ede2010-08-31 17:42:54 +000020/Volumes/data/lldb/svn/trunk/build/Debug/LLDB.framework/Resources/Python:/Volumes/data/lldb/svn/trunk/test:/Volumes/data/lldb/svn/trunk/test/plugins
Johnny Chena1affab2010-07-03 03:41:59 +000021$ python function_types/TestFunctionTypes.py
22.
23----------------------------------------------------------------------
24Ran 1 test in 0.363s
25
26OK
Johnny Chend0c24b22010-08-23 17:10:44 +000027$ LLDB_COMMAND_TRACE=YES python array_types/TestArrayTypes.py
Johnny Chen59ea45f2010-09-02 22:25:47 +000028
29...
Johnny Chend0c24b22010-08-23 17:10:44 +000030
31runCmd: breakpoint set -f main.c -l 42
32output: Breakpoint created: 1: file ='main.c', line = 42, locations = 1
33
34runCmd: run
35output: Launching '/Volumes/data/lldb/svn/trunk/test/array_types/a.out' (x86_64)
36
Johnny Chen59ea45f2010-09-02 22:25:47 +000037...
Johnny Chend0c24b22010-08-23 17:10:44 +000038
Johnny Chen59ea45f2010-09-02 22:25:47 +000039runCmd: frame variable strings
Johnny Chend0c24b22010-08-23 17:10:44 +000040output: (char *[4]) strings = {
41 (char *) strings[0] = 0x0000000100000f0c "Hello",
42 (char *) strings[1] = 0x0000000100000f12 "Hola",
43 (char *) strings[2] = 0x0000000100000f17 "Bonjour",
44 (char *) strings[3] = 0x0000000100000f1f "Guten Tag"
45}
46
Johnny Chen59ea45f2010-09-02 22:25:47 +000047runCmd: frame variable char_16
Johnny Chend0c24b22010-08-23 17:10:44 +000048output: (char [16]) char_16 = {
49 (char) char_16[0] = 'H',
50 (char) char_16[1] = 'e',
51 (char) char_16[2] = 'l',
52 (char) char_16[3] = 'l',
53 (char) char_16[4] = 'o',
54 (char) char_16[5] = ' ',
55 (char) char_16[6] = 'W',
56 (char) char_16[7] = 'o',
57 (char) char_16[8] = 'r',
58 (char) char_16[9] = 'l',
59 (char) char_16[10] = 'd',
60 (char) char_16[11] = '\n',
61 (char) char_16[12] = '\0',
62 (char) char_16[13] = '\0',
63 (char) char_16[14] = '\0',
64 (char) char_16[15] = '\0'
65}
66
Johnny Chen59ea45f2010-09-02 22:25:47 +000067runCmd: frame variable ushort_matrix
Johnny Chend0c24b22010-08-23 17:10:44 +000068output: (unsigned short [2][3]) ushort_matrix = {
69 (unsigned short [3]) ushort_matrix[0] = {
70 (unsigned short) ushort_matrix[0][0] = 0x0001,
71 (unsigned short) ushort_matrix[0][1] = 0x0002,
72 (unsigned short) ushort_matrix[0][2] = 0x0003
73 },
74 (unsigned short [3]) ushort_matrix[1] = {
75 (unsigned short) ushort_matrix[1][0] = 0x000b,
76 (unsigned short) ushort_matrix[1][1] = 0x0016,
77 (unsigned short) ushort_matrix[1][2] = 0x0021
78 }
79}
80
Johnny Chen59ea45f2010-09-02 22:25:47 +000081runCmd: frame variable long_6
Johnny Chend0c24b22010-08-23 17:10:44 +000082output: (long [6]) long_6 = {
83 (long) long_6[0] = 1,
84 (long) long_6[1] = 2,
85 (long) long_6[2] = 3,
86 (long) long_6[3] = 4,
87 (long) long_6[4] = 5,
88 (long) long_6[5] = 6
89}
90
91.
92----------------------------------------------------------------------
93Ran 1 test in 0.349s
94
95OK
Johnny Chena1affab2010-07-03 03:41:59 +000096$
97"""
98
Johnny Chena1cc8832010-08-30 21:35:00 +000099import os, sys
100from subprocess import *
Johnny Chen65572482010-08-25 18:49:48 +0000101import time
Johnny Chen1acaf632010-08-30 23:08:52 +0000102import types
Johnny Chen75e28f92010-08-05 23:42:46 +0000103import unittest2
Johnny Chena1affab2010-07-03 03:41:59 +0000104import lldb
105
Johnny Chen9de4ede2010-08-31 17:42:54 +0000106if "LLDB_COMMAND_TRACE" in os.environ and os.environ["LLDB_COMMAND_TRACE"]=="YES":
107 traceAlways = True
108else:
109 traceAlways = False
110
111
Johnny Chen96f08d52010-08-09 22:01:17 +0000112#
113# Some commonly used assert messages.
114#
115
116CURRENT_EXECUTABLE_SET = "Current executable set successfully"
117
Johnny Chen72a14342010-09-02 21:23:12 +0000118PROCESS_IS_VALID = "Process is valid"
119
120PROCESS_KILLED = "Process is killed successfully"
121
Johnny Chen1bb9f9a2010-08-27 23:47:36 +0000122RUN_SUCCEEDED = "Process is launched successfully"
Johnny Chen96f08d52010-08-09 22:01:17 +0000123
Johnny Chend85dae52010-08-09 23:44:24 +0000124RUN_COMPLETED = "Process exited successfully"
Johnny Chen96f08d52010-08-09 22:01:17 +0000125
Johnny Chend85dae52010-08-09 23:44:24 +0000126BREAKPOINT_CREATED = "Breakpoint created successfully"
127
Johnny Chen9b92c6e2010-08-17 21:33:31 +0000128BREAKPOINT_PENDING_CREATED = "Pending breakpoint created successfully"
129
Johnny Chend85dae52010-08-09 23:44:24 +0000130BREAKPOINT_HIT_ONCE = "Breakpoint resolved with hit cout = 1"
Johnny Chen96f08d52010-08-09 22:01:17 +0000131
132STOPPED_DUE_TO_BREAKPOINT = "Process state is stopped due to breakpoint"
133
134STOPPED_DUE_TO_STEP_IN = "Process state is stopped due to step in"
135
Johnny Chen4917e102010-08-24 22:07:56 +0000136DATA_TYPES_DISPLAYED_CORRECTLY = "Data type(s) displayed correctly"
137
Johnny Chenb4d1fff2010-08-26 20:04:17 +0000138VALID_BREAKPOINT = "Got a valid breakpoint"
139
Johnny Chen1bb9f9a2010-08-27 23:47:36 +0000140VALID_FILESPEC = "Got a valid filespec"
141
Johnny Chenb4d1fff2010-08-26 20:04:17 +0000142VALID_PROCESS = "Got a valid process"
143
144VALID_TARGET = "Got a valid target"
145
Johnny Chen22b95b22010-08-25 19:00:04 +0000146VARIABLES_DISPLAYED_CORRECTLY = "Variable(s) displayed correctly"
Johnny Chen96f08d52010-08-09 22:01:17 +0000147
Johnny Chenb4d1fff2010-08-26 20:04:17 +0000148
Johnny Chend85dae52010-08-09 23:44:24 +0000149#
150# And a generic "Command '%s' returns successfully" message generator.
151#
152def CMD_MSG(command):
153 return "Command '%s' returns successfully" % (command)
154
Johnny Chenb4d1fff2010-08-26 20:04:17 +0000155#
Johnny Chen6264bc62010-08-27 18:08:58 +0000156# Returns the enum from the input string.
Johnny Chenb4d1fff2010-08-26 20:04:17 +0000157#
Johnny Chen6264bc62010-08-27 18:08:58 +0000158def StopReasonEnum(string):
159 if string == "Invalid":
Johnny Chenb4d1fff2010-08-26 20:04:17 +0000160 return 0
Johnny Chen6264bc62010-08-27 18:08:58 +0000161 elif string == "None":
Johnny Chenb4d1fff2010-08-26 20:04:17 +0000162 return 1
Johnny Chen6264bc62010-08-27 18:08:58 +0000163 elif string == "Trace":
Johnny Chenb4d1fff2010-08-26 20:04:17 +0000164 return 2
Johnny Chen6264bc62010-08-27 18:08:58 +0000165 elif string == "Breakpoint":
Johnny Chenb4d1fff2010-08-26 20:04:17 +0000166 return 3
Johnny Chen6264bc62010-08-27 18:08:58 +0000167 elif string == "Watchpoint":
Johnny Chenb4d1fff2010-08-26 20:04:17 +0000168 return 4
Johnny Chen6264bc62010-08-27 18:08:58 +0000169 elif string == "Signal":
Johnny Chenb4d1fff2010-08-26 20:04:17 +0000170 return 5
Johnny Chen6264bc62010-08-27 18:08:58 +0000171 elif string == "Exception":
Johnny Chenb4d1fff2010-08-26 20:04:17 +0000172 return 6
Johnny Chen6264bc62010-08-27 18:08:58 +0000173 elif string == "PlanComplete":
Johnny Chenb4d1fff2010-08-26 20:04:17 +0000174 return 7
175 else:
176 raise Exception("Unknown stopReason string")
Johnny Chend85dae52010-08-09 23:44:24 +0000177
Johnny Chenf4ce2882010-08-26 21:49:29 +0000178#
Johnny Chen6264bc62010-08-27 18:08:58 +0000179# Returns the stopReason string given an enum.
180#
181def StopReasonString(enum):
182 if enum == 0:
183 return "Invalid"
184 elif enum == 1:
185 return "None"
186 elif enum == 2:
187 return "Trace"
188 elif enum == 3:
189 return "Breakpoint"
190 elif enum == 4:
191 return "Watchpoint"
192 elif enum == 5:
193 return "Signal"
194 elif enum == 6:
195 return "Exception"
196 elif enum == 7:
197 return "PlanComplete"
198 else:
199 raise Exception("Unknown stopReason enum")
200
201#
Johnny Chenf4ce2882010-08-26 21:49:29 +0000202# Returns an env variable array from the os.environ map object.
203#
204def EnvArray():
205 return map(lambda k,v: k+"="+v, os.environ.keys(), os.environ.values())
206
Johnny Chen9de4ede2010-08-31 17:42:54 +0000207# From 2.7's subprocess.check_output() convenience function.
208def system(*popenargs, **kwargs):
209 r"""Run command with arguments and return its output as a byte string.
210
211 If the exit code was non-zero it raises a CalledProcessError. The
212 CalledProcessError object will have the return code in the returncode
213 attribute and output in the output attribute.
214
215 The arguments are the same as for the Popen constructor. Example:
216
217 >>> check_output(["ls", "-l", "/dev/null"])
218 'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
219
220 The stdout argument is not allowed as it is used internally.
221 To capture standard error in the result, use stderr=STDOUT.
222
223 >>> check_output(["/bin/sh", "-c",
224 ... "ls -l non_existent_file ; exit 0"],
225 ... stderr=STDOUT)
226 'ls: non_existent_file: No such file or directory\n'
227 """
228 if 'stdout' in kwargs:
229 raise ValueError('stdout argument not allowed, it will be overridden.')
230 process = Popen(stdout=PIPE, *popenargs, **kwargs)
231 output, unused_err = process.communicate()
232 retcode = process.poll()
233
234 if traceAlways:
235 if isinstance(popenargs, types.StringTypes):
236 args = [popenargs]
237 else:
238 args = list(popenargs)
239 print >> sys.stderr
240 print >> sys.stderr, "os command:", args
241 print >> sys.stderr, "output:", output
242 print >> sys.stderr, "error:", unused_err
243 print >> sys.stderr, "retcode:", retcode
244
245 if retcode:
246 cmd = kwargs.get("args")
247 if cmd is None:
248 cmd = popenargs[0]
249 raise CalledProcessError(retcode, cmd, output=output)
250 return output
251
Johnny Chen9c10c182010-08-27 00:15:48 +0000252
Johnny Chen75e28f92010-08-05 23:42:46 +0000253class TestBase(unittest2.TestCase):
Johnny Chena1affab2010-07-03 03:41:59 +0000254 """This LLDB abstract base class is meant to be subclassed."""
255
256 # The concrete subclass should override this attribute.
Johnny Chenf8c723b2010-07-03 20:41:42 +0000257 mydir = None
Johnny Chena1affab2010-07-03 03:41:59 +0000258
Johnny Chenffde4fc2010-08-16 21:28:10 +0000259 # State pertaining to the inferior process, if any.
Johnny Chen59ea45f2010-09-02 22:25:47 +0000260 # This reflects inferior process started through the command interface with
261 # either the lldb "run" or "process launch" command.
262 # See also self.runCmd().
Johnny Chenffde4fc2010-08-16 21:28:10 +0000263 runStarted = False
264
Johnny Chen65572482010-08-25 18:49:48 +0000265 # Maximum allowed attempts when launching the inferior process.
266 # Can be overridden by the LLDB_MAX_LAUNCH_COUNT environment variable.
267 maxLaunchCount = 3;
268
269 # Time to wait before the next launching attempt in second(s).
270 # Can be overridden by the LLDB_TIME_WAIT environment variable.
271 timeWait = 1.0;
272
Johnny Chena1affab2010-07-03 03:41:59 +0000273 def setUp(self):
Johnny Chen6ead27f2010-08-07 01:13:18 +0000274 #import traceback
Johnny Chen88f83042010-08-05 21:23:45 +0000275 #traceback.print_stack()
276
Johnny Chenf8c723b2010-07-03 20:41:42 +0000277 # Fail fast if 'mydir' attribute is not overridden.
278 if not self.mydir or len(self.mydir) == 0:
279 raise Exception("Subclasses must override the 'mydir' attribute.")
Johnny Chena1affab2010-07-03 03:41:59 +0000280 # Save old working directory.
281 self.oldcwd = os.getcwd()
282
283 # Change current working directory if ${LLDB_TEST} is defined.
284 # See also dotest.py which sets up ${LLDB_TEST}.
285 if ("LLDB_TEST" in os.environ):
286 os.chdir(os.path.join(os.environ["LLDB_TEST"], self.mydir));
287
Johnny Chen65572482010-08-25 18:49:48 +0000288 if "LLDB_MAX_LAUNCH_COUNT" in os.environ:
289 self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"])
290
291 if "LLDB_TIME_WAIT" in os.environ:
292 self.timeWait = float(os.environ["LLDB_TIME_WAIT"])
293
Johnny Chena1affab2010-07-03 03:41:59 +0000294 # Create the debugger instance if necessary.
295 try:
296 self.dbg = lldb.DBG
Johnny Chena1affab2010-07-03 03:41:59 +0000297 except AttributeError:
298 self.dbg = lldb.SBDebugger.Create()
Johnny Chenf8c723b2010-07-03 20:41:42 +0000299
Johnny Chena1affab2010-07-03 03:41:59 +0000300 if not self.dbg.IsValid():
301 raise Exception('Invalid debugger instance')
302
303 # We want our debugger to be synchronous.
304 self.dbg.SetAsync(False)
305
Johnny Chen72a14342010-09-02 21:23:12 +0000306 # There is no process associated with the debugger as yet.
Johnny Chen59ea45f2010-09-02 22:25:47 +0000307 # See also self.tearDown() where it checks whether self.process has a
308 # valid reference and calls self.process.Kill() to kill the process.
Johnny Chen72a14342010-09-02 21:23:12 +0000309 self.process = None
310
Johnny Chena1affab2010-07-03 03:41:59 +0000311 # Retrieve the associated command interpreter instance.
312 self.ci = self.dbg.GetCommandInterpreter()
313 if not self.ci:
314 raise Exception('Could not get the command interpreter')
315
316 # And the result object.
317 self.res = lldb.SBCommandReturnObject()
318
Johnny Chena1affab2010-07-03 03:41:59 +0000319 def tearDown(self):
Johnny Chen72a14342010-09-02 21:23:12 +0000320 #import traceback
321 #traceback.print_stack()
322
323 # Terminate the current process being debugged, if any.
Johnny Chenffde4fc2010-08-16 21:28:10 +0000324 if self.runStarted:
Johnny Chen72a14342010-09-02 21:23:12 +0000325 self.runCmd("process kill", PROCESS_KILLED, check=False)
326 elif self.process and self.process.IsValid():
327 rc = self.process.Kill()
328 self.assertTrue(rc.Success(), PROCESS_KILLED)
Johnny Chenffde4fc2010-08-16 21:28:10 +0000329
Johnny Chena1affab2010-07-03 03:41:59 +0000330 del self.dbg
331
332 # Restore old working directory.
333 os.chdir(self.oldcwd)
Johnny Chen8df95eb2010-08-19 23:26:59 +0000334
Johnny Chen21f33412010-09-01 00:15:19 +0000335 def runCmd(self, cmd, msg=None, check=True, trace=False, setCookie=True):
Johnny Chen8df95eb2010-08-19 23:26:59 +0000336 """
337 Ask the command interpreter to handle the command and then check its
338 return status.
339 """
340 # Fail fast if 'cmd' is not meaningful.
341 if not cmd or len(cmd) == 0:
342 raise Exception("Bad 'cmd' parameter encountered")
Johnny Chen4f995f02010-08-20 17:57:32 +0000343
Johnny Chen9de4ede2010-08-31 17:42:54 +0000344 trace = (True if traceAlways else trace)
Johnny Chend0c24b22010-08-23 17:10:44 +0000345
Johnny Chen21f33412010-09-01 00:15:19 +0000346 running = (cmd.startswith("run") or cmd.startswith("process launch"))
Johnny Chen4f995f02010-08-20 17:57:32 +0000347
Johnny Chen21f33412010-09-01 00:15:19 +0000348 for i in range(self.maxLaunchCount if running else 1):
Johnny Chen65572482010-08-25 18:49:48 +0000349 self.ci.HandleCommand(cmd, self.res)
Johnny Chen4f995f02010-08-20 17:57:32 +0000350
Johnny Chen65572482010-08-25 18:49:48 +0000351 if trace:
352 print >> sys.stderr, "runCmd:", cmd
353 if self.res.Succeeded():
354 print >> sys.stderr, "output:", self.res.GetOutput()
355 else:
356 print >> sys.stderr, self.res.GetError()
Johnny Chen4f995f02010-08-20 17:57:32 +0000357
Johnny Chen029acae2010-08-20 21:03:09 +0000358 if self.res.Succeeded():
Johnny Chen65572482010-08-25 18:49:48 +0000359 break
Johnny Chen029acae2010-08-20 21:03:09 +0000360 else:
Johnny Chen21f33412010-09-01 00:15:19 +0000361 if running:
Johnny Chen65572482010-08-25 18:49:48 +0000362 # Process launch failed, wait some time before the next try.
363 time.sleep(self.timeWait)
Johnny Chen4f995f02010-08-20 17:57:32 +0000364
Johnny Chen72a14342010-09-02 21:23:12 +0000365 # Modify runStarted only if "run" or "process launch" was encountered.
366 if running:
367 self.runStarted = running and setCookie
Johnny Chen21f33412010-09-01 00:15:19 +0000368
Johnny Chen8df95eb2010-08-19 23:26:59 +0000369 if check:
370 self.assertTrue(self.res.Succeeded(),
371 msg if msg else CMD_MSG(cmd))
372
Johnny Chend0c24b22010-08-23 17:10:44 +0000373 def expect(self, cmd, msg=None, startstr=None, substrs=None, trace=False):
Johnny Chen8df95eb2010-08-19 23:26:59 +0000374 """
375 Similar to runCmd; with additional expect style output matching ability.
376
377 Ask the command interpreter to handle the command and then check its
378 return status. The 'msg' parameter specifies an informational assert
379 message. We expect the output from running the command to start with
380 'startstr' and matches the substrings contained in 'substrs'.
381 """
Johnny Chen9de4ede2010-08-31 17:42:54 +0000382 trace = (True if traceAlways else trace)
Johnny Chend0c24b22010-08-23 17:10:44 +0000383
Johnny Chene8b02f32010-08-20 19:17:39 +0000384 # First run the command.
Johnny Chend0c24b22010-08-23 17:10:44 +0000385 self.runCmd(cmd, trace = (True if trace else False))
Johnny Chen8df95eb2010-08-19 23:26:59 +0000386
Johnny Chene8b02f32010-08-20 19:17:39 +0000387 # Then compare the output against expected strings.
Johnny Chen8df95eb2010-08-19 23:26:59 +0000388 output = self.res.GetOutput()
389 matched = output.startswith(startstr) if startstr else True
Johnny Chenead35c82010-08-20 18:25:15 +0000390
Johnny Chen3f3fb132010-08-24 23:48:10 +0000391 if startstr and trace:
392 print >> sys.stderr, "Expecting start string:", startstr
393 print >> sys.stderr, "Matched" if matched else "Not matched"
394 print >> sys.stderr
Johnny Chenead35c82010-08-20 18:25:15 +0000395
Johnny Chen22b95b22010-08-25 19:00:04 +0000396 if substrs and matched:
Johnny Chen8df95eb2010-08-19 23:26:59 +0000397 for str in substrs:
398 matched = output.find(str) > 0
Johnny Chen3f3fb132010-08-24 23:48:10 +0000399 if trace:
400 print >> sys.stderr, "Expecting sub string:", str
401 print >> sys.stderr, "Matched" if matched else "Not matched"
Johnny Chen8df95eb2010-08-19 23:26:59 +0000402 if not matched:
403 break
Johnny Chen3f3fb132010-08-24 23:48:10 +0000404 if trace:
405 print >> sys.stderr
Johnny Chen8df95eb2010-08-19 23:26:59 +0000406
Johnny Chene8b02f32010-08-20 19:17:39 +0000407 self.assertTrue(matched, msg if msg else CMD_MSG(cmd))
Johnny Chen8df95eb2010-08-19 23:26:59 +0000408
Johnny Chena8b3cdd2010-08-25 22:52:45 +0000409 def invoke(self, obj, name, trace=False):
Johnny Chend8473bc2010-08-25 22:56:10 +0000410 """Use reflection to call a method dynamically with no argument."""
Johnny Chen9de4ede2010-08-31 17:42:54 +0000411 trace = (True if traceAlways else trace)
Johnny Chena8b3cdd2010-08-25 22:52:45 +0000412
413 method = getattr(obj, name)
414 import inspect
415 self.assertTrue(inspect.ismethod(method),
416 name + "is a method name of object: " + str(obj))
417 result = method()
Johnny Chen9de4ede2010-08-31 17:42:54 +0000418 if trace:
Johnny Chena8b3cdd2010-08-25 22:52:45 +0000419 print str(method) + ":", result
420 return result
Johnny Chen9c10c182010-08-27 00:15:48 +0000421
Johnny Chenc202b492010-09-01 22:08:51 +0000422 def breakAfterLaunch(self, process, func, trace=False):
423 """
424 Perform some dancees after LaunchProcess() to break at func name.
425
426 Return True if we can successfully break at the func name in due time.
427 """
428 trace = (True if traceAlways else trace)
429
430 count = 0
431 while True:
432 # The stop reason of the thread should be breakpoint.
433 thread = process.GetThreadAtIndex(0)
434 SR = thread.GetStopReason()
435 if trace:
436 print >> sys.stderr, "StopReason =", StopReasonString(SR)
437
438 if SR == StopReasonEnum("Breakpoint"):
439 frame = thread.GetFrameAtIndex(0)
440 name = frame.GetFunction().GetName()
441 if (name == func):
442 # We got what we want; now break out of the loop.
443 return True
444
445 # The inferior is in a transient state; continue the process.
446 time.sleep(1.0)
447 if trace:
448 print >> sys.stderr, "Continuing the process:", process
449 process.Continue()
450
451 count = count + 1
452 if count == 10:
453 if trace:
454 print >> sys.stderr, "Reached 10 iterations, giving up..."
455 # Enough iterations already, break out of the loop.
456 return False
457
458 # End of while loop.
459
460
Johnny Cheneef7a862010-08-30 22:26:48 +0000461 def buildDsym(self):
462 """Platform specific way to build binaries with dsym info."""
Johnny Chen9de4ede2010-08-31 17:42:54 +0000463 module = __import__(sys.platform)
464 if not module.buildDsym():
Johnny Cheneef7a862010-08-30 22:26:48 +0000465 raise Exception("Don't know how to build binary with dsym")
466
467 def buildDwarf(self):
468 """Platform specific way to build binaries with dwarf maps."""
Johnny Chen9de4ede2010-08-31 17:42:54 +0000469 module = __import__(sys.platform)
470 if not module.buildDwarf():
Johnny Cheneef7a862010-08-30 22:26:48 +0000471 raise Exception("Don't know how to build binary with dwarf")
472
Johnny Chen9c10c182010-08-27 00:15:48 +0000473 def DebugSBValue(self, frame, val):
Johnny Chen9de4ede2010-08-31 17:42:54 +0000474 """Debug print a SBValue object, if traceAlways is True."""
475 if not traceAlways:
Johnny Chen9c10c182010-08-27 00:15:48 +0000476 return
477
478 err = sys.stderr
479 err.write(val.GetName() + ":\n")
480 err.write('\t' + "TypeName -> " + val.GetTypeName() + '\n')
481 err.write('\t' + "ByteSize -> " + str(val.GetByteSize()) + '\n')
482 err.write('\t' + "NumChildren -> " + str(val.GetNumChildren()) + '\n')
483 err.write('\t' + "Value -> " + str(val.GetValue(frame)) + '\n')
484 err.write('\t' + "Summary -> " + str(val.GetSummary(frame)) + '\n')
485 err.write('\t' + "IsPtrType -> " + str(val.TypeIsPtrType()) + '\n')
486 err.write('\t' + "Location -> " + val.GetLocation(frame) + '\n')
487