3 def print_frames(thread, num_frames, current_thread):
4 # TODO: Make output header similar to bt.
5 print '%c thread #%i' % ('*' if current_thread else ' ', thread.idx)
8 selected_frame = thread.GetSelectedFrame()
10 for frame in thread.frames[:+num_frames]:
16 framestr = frame.EvaluateExpression('(char*)mono_pmip((void*)%s)' % pc).summary[1:-1]
17 var = 'frame #%i: %s%s' % (frame.idx, pc, framestr)
21 print fmt % ('*' if current_thread and frame.idx == selected_frame.idx else ' ', var)
23 def monobt(debugger, command, result, dict):
24 opts = {'all_bt': False, 'num_frames': None}
28 elif command.isdigit():
29 opts['num_frames'] = int(command)
31 print 'error: monobt [<number>|all]'
34 target = debugger.GetSelectedTarget()
35 process = target.process
37 if not process.IsValid():
38 print 'error: invalid process'
42 for thread in process.threads:
43 print_frames(thread, len(thread), process.selected_thread == thread)
46 thread = process.selected_thread
47 num_frames = len(thread) if opts['num_frames'] is None else opts['num_frames']
48 print_frames(thread, num_frames, True)
52 def __lldb_init_module (debugger, dict):
53 # This initializer is being run from LLDB in the embedded command interpreter
54 # Add any commands contained in this module to LLDB
55 debugger.HandleCommand('command script add -f monobt.monobt monobt')
56 print '"monobt" command installed'