Package lldb :: Class SBModule
[hide private]
[frames] | no frames]

Class SBModule

source code



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 comparion 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

Nested Classes [hide private]
  symbols_access
  sections_access
  compile_units_access
Instance Methods [hide private]
 
__setattr__(self, name, value)
x.__setattr__('name', value) <==> x.name = value
source code
 
__getattr__(self, name) source code
 
__repr__(self)
repr(x)
source code
 
__iter__(self) source code
 
__len__(self) source code
 
section_iter(self) source code
 
compile_unit_iter(self) source code
 
symbol_in_section_iter(self, section)
Given a module and its contained section, returns an iterator on the symbols within the section.
source code
 
__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
source code
 
__swig_destroy__(...)
delete_SBModule(SBModule self)
 
__del__(self) source code
 
__nonzero__(self) source code
 
IsValid(self)
IsValid(SBModule self) -> bool
source code
 
Clear(self)
Clear(SBModule self)
source code
 
GetFileSpec(self)
GetFileSpec(SBModule self) -> SBFileSpec
source code
 
GetPlatformFileSpec(self)
GetPlatformFileSpec(SBModule self) -> SBFileSpec
source code
 
SetPlatformFileSpec(self, *args)
SetPlatformFileSpec(SBModule self, SBFileSpec platform_file) -> bool
source code
 
GetUUIDString(self)
GetUUIDString(SBModule self) -> str const *
source code
 
FindSection(self, *args)
FindSection(SBModule self, str const * sect_name) -> SBSection
source code
 
ResolveFileAddress(self, *args)
ResolveFileAddress(SBModule self, lldb::addr_t vm_addr) -> SBAddress
source code
 
ResolveSymbolContextForAddress(self, *args)
ResolveSymbolContextForAddress(SBModule self, SBAddress addr, uint32_t resolve_scope) -> SBSymbolContext
source code
 
GetDescription(self, *args)
GetDescription(SBModule self, SBStream description) -> bool
source code
 
GetNumCompileUnits(self)
GetNumCompileUnits(SBModule self) -> uint32_t
source code
 
GetCompileUnitAtIndex(self, *args)
GetCompileUnitAtIndex(SBModule self, uint32_t arg2) -> SBCompileUnit
source code
 
GetNumSymbols(self)
GetNumSymbols(SBModule self) -> size_t
source code
 
GetSymbolAtIndex(self, *args)
GetSymbolAtIndex(SBModule self, size_t idx) -> SBSymbol
source code
 
FindSymbol(self, *args)
FindSymbol(SBModule self, str const * name, lldb::SymbolType type=eSymbolTypeAny) -> SBSymbol FindSymbol(SBModule self, str const * name) -> SBSymbol
source code
 
FindSymbols(self, *args)
FindSymbols(SBModule self, str const * name, lldb::SymbolType type=eSymbolTypeAny) -> SBSymbolContextList FindSymbols(SBModule self, str const * name) -> SBSymbolContextList
source code
 
GetNumSections(self)
GetNumSections(SBModule self) -> size_t
source code
 
GetSectionAtIndex(self, *args)
GetSectionAtIndex(SBModule self, size_t idx) -> SBSection
source code
 
FindFunctions(self, *args)
FindFunctions(SBModule self, str const * name, uint32_t name_type_mask=eFunctionNameTypeAny) -> SBSymbolContextList FindFunctions(SBModule self, str const * name) -> SBSymbolContextList
source code
 
FindFirstType(self, *args)
FindFirstType(SBModule self, str const * name) -> SBType
source code
 
FindTypes(self, *args)
FindTypes(SBModule self, str const * type) -> SBTypeList
source code
 
GetBasicType(self, *args)
GetBasicType(SBModule self, lldb::BasicType type) -> SBType
source code
 
GetTypes(self, *args)
GetTypes(SBModule self, uint32_t type_mask=eTypeClassAny) -> SBTypeList GetTypes(SBModule self) -> SBTypeList
source code
 
FindGlobalVariables(self, *args)
FindGlobalVariables(SBModule self, SBTarget target, str const * name, uint32_t max_matches) -> SBValueList
source code
 
FindFirstGlobalVariable(self, *args)
FindFirstGlobalVariable(SBModule self, SBTarget target, str const * name) -> SBValue
source code
 
GetByteOrder(self)
GetByteOrder(SBModule self) -> lldb::ByteOrder
source code
 
