blob: 616b33eabf1d1ffc51689d0974b32eb30d93cdfe [file] [log] [blame]
Johnny Chenbf6ffa32010-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 Chen8d55a342010-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 Chenbf6ffa32010-07-03 03:41:59 +000017$ echo $LLDB_TEST
18/Volumes/data/lldb/svn/trunk/test
19$ echo $PYTHONPATH
Johnny Chen8d55a342010-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 Chenbf6ffa32010-07-03 03:41:59 +000021$ python function_types/TestFunctionTypes.py
22.
23----------------------------------------------------------------------
24Ran 1 test in 0.363s
25
26OK
Johnny Chend0190a62010-08-23 17:10:44 +000027$ LLDB_COMMAND_TRACE=YES python array_types/TestArrayTypes.py
28LLDB_COMMAND_TRACE=YES python array_types/TestArrayTypes.py
29runCmd: file /Volumes/data/lldb/svn/trunk/test/array_types/a.out
30output: Current executable set to '/Volumes/data/lldb/svn/trunk/test/array_types/a.out' (x86_64).
31
32runCmd: breakpoint set -f main.c -l 42
33output: Breakpoint created: 1: file ='main.c', line = 42, locations = 1
34
35runCmd: run
36output: Launching '/Volumes/data/lldb/svn/trunk/test/array_types/a.out' (x86_64)
37
38runCmd: thread list
39output: Process 24987 state is Stopped
40 thread #1: tid = 0x2e03, pc = 0x0000000100000df4, where = a.out`main + 612 at /Volumes/data/lldb/svn/trunk/test/array_types/main.c:45, stop reason = breakpoint 1.1, queue = com.apple.main-thread
41
42runCmd: breakpoint list
43output: Current breakpoints:
441: file ='main.c', line = 42, locations = 1, resolved = 1
45 1.1: where = a.out`main + 612 at /Volumes/data/lldb/svn/trunk/test/array_types/main.c:45, address = 0x0000000100000df4, resolved, hit count = 1
46
47
48runCmd: variable list strings
49output: (char *[4]) strings = {
50 (char *) strings[0] = 0x0000000100000f0c "Hello",
51 (char *) strings[1] = 0x0000000100000f12 "Hola",
52 (char *) strings[2] = 0x0000000100000f17 "Bonjour",
53 (char *) strings[3] = 0x0000000100000f1f "Guten Tag"
54}
55
56runCmd: variable list char_16
57output: (char [16]) char_16 = {
58 (char) char_16[0] = 'H',
59 (char) char_16[1] = 'e',
60 (char) char_16[2] = 'l',
61 (char) char_16[3] = 'l',
62 (char) char_16[4] = 'o',
63 (char) char_16[5] = ' ',
64 (char) char_16[6] = 'W',
65 (char) char_16[7] = 'o',
66 (char) char_16[8] = 'r',
67 (char) char_16[9] = 'l',
68 (char) char_16[10] = 'd',
69 (char) char_16[11] = '\n',
70 (char) char_16[12] = '\0',
71 (char) char_16[13] = '\0',
72 (char) char_16[14] = '\0',
73 (char) char_16[15] = '\0'
74}
75
76runCmd: variable list ushort_matrix
77output: (unsigned short [2][3]) ushort_matrix = {
78 (unsigned short [3]) ushort_matrix[0] = {
79 (unsigned short) ushort_matrix[0][0] = 0x0001,
80 (unsigned short) ushort_matrix[0][1] = 0x0002,
81 (unsigned short) ushort_matrix[0][2] = 0x0003
82 },
83 (unsigned short [3]) ushort_matrix[1] = {
84 (unsigned short) ushort_matrix[1][0] = 0x000b,
85 (unsigned short) ushort_matrix[1][1] = 0x0016,
86 (unsigned short) ushort_matrix[1][2] = 0x0021
87 }
88}
89
90runCmd: variable list long_6
91output: (long [6]) long_6 = {
92 (long) long_6[0] = 1,
93 (long) long_6[1] = 2,
94 (long) long_6[2] = 3,
95 (long) long_6[3] = 4,
96 (long) long_6[4] = 5,
97 (long) long_6[5] = 6
98}
99
100.
101----------------------------------------------------------------------
102Ran 1 test in 0.349s
103
104OK
Johnny Chenbf6ffa32010-07-03 03:41:59 +0000105$
106"""
107
Johnny Chen8952a2d2010-08-30 21:35:00 +0000108import os, sys
109from subprocess import *
Johnny Chenf2b70232010-08-25 18:49:48 +0000110import time
Johnny Chena33a93c2010-08-30 23:08:52 +0000111import types
Johnny Chen73258832010-08-05 23:42:46 +0000112import unittest2
Johnny Chenbf6ffa32010-07-03 03:41:59 +0000113import lldb
114
Johnny Chen8d55a342010-08-31 17:42:54 +0000115if "LLDB_COMMAND_TRACE" in os.environ and os.environ["LLDB_COMMAND_TRACE"]=="YES":
116 traceAlways = True
117else:
118 traceAlways = False
119
120
Johnny Chen00778092010-08-09 22:01:17 +0000121#
122# Some commonly used assert messages.
123#
124
125CURRENT_EXECUTABLE_SET = "Current executable set successfully"
126
Johnny Chen7d1d7532010-09-02 21:23:12 +0000127PROCESS_IS_VALID = "Process is valid"
128
129PROCESS_KILLED = "Process is killed successfully"
130
Johnny Chen5ee88192010-08-27 23:47:36 +0000131RUN_SUCCEEDED = "Process is launched successfully"
Johnny Chen00778092010-08-09 22:01:17 +0000132
Johnny Chen17941842010-08-09 23:44:24 +0000133RUN_COMPLETED = "Process exited successfully"
Johnny Chen00778092010-08-09 22:01:17 +0000134
Johnny Chen17941842010-08-09 23:44:24 +0000135BREAKPOINT_CREATED = "Breakpoint created successfully"
136
Johnny Chene76896c2010-08-17 21:33:31 +0000137BREAKPOINT_PENDING_CREATED = "Pending breakpoint created successfully"
138
Johnny Chen17941842010-08-09 23:44:24 +0000139BREAKPOINT_HIT_ONCE = "Breakpoint resolved with hit cout = 1"
Johnny Chen00778092010-08-09 22:01:17 +0000140
141STOPPED_DUE_TO_BREAKPOINT = "Process state is stopped due to breakpoint"
142
143STOPPED_DUE_TO_STEP_IN = "Process state is stopped due to step in"
144
Johnny Chen3c884a02010-08-24 22:07:56 +0000145DATA_TYPES_DISPLAYED_CORRECTLY = "Data type(s) displayed correctly"
146
Johnny Chen5fca8ca2010-08-26 20:04:17 +0000147VALID_BREAKPOINT = "Got a valid breakpoint"
148
Johnny Chen5ee88192010-08-27 23:47:36 +0000149VALID_FILESPEC = "Got a valid filespec"
150
Johnny Chen5fca8ca2010-08-26 20:04:17 +0000151VALID_PROCESS = "Got a valid process"
152
153VALID_TARGET = "Got a valid target"
154
Johnny Chen981463d2010-08-25 19:00:04 +0000155VARIABLES_DISPLAYED_CORRECTLY = "Variable(s) displayed correctly"
Johnny Chen00778092010-08-09 22:01:17 +0000156
Johnny Chen5fca8ca2010-08-26 20:04:17 +0000157
Johnny Chen17941842010-08-09 23:44:24 +0000158#
159# And a generic "Command '%s' returns successfully" message generator.
160#
161def CMD_MSG(command):
162 return "Command '%s' returns successfully" % (command)
163
Johnny Chen5fca8ca2010-08-26 20:04:17 +0000164#
Johnny Chen82d404c82010-08-27 18:08:58 +0000165# Returns the enum from the input string.
Johnny Chen5fca8ca2010-08-26 20:04:17 +0000166#
Johnny Chen82d404c82010-08-27 18:08:58 +0000167def StopReasonEnum(string):
168 if string == "Invalid":
Johnny Chen5fca8ca2010-08-26 20:04:17 +0000169 return 0
Johnny Chen82d404c82010-08-27 18:08:58 +0000170 elif string == "None":
Johnny Chen5fca8ca2010-08-26 20:04:17 +0000171 return 1
Johnny Chen82d404c82010-08-27 18:08:58 +0000172 elif string == "Trace":
Johnny Chen5fca8ca2010-08-26 20:04:17 +0000173 return 2
Johnny Chen82d404c82010-08-27 18:08:58 +0000174 elif string == "Breakpoint":
Johnny Chen5fca8ca2010-08-26 20:04:17 +0000175 return 3
Johnny Chen82d404c82010-08-27 18:08:58 +0000176 elif string == "Watchpoint":
Johnny Chen5fca8ca2010-08-26 20:04:17 +0000177 return 4
Johnny Chen82d404c82010-08-27 18:08:58 +0000178 elif string == "Signal":
Johnny Chen5fca8ca2010-08-26 20:04:17 +0000179 return 5
Johnny Chen82d404c82010-08-27 18:08:58 +0000180 elif string == "Exception":
Johnny Chen5fca8ca2010-08-26 20:04:17 +0000181 return 6
Johnny Chen82d404c82010-08-27 18:08:58 +0000182 elif string == "PlanComplete":
Johnny Chen5fca8ca2010-08-26 20:04:17 +0000183 return 7
184 else:
185 raise Exception("Unknown stopReason string")
Johnny Chen17941842010-08-09 23:44:24 +0000186
Johnny Chen27c41232010-08-26 21:49:29 +0000187#
Johnny Chen82d404c82010-08-27 18:08:58 +0000188# Returns the stopReason string given an enum.
189#
190def StopReasonString(enum):
191 if enum == 0:
192 return "Invalid"
193 elif enum == 1:
194 return "None"
195 elif enum == 2:
196 return "Trace"
197 elif enum == 3:
198 return "Breakpoint"
199 elif enum == 4:
200 return "Watchpoint"
201 elif enum == 5:
202 return "Signal"
203 elif enum == 6:
204 return "Exception"
205 elif enum == 7:
206 return "PlanComplete"
207 else:
208 raise Exception("Unknown stopReason enum")
209
210#
Johnny Chen27c41232010-08-26 21:49:29 +0000211# Returns an env variable array from the os.environ map object.
212#
213def EnvArray():
214 return map(lambda k,v: k+"="+v, os.environ.keys(), os.environ.values())
215
Johnny Chen8d55a342010-08-31 17:42:54 +0000216# From 2.7's subprocess.check_output() convenience function.
217def system(*popenargs, **kwargs):
218 r"""Run command with arguments and return its output as a byte string.
219
220 If the exit code was non-zero it raises a CalledProcessError. The
221 CalledProcessError object will have the return code in the returncode
222 attribute and output in the output attribute.
223
224 The arguments are the same as for the Popen constructor. Example:
225
226 >>> check_output(["ls", "-l", "/dev/null"])
227 'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
228
229 The stdout argument is not allowed as it is used internally.
230 To capture standard error in the result, use stderr=STDOUT.
231
232 >>> check_output(["/bin/sh", "-c",
233 ... "ls -l non_existent_file ; exit 0"],
234 ... stderr=STDOUT)
235 'ls: non_existent_file: No such file or directory\n'
236 """
237 if 'stdout' in kwargs:
238 raise ValueError('stdout argument not allowed, it will be overridden.')
239 process = Popen(stdout=PIPE, *popenargs, **kwargs)
240 output, unused_err = process.communicate()
241 retcode = process.poll()
242
243 if traceAlways:
244 if isinstance(popenargs, types.StringTypes):
245 args = [popenargs]
246 else:
247 args = list(popenargs)
248 print >> sys.stderr
249 print >> sys.stderr, "os command:", args
250 print >> sys.stderr, "output:", output
251 print >> sys.stderr, "error:", unused_err
252 print >> sys.stderr, "retcode:", retcode
253
254 if retcode:
255 cmd = kwargs.get("args")
256 if cmd is None:
257 cmd = popenargs[0]
258 raise CalledProcessError(retcode, cmd, output=output)
259 return output
260
Johnny Chen827edff2010-08-27 00:15:48 +0000261
Johnny Chen73258832010-08-05 23:42:46 +0000262class TestBase(unittest2.TestCase):
Johnny Chenbf6ffa32010-07-03 03:41:59 +0000263 """This LLDB abstract base class is meant to be subclassed."""
264
265 # The concrete subclass should override this attribute.
Johnny Chenf02ec122010-07-03 20:41:42 +0000266 mydir = None
Johnny Chenbf6ffa32010-07-03 03:41:59 +0000267
Johnny Chen6ca006c2010-08-16 21:28:10 +0000268 # State pertaining to the inferior process, if any.
269 runStarted = False
270
Johnny Chenf2b70232010-08-25 18:49:48 +0000271 # Maximum allowed attempts when launching the inferior process.
272 # Can be overridden by the LLDB_MAX_LAUNCH_COUNT environment variable.
273 maxLaunchCount = 3;
274
275 # Time to wait before the next launching attempt in second(s).
276 # Can be overridden by the LLDB_TIME_WAIT environment variable.
277 timeWait = 1.0;
278
Johnny Chenbf6ffa32010-07-03 03:41:59 +0000279 def setUp(self):
Johnny Chen9289a652010-08-07 01:13:18 +0000280 #import traceback
Johnny Chena2124952010-08-05 21:23:45 +0000281 #traceback.print_stack()
282
Johnny Chenf02ec122010-07-03 20:41:42 +0000283 # Fail fast if 'mydir' attribute is not overridden.
284 if not self.mydir or len(self.mydir) == 0:
285 raise Exception("Subclasses must override the 'mydir' attribute.")
Johnny Chenbf6ffa32010-07-03 03:41:59 +0000286 # Save old working directory.
287 self.oldcwd = os.getcwd()
288
289 # Change current working directory if ${LLDB_TEST} is defined.
290 # See also dotest.py which sets up ${LLDB_TEST}.
291 if ("LLDB_TEST" in os.environ):
292 os.chdir(os.path.join(os.environ["LLDB_TEST"], self.mydir));
293
Johnny Chenf2b70232010-08-25 18:49:48 +0000294 if "LLDB_MAX_LAUNCH_COUNT" in os.environ:
295 self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"])
296
297 if "LLDB_TIME_WAIT" in os.environ:
298 self.timeWait = float(os.environ["LLDB_TIME_WAIT"])
299
Johnny Chenbf6ffa32010-07-03 03:41:59 +0000300 # Create the debugger instance if necessary.
301 try:
302 self.dbg = lldb.DBG
Johnny Chenbf6ffa32010-07-03 03:41:59 +0000303 except AttributeError:
304 self.dbg = lldb.SBDebugger.Create()
Johnny Chenf02ec122010-07-03 20:41:42 +0000305
Johnny Chenbf6ffa32010-07-03 03:41:59 +0000306 if not self.dbg.IsValid():
307 raise Exception('Invalid debugger instance')
308
309 # We want our debugger to be synchronous.
310 self.dbg.SetAsync(False)
311
Johnny Chen7d1d7532010-09-02 21:23:12 +0000312 # There is no process associated with the debugger as yet.
313 self.process = None
314
Johnny Chenbf6ffa32010-07-03 03:41:59 +0000315 # Retrieve the associated command interpreter instance.
316 self.ci = self.dbg.GetCommandInterpreter()
317 if not self.ci:
318 raise Exception('Could not get the command interpreter')
319
320 # And the result object.
321 self.res = lldb.SBCommandReturnObject()
322
Johnny Chenbf6ffa32010-07-03 03:41:59 +0000323 def tearDown(self):
Johnny Chen7d1d7532010-09-02 21:23:12 +0000324 #import traceback
325 #traceback.print_stack()
326
327 # Terminate the current process being debugged, if any.
Johnny Chen6ca006c2010-08-16 21:28:10 +0000328 if self.runStarted:
Johnny Chen7d1d7532010-09-02 21:23:12 +0000329 self.runCmd("process kill", PROCESS_KILLED, check=False)
330 elif self.process and self.process.IsValid():
331 rc = self.process.Kill()
332 self.assertTrue(rc.Success(), PROCESS_KILLED)
Johnny Chen6ca006c2010-08-16 21:28:10 +0000333
Johnny Chenbf6ffa32010-07-03 03:41:59 +0000334 del self.dbg
335
336 # Restore old working directory.
337 os.chdir(self.oldcwd)
Johnny Chen27f212d2010-08-19 23:26:59 +0000338
Johnny Chen63dfb272010-09-01 00:15:19 +0000339 def runCmd(self, cmd, msg=None, check=True, trace=False, setCookie=True):
Johnny Chen27f212d2010-08-19 23:26:59 +0000340 """
341 Ask the command interpreter to handle the command and then check its
342 return status.
343 """
344 # Fail fast if 'cmd' is not meaningful.
345 if not cmd or len(cmd) == 0:
346 raise Exception("Bad 'cmd' parameter encountered")
Johnny Chen5bbb88f2010-08-20 17:57:32 +0000347
Johnny Chen8d55a342010-08-31 17:42:54 +0000348 trace = (True if traceAlways else trace)
Johnny Chend0190a62010-08-23 17:10:44 +0000349
Johnny Chen63dfb272010-09-01 00:15:19 +0000350 running = (cmd.startswith("run") or cmd.startswith("process launch"))
Johnny Chen5bbb88f2010-08-20 17:57:32 +0000351
Johnny Chen63dfb272010-09-01 00:15:19 +0000352 for i in range(self.maxLaunchCount if running else 1):
Johnny Chenf2b70232010-08-25 18:49:48 +0000353 self.ci.HandleCommand(cmd, self.res)
Johnny Chen5bbb88f2010-08-20 17:57:32 +0000354
Johnny Chenf2b70232010-08-25 18:49:48 +0000355 if trace:
356 print >> sys.stderr, "runCmd:", cmd
357 if self.res.Succeeded():
358 print >> sys.stderr, "output:", self.res.GetOutput()
359 else:
360 print >> sys.stderr, self.res.GetError()
Johnny Chen5bbb88f2010-08-20 17:57:32 +0000361
Johnny Chenff3d01d2010-08-20 21:03:09 +0000362 if self.res.Succeeded():
Johnny Chenf2b70232010-08-25 18:49:48 +0000363 break
Johnny Chenff3d01d2010-08-20 21:03:09 +0000364 else:
Johnny Chen63dfb272010-09-01 00:15:19 +0000365 if running:
Johnny Chenf2b70232010-08-25 18:49:48 +0000366 # Process launch failed, wait some time before the next try.
367 time.sleep(self.timeWait)
Johnny Chen5bbb88f2010-08-20 17:57:32 +0000368
Johnny Chen7d1d7532010-09-02 21:23:12 +0000369 # Modify runStarted only if "run" or "process launch" was encountered.
370 if running:
371 self.runStarted = running and setCookie
Johnny Chen63dfb272010-09-01 00:15:19 +0000372
Johnny Chen27f212d2010-08-19 23:26:59 +0000373 if check:
374 self.assertTrue(self.res.Succeeded(),
375 msg if msg else CMD_MSG(cmd))
376
Johnny Chend0190a62010-08-23 17:10:44 +0000377 def expect(self, cmd, msg=None, startstr=None, substrs=None, trace=False):
Johnny Chen27f212d2010-08-19 23:26:59 +0000378 """
379 Similar to runCmd; with additional expect style output matching ability.
380
381 Ask the command interpreter to handle the command and then check its
382 return status. The 'msg' parameter specifies an informational assert
383 message. We expect the output from running the command to start with
384 'startstr' and matches the substrings contained in 'substrs'.
385 """
Johnny Chen8d55a342010-08-31 17:42:54 +0000386 trace = (True if traceAlways else trace)
Johnny Chend0190a62010-08-23 17:10:44 +0000387
Johnny Chen74f26b82010-08-20 19:17:39 +0000388 # First run the command.
Johnny Chend0190a62010-08-23 17:10:44 +0000389 self.runCmd(cmd, trace = (True if trace else False))
Johnny Chen27f212d2010-08-19 23:26:59 +0000390
Johnny Chen74f26b82010-08-20 19:17:39 +0000391 # Then compare the output against expected strings.
Johnny Chen27f212d2010-08-19 23:26:59 +0000392 output = self.res.GetOutput()
393 matched = output.startswith(startstr) if startstr else True
Johnny Chenb145bba2010-08-20 18:25:15 +0000394
Johnny Chenc7c9fcf2010-08-24 23:48:10 +0000395 if startstr and trace:
396 print >> sys.stderr, "Expecting start string:", startstr
397 print >> sys.stderr, "Matched" if matched else "Not matched"
398 print >> sys.stderr
Johnny Chenb145bba2010-08-20 18:25:15 +0000399
Johnny Chen981463d2010-08-25 19:00:04 +0000400 if substrs and matched:
Johnny Chen27f212d2010-08-19 23:26:59 +0000401 for str in substrs:
402 matched = output.find(str) > 0
Johnny Chenc7c9fcf2010-08-24 23:48:10 +0000403 if trace:
404 print >> sys.stderr, "Expecting sub string:", str
405 print >> sys.stderr, "Matched" if matched else "Not matched"
Johnny Chen27f212d2010-08-19 23:26:59 +0000406 if not matched:
407 break
Johnny Chenc7c9fcf2010-08-24 23:48:10 +0000408 if trace:
409 print >> sys.stderr
Johnny Chen27f212d2010-08-19 23:26:59 +0000410
Johnny Chen74f26b82010-08-20 19:17:39 +0000411 self.assertTrue(matched, msg if msg else CMD_MSG(cmd))
Johnny Chen27f212d2010-08-19 23:26:59 +0000412
Johnny Chenf3c59232010-08-25 22:52:45 +0000413 def invoke(self, obj, name, trace=False):
Johnny Chen61703c92010-08-25 22:56:10 +0000414 """Use reflection to call a method dynamically with no argument."""
Johnny Chen8d55a342010-08-31 17:42:54 +0000415 trace = (True if traceAlways else trace)
Johnny Chenf3c59232010-08-25 22:52:45 +0000416
417 method = getattr(obj, name)
418 import inspect
419 self.assertTrue(inspect.ismethod(method),
420 name + "is a method name of object: " + str(obj))
421 result = method()
Johnny Chen8d55a342010-08-31 17:42:54 +0000422 if trace:
Johnny Chenf3c59232010-08-25 22:52:45 +0000423 print str(method) + ":", result
424 return result
Johnny Chen827edff2010-08-27 00:15:48 +0000425
Johnny Chen13639082010-09-01 22:08:51 +0000426 def breakAfterLaunch(self, process, func, trace=False):
427 """
428 Perform some dancees after LaunchProcess() to break at func name.
429
430 Return True if we can successfully break at the func name in due time.
431 """
432 trace = (True if traceAlways else trace)
433
434 count = 0
435 while True:
436 # The stop reason of the thread should be breakpoint.
437 thread = process.GetThreadAtIndex(0)
438 SR = thread.GetStopReason()
439 if trace:
440 print >> sys.stderr, "StopReason =", StopReasonString(SR)
441
442 if SR == StopReasonEnum("Breakpoint"):
443 frame = thread.GetFrameAtIndex(0)
444 name = frame.GetFunction().GetName()
445 if (name == func):
446 # We got what we want; now break out of the loop.
447 return True
448
449 # The inferior is in a transient state; continue the process.
450 time.sleep(1.0)
451 if trace:
452 print >> sys.stderr, "Continuing the process:", process
453 process.Continue()
454
455 count = count + 1
456 if count == 10:
457 if trace:
458 print >> sys.stderr, "Reached 10 iterations, giving up..."
459 # Enough iterations already, break out of the loop.
460 return False
461
462 # End of while loop.
463
464
Johnny Chen2f1ad5e2010-08-30 22:26:48 +0000465 def buildDsym(self):
466 """Platform specific way to build binaries with dsym info."""
Johnny Chen8d55a342010-08-31 17:42:54 +0000467 module = __import__(sys.platform)
468 if not module.buildDsym():
Johnny Chen2f1ad5e2010-08-30 22:26:48 +0000469 raise Exception("Don't know how to build binary with dsym")
470
471 def buildDwarf(self):
472 """Platform specific way to build binaries with dwarf maps."""
Johnny Chen8d55a342010-08-31 17:42:54 +0000473 module = __import__(sys.platform)
474 if not module.buildDwarf():
Johnny Chen2f1ad5e2010-08-30 22:26:48 +0000475 raise Exception("Don't know how to build binary with dwarf")
476
Johnny Chen827edff2010-08-27 00:15:48 +0000477 def DebugSBValue(self, frame, val):
Johnny Chen8d55a342010-08-31 17:42:54 +0000478 """Debug print a SBValue object, if traceAlways is True."""
479 if not traceAlways:
Johnny Chen827edff2010-08-27 00:15:48 +0000480 return
481
482 err = sys.stderr
483 err.write(val.GetName() + ":\n")
484 err.write('\t' + "TypeName -> " + val.GetTypeName() + '\n')
485 err.write('\t' + "ByteSize -> " + str(val.GetByteSize()) + '\n')
486 err.write('\t' + "NumChildren -> " + str(val.GetNumChildren()) + '\n')
487 err.write('\t' + "Value -> " + str(val.GetValue(frame)) + '\n')
488 err.write('\t' + "Summary -> " + str(val.GetSummary(frame)) + '\n')
489 err.write('\t' + "IsPtrType -> " + str(val.TypeIsPtrType()) + '\n')
490 err.write('\t' + "Location -> " + val.GetLocation(frame) + '\n')
491