Make some more of the LLDB/SWIG/Python glue Python 3 aware.
Mostly this is just converting some print statements to print functions. llvm-svn: 250533
This commit is contained in:
parent
5c3a198266
commit
5f3fd800f7
|
@ -128,7 +128,7 @@ public:
|
|||
if range_idx < len(self):
|
||||
return [self.sbblock.GetRangeStartAddress(range_idx), self.sbblock.GetRangeEndAddress(range_idx)]
|
||||
else:
|
||||
print "error: unsupported item type: %s" % type(key)
|
||||
print("error: unsupported item type: %s" % type(key))
|
||||
return None
|
||||
|
||||
def get_ranges_access_object(self):
|
||||
|
|
|
@ -67,8 +67,8 @@ TestBreakpointIgnoreCount.py),
|
|||
SBBreakpoint supports breakpoint location iteration, for example,
|
||||
|
||||
for bl in breakpoint:
|
||||
print 'breakpoint location load addr: %s' % hex(bl.GetLoadAddress())
|
||||
print 'breakpoint location condition: %s' % hex(bl.GetCondition())
|
||||
print('breakpoint location load addr: %s' % hex(bl.GetLoadAddress()))
|
||||
print('breakpoint location condition: %s' % hex(bl.GetCondition()))
|
||||
|
||||
and rich comparion methods which allow the API program to use,
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@ SBCompileUnit supports line entry iteration. For example,
|
|||
compileUnit = context.GetCompileUnit()
|
||||
|
||||
for lineEntry in compileUnit:
|
||||
print 'line entry: %s:%d' % (str(lineEntry.GetFileSpec()),
|
||||
lineEntry.GetLine())
|
||||
print 'start addr: %s' % str(lineEntry.GetStartAddress())
|
||||
print 'end addr: %s' % str(lineEntry.GetEndAddress())
|
||||
print('line entry: %s:%d' % (str(lineEntry.GetFileSpec()),
|
||||
lineEntry.GetLine()))
|
||||
print('start addr: %s' % str(lineEntry.GetStartAddress()))
|
||||
print('end addr: %s' % str(lineEntry.GetEndAddress()))
|
||||
|
||||
produces:
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ debugger = lldb.SBDebugger.Create()
|
|||
debugger.SetAsync (False)
|
||||
|
||||
# Create a target from a file and arch
|
||||
print 'Creating a target for \'%s\'' % exe
|
||||
print('Creating a target for \'%s\'' % exe)
|
||||
|
||||
target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT)
|
||||
|
||||
|
@ -82,17 +82,17 @@ if target:
|
|||
disassemble_instructions (insts)
|
||||
|
||||
registerList = frame.GetRegisters()
|
||||
print 'Frame registers (size of register set = %d):' % registerList.GetSize()
|
||||
print('Frame registers (size of register set = %d):' % registerList.GetSize())
|
||||
for value in registerList:
|
||||
#print value
|
||||
print '%s (number of children = %d):' % (value.GetName(), value.GetNumChildren())
|
||||
print('%s (number of children = %d):' % (value.GetName(), value.GetNumChildren()))
|
||||
for child in value:
|
||||
print 'Name: ', child.GetName(), ' Value: ', child.GetValue()
|
||||
print('Name: ', child.GetName(), ' Value: ', child.GetValue())
|
||||
|
||||
print 'Hit the breakpoint at main, enter to continue and wait for program to exit or \'Ctrl-D\'/\'quit\' to terminate the program'
|
||||
print('Hit the breakpoint at main, enter to continue and wait for program to exit or \'Ctrl-D\'/\'quit\' to terminate the program')
|
||||
next = sys.stdin.readline()
|
||||
if not next or next.rstrip('\n') == 'quit':
|
||||
print 'Terminating the inferior process...'
|
||||
print('Terminating the inferior process...')
|
||||
process.Kill()
|
||||
else:
|
||||
# Now continue to the program exit
|
||||
|
@ -101,9 +101,9 @@ if target:
|
|||
# program exit. Print out some process info
|
||||
print process
|
||||
elif state == lldb.eStateExited:
|
||||
print 'Didn\'t hit the breakpoint at main, program has exited...'
|
||||
print('Didn\'t hit the breakpoint at main, program has exited...')
|
||||
else:
|
||||
print 'Unexpected process state: %s, killing process...' % debugger.StateAsCString (state)
|
||||
print('Unexpected process state: %s, killing process...' % debugger.StateAsCString (state))
|
||||
process.Kill()
|
||||
") SBDebugger;
|
||||
class SBDebugger
|
||||
|
|
|
@ -76,17 +76,17 @@ from test/python_api/event/TestEventspy:
|
|||
# After that, the thread exits.
|
||||
while not count > 3:
|
||||
if traceOn:
|
||||
print 'Try wait for event...'
|
||||
print('Try wait for event...')
|
||||
if listener.WaitForEventForBroadcasterWithType(5,
|
||||
broadcaster,
|
||||
lldb.SBProcess.eBroadcastBitStateChanged,
|
||||
event):
|
||||
if traceOn:
|
||||
desc = lldbutil.get_description(event)
|
||||
print 'Event description:', desc
|
||||
print 'Event data flavor:', event.GetDataFlavor()
|
||||
print 'Process state:', lldbutil.state_type_to_str(process.GetState())
|
||||
print
|
||||
desc = lldbutil.get_description(event))
|
||||
print('Event description:', desc)
|
||||
print('Event data flavor:', event.GetDataFlavor())
|
||||
print('Process state:', lldbutil.state_type_to_str(process.GetState()))
|
||||
print()
|
||||
else:
|
||||
if traceOn:
|
||||
print 'timeout occurred waiting for event...'
|
||||
|
|
|
@ -14,10 +14,10 @@ namespace lldb {
|
|||
a source file location. SBCompileUnit contains SBLineEntry(s). For example,
|
||||
|
||||
for lineEntry in compileUnit:
|
||||
print 'line entry: %s:%d' % (str(lineEntry.GetFileSpec()),
|
||||
lineEntry.GetLine())
|
||||
print 'start addr: %s' % str(lineEntry.GetStartAddress())
|
||||
print 'end addr: %s' % str(lineEntry.GetEndAddress())
|
||||
print('line entry: %s:%d' % (str(lineEntry.GetFileSpec()),
|
||||
lineEntry.GetLine()))
|
||||
print('start addr: %s' % str(lineEntry.GetStartAddress()))
|
||||
print('end addr: %s' % str(lineEntry.GetEndAddress()))
|
||||
|
||||
produces:
|
||||
|
||||
|
|
|
@ -29,24 +29,24 @@ SBModule supports symbol iteration, for example,
|
|||
and rich comparion methods which allow the API program to use,
|
||||
|
||||
if thisModule == thatModule:
|
||||
print 'This module is the same as that module'
|
||||
print('This module is the same as that module')
|
||||
|
||||
to test module equality. A module also contains object file sections, namely
|
||||
SBSection. SBModule supports section iteration through section_iter(), for
|
||||
example,
|
||||
|
||||
print 'Number of sections: %d' % module.GetNumSections()
|
||||
print('Number of sections: %d' % module.GetNumSections())
|
||||
for sec in module.section_iter():
|
||||
print sec
|
||||
print(sec)
|
||||
|
||||
And to iterate the symbols within a SBSection, use symbol_in_section_iter(),
|
||||
|
||||
# Iterates the text section and prints each symbols within each sub-section.
|
||||
for subsec in text_sec:
|
||||
print INDENT + repr(subsec)
|
||||
print(INDENT + repr(subsec))
|
||||
for sym in exe_module.symbol_in_section_iter(subsec):
|
||||
print INDENT2 + repr(sym)
|
||||
print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType())
|
||||
print(INDENT2 + repr(sym))
|
||||
print(INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType()))
|
||||
|
||||
produces this following output:
|
||||
|
||||
|
@ -365,7 +365,7 @@ public:
|
|||
matches.append(symbol)
|
||||
return matches
|
||||
else:
|
||||
print "error: unsupported item type: %s" % type(key)
|
||||
print("error: unsupported item type: %s" % type(key))
|
||||
return None
|
||||
|
||||
def get_symbols_access_object(self):
|
||||
|
@ -415,7 +415,7 @@ public:
|
|||
matches.append(section)
|
||||
return matches
|
||||
else:
|
||||
print "error: unsupported item type: %s" % type(key)
|
||||
print("error: unsupported item type: %s" % type(key))
|
||||
return None
|
||||
|
||||
class compile_units_access(object):
|
||||
|
@ -455,7 +455,7 @@ public:
|
|||
matches.append(comp_unit)
|
||||
return matches
|
||||
else:
|
||||
print "error: unsupported item type: %s" % type(key)
|
||||
print("error: unsupported item type: %s" % type(key))
|
||||
return None
|
||||
|
||||
def get_sections_access_object(self):
|
||||
|
|
|
@ -276,7 +276,7 @@ public:
|
|||
new_value = str(bytes)
|
||||
result = process.WriteMemory(addr, new_value, error)
|
||||
if not error.Success() or result != len(bytes):
|
||||
print 'SBProcess.WriteMemory() failed!'
|
||||
print('SBProcess.WriteMemory() failed!')
|
||||
") WriteMemory;
|
||||
size_t
|
||||
WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error);
|
||||
|
@ -290,9 +290,9 @@ public:
|
|||
error = lldb.SBError()
|
||||
cstring = process.ReadCStringFromMemory(0x1000, 256, error)
|
||||
if error.Success():
|
||||
print 'cstring: ', cstring
|
||||
print('cstring: ', cstring)
|
||||
else
|
||||
print 'error: ', error
|
||||
print('error: ', error)
|
||||
") ReadCStringFromMemory;
|
||||
|
||||
size_t
|
||||
|
@ -306,9 +306,9 @@ public:
|
|||
error = lldb.SBError()
|
||||
uint = ReadUnsignedFromMemory(0x1000, 4, error)
|
||||
if error.Success():
|
||||
print 'integer: %u' % uint
|
||||
print('integer: %u' % uint)
|
||||
else
|
||||
print 'error: ', error
|
||||
print('error: ', error)
|
||||
|
||||
") ReadUnsignedFromMemory;
|
||||
|
||||
|
@ -322,9 +322,9 @@ public:
|
|||
error = lldb.SBError()
|
||||
ptr = ReadPointerFromMemory(0x1000, error)
|
||||
if error.Success():
|
||||
print 'pointer: 0x%x' % ptr
|
||||
print('pointer: 0x%x' % ptr)
|
||||
else
|
||||
print 'error: ', error
|
||||
print('error: ', error)
|
||||
|
||||
") ReadPointerFromMemory;
|
||||
|
||||
|
|
|
@ -795,7 +795,7 @@ public:
|
|||
matching_modules.append(module)
|
||||
return matching_modules
|
||||
else:
|
||||
print "error: unsupported item type: %s" % type(key)
|
||||
print("error: unsupported item type: %s" % type(key))
|
||||
return None
|
||||
|
||||
def get_modules_access_object(self):
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace lldb {
|
|||
elif isinstance(key,self.regex_type):
|
||||
return self.get_by_name_function(self.sbcategory,SBTypeNameSpecifier(key.pattern,True))
|
||||
else:
|
||||
print "error: unsupported item type: %s" % type(key)
|
||||
print("error: unsupported item type: %s" % type(key))
|
||||
return None
|
||||
|
||||
def get_formats_access_object(self):
|
||||
|
|
|
@ -22,9 +22,9 @@ frame as an SBValue, and iterate through all the registers,
|
|||
GPRs = regs
|
||||
break
|
||||
|
||||
print '%s (number of children = %d):' % (GPRs.GetName(), GPRs.GetNumChildren())
|
||||
print('%s (number of children = %d):' % (GPRs.GetName(), GPRs.GetNumChildren()))
|
||||
for reg in GPRs:
|
||||
print 'Name: ', reg.GetName(), ' Value: ', reg.GetValue()
|
||||
print('Name: ', reg.GetName(), ' Value: ', reg.GetValue())
|
||||
|
||||
produces the output:
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ def get_GPRs(frame):
|
|||
from lldbutil import get_GPRs
|
||||
regs = get_GPRs(frame)
|
||||
for reg in regs:
|
||||
print '%s => %s' % (reg.GetName(), reg.GetValue())
|
||||
print('%s => %s' % (reg.GetName(), reg.GetValue()))
|
||||
...
|
||||
'''
|
||||
return get_registers(frame, 'general purpose')
|
||||
|
@ -48,7 +48,7 @@ def get_FPRs(frame):
|
|||
from lldbutil import get_FPRs
|
||||
regs = get_FPRs(frame)
|
||||
for reg in regs:
|
||||
print '%s => %s' % (reg.GetName(), reg.GetValue())
|
||||
print('%s => %s' % (reg.GetName(), reg.GetValue()))
|
||||
...
|
||||
'''
|
||||
return get_registers(frame, 'floating point')
|
||||
|
@ -61,7 +61,7 @@ def get_ESRs(frame):
|
|||
from lldbutil import get_ESRs
|
||||
regs = get_ESRs(frame)
|
||||
for reg in regs:
|
||||
print '%s => %s' % (reg.GetName(), reg.GetValue())
|
||||
print('%s => %s' % (reg.GetName(), reg.GetValue()))
|
||||
...
|
||||
'''
|
||||
return get_registers(frame, 'exception state')"
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import __builtin__
|
||||
import sys
|
||||
if sys.version_info[0] < 3:
|
||||
import __builtin__ as builtins
|
||||
else:
|
||||
import builtins
|
||||
import code
|
||||
import lldb
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
try:
|
||||
|
@ -42,8 +45,8 @@ def setquit():
|
|||
# "sys.exit(123)"
|
||||
global g_builtin_override_called
|
||||
g_builtin_override_called = False
|
||||
__builtin__.quit = LLDBQuitter('quit')
|
||||
__builtin__.exit = LLDBQuitter('exit')
|
||||
builtins.quit = LLDBQuitter('quit')
|
||||
builtins.exit = LLDBQuitter('exit')
|
||||
|
||||
# When running one line, we might place the string to run in this string
|
||||
# in case it would be hard to correctly escape a string's contents
|
||||
|
@ -94,7 +97,7 @@ def run_python_interpreter (local_dict):
|
|||
except SystemExit as e:
|
||||
global g_builtin_override_called
|
||||
if not g_builtin_override_called:
|
||||
print 'Script exited with %s' %(e)
|
||||
print('Script exited with %s' %(e))
|
||||
|
||||
def run_one_line (local_dict, input_string):
|
||||
global g_run_one_line_str
|
||||
|
@ -109,4 +112,4 @@ def run_one_line (local_dict, input_string):
|
|||
except SystemExit as e:
|
||||
global g_builtin_override_called
|
||||
if not g_builtin_override_called:
|
||||
print 'Script exited with %s' %(e)
|
||||
print('Script exited with %s' %(e))
|
||||
|
|
Loading…
Reference in New Issue