GetAddressByteSize(self)
GetAddressByteSize(SBModule self) -> uint32_t
source code
 
GetTriple(self)
GetTriple(SBModule self) -> str const *
source code
 
GetVersion(self)
GetVersion(SBModule self) -> uint32_t
source code
 
get_symbols_access_object(self)
An accessor function that returns a symbols_access() object which allows lazy symbol access from a lldb.SBModule object.
source code
 
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.
source code
 
get_symbols_array(self)
An accessor function that returns a list() that contains all symbols in a lldb.SBModule object.
source code
 
get_sections_access_object(self)
An accessor function that returns a sections_access() object which allows lazy section array access.
source code
 
get_sections_array(self)
An accessor function that returns an array object that contains all sections in this module object.
source code
 
get_compile_units_array(self)
An accessor function that returns an array object that contains all compile_units in this module object.
source code
 
get_uuid(self) source code
 
__str__(self)
__str__(SBModule self) -> PyObject *
source code
 
__eq__(self, rhs) source code
 
__ne__(self, rhs) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __sizeof__, __subclasshook__

Class Variables [hide private]
  __swig_setmethods__ = {}
  __swig_getmethods__ = {}
Properties [hide private]
  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(...)]").
  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(...)]").
  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.

Inherited from object: __class__

Method Details [hide private]

__setattr__(self, name, value)

source code 

x.__setattr__('name', value) <==> x.name = value

Overrides: object.__setattr__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__init__(self, *args)
(Constructor)

source code 

__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

Overrides: object.__init__

GetFileSpec(self)

source code 

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.

GetPlatformFileSpec(self)

source code 

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.

GetUUIDString(self)

source code 

GetUUIDString(SBModule self) -> str const *

Returns the UUID of the module as a Python string.

FindFunctions(self, *args)

source code 

FindFunctions(SBModule self, str const * name, uint32_t name_type_mask=eFunctionNameTypeAny) -> 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.

GetTypes(self, *args)

source code 

GetTypes(SBModule self, uint32_t type_mask=eTypeClassAny) -> 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

FindGlobalVariables(self, *args)

source code 

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.

FindFirstGlobalVariable(self, *args)

source code 

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).

__str__(self)
(Informal representation operator)

source code 

__str__(SBModule self) -> PyObject *

Overrides: object.__str__

Property Details [hide private]

addr_size

A read only property that returns the size in bytes of an address for this module.

Get Method:
GetAddressByteSize(self) - GetAddressByteSize(SBModule self) -> uint32_t

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.

Get Method:
GetByteOrder(self) - GetByteOrder(SBModule self) -> lldb::ByteOrder

compile_units

A read only property that returns a list() of lldb.SBCompileUnit objects contained in this module.

Get Method:
get_compile_units_array(self) - An accessor function that returns an array object that contains all compile_units in this module object.

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.

Get Method:
GetFileSpec(self) - GetFileSpec(SBModule self) -> SBFileSpec

num_sections

A read only property that returns number of sections in the module as an integer.

Get Method:
GetNumSections(self) - GetNumSections(SBModule self) -> size_t

num_symbols

A read only property that returns number of symbols in the module symbol table as an integer.

Get Method:
GetNumSymbols(self) - GetNumSymbols(SBModule self) -> size_t

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.

Get Method:
GetPlatformFileSpec(self) - GetPlatformFileSpec(SBModule self) -> SBFileSpec

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.

Get Method:
get_sections_access_object(self) - An accessor function that returns a sections_access() object which allows lazy section array access.

sections

A read only property that returns a list() of lldb.SBSection objects contained in this module.

Get Method:
get_sections_array(self) - An accessor function that returns an array object that contains all sections in this module object.

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

Get Method:
get_symbols_access_object(self) - An accessor function that returns a symbols_access() object which allows lazy symbol access from a lldb.SBModule object.

symbols

A read only property that returns a list() of lldb.SBSymbol objects contained in this module.

Get Method:
get_symbols_array(self) - An accessor function that returns a list() that contains all symbols in a lldb.SBModule object.

triple

A read only property that returns the target triple (arch-vendor-os) for this module.

Get Method:
GetTriple(self) - GetTriple(SBModule self) -> str const *

uuid

A read only property that returns a standard python uuid.UUID object that represents the UUID of this module.

Get Method:
get_uuid(self)