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