1*662548c8SAlex Langford %feature("docstring", 2*662548c8SAlex Langford "Represents an executable image and its associated object and symbol files. 3*662548c8SAlex Langford 4*662548c8SAlex Langford The module is designed to be able to select a single slice of an 5*662548c8SAlex Langford executable image as it would appear on disk and during program 6*662548c8SAlex Langford execution. 7*662548c8SAlex Langford 8*662548c8SAlex Langford You can retrieve SBModule from :py:class:`SBSymbolContext` , which in turn is available 9*662548c8SAlex Langford from SBFrame. 10*662548c8SAlex Langford 11*662548c8SAlex Langford SBModule supports symbol iteration, for example, :: 12*662548c8SAlex Langford 13*662548c8SAlex Langford for symbol in module: 14*662548c8SAlex Langford name = symbol.GetName() 15*662548c8SAlex Langford saddr = symbol.GetStartAddress() 16*662548c8SAlex Langford eaddr = symbol.GetEndAddress() 17*662548c8SAlex Langford 18*662548c8SAlex Langford and rich comparison methods which allow the API program to use, :: 19*662548c8SAlex Langford 20*662548c8SAlex Langford if thisModule == thatModule: 21*662548c8SAlex Langford print('This module is the same as that module') 22*662548c8SAlex Langford 23*662548c8SAlex Langford to test module equality. A module also contains object file sections, namely 24*662548c8SAlex Langford :py:class:`SBSection` . SBModule supports section iteration through section_iter(), for 25*662548c8SAlex Langford example, :: 26*662548c8SAlex Langford 27*662548c8SAlex Langford print('Number of sections: %d' % module.GetNumSections()) 28*662548c8SAlex Langford for sec in module.section_iter(): 29*662548c8SAlex Langford print(sec) 30*662548c8SAlex Langford 31*662548c8SAlex Langford And to iterate the symbols within a SBSection, use symbol_in_section_iter(), :: 32*662548c8SAlex Langford 33*662548c8SAlex Langford # Iterates the text section and prints each symbols within each sub-section. 34*662548c8SAlex Langford for subsec in text_sec: 35*662548c8SAlex Langford print(INDENT + repr(subsec)) 36*662548c8SAlex Langford for sym in exe_module.symbol_in_section_iter(subsec): 37*662548c8SAlex Langford print(INDENT2 + repr(sym)) 38*662548c8SAlex Langford print(INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType())) 39*662548c8SAlex Langford 40*662548c8SAlex Langford produces this following output: :: 41*662548c8SAlex Langford 42*662548c8SAlex Langford [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text 43*662548c8SAlex Langford id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870) 44*662548c8SAlex Langford symbol type: code 45*662548c8SAlex Langford id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0) 46*662548c8SAlex Langford symbol type: code 47*662548c8SAlex Langford id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c) 48*662548c8SAlex Langford symbol type: code 49*662548c8SAlex Langford id = {0x00000023}, name = 'start', address = 0x0000000100001780 50*662548c8SAlex Langford symbol type: code 51*662548c8SAlex Langford [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs 52*662548c8SAlex Langford id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62) 53*662548c8SAlex Langford symbol type: trampoline 54*662548c8SAlex Langford id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68) 55*662548c8SAlex Langford symbol type: trampoline 56*662548c8SAlex Langford id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e) 57*662548c8SAlex Langford symbol type: trampoline 58*662548c8SAlex Langford id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74) 59*662548c8SAlex Langford symbol type: trampoline 60*662548c8SAlex Langford id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a) 61*662548c8SAlex Langford symbol type: trampoline 62*662548c8SAlex Langford id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80) 63*662548c8SAlex Langford symbol type: trampoline 64*662548c8SAlex Langford id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86) 65*662548c8SAlex Langford symbol type: trampoline 66*662548c8SAlex Langford id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c) 67*662548c8SAlex Langford symbol type: trampoline 68*662548c8SAlex Langford id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92) 69*662548c8SAlex Langford symbol type: trampoline 70*662548c8SAlex Langford id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98) 71*662548c8SAlex Langford symbol type: trampoline 72*662548c8SAlex Langford id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e) 73*662548c8SAlex Langford symbol type: trampoline 74*662548c8SAlex Langford id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4) 75*662548c8SAlex Langford symbol type: trampoline 76*662548c8SAlex Langford [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper 77*662548c8SAlex Langford [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring 78*662548c8SAlex Langford [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info 79*662548c8SAlex Langford [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame 80*662548c8SAlex Langford " 81*662548c8SAlex Langford ) lldb::SBModule; 82*662548c8SAlex Langford 83*662548c8SAlex Langford %feature("docstring", " 84*662548c8SAlex Langford Check if the module is file backed. 85*662548c8SAlex Langford 86*662548c8SAlex Langford @return 87*662548c8SAlex Langford 88*662548c8SAlex Langford True, if the module is backed by an object file on disk. 89*662548c8SAlex Langford False, if the module is backed by an object file in memory." 90*662548c8SAlex Langford ) lldb::SBModule::IsFileBacked; 91*662548c8SAlex Langford 92*662548c8SAlex Langford %feature("docstring", " 93*662548c8SAlex Langford Get const accessor for the module file specification. 94*662548c8SAlex Langford 95*662548c8SAlex Langford This function returns the file for the module on the host system 96*662548c8SAlex Langford that is running LLDB. This can differ from the path on the 97*662548c8SAlex Langford platform since we might be doing remote debugging. 98*662548c8SAlex Langford 99*662548c8SAlex Langford @return 100*662548c8SAlex Langford A const reference to the file specification object." 101*662548c8SAlex Langford ) lldb::SBModule::GetFileSpec; 102*662548c8SAlex Langford 103*662548c8SAlex Langford %feature("docstring", " 104*662548c8SAlex Langford Get accessor for the module platform file specification. 105*662548c8SAlex Langford 106*662548c8SAlex Langford Platform file refers to the path of the module as it is known on 107*662548c8SAlex Langford the remote system on which it is being debugged. For local 108*662548c8SAlex Langford debugging this is always the same as Module::GetFileSpec(). But 109*662548c8SAlex Langford remote debugging might mention a file '/usr/lib/liba.dylib' 110*662548c8SAlex Langford which might be locally downloaded and cached. In this case the 111*662548c8SAlex Langford platform file could be something like: 112*662548c8SAlex Langford '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib' 113*662548c8SAlex Langford The file could also be cached in a local developer kit directory. 114*662548c8SAlex Langford 115*662548c8SAlex Langford @return 116*662548c8SAlex Langford A const reference to the file specification object." 117*662548c8SAlex Langford ) lldb::SBModule::GetPlatformFileSpec; 118*662548c8SAlex Langford 119*662548c8SAlex Langford %feature("docstring", "Returns the UUID of the module as a Python string." 120*662548c8SAlex Langford ) lldb::SBModule::GetUUIDString; 121*662548c8SAlex Langford 122*662548c8SAlex Langford %feature("docstring", " 123*662548c8SAlex Langford Find compile units related to this module and passed source 124*662548c8SAlex Langford file. 125*662548c8SAlex Langford 126*662548c8SAlex Langford @param[in] sb_file_spec 127*662548c8SAlex Langford A :py:class:`SBFileSpec` object that contains source file 128*662548c8SAlex Langford specification. 129*662548c8SAlex Langford 130*662548c8SAlex Langford @return 131*662548c8SAlex Langford A :py:class:`SBSymbolContextList` that gets filled in with all of 132*662548c8SAlex Langford the symbol contexts for all the matches." 133*662548c8SAlex Langford ) lldb::SBModule::FindCompileUnits; 134*662548c8SAlex Langford 135*662548c8SAlex Langford %feature("docstring", " 136*662548c8SAlex Langford Find functions by name. 137*662548c8SAlex Langford 138*662548c8SAlex Langford @param[in] name 139*662548c8SAlex Langford The name of the function we are looking for. 140*662548c8SAlex Langford 141*662548c8SAlex Langford @param[in] name_type_mask 142*662548c8SAlex Langford A logical OR of one or more FunctionNameType enum bits that 143*662548c8SAlex Langford indicate what kind of names should be used when doing the 144*662548c8SAlex Langford lookup. Bits include fully qualified names, base names, 145*662548c8SAlex Langford C++ methods, or ObjC selectors. 146*662548c8SAlex Langford See FunctionNameType for more details. 147*662548c8SAlex Langford 148*662548c8SAlex Langford @return 149*662548c8SAlex Langford A symbol context list that gets filled in with all of the 150*662548c8SAlex Langford matches." 151*662548c8SAlex Langford ) lldb::SBModule::FindFunctions; 152*662548c8SAlex Langford 153*662548c8SAlex Langford %feature("docstring", " 154*662548c8SAlex Langford Get all types matching type_mask from debug info in this 155*662548c8SAlex Langford module. 156*662548c8SAlex Langford 157*662548c8SAlex Langford @param[in] type_mask 158*662548c8SAlex Langford A bitfield that consists of one or more bits logically OR'ed 159*662548c8SAlex Langford together from the lldb::TypeClass enumeration. This allows 160*662548c8SAlex Langford you to request only structure types, or only class, struct 161*662548c8SAlex Langford and union types. Passing in lldb::eTypeClassAny will return 162*662548c8SAlex Langford all types found in the debug information for this module. 163*662548c8SAlex Langford 164*662548c8SAlex Langford @return 165*662548c8SAlex Langford A list of types in this module that match type_mask" 166*662548c8SAlex Langford ) lldb::SBModule::GetTypes; 167*662548c8SAlex Langford 168*662548c8SAlex Langford %feature("docstring", " 169*662548c8SAlex Langford Find global and static variables by name. 170*662548c8SAlex Langford 171*662548c8SAlex Langford @param[in] target 172*662548c8SAlex Langford A valid SBTarget instance representing the debuggee. 173*662548c8SAlex Langford 174*662548c8SAlex Langford @param[in] name 175*662548c8SAlex Langford The name of the global or static variable we are looking 176*662548c8SAlex Langford for. 177*662548c8SAlex Langford 178*662548c8SAlex Langford @param[in] max_matches 179*662548c8SAlex Langford Allow the number of matches to be limited to max_matches. 180*662548c8SAlex Langford 181*662548c8SAlex Langford @return 182*662548c8SAlex Langford A list of matched variables in an SBValueList." 183*662548c8SAlex Langford ) lldb::SBModule::FindGlobalVariables; 184*662548c8SAlex Langford 185*662548c8SAlex Langford %feature("docstring", " 186*662548c8SAlex Langford Find the first global (or static) variable by name. 187*662548c8SAlex Langford 188*662548c8SAlex Langford @param[in] target 189*662548c8SAlex Langford A valid SBTarget instance representing the debuggee. 190*662548c8SAlex Langford 191*662548c8SAlex Langford @param[in] name 192*662548c8SAlex Langford The name of the global or static variable we are looking 193*662548c8SAlex Langford for. 194*662548c8SAlex Langford 195*662548c8SAlex Langford @return 196*662548c8SAlex Langford An SBValue that gets filled in with the found variable (if any)." 197*662548c8SAlex Langford ) lldb::SBModule::FindFirstGlobalVariable; 198*662548c8SAlex Langford 199*662548c8SAlex Langford %feature("docstring", " 200*662548c8SAlex Langford Returns the number of modules in the module cache. This is an 201*662548c8SAlex Langford implementation detail exposed for testing and should not be relied upon. 202*662548c8SAlex Langford 203*662548c8SAlex Langford @return 204*662548c8SAlex Langford The number of modules in the module cache." 205*662548c8SAlex Langford ) lldb::SBModule::GetNumberAllocatedModules; 206*662548c8SAlex Langford 207*662548c8SAlex Langford %feature("docstring", " 208*662548c8SAlex Langford Removes all modules which are no longer needed by any part of LLDB from 209*662548c8SAlex Langford the module cache. 210*662548c8SAlex Langford 211*662548c8SAlex Langford This is an implementation detail exposed for testing and should not be 212*662548c8SAlex Langford relied upon. Use SBDebugger::MemoryPressureDetected instead to reduce 213*662548c8SAlex Langford LLDB's memory consumption during execution. 214*662548c8SAlex Langford ") lldb::SBModule::GarbageCollectAllocatedModules; 215