command script add {command_name} -f {python_script_name}.{function_name or class_name} // 以上大括号里的,都是要自己填充的
接下来就是实现命令具体的内容了
一共有两种定义命令具体内容的办法,一是通过函数,而是通过类。很明显通过类会更加的具体、完整。
类的定义方法:
1 2 3 4 5 6 7 8 9
class CommandObjectType: def __init__(self, debugger, session_dict): this call should initialize the command with respect to the command interpreter for the passed-in debugger def __call__(self, debugger, command, exe_ctx, result): this is the actual bulk of the command, akin to Python command functions def get_short_help(self): this call should return the short help text for this command[1] def get_long_help(self): this call should return the long help text for this command[1]
for i in lldb.debugger.GetSelectedTarget().module_iter(): print(i)
获取程序运行所有module的uuid,包括动态链接库
1 2
for i in lldb.debugger.GetSelectedTarget().module_iter(): print(i.uuid)
获得target的module的section
1 2 3 4
fullpath = getTarget().executable.fullpath modules = getTarget().module[fullpath] for i in modules.section_iter(): print(i)
获取所有module的目录
1 2
for module in getTarget().module_iter(): print(module.file)
获取某一个模块的路径
1 2
for module in getTarget().module_iter(): print(module.file)
lldb.SBSymbol
获取所有的symols(结构体、函数名等)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
for i in getTarget().module_iter(): for symbol in i: print(symbol.GetName()) 输出结果如下 [0x0000000000000000-0x0000000100000000) hello.__PAGEZERO [0x0000000100000000-0x0000000100001000) hello.__TEXT [0x0000000100001000-0x0000000100002000) hello.__DATA_CONST [0x0000000100002000-0x0000000100003000) hello.__DATA [0x0000000100003000-0x0000000100008000) hello.__LINKEDIT ```
## lldb.SBSection --- ### 获取某一个模块所有的区段地址和名称
for module in getTarget().module_iter():
for section in module.get_sections_array():
print(section.GetLoadAddress(getTarget()))
print(section.GetName())
运行结果:
/usr/lib/system/libsystem_trace.dylib
140734928015360
__TEXT
140735571328992
__DATA
140736423665664
__LINKEDIT
/usr/lib/system/libunwind.dylib
140734928113664
__TEXT
140735571336960
__DATA
140736423665664
__LINKEDIT
……
1 2 3 4
### 查看区段可读可写可执行权限
for module in getTarget().module_iter():
for section in module.get_sections_array():
print(section.GetPermissions())
1 2 3
## lldb.SBFrame ### 获取寄存器
registers = frame.GetRegisters()
for value in registers:
for child in value:
print(child.GetValue())
print(child.GetName())
| SBModule supports symbol iteration, for example,
|
| for symbol in module:
| name = symbol.GetName()
| saddr = symbol.GetStartAddress()
| eaddr = symbol.GetEndAddress()
Help on SBModule in module lldb object:
class SBModule(builtins.object)
| SBModule(args)
|
| Represents an executable image and its associated object and symbol files.
|
| The module is designed to be able to select a single slice of an
| executable image as it would appear on disk and during program
| execution.
|
| You can retrieve SBModule from SBSymbolContext, which in turn is available
| from SBFrame.
|
| SBModule supports symbol iteration, for example,
|
| for symbol in module:
| name = symbol.GetName()
| saddr = symbol.GetStartAddress()
| eaddr = symbol.GetEndAddress()
|
| and rich comparison methods which allow the API program to use,
|
| if thisModule == thatModule:
| 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())
| for sec in module.section_iter():
| 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))
| 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()))
|
| produces this following output:
|
| [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text
| id = {0x00000004}, name = ‘mask_access(MaskAction, unsigned int)’, range = [0x00000001000017c0-0x0000000100001870)
| symbol type: code
| id = {0x00000008}, name = 'thread_func(void)’, range = [0x0000000100001870-0x00000001000019b0)
| symbol type: code
| id = {0x0000000c}, name = ‘main’, range = [0x00000001000019b0-0x0000000100001d5c)
| symbol type: code
| id = {0x00000023}, name = ‘start’, address = 0x0000000100001780
| symbol type: code
| [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs
| id = {0x00000024}, name = ‘__stack_chk_fail’, range = [0x0000000100001d5c-0x0000000100001d62)
| symbol type: trampoline
| id = {0x00000028}, name = ‘exit’, range = [0x0000000100001d62-0x0000000100001d68)
| symbol type: trampoline
| id = {0x00000029}, name = ‘fflush’, range = [0x0000000100001d68-0x0000000100001d6e)
| symbol type: trampoline
| id = {0x0000002a}, name = ‘fgets’, range = [0x0000000100001d6e-0x0000000100001d74)
| symbol type: trampoline
| id = {0x0000002b}, name = ‘printf’, range = [0x0000000100001d74-0x0000000100001d7a)
| symbol type: trampoline
| id = {0x0000002c}, name = ‘pthread_create’, range = [0x0000000100001d7a-0x0000000100001d80)
| symbol type: trampoline
| id = {0x0000002d}, name = ‘pthread_join’, range = [0x0000000100001d80-0x0000000100001d86)
| symbol type: trampoline
| id = {0x0000002e}, name = ‘pthread_mutex_lock’, range = [0x0000000100001d86-0x0000000100001d8c)
| symbol type: trampoline
| id = {0x0000002f}, name = ‘pthread_mutex_unlock’, range = [0x0000000100001d8c-0x0000000100001d92)
| symbol type: trampoline
| id = {0x00000030}, name = ‘rand’, range = [0x0000000100001d92-0x0000000100001d98)
| symbol type: trampoline
| id = {0x00000031}, name = ‘strtoul’, range = [0x0000000100001d98-0x0000000100001d9e)
| symbol type: trampoline
| id = {0x00000032}, name = ‘usleep’, range = [0x0000000100001d9e-0x0000000100001da4)
| symbol type: trampoline
| [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper
| [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring
| [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info
| [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame
|
| Methods defined here:
|
| Clear(self)
| Clear(SBModule self)
|
| FindCompileUnits(self, sb_file_spec)
| FindCompileUnits(SBModule self, SBFileSpec sb_file_spec) -> SBSymbolContextList
|
|
| Find compile units related to *this module and passed source
| file.
|
| @param[in] sb_file_spec
| A lldb::SBFileSpec object that contains source file
| specification.
|
| @return
| A lldb::SBSymbolContextList that gets filled in with all of
| the symbol contexts for all the matches.
|
| FindFirstGlobalVariable(self, target, name)
| FindFirstGlobalVariable(SBModule self, SBTarget target, str const * name) -> SBValue
|
|
| Find the first global (or static) variable by name.
|
| @param[in] target
| A valid SBTarget instance representing the debuggee.
|
| @param[in] name
| The name of the global or static variable we are looking
| for.
|
| @return
| An SBValue that gets filled in with the found variable (if any).
|
| FindFirstType(self, name)
| FindFirstType(SBModule self, str const * name) -> SBType
|
| FindFunctions(self, *args)
| FindFunctions(SBModule self, str const * name, uint32_t name_type_mask) -> SBSymbolContextList
| FindFunctions(SBModule self, str const * name) -> SBSymbolContextList
|
|
| Find functions by name.
|
| @param[in] name
| The name of the function we are looking for.
|
| @param[in] name_type_mask
| A logical OR of one or more FunctionNameType enum bits that
| indicate what kind of names should be used when doing the
| lookup. Bits include fully qualified names, base names,
| C++ methods, or ObjC selectors.
| See FunctionNameType for more details.
|
| @return
| A symbol context list that gets filled in with all of the
| matches.
|
| FindGlobalVariables(self, target, name, max_matches)
| FindGlobalVariables(SBModule self, SBTarget target, str const * name, uint32_t max_matches) -> SBValueList
|
|
| Find global and static variables by name.
|
| @param[in] target
| A valid SBTarget instance representing the debuggee.
|
| @param[in] name
| The name of the global or static variable we are looking
| for.
|
| @param[in] max_matches
| Allow the number of matches to be limited to max_matches.
|
| @return
| A list of matched variables in an SBValueList.
|
| FindSection(self, sect_name)
| FindSection(SBModule self, str const * sect_name) -> SBSection
|
| FindSymbol(self, *args)
| FindSymbol(SBModule self, str const * name, lldb::SymbolType type) -> SBSymbol
| FindSymbol(SBModule self, str const * name) -> SBSymbol
|
| FindSymbols(self, *args)
| FindSymbols(SBModule self, str const * name, lldb::SymbolType type) -> SBSymbolContextList
| FindSymbols(SBModule self, str const * name) -> SBSymbolContextList
|
| FindTypes(self, type)
| FindTypes(SBModule self, str const * type) -> SBTypeList
|
| GetAddressByteSize(self)
| GetAddressByteSize(SBModule self) -> uint32_t
|
| GetBasicType(self, type)
| GetBasicType(SBModule self, lldb::BasicType type) -> SBType
|
| GetByteOrder(self)
| GetByteOrder(SBModule self) -> lldb::ByteOrder
|
| GetCompileUnitAtIndex(self, arg2)
| GetCompileUnitAtIndex(SBModule self, uint32_t arg2) -> SBCompileUnit
|
| GetDescription(self, description)
| GetDescription(SBModule self, SBStream description) -> bool
|
| GetFileSpec(self)
| GetFileSpec(SBModule self) -> SBFileSpec
|
|
| Get const accessor for the module file specification.
|
| This function returns the file for the module on the host system
| that is running LLDB. This can differ from the path on the
| platform since we might be doing remote debugging.
|
| @return
| A const reference to the file specification object.
|
| GetNumCompileUnits(self)
| GetNumCompileUnits(SBModule self) -> uint32_t
|
| GetNumSections(self)
| GetNumSections(SBModule self) -> size_t
|
| GetNumSymbols(self)
| GetNumSymbols(SBModule self) -> size_t
|
| GetObjectFileEntryPointAddress(self)
| GetObjectFileEntryPointAddress(SBModule self) -> SBAddress
|
| GetObjectFileHeaderAddress(self)
| GetObjectFileHeaderAddress(SBModule self) -> SBAddress
|
| GetPlatformFileSpec(self)
| GetPlatformFileSpec(SBModule self) -> SBFileSpec
|
|
| Get accessor for the module platform file specification.
|
| Platform file refers to the path of the module as it is known on
| the remote system on which it is being debugged. For local
| debugging this is always the same as Module::GetFileSpec(). But
| remote debugging might mention a file ‘/usr/lib/liba.dylib’
| which might be locally downloaded and cached. In this case the
| platform file could be something like:
| ‘/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib’
| The file could also be cached in a local developer kit directory.
|
| @return
| A const reference to the file specification object.
|
| GetRemoteInstallFileSpec(self)
| GetRemoteInstallFileSpec(SBModule self) -> SBFileSpec
|
| GetSectionAtIndex(self, idx)
| GetSectionAtIndex(SBModule self, size_t idx) -> SBSection
|
| GetSymbolAtIndex(self, idx)
| GetSymbolAtIndex(SBModule self, size_t idx) -> SBSymbol
|
| GetSymbolFileSpec(self)
| GetSymbolFileSpec(SBModule self) -> SBFileSpec
|
| GetTriple(self)
| GetTriple(SBModule self) -> str const *
|
| GetTypeByID(self, uid)
| GetTypeByID(SBModule self, lldb::user_id_t uid) -> SBType
|
| GetTypes(self, *args)
| GetTypes(SBModule self, uint32_t type_mask) -> SBTypeList
| GetTypes(SBModule self) -> SBTypeList
|
|
| Get all types matching type_mask from debug info in this
| module.
|
| @param[in] type_mask
| A bitfield that consists of one or more bits logically OR’ed
| together from the lldb::TypeClass enumeration. This allows
| you to request only structure types, or only class, struct
| and union types. Passing in lldb::eTypeClassAny will return
| all types found in the debug information for this module.
|
| @return
| A list of types in this module that match type_mask
|
| GetUUIDString(self)
| GetUUIDString(SBModule self) -> str const *
|
| Returns the UUID of the module as a Python string.
|
| GetVersion(self)
| GetVersion(SBModule self) -> uint32_t
|
| IsTypeSystemCompatible(self, language)
| IsTypeSystemCompatible(SBModule self, lldb::LanguageType language) -> SBError
|
| IsValid(self)
| IsValid(SBModule self) -> bool
|
| ResolveFileAddress(self, vm_addr)
| ResolveFileAddress(SBModule self, lldb::addr_t vm_addr) -> SBAddress
|
| ResolveSymbolContextForAddress(self, addr, resolve_scope)
| ResolveSymbolContextForAddress(SBModule self, SBAddress addr, uint32_t resolve_scope) -> SBSymbolContext
|
| SetPlatformFileSpec(self, platform_file)
| SetPlatformFileSpec(SBModule self, SBFileSpec platform_file) -> bool
|
| SetRemoteInstallFileSpec(self, file)
| SetRemoteInstallFileSpec(SBModule self, SBFileSpec file) -> bool
|
| bool = nonzero(self)
|
| del lambda self
|
| eq(self, rhs)
| Return self==value.
|
| getattr lambda self, name
|
| init(self, *args)
| init(lldb::SBModule self) -> SBModule
| init(lldb::SBModule self, SBModule rhs) -> SBModule
| init(lldb::SBModule self, SBModuleSpec module_spec) -> SBModule
| init(lldb::SBModule self, SBProcess process, lldb::addr_t header_addr) -> SBModule
|
| iter(self)
|
| len(self)
|
| ne(self, rhs)
| Return self!=value.
|
| nonzero(self)
|
| repr = _swig_repr(self)
|
| setattr lambda self, name, value
|
| str(self)
| str(SBModule self) -> PyObject *
|
| compile_unit_iter(self)
|
| get_compile_units_access_object(self)
| An accessor function that returns a compile_units_access() object which allows lazy compile unit access from a lldb.SBModule object.
|
| get_compile_units_array(self)
| An accessor function that returns an array object that contains all compile_units in this module object.
|
| get_sections_access_object(self)
| An accessor function that returns a sections_access() object which allows lazy section array access.
|
| get_sections_array(self)
| An accessor function that returns an array object that contains all sections in this module object.
|
| get_symbols_access_object(self)
| An accessor function that returns a symbols_access() object which allows lazy symbol access from a lldb.SBModule object.
|
| get_symbols_array(self)
| An accessor function that returns a list() that contains all symbols in a lldb.SBModule object.
|
| get_uuid(self)
|
| section_iter(self)
|
| symbol_in_section_iter(self, section)
| Given a module and its contained section, returns an iterator on the
| symbols within the section.
list of weak references to the object (if defined)
addr_size
A read only property that returns the size in bytes of an address for this module.
byte_order
A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this module.
compile_units
A read only property that returns a list() of lldb.SBCompileUnit objects contained in this module.
file
A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented where it is being debugged.
num_sections
A read only property that returns number of sections in the module as an integer.
num_symbols
A read only property that returns number of symbols in the module symbol table as an integer.
platform_file
A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented on the current host system.
section
A read only property that can be used to access compile units by index (“compile_unit = module.compile_unit[0]”), name (“compile_unit = module.compile_unit[‘main.cpp’]”), or using a regular expression (“compile_unit = module.compile_unit[re.compile(…)]”). The return value is a single lldb.SBCompileUnit object for array access or by full or partial path, and a list() of lldb.SBCompileUnit objects regular expressions.
sections
A read only property that returns a list() of lldb.SBSection objects contained in this module.
symbol
A read only property that can be used to access symbols by index (“symbol = module.symbol[0]”), name (“symbols = module.symbol[‘main’]”), or using a regular expression (“symbols = module.symbol[re.compile(…)]”). The return value is a single lldb.SBSymbol object for array access, and a list() of lldb.SBSymbol objects for name and regular expression access
symbols
A read only property that returns a list() of lldb.SBSymbol objects contained in this module.
triple
A read only property that returns the target triple (arch-vendor-os) for this module.
uuid
A read only property that returns a standard python uuid.UUID object that represents the UUID of this module.
class SBTarget(builtins.object)
| SBTarget(*args)
|
| Represents the target program running under the debugger.
|
| SBTarget supports module, breakpoint, and watchpoint iterations. For example,
|
| for m in target.module_iter():
| print m
|
| produces:
|
| (x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out
| (x86_64) /usr/lib/dyld
| (x86_64) /usr/lib/libstdc++.6.dylib
| (x86_64) /usr/lib/libSystem.B.dylib
| (x86_64) /usr/lib/system/libmathCommon.A.dylib
| (x86_64) /usr/lib/libSystem.B.dylib(__commpage)
|
| and,
|
| for b in target.breakpoint_iter():
| print b
|
| produces:
|
| SBBreakpoint: id = 1, file =‘main.cpp’, line = 66, locations = 1
| SBBreakpoint: id = 2, file =‘main.cpp’, line = 85, locations = 1
|
| and,
|
| for wp_loc in target.watchpoint_iter():
| print wp_loc
|
| produces:
|
| Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw
| declare @ ‘/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12’
| hw_index = 0 hit_count = 2 ignore_count = 0
|
| Methods defined here:
|
| AddModule(self, *args)
| AddModule(SBTarget self, SBModule module) -> bool
| AddModule(SBTarget self, str const * path, str const * triple, str const * uuid) -> SBModule
| AddModule(SBTarget self, str const * path, str const * triple, str const * uuid_cstr, str const * symfile) -> SBModule
| AddModule(SBTarget self, SBModuleSpec module_spec) -> SBModule
|
| AppendImageSearchPath(self, arg2, to, error)
| AppendImageSearchPath(SBTarget self, str const * arg2, str const * to, SBError error)
|
|
| Append the path mapping (from -> to) to the target’s paths mapping list.
|
| Attach(self, attach_info, error)
| Attach(SBTarget self, SBAttachInfo attach_info, SBError error) -> SBProcess
|
| AttachToProcessWithID(self, listener, pid, error)
| AttachToProcessWithID(SBTarget self, SBListener listener, lldb::pid_t pid, SBError error) -> SBProcess
|
|
| Attach to process with pid.
|
| @param[in] listener
| An optional listener that will receive all process events.
| If listener is valid then listener will listen to all
| process events. If not valid, then this target’s debugger
| (SBTarget::GetDebugger()) will listen to all process events.
|
| @param[in] pid
| The process ID to attach to.
|
| @param[out]
| An error explaining what went wrong if attach fails.
|
| @return
| A process object for the attached process.
|
| AttachToProcessWithName(self, listener, name, wait_for, error)
| AttachToProcessWithName(SBTarget self, SBListener listener, str const * name, bool wait_for, SBError error) -> SBProcess
|
|
| Attach to process with name.
|
| @param[in] listener
| An optional listener that will receive all process events.
| If listener is valid then listener will listen to all
| process events. If not valid, then this target’s debugger
| (SBTarget::GetDebugger()) will listen to all process events.
|
| @param[in] name
| Basename of process to attach to.
|
| @param[in] wait_for
| If true wait for a new instance of ‘name’ to be launched.
|
| @param[out]
| An error explaining what went wrong if attach fails.
|
| @return
| A process object for the attached process.
|
| BreakpointCreateByAddress(self, address)
| BreakpointCreateByAddress(SBTarget self, lldb::addr_t address) -> SBBreakpoint
|
| BreakpointCreateByLocation(self, *args)
| BreakpointCreateByLocation(SBTarget self, str const * file, uint32_t line) -> SBBreakpoint
| BreakpointCreateByLocation(SBTarget self, SBFileSpec file_spec, uint32_t line) -> SBBreakpoint
| BreakpointCreateByLocation(SBTarget self, SBFileSpec file_spec, uint32_t line, lldb::addr_t offset) -> SBBreakpoint
| BreakpointCreateByLocation(SBTarget self, SBFileSpec file_spec, uint32_t line, lldb::addr_t offset, SBFileSpecList module_list) -> SBBreakpoint
| BreakpointCreateByLocation(SBTarget self, SBFileSpec file_spec, uint32_t line, uint32_t column, lldb::addr_t offset, SBFileSpecList module_list) -> SBBreakpoint
|
| BreakpointCreateByName(self, *args)
| BreakpointCreateByName(SBTarget self, str const * symbol_name, str const * module_name=None) -> SBBreakpoint
| BreakpointCreateByName(SBTarget self, str const * symbol_name) -> SBBreakpoint
| BreakpointCreateByName(SBTarget self, str const * symbol_name, uint32_t func_name_type, SBFileSpecList module_list, SBFileSpecList comp_unit_list) -> SBBreakpoint
| BreakpointCreateByName(SBTarget self, str const * symbol_name, uint32_t func_name_type, lldb::LanguageType symbol_language, SBFileSpecList module_list, SBFileSpecList comp_unit_list) -> SBBreakpoint
|
| BreakpointCreateByNames(self, *args)
| BreakpointCreateByNames(SBTarget self, str const ** symbol_name, uint32_t name_type_mask, SBFileSpecList module_list, SBFileSpecList comp_unit_list) -> SBBreakpoint
| BreakpointCreateByNames(SBTarget self, str const ** symbol_name, uint32_t name_type_mask, lldb::LanguageType symbol_language, SBFileSpecList module_list, SBFileSpecList comp_unit_list) -> SBBreakpoint
| BreakpointCreateByNames(SBTarget self, str const ** symbol_name, uint32_t name_type_mask, lldb::LanguageType symbol_language, lldb::addr_t offset, SBFileSpecList module_list, SBFileSpecList comp_unit_list) -> SBBreakpoint
|
| BreakpointCreateByRegex(self, *args)
| BreakpointCreateByRegex(SBTarget self, str const * symbol_name_regex, str const * module_name=None) -> SBBreakpoint
| BreakpointCreateByRegex(SBTarget self, str const * symbol_name_regex) -> SBBreakpoint
| BreakpointCreateByRegex(SBTarget self, str const * symbol_name_regex, lldb::LanguageType symbol_language, SBFileSpecList module_list, SBFileSpecList comp_unit_list) -> SBBreakpoint
|
| BreakpointCreateBySBAddress(self, sb_address)
| BreakpointCreateBySBAddress(SBTarget self, SBAddress sb_address) -> SBBreakpoint
|
| BreakpointCreateBySourceRegex(self, *args)
| BreakpointCreateBySourceRegex(SBTarget self, str const * source_regex, SBFileSpec source_file, str const * module_name=None) -> SBBreakpoint
| BreakpointCreateBySourceRegex(SBTarget self, str const * source_regex, SBFileSpec source_file) -> SBBreakpoint
| BreakpointCreateBySourceRegex(SBTarget self, str const * source_regex, SBFileSpecList module_list, SBFileSpecList file_list) -> SBBreakpoint
| BreakpointCreateBySourceRegex(SBTarget self, str const * source_regex, SBFileSpecList module_list, SBFileSpecList source_file, SBStringList func_names) -> SBBreakpoint
|
| BreakpointCreateForException(self, *args)
| BreakpointCreateForException(SBTarget self, lldb::LanguageType language, bool catch_bp, bool throw_bp) -> SBBreakpoint
| BreakpointCreateForException(SBTarget self, lldb::LanguageType language, bool catch_bp, bool throw_bp, SBStringList extra_args) -> SBBreakpoint
|
| BreakpointCreateFromScript(self, class_name, extra_args, module_list, file_list, request_hardware=False)
| BreakpointCreateFromScript(SBTarget self, str const * class_name, SBStructuredData extra_args, SBFileSpecList module_list, SBFileSpecList file_list, bool request_hardware=False) -> SBBreakpoint
| BreakpointCreateFromScript(SBTarget self, str const * class_name, SBStructuredData extra_args, SBFileSpecList module_list, SBFileSpecList file_list) -> SBBreakpoint
|
|
| Create a breakpoint using a scripted resolver.
|
| @param[in] class_name
| This is the name of the class that implements a scripted resolver.
| The class should have the following signature:
| class Resolver:
| def init(self, bkpt, extra_args):
| # bkpt - the breakpoint for which this is the resolver. When
| # the resolver finds an interesting address, call AddLocation
| # on this breakpoint to add it.
| #
| # extra_args - an SBStructuredData that can be used to
| # parametrize this instance. Same as the extra_args passed
| # to BreakpointCreateFromScript.
|
| def get_depth (self):
| # This is optional, but if defined, you should return the
| # depth at which you want the callback to be called. The
| # available options are:
| # lldb.eSearchDepthModule
| # lldb.eSearchDepthCompUnit
| # The default if you don’t implement this method is
| # eSearchDepthModule.
|
| def callback(self, sym_ctx):
| # sym_ctx - an SBSymbolContext that is the cursor in the
| # search through the program to resolve breakpoints.
| # The sym_ctx will be filled out to the depth requested in
| # get_depth.
| # Look in this sym_ctx for new breakpoint locations,
| # and if found use bkpt.AddLocation to add them.
| # Note, you will only get called for modules/compile_units that
| # pass the SearchFilter provided by the module_list & file_list
| # passed into BreakpointCreateFromScript.
|
| def get_short_help(self):
| # Optional, but if implemented return a short string that will
| # be printed at the beginning of the break list output for the
| # breakpoint.
|
| @param[in] extra_args
| This is an SBStructuredData object that will get passed to the
| constructor of the class in class_name. You can use this to
| reuse the same class, parametrizing it with entries from this
| dictionary.
|
| @param module_list
| If this is non-empty, this will be used as the module filter in the
| SearchFilter created for this breakpoint.
|
| @param file_list
| If this is non-empty, this will be used as the comp unit filter in the
| SearchFilter created for this breakpoint.
|
| @return
| An SBBreakpoint that will set locations based on the logic in the
| resolver’s search callback.
|
| BreakpointDelete(self, break_id)
| BreakpointDelete(SBTarget self, lldb::break_id_t break_id) -> bool
|
| BreakpointsCreateFromFile(self, *args)
| BreakpointsCreateFromFile(SBTarget self, SBFileSpec source_file, SBBreakpointList bkpt_list) -> SBError
| BreakpointsCreateFromFile(SBTarget self, SBFileSpec source_file, SBStringList matching_names, SBBreakpointList new_bps) -> SBError
|
|
| Read breakpoints from source_file and return the newly created
| breakpoints in bkpt_list.
|
| @param[in] source_file
| The file from which to read the breakpoints
|
| @param[in] matching_names
| Only read in breakpoints whose names match one of the names in this
| list.
|
| @param[out] bkpt_list
| A list of the newly created breakpoints.
|
| @return
| An SBError detailing any errors in reading in the breakpoints.
|
| BreakpointsWriteToFile(self, *args)
| BreakpointsWriteToFile(SBTarget self, SBFileSpec dest_file) -> SBError
| BreakpointsWriteToFile(SBTarget self, SBFileSpec dest_file, SBBreakpointList bkpt_list, bool append=False) -> SBError
| BreakpointsWriteToFile(SBTarget self, SBFileSpec dest_file, SBBreakpointList bkpt_list) -> SBError
|
| Clear(self)
| Clear(SBTarget self)
|
| ClearModuleLoadAddress(self, module)
| ClearModuleLoadAddress(SBTarget self, SBModule module) -> SBError
|
| ClearSectionLoadAddress(self, section)
| ClearSectionLoadAddress(SBTarget self, SBSection section) -> SBError
|
| ConnectRemote(self, listener, url, plugin_name, error)
| ConnectRemote(SBTarget self, SBListener listener, str const * url, str const * plugin_name, SBError error) -> SBProcess
|
|
| Connect to a remote debug server with url.
|
| @param[in] listener
| An optional listener that will receive all process events.
| If listener is valid then listener will listen to all
| process events. If not valid, then this target’s debugger
| (SBTarget::GetDebugger()) will listen to all process events.
|
| @param[in] url
| The url to connect to, e.g., ‘connect://localhost:12345’.
|
| @param[in] plugin_name
| The plugin name to be used; can be NULL.
|
| @param[out]
| An error explaining what went wrong if the connect fails.
|
| @return
| A process object for the connected process.
|
| CreateValueFromAddress(self, name, addr, type)
| CreateValueFromAddress(SBTarget self, str const * name, SBAddress addr, SBType type) -> SBValue
|
|
| Create an SBValue with the given name by treating the memory starting at addr as an entity of type.
|
| @param[in] name
| The name of the resultant SBValue
|
| @param[in] addr
| The address of the start of the memory region to be used.
|
| @param[in] type
| The type to use to interpret the memory starting at addr.
|
| @return
| An SBValue of the given type, may be invalid if there was an error reading
| the underlying memory.
|
| CreateValueFromData(self, name, data, type)
| CreateValueFromData(SBTarget self, str const * name, SBData data, SBType type) -> SBValue
|
| CreateValueFromExpression(self, name, expr)
| CreateValueFromExpression(SBTarget self, str const * name, str const * expr) -> SBValue
|
| DeleteAllBreakpoints(self)
| DeleteAllBreakpoints(SBTarget self) -> bool
|
| DeleteAllWatchpoints(self)
| DeleteAllWatchpoints(SBTarget self) -> bool
|
| DeleteBreakpointName(self, name)
| DeleteBreakpointName(SBTarget self, str const * name)
|
| DeleteWatchpoint(self, watch_id)
| DeleteWatchpoint(SBTarget self, lldb::watch_id_t watch_id) -> bool
|
| DisableAllBreakpoints(self)
| DisableAllBreakpoints(SBTarget self) -> bool
|
| DisableAllWatchpoints(self)
| DisableAllWatchpoints(SBTarget self) -> bool
|
| EnableAllBreakpoints(self)
| EnableAllBreakpoints(SBTarget self) -> bool
|
| EnableAllWatchpoints(self)
| EnableAllWatchpoints(SBTarget self) -> bool
|
| EvaluateExpression(self, *args)
| EvaluateExpression(SBTarget self, str const * expr) -> SBValue
| EvaluateExpression(SBTarget self, str const * expr, SBExpressionOptions options) -> SBValue
|
| FindBreakpointByID(self, break_id)
| FindBreakpointByID(SBTarget self, lldb::break_id_t break_id) -> SBBreakpoint
|
| FindBreakpointsByName(self, name, bkpt_list)
| FindBreakpointsByName(SBTarget self, str const * name, SBBreakpointList bkpt_list) -> bool
|
| FindCompileUnits(self, sb_file_spec)
| FindCompileUnits(SBTarget self, SBFileSpec sb_file_spec) -> SBSymbolContextList
|
|
| Find compile units related to *this target and passed source
| file.
|
| @param[in] sb_file_spec
| A lldb::SBFileSpec object that contains source file
| specification.
|
| @return
| A lldb::SBSymbolContextList that gets filled in with all of
| the symbol contexts for all the matches.
|
| FindFirstGlobalVariable(self, name)
| FindFirstGlobalVariable(SBTarget self, str const * name) -> SBValue
|
|
| Find the first global (or static) variable by name.
|
| @param[in] name
| The name of the global or static variable we are looking
| for.
|
| @return
| An SBValue that gets filled in with the found variable (if any).
|
| FindFirstType(self, type)
| FindFirstType(SBTarget self, str const * type) -> SBType
|
| FindFunctions(self, *args)
| FindFunctions(SBTarget self, str const * name, uint32_t name_type_mask) -> SBSymbolContextList
| FindFunctions(SBTarget self, str const * name) -> SBSymbolContextList
|
|
| Find functions by name.
|
| @param[in] name
| The name of the function we are looking for.
|
| @param[in] name_type_mask
| A logical OR of one or more FunctionNameType enum bits that
| indicate what kind of names should be used when doing the
| lookup. Bits include fully qualified names, base names,
| C++ methods, or ObjC selectors.
| See FunctionNameType for more details.
|
| @return
| A lldb::SBSymbolContextList that gets filled in with all of
| the symbol contexts for all the matches.
|
| FindGlobalFunctions(self, name, max_matches, matchtype)
| FindGlobalFunctions(SBTarget self, str const * name, uint32_t max_matches, lldb::MatchType matchtype) -> SBSymbolContextList
|
| FindGlobalVariables(self, *args)
| FindGlobalVariables(SBTarget self, str const * name, uint32_t max_matches) -> SBValueList
| FindGlobalVariables(SBTarget self, str const * name, uint32_t max_matches, lldb::MatchType matchtype) -> SBValueList
|
|
| Find global and static variables by name.
|
| @param[in] name
| The name of the global or static variable we are looking
| for.
|
| @param[in] max_matches
| Allow the number of matches to be limited to max_matches.
|
| @return
| A list of matched variables in an SBValueList.
|
| FindModule(self, file_spec)
| FindModule(SBTarget self, SBFileSpec file_spec) -> SBModule
|
| FindSymbols(self, *args)
| FindSymbols(SBTarget self, str const * name, lldb::SymbolType type) -> SBSymbolContextList
| FindSymbols(SBTarget self, str const * name) -> SBSymbolContextList
|
| FindTypes(self, type)
| FindTypes(SBTarget self, str const * type) -> SBTypeList
|
| FindWatchpointByID(self, watch_id)
| FindWatchpointByID(SBTarget self, lldb::watch_id_t watch_id) -> SBWatchpoint
|
| GetAddressByteSize(self)
| GetAddressByteSize(SBTarget self) -> uint32_t
|
| GetBasicType(self, type)
| GetBasicType(SBTarget self, lldb::BasicType type) -> SBType
|
| GetBreakpointAtIndex(self, idx)
| GetBreakpointAtIndex(SBTarget self, uint32_t idx) -> SBBreakpoint
|
| GetBreakpointNames(self, names)
| GetBreakpointNames(SBTarget self, SBStringList names)
|
| GetBroadcaster(self)
| GetBroadcaster(SBTarget self) -> SBBroadcaster
|
| GetByteOrder(self)
| GetByteOrder(SBTarget self) -> lldb::ByteOrder
|
| GetCodeByteSize(self)
| GetCodeByteSize(SBTarget self) -> uint32_t
|
|
| Architecture code byte width accessor
|
| @return
| The size in 8-bit (host) bytes of a minimum addressable
| unit from the Architecture’s code bus
|
| GetCollectingStats(self)
| GetCollectingStats(SBTarget self) -> bool
|
| GetDataByteSize(self)
| GetDataByteSize(SBTarget self) -> uint32_t
|
|
| Architecture data byte width accessor
|
| @return
| The size in 8-bit (host) bytes of a minimum addressable
| unit from the Architecture’s data bus
|
| GetDebugger(self)
| GetDebugger(SBTarget self) -> SBDebugger
|
| GetDescription(self, description, description_level)
| GetDescription(SBTarget self, SBStream description, lldb::DescriptionLevel description_level) -> bool
|
| GetExecutable(self)
| GetExecutable(SBTarget self) -> SBFileSpec
|
| GetInstructions(self, base_addr, buf)
| GetInstructions(SBTarget self, SBAddress base_addr, void const * buf) -> SBInstructionList
|
|
| Disassemble the bytes in a buffer and return them in an SBInstructionList.
| Parameters:
| base_addr – used for symbolicating the offsets in the byte stream when disassembling
| buf – bytes to be disassembled
| size – (C++) size of the buffer
| Returns an SBInstructionList.
|
| GetInstructionsWithFlavor(self, base_addr, flavor_string, buf)
| GetInstructionsWithFlavor(SBTarget self, SBAddress base_addr, str const * flavor_string, void const * buf) -> SBInstructionList
|
|
| Disassemble the bytes in a buffer and return them in an SBInstructionList, with a supplied flavor.
| Parameters:
| base_addr – used for symbolicating the offsets in the byte stream when disassembling
| flavor – may be ‘intel’ or ‘att’ on x86 targets to specify that style of disassembly
| buf – bytes to be disassembled
| size – (C++) size of the buffer
| Returns an SBInstructionList.
|
| GetLaunchInfo(self)
| GetLaunchInfo(SBTarget self) -> SBLaunchInfo
|
| GetModuleAtIndex(self, idx)
| GetModuleAtIndex(SBTarget self, uint32_t idx) -> SBModule
|
| GetNumBreakpoints(self)
| GetNumBreakpoints(SBTarget self) -> uint32_t
|
| GetNumModules(self)
| GetNumModules(SBTarget self) -> uint32_t
|
| GetNumWatchpoints(self)
| GetNumWatchpoints(SBTarget self) -> uint32_t
|
| GetPlatform(self)
| GetPlatform(SBTarget self) -> SBPlatform
|
|
| Return the platform object associated with the target.
|
| After return, the platform object should be checked for
| validity.
|
| @return
| A platform object.
|
| GetProcess(self)
| GetProcess(SBTarget self) -> SBProcess
|
| GetSourceManager(self)
| GetSourceManager(SBTarget self) -> SBSourceManager
|
| GetStackRedZoneSize(self)
| GetStackRedZoneSize(SBTarget self) -> lldb::addr_t
|
| GetStatistics(self)
| GetStatistics(SBTarget self) -> SBStructuredData
|
| GetTriple(self)
| GetTriple(SBTarget self) -> str const *
|
| GetWatchpointAtIndex(self, idx)
| GetWatchpointAtIndex(SBTarget self, uint32_t idx) -> SBWatchpoint
|
| Install(self)
| Install(SBTarget self) -> SBError
|
|
| Install any binaries that need to be installed.
|
| This function does nothing when debugging on the host system.
| When connected to remote platforms, the target’s main executable
| and any modules that have their install path set will be
| installed on the remote platform. If the main executable doesn’t
| have an install location set, it will be installed in the remote
| platform’s working directory.
|
| @return
| An error describing anything that went wrong during
| installation.
|
| IsValid(self)
| IsValid(SBTarget self) -> bool
|
| Launch(self, *args)
| Launch(SBTarget self, SBListener listener, str const ** argv, str const ** envp, str const * stdin_path, str const * stdout_path, str const * stderr_path, str const * working_directory, uint32_t launch_flags, bool stop_at_entry, SBError error) -> SBProcess
| Launch(SBTarget self, SBLaunchInfo launch_info, SBError error) -> SBProcess
|
|
| Launch a new process.
|
| Launch a new process by spawning a new process using the
| target object’s executable module’s file as the file to launch.
| Arguments are given in argv, and the environment variables
| are in envp. Standard input and output files can be
| optionally re-directed to stdin_path, stdout_path, and
| stderr_path.
|
| @param[in] listener
| An optional listener that will receive all process events.
| If listener is valid then listener will listen to all
| process events. If not valid, then this target’s debugger
| (SBTarget::GetDebugger()) will listen to all process events.
|
| @param[in] argv
| The argument array.
|
| @param[in] envp
| The environment array.
|
| @param[in] launch_flags
| Flags to modify the launch (@see lldb::LaunchFlags)
|
| @param[in] stdin_path
| The path to use when re-directing the STDIN of the new
| process. If all stdXX_path arguments are NULL, a pseudo
| terminal will be used.
|
| @param[in] stdout_path
| The path to use when re-directing the STDOUT of the new
| process. If all stdXX_path arguments are NULL, a pseudo
| terminal will be used.
|
| @param[in] stderr_path
| The path to use when re-directing the STDERR of the new
| process. If all stdXX_path arguments are NULL, a pseudo
| terminal will be used.
|
| @param[in] working_directory
| The working directory to have the child process run in
|
| @param[in] launch_flags
| Some launch options specified by logical OR’ing
| lldb::LaunchFlags enumeration values together.
|
| @param[in] stop_at_entry
| If false do not stop the inferior at the entry point.
|
| @param[out]
| An error object. Contains the reason if there is some failure.
|
| @return
| A process object for the newly created process.
|
| For example,
|
| process = target.Launch(self.dbg.GetListener(), None, None,
| None, ‘/tmp/stdout.txt’, None,
| None, 0, False, error)
|
| launches a new process by passing nothing for both the args and the envs
| and redirect the standard output of the inferior to the /tmp/stdout.txt
| file. It does not specify a working directory so that the debug server
| will use its idea of what the current working directory is for the
| inferior. Also, we ask the debugger not to stop the inferior at the
| entry point. If no breakpoint is specified for the inferior, it should
| run to completion if no user interaction is required.
|
| LaunchSimple(self, argv, envp, working_directory)
| LaunchSimple(SBTarget self, str const ** argv, str const ** envp, str const * working_directory) -> SBProcess
|
|
| Launch a new process with sensible defaults.
|
| @param[in] argv
| The argument array.
|
| @param[in] envp
| The environment array.
|
| @param[in] working_directory
| The working directory to have the child process run in
|
| Default: listener
| Set to the target’s debugger (SBTarget::GetDebugger())
|
| Default: launch_flags
| Empty launch flags
|
| Default: stdin_path
| Default: stdout_path
| Default: stderr_path
| A pseudo terminal will be used.
|
| @return
| A process object for the newly created process.
|
| For example,
|
| process = target.LaunchSimple([‘X’, ‘Y’, ‘Z’], None, os.getcwd())
|
| launches a new process by passing ‘X’, ‘Y’, ‘Z’ as the args to the
| executable.
|
| LoadCore(self, *args)
| LoadCore(SBTarget self, str const * core_file) -> SBProcess
| LoadCore(SBTarget self, str const * core_file, SBError error) -> SBProcess
|
|
| Load a core file
|
| @param[in] core_file
| File path of the core dump.
|
| @param[out] error
| An error explaining what went wrong if the operation fails.
| (Optional)
|
| @return
| A process object for the newly created core file.
|
| For example,
|
| process = target.LoadCore(’./a.out.core’)
|
| loads a new core file and returns the process object.
|
| ReadInstructions(self, *args)
| ReadInstructions(SBTarget self, SBAddress base_addr, uint32_t count) -> SBInstructionList
| ReadInstructions(SBTarget self, SBAddress base_addr, uint32_t count, str const * flavor_string) -> SBInstructionList
|
|
| Disassemble a specified number of instructions starting at an address.
| Parameters:
| base_addr – the address to start disassembly from
| count – the number of instructions to disassemble
| flavor_string – may be ‘intel’ or ‘att’ on x86 targets to specify that style of disassembly
| Returns an SBInstructionList.
|
| ReadMemory(self, addr, buf, error)
| ReadMemory(SBTarget self, SBAddress addr, void * buf, SBError error) -> size_t
|
|
| Read target memory. If a target process is running then memory
| is read from here. Otherwise the memory is read from the object
| files. For a target whose bytes are sized as a multiple of host
| bytes, the data read back will preserve the target’s byte order.
|
| @param[in] addr
| A target address to read from.
|
| @param[out] buf
| The buffer to read memory into.
|
| @param[in] size
| The maximum number of host bytes to read in the buffer passed
| into this call
|
| @param[out] error
| Error information is written here if the memory read fails.
|
| @return
| The amount of data read in host bytes.
|
| RemoveModule(self, module)
| RemoveModule(SBTarget self, SBModule module) -> bool
|
| ResolveFileAddress(self, file_addr)
| ResolveFileAddress(SBTarget self, lldb::addr_t file_addr) -> SBAddress
|
|
| Resolve a current file address into a section offset address.
|
| @param[in] file_addr
|
| @return
| An SBAddress which will be valid if…
|
| ResolveLoadAddress(self, vm_addr)
| ResolveLoadAddress(SBTarget self, lldb::addr_t vm_addr) -> SBAddress
|
| ResolvePastLoadAddress(self, stop_id, vm_addr)
| ResolvePastLoadAddress(SBTarget self, uint32_t stop_id, lldb::addr_t vm_addr) -> SBAddress
|
| ResolveSymbolContextForAddress(self, addr, resolve_scope)
| ResolveSymbolContextForAddress(SBTarget self, SBAddress addr, uint32_t resolve_scope) -> SBSymbolContext
|
| SetCollectingStats(self, v)
| SetCollectingStats(SBTarget self, bool v)
|
| SetLaunchInfo(self, launch_info)
| SetLaunchInfo(SBTarget self, SBLaunchInfo launch_info)
|
| SetModuleLoadAddress(self, module, sections_offset)
| SetModuleLoadAddress(SBTarget self, SBModule module, int64_t sections_offset) -> SBError
|
| SetSectionLoadAddress(self, section, section_base_addr)
| SetSectionLoadAddress(SBTarget self, SBSection section, lldb::addr_t section_base_addr) -> SBError
|
| WatchAddress(self, addr, size, read, write, error)
| WatchAddress(SBTarget self, lldb::addr_t addr, size_t size, bool read, bool write, SBError error) -> SBWatchpoint
|
| bool = nonzero(self)
|
| del lambda self
|
| eq(self, rhs)
| Return self==value.
|
| getattr lambda self, name
|
| init(self, *args)
| init(lldb::SBTarget self) -> SBTarget
| init(lldb::SBTarget self, SBTarget rhs) -> SBTarget
|
| ne(self, rhs)
| Return self!=value.
|
| nonzero(self)
|
| repr = _swig_repr(self)
|
| setattr lambda self, name, value
|
| str(self)
| str(SBTarget self) -> PyObject *
|
| breakpoint_iter(self)
|
| get_modules_access_object(self)
| An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.
|
| get_modules_array(self)
| An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.
|
| module_iter(self)
|
| watchpoint_iter(self)
list of weak references to the object (if defined)
addr_size
A read only property that returns the size in bytes of an address for this target.
broadcaster
A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this target.
byte_order
A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this target.
code_byte_size
A read only property that returns the size in host bytes of a byte in the code address space for this target.
data_byte_size
A read only property that returns the size in host bytes of a byte in the data address space for this target.
debugger
A read only property that returns an lldb object that represents the debugger (lldb.SBDebugger) that owns this target.
executable
A read only property that returns an lldb object that represents the main executable module (lldb.SBModule) for this target.
module
A read only property that returns an object that implements python operator overloading with the square brackets().\n target.module[] allows array access to any modules.\n target.module[] allows access to modules by basename, full path, or uuid string value.\n target.module[uuid.UUID()] allows module access by UUID.\n target.module[re] allows module access using a regular expression that matches the module full path.
modules
A read only property that returns a list() of lldb.SBModule objects contained in this target. This list is a list all modules that the target currently is tracking (the main executable and all dependent shared libraries).
num_breakpoints
A read only property that returns the number of breakpoints that this target has as an integer.
num_watchpoints
A read only property that returns the number of watchpoints that this target has as an integer.
platform
A read only property that returns the platform associated with with this target.
process
A read only property that returns an lldb object that represents the process (lldb.SBProcess) that this target owns.
triple
A read only property that returns the target triple (arch-vendor-os) for this target as a string.
list of weak references to the object (if defined)
addr
A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this section.
data
A read only property that returns an lldb object that represents the bytes for this section (lldb.SBData) for this section.
file_addr
A read only property that returns an integer that represents the starting “file” address for this section, or the address of the section in the object file in which it is defined.
file_offset
A read only property that returns the file offset in bytes of this section as an integer.
file_size
A read only property that returns the file size in bytes of this section as an integer.
name
A read only property that returns the name of this section as a string.
size
A read only property that returns the size in bytes of this section as an integer.
target_byte_size
A read only property that returns the size of a target byte represented by this section as a number of host bytes.
type
A read only property that returns an lldb enumeration value (see enumerations that start with “lldb.eSectionType”) that represents the type of this section (code, data, etc.).