15ffd83dbSDimitry Andric //===-- SBModule.cpp ------------------------------------------------------===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #include "lldb/API/SBModule.h" 10*0b57cec5SDimitry Andric #include "SBReproducerPrivate.h" 11*0b57cec5SDimitry Andric #include "lldb/API/SBAddress.h" 12*0b57cec5SDimitry Andric #include "lldb/API/SBFileSpec.h" 13*0b57cec5SDimitry Andric #include "lldb/API/SBModuleSpec.h" 14*0b57cec5SDimitry Andric #include "lldb/API/SBProcess.h" 15*0b57cec5SDimitry Andric #include "lldb/API/SBStream.h" 16*0b57cec5SDimitry Andric #include "lldb/API/SBSymbolContextList.h" 17*0b57cec5SDimitry Andric #include "lldb/Core/Module.h" 18*0b57cec5SDimitry Andric #include "lldb/Core/Section.h" 19*0b57cec5SDimitry Andric #include "lldb/Core/ValueObjectList.h" 20*0b57cec5SDimitry Andric #include "lldb/Core/ValueObjectVariable.h" 21*0b57cec5SDimitry Andric #include "lldb/Symbol/ObjectFile.h" 22*0b57cec5SDimitry Andric #include "lldb/Symbol/SymbolFile.h" 23*0b57cec5SDimitry Andric #include "lldb/Symbol/Symtab.h" 24*0b57cec5SDimitry Andric #include "lldb/Symbol/TypeSystem.h" 25*0b57cec5SDimitry Andric #include "lldb/Symbol/VariableList.h" 26*0b57cec5SDimitry Andric #include "lldb/Target/Target.h" 27*0b57cec5SDimitry Andric #include "lldb/Utility/StreamString.h" 28*0b57cec5SDimitry Andric 29*0b57cec5SDimitry Andric using namespace lldb; 30*0b57cec5SDimitry Andric using namespace lldb_private; 31*0b57cec5SDimitry Andric 32*0b57cec5SDimitry Andric SBModule::SBModule() : m_opaque_sp() { 33*0b57cec5SDimitry Andric LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBModule); 34*0b57cec5SDimitry Andric } 35*0b57cec5SDimitry Andric 36*0b57cec5SDimitry Andric SBModule::SBModule(const lldb::ModuleSP &module_sp) : m_opaque_sp(module_sp) {} 37*0b57cec5SDimitry Andric 38*0b57cec5SDimitry Andric SBModule::SBModule(const SBModuleSpec &module_spec) : m_opaque_sp() { 39*0b57cec5SDimitry Andric LLDB_RECORD_CONSTRUCTOR(SBModule, (const lldb::SBModuleSpec &), module_spec); 40*0b57cec5SDimitry Andric 41*0b57cec5SDimitry Andric ModuleSP module_sp; 42*0b57cec5SDimitry Andric Status error = ModuleList::GetSharedModule( 43*0b57cec5SDimitry Andric *module_spec.m_opaque_up, module_sp, nullptr, nullptr, nullptr); 44*0b57cec5SDimitry Andric if (module_sp) 45*0b57cec5SDimitry Andric SetSP(module_sp); 46*0b57cec5SDimitry Andric } 47*0b57cec5SDimitry Andric 48*0b57cec5SDimitry Andric SBModule::SBModule(const SBModule &rhs) : m_opaque_sp(rhs.m_opaque_sp) { 49*0b57cec5SDimitry Andric LLDB_RECORD_CONSTRUCTOR(SBModule, (const lldb::SBModule &), rhs); 50*0b57cec5SDimitry Andric } 51*0b57cec5SDimitry Andric 52*0b57cec5SDimitry Andric SBModule::SBModule(lldb::SBProcess &process, lldb::addr_t header_addr) 53*0b57cec5SDimitry Andric : m_opaque_sp() { 54*0b57cec5SDimitry Andric LLDB_RECORD_CONSTRUCTOR(SBModule, (lldb::SBProcess &, lldb::addr_t), process, 55*0b57cec5SDimitry Andric header_addr); 56*0b57cec5SDimitry Andric 57*0b57cec5SDimitry Andric ProcessSP process_sp(process.GetSP()); 58*0b57cec5SDimitry Andric if (process_sp) { 59*0b57cec5SDimitry Andric m_opaque_sp = process_sp->ReadModuleFromMemory(FileSpec(), header_addr); 60*0b57cec5SDimitry Andric if (m_opaque_sp) { 61*0b57cec5SDimitry Andric Target &target = process_sp->GetTarget(); 62*0b57cec5SDimitry Andric bool changed = false; 63*0b57cec5SDimitry Andric m_opaque_sp->SetLoadAddress(target, 0, true, changed); 64*0b57cec5SDimitry Andric target.GetImages().Append(m_opaque_sp); 65*0b57cec5SDimitry Andric } 66*0b57cec5SDimitry Andric } 67*0b57cec5SDimitry Andric } 68*0b57cec5SDimitry Andric 69*0b57cec5SDimitry Andric const SBModule &SBModule::operator=(const SBModule &rhs) { 70*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(const lldb::SBModule &, 71*0b57cec5SDimitry Andric SBModule, operator=,(const lldb::SBModule &), rhs); 72*0b57cec5SDimitry Andric 73*0b57cec5SDimitry Andric if (this != &rhs) 74*0b57cec5SDimitry Andric m_opaque_sp = rhs.m_opaque_sp; 75*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(*this); 76*0b57cec5SDimitry Andric } 77*0b57cec5SDimitry Andric 785ffd83dbSDimitry Andric SBModule::~SBModule() = default; 79*0b57cec5SDimitry Andric 80*0b57cec5SDimitry Andric bool SBModule::IsValid() const { 81*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModule, IsValid); 82*0b57cec5SDimitry Andric return this->operator bool(); 83*0b57cec5SDimitry Andric } 84*0b57cec5SDimitry Andric SBModule::operator bool() const { 85*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModule, operator bool); 86*0b57cec5SDimitry Andric 87*0b57cec5SDimitry Andric return m_opaque_sp.get() != nullptr; 88*0b57cec5SDimitry Andric } 89*0b57cec5SDimitry Andric 90*0b57cec5SDimitry Andric void SBModule::Clear() { 91*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(void, SBModule, Clear); 92*0b57cec5SDimitry Andric 93*0b57cec5SDimitry Andric m_opaque_sp.reset(); 94*0b57cec5SDimitry Andric } 95*0b57cec5SDimitry Andric 96*0b57cec5SDimitry Andric SBFileSpec SBModule::GetFileSpec() const { 97*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule, GetFileSpec); 98*0b57cec5SDimitry Andric 99*0b57cec5SDimitry Andric SBFileSpec file_spec; 100*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 101*0b57cec5SDimitry Andric if (module_sp) 102*0b57cec5SDimitry Andric file_spec.SetFileSpec(module_sp->GetFileSpec()); 103*0b57cec5SDimitry Andric 104*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(file_spec); 105*0b57cec5SDimitry Andric } 106*0b57cec5SDimitry Andric 107*0b57cec5SDimitry Andric lldb::SBFileSpec SBModule::GetPlatformFileSpec() const { 108*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule, 109*0b57cec5SDimitry Andric GetPlatformFileSpec); 110*0b57cec5SDimitry Andric 111*0b57cec5SDimitry Andric 112*0b57cec5SDimitry Andric SBFileSpec file_spec; 113*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 114*0b57cec5SDimitry Andric if (module_sp) 115*0b57cec5SDimitry Andric file_spec.SetFileSpec(module_sp->GetPlatformFileSpec()); 116*0b57cec5SDimitry Andric 117*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(file_spec); 118*0b57cec5SDimitry Andric } 119*0b57cec5SDimitry Andric 120*0b57cec5SDimitry Andric bool SBModule::SetPlatformFileSpec(const lldb::SBFileSpec &platform_file) { 121*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(bool, SBModule, SetPlatformFileSpec, 122*0b57cec5SDimitry Andric (const lldb::SBFileSpec &), platform_file); 123*0b57cec5SDimitry Andric 124*0b57cec5SDimitry Andric bool result = false; 125*0b57cec5SDimitry Andric 126*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 127*0b57cec5SDimitry Andric if (module_sp) { 128*0b57cec5SDimitry Andric module_sp->SetPlatformFileSpec(*platform_file); 129*0b57cec5SDimitry Andric result = true; 130*0b57cec5SDimitry Andric } 131*0b57cec5SDimitry Andric 132*0b57cec5SDimitry Andric return result; 133*0b57cec5SDimitry Andric } 134*0b57cec5SDimitry Andric 135*0b57cec5SDimitry Andric lldb::SBFileSpec SBModule::GetRemoteInstallFileSpec() { 136*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModule, 137*0b57cec5SDimitry Andric GetRemoteInstallFileSpec); 138*0b57cec5SDimitry Andric 139*0b57cec5SDimitry Andric SBFileSpec sb_file_spec; 140*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 141*0b57cec5SDimitry Andric if (module_sp) 142*0b57cec5SDimitry Andric sb_file_spec.SetFileSpec(module_sp->GetRemoteInstallFileSpec()); 143*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_file_spec); 144*0b57cec5SDimitry Andric } 145*0b57cec5SDimitry Andric 146*0b57cec5SDimitry Andric bool SBModule::SetRemoteInstallFileSpec(lldb::SBFileSpec &file) { 147*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(bool, SBModule, SetRemoteInstallFileSpec, 148*0b57cec5SDimitry Andric (lldb::SBFileSpec &), file); 149*0b57cec5SDimitry Andric 150*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 151*0b57cec5SDimitry Andric if (module_sp) { 152*0b57cec5SDimitry Andric module_sp->SetRemoteInstallFileSpec(file.ref()); 153*0b57cec5SDimitry Andric return true; 154*0b57cec5SDimitry Andric } 155*0b57cec5SDimitry Andric return false; 156*0b57cec5SDimitry Andric } 157*0b57cec5SDimitry Andric 158*0b57cec5SDimitry Andric const uint8_t *SBModule::GetUUIDBytes() const { 159*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(const uint8_t *, SBModule, GetUUIDBytes); 160*0b57cec5SDimitry Andric 161*0b57cec5SDimitry Andric const uint8_t *uuid_bytes = nullptr; 162*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 163*0b57cec5SDimitry Andric if (module_sp) 164*0b57cec5SDimitry Andric uuid_bytes = module_sp->GetUUID().GetBytes().data(); 165*0b57cec5SDimitry Andric 166*0b57cec5SDimitry Andric return uuid_bytes; 167*0b57cec5SDimitry Andric } 168*0b57cec5SDimitry Andric 169*0b57cec5SDimitry Andric const char *SBModule::GetUUIDString() const { 170*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBModule, GetUUIDString); 171*0b57cec5SDimitry Andric 172*0b57cec5SDimitry Andric const char *uuid_cstr = nullptr; 173*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 174*0b57cec5SDimitry Andric if (module_sp) { 175*0b57cec5SDimitry Andric // We are going to return a "const char *" value through the public API, so 176*0b57cec5SDimitry Andric // we need to constify it so it gets added permanently the string pool and 177*0b57cec5SDimitry Andric // then we don't need to worry about the lifetime of the string as it will 178*0b57cec5SDimitry Andric // never go away once it has been put into the ConstString string pool 179*0b57cec5SDimitry Andric uuid_cstr = ConstString(module_sp->GetUUID().GetAsString()).GetCString(); 180*0b57cec5SDimitry Andric } 181*0b57cec5SDimitry Andric 182*0b57cec5SDimitry Andric if (uuid_cstr && uuid_cstr[0]) { 183*0b57cec5SDimitry Andric return uuid_cstr; 184*0b57cec5SDimitry Andric } 185*0b57cec5SDimitry Andric 186*0b57cec5SDimitry Andric return nullptr; 187*0b57cec5SDimitry Andric } 188*0b57cec5SDimitry Andric 189*0b57cec5SDimitry Andric bool SBModule::operator==(const SBModule &rhs) const { 190*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST(bool, SBModule, operator==,(const lldb::SBModule &), 191*0b57cec5SDimitry Andric rhs); 192*0b57cec5SDimitry Andric 193*0b57cec5SDimitry Andric if (m_opaque_sp) 194*0b57cec5SDimitry Andric return m_opaque_sp.get() == rhs.m_opaque_sp.get(); 195*0b57cec5SDimitry Andric return false; 196*0b57cec5SDimitry Andric } 197*0b57cec5SDimitry Andric 198*0b57cec5SDimitry Andric bool SBModule::operator!=(const SBModule &rhs) const { 199*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST(bool, SBModule, operator!=,(const lldb::SBModule &), 200*0b57cec5SDimitry Andric rhs); 201*0b57cec5SDimitry Andric 202*0b57cec5SDimitry Andric if (m_opaque_sp) 203*0b57cec5SDimitry Andric return m_opaque_sp.get() != rhs.m_opaque_sp.get(); 204*0b57cec5SDimitry Andric return false; 205*0b57cec5SDimitry Andric } 206*0b57cec5SDimitry Andric 207*0b57cec5SDimitry Andric ModuleSP SBModule::GetSP() const { return m_opaque_sp; } 208*0b57cec5SDimitry Andric 209*0b57cec5SDimitry Andric void SBModule::SetSP(const ModuleSP &module_sp) { m_opaque_sp = module_sp; } 210*0b57cec5SDimitry Andric 211*0b57cec5SDimitry Andric SBAddress SBModule::ResolveFileAddress(lldb::addr_t vm_addr) { 212*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBAddress, SBModule, ResolveFileAddress, 213*0b57cec5SDimitry Andric (lldb::addr_t), vm_addr); 214*0b57cec5SDimitry Andric 215*0b57cec5SDimitry Andric lldb::SBAddress sb_addr; 216*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 217*0b57cec5SDimitry Andric if (module_sp) { 218*0b57cec5SDimitry Andric Address addr; 219*0b57cec5SDimitry Andric if (module_sp->ResolveFileAddress(vm_addr, addr)) 220*0b57cec5SDimitry Andric sb_addr.ref() = addr; 221*0b57cec5SDimitry Andric } 222*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_addr); 223*0b57cec5SDimitry Andric } 224*0b57cec5SDimitry Andric 225*0b57cec5SDimitry Andric SBSymbolContext 226*0b57cec5SDimitry Andric SBModule::ResolveSymbolContextForAddress(const SBAddress &addr, 227*0b57cec5SDimitry Andric uint32_t resolve_scope) { 228*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBModule, 229*0b57cec5SDimitry Andric ResolveSymbolContextForAddress, 230*0b57cec5SDimitry Andric (const lldb::SBAddress &, uint32_t), addr, resolve_scope); 231*0b57cec5SDimitry Andric 232*0b57cec5SDimitry Andric SBSymbolContext sb_sc; 233*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 234*0b57cec5SDimitry Andric SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); 235*0b57cec5SDimitry Andric if (module_sp && addr.IsValid()) 236*0b57cec5SDimitry Andric module_sp->ResolveSymbolContextForAddress(addr.ref(), scope, *sb_sc); 237*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_sc); 238*0b57cec5SDimitry Andric } 239*0b57cec5SDimitry Andric 240*0b57cec5SDimitry Andric bool SBModule::GetDescription(SBStream &description) { 241*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(bool, SBModule, GetDescription, (lldb::SBStream &), 242*0b57cec5SDimitry Andric description); 243*0b57cec5SDimitry Andric 244*0b57cec5SDimitry Andric Stream &strm = description.ref(); 245*0b57cec5SDimitry Andric 246*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 247*0b57cec5SDimitry Andric if (module_sp) { 248480093f4SDimitry Andric module_sp->GetDescription(strm.AsRawOstream()); 249*0b57cec5SDimitry Andric } else 250*0b57cec5SDimitry Andric strm.PutCString("No value"); 251*0b57cec5SDimitry Andric 252*0b57cec5SDimitry Andric return true; 253*0b57cec5SDimitry Andric } 254*0b57cec5SDimitry Andric 255*0b57cec5SDimitry Andric uint32_t SBModule::GetNumCompileUnits() { 256*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBModule, GetNumCompileUnits); 257*0b57cec5SDimitry Andric 258*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 259*0b57cec5SDimitry Andric if (module_sp) { 260*0b57cec5SDimitry Andric return module_sp->GetNumCompileUnits(); 261*0b57cec5SDimitry Andric } 262*0b57cec5SDimitry Andric return 0; 263*0b57cec5SDimitry Andric } 264*0b57cec5SDimitry Andric 265*0b57cec5SDimitry Andric SBCompileUnit SBModule::GetCompileUnitAtIndex(uint32_t index) { 266*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBCompileUnit, SBModule, GetCompileUnitAtIndex, 267*0b57cec5SDimitry Andric (uint32_t), index); 268*0b57cec5SDimitry Andric 269*0b57cec5SDimitry Andric SBCompileUnit sb_cu; 270*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 271*0b57cec5SDimitry Andric if (module_sp) { 272*0b57cec5SDimitry Andric CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex(index); 273*0b57cec5SDimitry Andric sb_cu.reset(cu_sp.get()); 274*0b57cec5SDimitry Andric } 275*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_cu); 276*0b57cec5SDimitry Andric } 277*0b57cec5SDimitry Andric 278*0b57cec5SDimitry Andric SBSymbolContextList SBModule::FindCompileUnits(const SBFileSpec &sb_file_spec) { 279*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBModule, FindCompileUnits, 280*0b57cec5SDimitry Andric (const lldb::SBFileSpec &), sb_file_spec); 281*0b57cec5SDimitry Andric 282*0b57cec5SDimitry Andric SBSymbolContextList sb_sc_list; 283*0b57cec5SDimitry Andric const ModuleSP module_sp(GetSP()); 284*0b57cec5SDimitry Andric if (sb_file_spec.IsValid() && module_sp) { 2859dba64beSDimitry Andric module_sp->FindCompileUnits(*sb_file_spec, *sb_sc_list); 286*0b57cec5SDimitry Andric } 287*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_sc_list); 288*0b57cec5SDimitry Andric } 289*0b57cec5SDimitry Andric 290*0b57cec5SDimitry Andric static Symtab *GetUnifiedSymbolTable(const lldb::ModuleSP &module_sp) { 2919dba64beSDimitry Andric if (module_sp) 2929dba64beSDimitry Andric return module_sp->GetSymtab(); 293*0b57cec5SDimitry Andric return nullptr; 294*0b57cec5SDimitry Andric } 295*0b57cec5SDimitry Andric 296*0b57cec5SDimitry Andric size_t SBModule::GetNumSymbols() { 297*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModule, GetNumSymbols); 298*0b57cec5SDimitry Andric 299*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 3009dba64beSDimitry Andric if (Symtab *symtab = GetUnifiedSymbolTable(module_sp)) 301*0b57cec5SDimitry Andric return symtab->GetNumSymbols(); 302*0b57cec5SDimitry Andric return 0; 303*0b57cec5SDimitry Andric } 304*0b57cec5SDimitry Andric 305*0b57cec5SDimitry Andric SBSymbol SBModule::GetSymbolAtIndex(size_t idx) { 306*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBSymbol, SBModule, GetSymbolAtIndex, (size_t), idx); 307*0b57cec5SDimitry Andric 308*0b57cec5SDimitry Andric SBSymbol sb_symbol; 309*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 310*0b57cec5SDimitry Andric Symtab *symtab = GetUnifiedSymbolTable(module_sp); 311*0b57cec5SDimitry Andric if (symtab) 312*0b57cec5SDimitry Andric sb_symbol.SetSymbol(symtab->SymbolAtIndex(idx)); 313*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_symbol); 314*0b57cec5SDimitry Andric } 315*0b57cec5SDimitry Andric 316*0b57cec5SDimitry Andric lldb::SBSymbol SBModule::FindSymbol(const char *name, 317*0b57cec5SDimitry Andric lldb::SymbolType symbol_type) { 318*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBSymbol, SBModule, FindSymbol, 319*0b57cec5SDimitry Andric (const char *, lldb::SymbolType), name, symbol_type); 320*0b57cec5SDimitry Andric 321*0b57cec5SDimitry Andric SBSymbol sb_symbol; 322*0b57cec5SDimitry Andric if (name && name[0]) { 323*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 324*0b57cec5SDimitry Andric Symtab *symtab = GetUnifiedSymbolTable(module_sp); 325*0b57cec5SDimitry Andric if (symtab) 326*0b57cec5SDimitry Andric sb_symbol.SetSymbol(symtab->FindFirstSymbolWithNameAndType( 327*0b57cec5SDimitry Andric ConstString(name), symbol_type, Symtab::eDebugAny, 328*0b57cec5SDimitry Andric Symtab::eVisibilityAny)); 329*0b57cec5SDimitry Andric } 330*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_symbol); 331*0b57cec5SDimitry Andric } 332*0b57cec5SDimitry Andric 333*0b57cec5SDimitry Andric lldb::SBSymbolContextList SBModule::FindSymbols(const char *name, 334*0b57cec5SDimitry Andric lldb::SymbolType symbol_type) { 335*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBModule, FindSymbols, 336*0b57cec5SDimitry Andric (const char *, lldb::SymbolType), name, symbol_type); 337*0b57cec5SDimitry Andric 338*0b57cec5SDimitry Andric SBSymbolContextList sb_sc_list; 339*0b57cec5SDimitry Andric if (name && name[0]) { 340*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 341*0b57cec5SDimitry Andric Symtab *symtab = GetUnifiedSymbolTable(module_sp); 342*0b57cec5SDimitry Andric if (symtab) { 343*0b57cec5SDimitry Andric std::vector<uint32_t> matching_symbol_indexes; 3449dba64beSDimitry Andric symtab->FindAllSymbolsWithNameAndType(ConstString(name), symbol_type, 3459dba64beSDimitry Andric matching_symbol_indexes); 3469dba64beSDimitry Andric const size_t num_matches = matching_symbol_indexes.size(); 347*0b57cec5SDimitry Andric if (num_matches) { 348*0b57cec5SDimitry Andric SymbolContext sc; 349*0b57cec5SDimitry Andric sc.module_sp = module_sp; 350*0b57cec5SDimitry Andric SymbolContextList &sc_list = *sb_sc_list; 351*0b57cec5SDimitry Andric for (size_t i = 0; i < num_matches; ++i) { 352*0b57cec5SDimitry Andric sc.symbol = symtab->SymbolAtIndex(matching_symbol_indexes[i]); 353*0b57cec5SDimitry Andric if (sc.symbol) 354*0b57cec5SDimitry Andric sc_list.Append(sc); 355*0b57cec5SDimitry Andric } 356*0b57cec5SDimitry Andric } 357*0b57cec5SDimitry Andric } 358*0b57cec5SDimitry Andric } 359*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_sc_list); 360*0b57cec5SDimitry Andric } 361*0b57cec5SDimitry Andric 362*0b57cec5SDimitry Andric size_t SBModule::GetNumSections() { 363*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModule, GetNumSections); 364*0b57cec5SDimitry Andric 365*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 366*0b57cec5SDimitry Andric if (module_sp) { 367*0b57cec5SDimitry Andric // Give the symbol vendor a chance to add to the unified section list. 3689dba64beSDimitry Andric module_sp->GetSymbolFile(); 369*0b57cec5SDimitry Andric SectionList *section_list = module_sp->GetSectionList(); 370*0b57cec5SDimitry Andric if (section_list) 371*0b57cec5SDimitry Andric return section_list->GetSize(); 372*0b57cec5SDimitry Andric } 373*0b57cec5SDimitry Andric return 0; 374*0b57cec5SDimitry Andric } 375*0b57cec5SDimitry Andric 376*0b57cec5SDimitry Andric SBSection SBModule::GetSectionAtIndex(size_t idx) { 377*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBSection, SBModule, GetSectionAtIndex, (size_t), 378*0b57cec5SDimitry Andric idx); 379*0b57cec5SDimitry Andric 380*0b57cec5SDimitry Andric SBSection sb_section; 381*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 382*0b57cec5SDimitry Andric if (module_sp) { 383*0b57cec5SDimitry Andric // Give the symbol vendor a chance to add to the unified section list. 3849dba64beSDimitry Andric module_sp->GetSymbolFile(); 385*0b57cec5SDimitry Andric SectionList *section_list = module_sp->GetSectionList(); 386*0b57cec5SDimitry Andric 387*0b57cec5SDimitry Andric if (section_list) 388*0b57cec5SDimitry Andric sb_section.SetSP(section_list->GetSectionAtIndex(idx)); 389*0b57cec5SDimitry Andric } 390*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_section); 391*0b57cec5SDimitry Andric } 392*0b57cec5SDimitry Andric 393*0b57cec5SDimitry Andric lldb::SBSymbolContextList SBModule::FindFunctions(const char *name, 394*0b57cec5SDimitry Andric uint32_t name_type_mask) { 395*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBModule, FindFunctions, 396*0b57cec5SDimitry Andric (const char *, uint32_t), name, name_type_mask); 397*0b57cec5SDimitry Andric 398*0b57cec5SDimitry Andric lldb::SBSymbolContextList sb_sc_list; 399*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 400*0b57cec5SDimitry Andric if (name && module_sp) { 401*0b57cec5SDimitry Andric const bool symbols_ok = true; 402*0b57cec5SDimitry Andric const bool inlines_ok = true; 403*0b57cec5SDimitry Andric FunctionNameType type = static_cast<FunctionNameType>(name_type_mask); 4045ffd83dbSDimitry Andric module_sp->FindFunctions(ConstString(name), CompilerDeclContext(), type, 4055ffd83dbSDimitry Andric symbols_ok, inlines_ok, *sb_sc_list); 406*0b57cec5SDimitry Andric } 407*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_sc_list); 408*0b57cec5SDimitry Andric } 409*0b57cec5SDimitry Andric 410*0b57cec5SDimitry Andric SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name, 411*0b57cec5SDimitry Andric uint32_t max_matches) { 412*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBValueList, SBModule, FindGlobalVariables, 413*0b57cec5SDimitry Andric (lldb::SBTarget &, const char *, uint32_t), target, name, 414*0b57cec5SDimitry Andric max_matches); 415*0b57cec5SDimitry Andric 416*0b57cec5SDimitry Andric SBValueList sb_value_list; 417*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 418*0b57cec5SDimitry Andric if (name && module_sp) { 419*0b57cec5SDimitry Andric VariableList variable_list; 4205ffd83dbSDimitry Andric module_sp->FindGlobalVariables(ConstString(name), CompilerDeclContext(), 4215ffd83dbSDimitry Andric max_matches, variable_list); 422480093f4SDimitry Andric for (const VariableSP &var_sp : variable_list) { 423*0b57cec5SDimitry Andric lldb::ValueObjectSP valobj_sp; 424*0b57cec5SDimitry Andric TargetSP target_sp(target.GetSP()); 425480093f4SDimitry Andric valobj_sp = ValueObjectVariable::Create(target_sp.get(), var_sp); 426*0b57cec5SDimitry Andric if (valobj_sp) 427*0b57cec5SDimitry Andric sb_value_list.Append(SBValue(valobj_sp)); 428*0b57cec5SDimitry Andric } 429*0b57cec5SDimitry Andric } 430*0b57cec5SDimitry Andric 431*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_value_list); 432*0b57cec5SDimitry Andric } 433*0b57cec5SDimitry Andric 434*0b57cec5SDimitry Andric lldb::SBValue SBModule::FindFirstGlobalVariable(lldb::SBTarget &target, 435*0b57cec5SDimitry Andric const char *name) { 436*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBValue, SBModule, FindFirstGlobalVariable, 437*0b57cec5SDimitry Andric (lldb::SBTarget &, const char *), target, name); 438*0b57cec5SDimitry Andric 439*0b57cec5SDimitry Andric SBValueList sb_value_list(FindGlobalVariables(target, name, 1)); 440*0b57cec5SDimitry Andric if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0) 441*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0)); 442*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(SBValue()); 443*0b57cec5SDimitry Andric } 444*0b57cec5SDimitry Andric 445*0b57cec5SDimitry Andric lldb::SBType SBModule::FindFirstType(const char *name_cstr) { 446*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBType, SBModule, FindFirstType, (const char *), 447*0b57cec5SDimitry Andric name_cstr); 448*0b57cec5SDimitry Andric 449*0b57cec5SDimitry Andric SBType sb_type; 450*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 451*0b57cec5SDimitry Andric if (name_cstr && module_sp) { 452*0b57cec5SDimitry Andric SymbolContext sc; 453*0b57cec5SDimitry Andric const bool exact_match = false; 454*0b57cec5SDimitry Andric ConstString name(name_cstr); 455*0b57cec5SDimitry Andric 456*0b57cec5SDimitry Andric sb_type = SBType(module_sp->FindFirstType(sc, name, exact_match)); 457*0b57cec5SDimitry Andric 458*0b57cec5SDimitry Andric if (!sb_type.IsValid()) { 4599dba64beSDimitry Andric auto type_system_or_err = 460*0b57cec5SDimitry Andric module_sp->GetTypeSystemForLanguage(eLanguageTypeC); 4619dba64beSDimitry Andric if (auto err = type_system_or_err.takeError()) { 4629dba64beSDimitry Andric llvm::consumeError(std::move(err)); 4639dba64beSDimitry Andric return LLDB_RECORD_RESULT(SBType()); 4649dba64beSDimitry Andric } 4659dba64beSDimitry Andric sb_type = SBType(type_system_or_err->GetBuiltinTypeByName(name)); 466*0b57cec5SDimitry Andric } 467*0b57cec5SDimitry Andric } 468*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_type); 469*0b57cec5SDimitry Andric } 470*0b57cec5SDimitry Andric 471*0b57cec5SDimitry Andric lldb::SBType SBModule::GetBasicType(lldb::BasicType type) { 472*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBType, SBModule, GetBasicType, (lldb::BasicType), 473*0b57cec5SDimitry Andric type); 474*0b57cec5SDimitry Andric 475*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 476*0b57cec5SDimitry Andric if (module_sp) { 4779dba64beSDimitry Andric auto type_system_or_err = 478*0b57cec5SDimitry Andric module_sp->GetTypeSystemForLanguage(eLanguageTypeC); 4799dba64beSDimitry Andric if (auto err = type_system_or_err.takeError()) { 4809dba64beSDimitry Andric llvm::consumeError(std::move(err)); 4819dba64beSDimitry Andric } else { 4829dba64beSDimitry Andric return LLDB_RECORD_RESULT( 4839dba64beSDimitry Andric SBType(type_system_or_err->GetBasicTypeFromAST(type))); 4849dba64beSDimitry Andric } 485*0b57cec5SDimitry Andric } 486*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(SBType()); 487*0b57cec5SDimitry Andric } 488*0b57cec5SDimitry Andric 489*0b57cec5SDimitry Andric lldb::SBTypeList SBModule::FindTypes(const char *type) { 490*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBTypeList, SBModule, FindTypes, (const char *), 491*0b57cec5SDimitry Andric type); 492*0b57cec5SDimitry Andric 493*0b57cec5SDimitry Andric SBTypeList retval; 494*0b57cec5SDimitry Andric 495*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 496*0b57cec5SDimitry Andric if (type && module_sp) { 497*0b57cec5SDimitry Andric TypeList type_list; 498*0b57cec5SDimitry Andric const bool exact_match = false; 499*0b57cec5SDimitry Andric ConstString name(type); 500*0b57cec5SDimitry Andric llvm::DenseSet<SymbolFile *> searched_symbol_files; 5019dba64beSDimitry Andric module_sp->FindTypes(name, exact_match, UINT32_MAX, searched_symbol_files, 5029dba64beSDimitry Andric type_list); 503*0b57cec5SDimitry Andric 5049dba64beSDimitry Andric if (type_list.Empty()) { 5059dba64beSDimitry Andric auto type_system_or_err = 5069dba64beSDimitry Andric module_sp->GetTypeSystemForLanguage(eLanguageTypeC); 5079dba64beSDimitry Andric if (auto err = type_system_or_err.takeError()) { 5089dba64beSDimitry Andric llvm::consumeError(std::move(err)); 5099dba64beSDimitry Andric } else { 5109dba64beSDimitry Andric CompilerType compiler_type = 5119dba64beSDimitry Andric type_system_or_err->GetBuiltinTypeByName(name); 5129dba64beSDimitry Andric if (compiler_type) 5139dba64beSDimitry Andric retval.Append(SBType(compiler_type)); 5149dba64beSDimitry Andric } 5159dba64beSDimitry Andric } else { 5169dba64beSDimitry Andric for (size_t idx = 0; idx < type_list.GetSize(); idx++) { 517*0b57cec5SDimitry Andric TypeSP type_sp(type_list.GetTypeAtIndex(idx)); 518*0b57cec5SDimitry Andric if (type_sp) 519*0b57cec5SDimitry Andric retval.Append(SBType(type_sp)); 520*0b57cec5SDimitry Andric } 521*0b57cec5SDimitry Andric } 522*0b57cec5SDimitry Andric } 523*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(retval); 524*0b57cec5SDimitry Andric } 525*0b57cec5SDimitry Andric 526*0b57cec5SDimitry Andric lldb::SBType SBModule::GetTypeByID(lldb::user_id_t uid) { 527*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBType, SBModule, GetTypeByID, (lldb::user_id_t), 528*0b57cec5SDimitry Andric uid); 529*0b57cec5SDimitry Andric 530*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 531*0b57cec5SDimitry Andric if (module_sp) { 5329dba64beSDimitry Andric if (SymbolFile *symfile = module_sp->GetSymbolFile()) { 5339dba64beSDimitry Andric Type *type_ptr = symfile->ResolveTypeUID(uid); 534*0b57cec5SDimitry Andric if (type_ptr) 535*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(SBType(type_ptr->shared_from_this())); 536*0b57cec5SDimitry Andric } 537*0b57cec5SDimitry Andric } 538*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(SBType()); 539*0b57cec5SDimitry Andric } 540*0b57cec5SDimitry Andric 541*0b57cec5SDimitry Andric lldb::SBTypeList SBModule::GetTypes(uint32_t type_mask) { 542*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBTypeList, SBModule, GetTypes, (uint32_t), 543*0b57cec5SDimitry Andric type_mask); 544*0b57cec5SDimitry Andric 545*0b57cec5SDimitry Andric SBTypeList sb_type_list; 546*0b57cec5SDimitry Andric 547*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 548*0b57cec5SDimitry Andric if (!module_sp) 549*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_type_list); 5509dba64beSDimitry Andric SymbolFile *symfile = module_sp->GetSymbolFile(); 5519dba64beSDimitry Andric if (!symfile) 552*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_type_list); 553*0b57cec5SDimitry Andric 554*0b57cec5SDimitry Andric TypeClass type_class = static_cast<TypeClass>(type_mask); 555*0b57cec5SDimitry Andric TypeList type_list; 5569dba64beSDimitry Andric symfile->GetTypes(nullptr, type_class, type_list); 557*0b57cec5SDimitry Andric sb_type_list.m_opaque_up->Append(type_list); 558*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_type_list); 559*0b57cec5SDimitry Andric } 560*0b57cec5SDimitry Andric 561*0b57cec5SDimitry Andric SBSection SBModule::FindSection(const char *sect_name) { 562*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBSection, SBModule, FindSection, (const char *), 563*0b57cec5SDimitry Andric sect_name); 564*0b57cec5SDimitry Andric 565*0b57cec5SDimitry Andric SBSection sb_section; 566*0b57cec5SDimitry Andric 567*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 568*0b57cec5SDimitry Andric if (sect_name && module_sp) { 569*0b57cec5SDimitry Andric // Give the symbol vendor a chance to add to the unified section list. 5709dba64beSDimitry Andric module_sp->GetSymbolFile(); 571*0b57cec5SDimitry Andric SectionList *section_list = module_sp->GetSectionList(); 572*0b57cec5SDimitry Andric if (section_list) { 573*0b57cec5SDimitry Andric ConstString const_sect_name(sect_name); 574*0b57cec5SDimitry Andric SectionSP section_sp(section_list->FindSectionByName(const_sect_name)); 575*0b57cec5SDimitry Andric if (section_sp) { 576*0b57cec5SDimitry Andric sb_section.SetSP(section_sp); 577*0b57cec5SDimitry Andric } 578*0b57cec5SDimitry Andric } 579*0b57cec5SDimitry Andric } 580*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_section); 581*0b57cec5SDimitry Andric } 582*0b57cec5SDimitry Andric 583*0b57cec5SDimitry Andric lldb::ByteOrder SBModule::GetByteOrder() { 584*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBModule, GetByteOrder); 585*0b57cec5SDimitry Andric 586*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 587*0b57cec5SDimitry Andric if (module_sp) 588*0b57cec5SDimitry Andric return module_sp->GetArchitecture().GetByteOrder(); 589*0b57cec5SDimitry Andric return eByteOrderInvalid; 590*0b57cec5SDimitry Andric } 591*0b57cec5SDimitry Andric 592*0b57cec5SDimitry Andric const char *SBModule::GetTriple() { 593*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(const char *, SBModule, GetTriple); 594*0b57cec5SDimitry Andric 595*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 596*0b57cec5SDimitry Andric if (module_sp) { 597*0b57cec5SDimitry Andric std::string triple(module_sp->GetArchitecture().GetTriple().str()); 598*0b57cec5SDimitry Andric // Unique the string so we don't run into ownership issues since the const 599*0b57cec5SDimitry Andric // strings put the string into the string pool once and the strings never 600*0b57cec5SDimitry Andric // comes out 601*0b57cec5SDimitry Andric ConstString const_triple(triple.c_str()); 602*0b57cec5SDimitry Andric return const_triple.GetCString(); 603*0b57cec5SDimitry Andric } 604*0b57cec5SDimitry Andric return nullptr; 605*0b57cec5SDimitry Andric } 606*0b57cec5SDimitry Andric 607*0b57cec5SDimitry Andric uint32_t SBModule::GetAddressByteSize() { 608*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBModule, GetAddressByteSize); 609*0b57cec5SDimitry Andric 610*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 611*0b57cec5SDimitry Andric if (module_sp) 612*0b57cec5SDimitry Andric return module_sp->GetArchitecture().GetAddressByteSize(); 613*0b57cec5SDimitry Andric return sizeof(void *); 614*0b57cec5SDimitry Andric } 615*0b57cec5SDimitry Andric 616*0b57cec5SDimitry Andric uint32_t SBModule::GetVersion(uint32_t *versions, uint32_t num_versions) { 617*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(uint32_t, SBModule, GetVersion, (uint32_t *, uint32_t), 618*0b57cec5SDimitry Andric versions, num_versions); 619*0b57cec5SDimitry Andric 620*0b57cec5SDimitry Andric llvm::VersionTuple version; 621*0b57cec5SDimitry Andric if (ModuleSP module_sp = GetSP()) 622*0b57cec5SDimitry Andric version = module_sp->GetVersion(); 623*0b57cec5SDimitry Andric uint32_t result = 0; 624*0b57cec5SDimitry Andric if (!version.empty()) 625*0b57cec5SDimitry Andric ++result; 626*0b57cec5SDimitry Andric if (version.getMinor()) 627*0b57cec5SDimitry Andric ++result; 628*0b57cec5SDimitry Andric if(version.getSubminor()) 629*0b57cec5SDimitry Andric ++result; 630*0b57cec5SDimitry Andric 631*0b57cec5SDimitry Andric if (!versions) 632*0b57cec5SDimitry Andric return result; 633*0b57cec5SDimitry Andric 634*0b57cec5SDimitry Andric if (num_versions > 0) 635*0b57cec5SDimitry Andric versions[0] = version.empty() ? UINT32_MAX : version.getMajor(); 636*0b57cec5SDimitry Andric if (num_versions > 1) 637*0b57cec5SDimitry Andric versions[1] = version.getMinor().getValueOr(UINT32_MAX); 638*0b57cec5SDimitry Andric if (num_versions > 2) 639*0b57cec5SDimitry Andric versions[2] = version.getSubminor().getValueOr(UINT32_MAX); 640*0b57cec5SDimitry Andric for (uint32_t i = 3; i < num_versions; ++i) 641*0b57cec5SDimitry Andric versions[i] = UINT32_MAX; 642*0b57cec5SDimitry Andric return result; 643*0b57cec5SDimitry Andric } 644*0b57cec5SDimitry Andric 645*0b57cec5SDimitry Andric lldb::SBFileSpec SBModule::GetSymbolFileSpec() const { 646*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule, 647*0b57cec5SDimitry Andric GetSymbolFileSpec); 648*0b57cec5SDimitry Andric 649*0b57cec5SDimitry Andric lldb::SBFileSpec sb_file_spec; 650*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 651*0b57cec5SDimitry Andric if (module_sp) { 6529dba64beSDimitry Andric if (SymbolFile *symfile = module_sp->GetSymbolFile()) 6539dba64beSDimitry Andric sb_file_spec.SetFileSpec(symfile->GetObjectFile()->GetFileSpec()); 654*0b57cec5SDimitry Andric } 655*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_file_spec); 656*0b57cec5SDimitry Andric } 657*0b57cec5SDimitry Andric 658*0b57cec5SDimitry Andric lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const { 659*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBModule, 660*0b57cec5SDimitry Andric GetObjectFileHeaderAddress); 661*0b57cec5SDimitry Andric 662*0b57cec5SDimitry Andric lldb::SBAddress sb_addr; 663*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 664*0b57cec5SDimitry Andric if (module_sp) { 665*0b57cec5SDimitry Andric ObjectFile *objfile_ptr = module_sp->GetObjectFile(); 666*0b57cec5SDimitry Andric if (objfile_ptr) 667*0b57cec5SDimitry Andric sb_addr.ref() = objfile_ptr->GetBaseAddress(); 668*0b57cec5SDimitry Andric } 669*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_addr); 670*0b57cec5SDimitry Andric } 671*0b57cec5SDimitry Andric 672*0b57cec5SDimitry Andric lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const { 673*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBModule, 674*0b57cec5SDimitry Andric GetObjectFileEntryPointAddress); 675*0b57cec5SDimitry Andric 676*0b57cec5SDimitry Andric lldb::SBAddress sb_addr; 677*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 678*0b57cec5SDimitry Andric if (module_sp) { 679*0b57cec5SDimitry Andric ObjectFile *objfile_ptr = module_sp->GetObjectFile(); 680*0b57cec5SDimitry Andric if (objfile_ptr) 681*0b57cec5SDimitry Andric sb_addr.ref() = objfile_ptr->GetEntryPointAddress(); 682*0b57cec5SDimitry Andric } 683*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_addr); 684*0b57cec5SDimitry Andric } 685*0b57cec5SDimitry Andric 6865ffd83dbSDimitry Andric uint32_t SBModule::GetNumberAllocatedModules() { 6875ffd83dbSDimitry Andric LLDB_RECORD_STATIC_METHOD_NO_ARGS(uint32_t, SBModule, 6885ffd83dbSDimitry Andric GetNumberAllocatedModules); 6895ffd83dbSDimitry Andric 6905ffd83dbSDimitry Andric return Module::GetNumberAllocatedModules(); 6915ffd83dbSDimitry Andric } 6925ffd83dbSDimitry Andric 693*0b57cec5SDimitry Andric namespace lldb_private { 694*0b57cec5SDimitry Andric namespace repro { 695*0b57cec5SDimitry Andric 696*0b57cec5SDimitry Andric template <> 697*0b57cec5SDimitry Andric void RegisterMethods<SBModule>(Registry &R) { 698*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBModule, ()); 699*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBModule, (const lldb::SBModuleSpec &)); 700*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBModule, (const lldb::SBModule &)); 701*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBModule, (lldb::SBProcess &, lldb::addr_t)); 702*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const lldb::SBModule &, 703*0b57cec5SDimitry Andric SBModule, operator=,(const lldb::SBModule &)); 704*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBModule, IsValid, ()); 705*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBModule, operator bool, ()); 706*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBModule, Clear, ()); 707*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetFileSpec, ()); 708*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetPlatformFileSpec, 709*0b57cec5SDimitry Andric ()); 710*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(bool, SBModule, SetPlatformFileSpec, 711*0b57cec5SDimitry Andric (const lldb::SBFileSpec &)); 712*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModule, GetRemoteInstallFileSpec, 713*0b57cec5SDimitry Andric ()); 714*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(bool, SBModule, SetRemoteInstallFileSpec, 715*0b57cec5SDimitry Andric (lldb::SBFileSpec &)); 716*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(const char *, SBModule, GetUUIDString, ()); 717*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, 718*0b57cec5SDimitry Andric SBModule, operator==,(const lldb::SBModule &)); 719*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, 720*0b57cec5SDimitry Andric SBModule, operator!=,(const lldb::SBModule &)); 721*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBAddress, SBModule, ResolveFileAddress, 722*0b57cec5SDimitry Andric (lldb::addr_t)); 723*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBModule, 724*0b57cec5SDimitry Andric ResolveSymbolContextForAddress, 725*0b57cec5SDimitry Andric (const lldb::SBAddress &, uint32_t)); 726*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(bool, SBModule, GetDescription, (lldb::SBStream &)); 727*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(uint32_t, SBModule, GetNumCompileUnits, ()); 728*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBCompileUnit, SBModule, GetCompileUnitAtIndex, 729*0b57cec5SDimitry Andric (uint32_t)); 730*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindCompileUnits, 731*0b57cec5SDimitry Andric (const lldb::SBFileSpec &)); 732*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(size_t, SBModule, GetNumSymbols, ()); 733*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSymbol, SBModule, GetSymbolAtIndex, (size_t)); 734*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSymbol, SBModule, FindSymbol, 735*0b57cec5SDimitry Andric (const char *, lldb::SymbolType)); 736*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindSymbols, 737*0b57cec5SDimitry Andric (const char *, lldb::SymbolType)); 738*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(size_t, SBModule, GetNumSections, ()); 739*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, GetSectionAtIndex, 740*0b57cec5SDimitry Andric (size_t)); 741*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindFunctions, 742*0b57cec5SDimitry Andric (const char *, uint32_t)); 743*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBValueList, SBModule, FindGlobalVariables, 744*0b57cec5SDimitry Andric (lldb::SBTarget &, const char *, uint32_t)); 745*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBValue, SBModule, FindFirstGlobalVariable, 746*0b57cec5SDimitry Andric (lldb::SBTarget &, const char *)); 747*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBType, SBModule, FindFirstType, (const char *)); 748*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetBasicType, 749*0b57cec5SDimitry Andric (lldb::BasicType)); 750*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBTypeList, SBModule, FindTypes, (const char *)); 751*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetTypeByID, 752*0b57cec5SDimitry Andric (lldb::user_id_t)); 753*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBTypeList, SBModule, GetTypes, (uint32_t)); 754*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, FindSection, 755*0b57cec5SDimitry Andric (const char *)); 756*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::ByteOrder, SBModule, GetByteOrder, ()); 757*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const char *, SBModule, GetTriple, ()); 758*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(uint32_t, SBModule, GetAddressByteSize, ()); 759*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(uint32_t, SBModule, GetVersion, 760*0b57cec5SDimitry Andric (uint32_t *, uint32_t)); 761*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetSymbolFileSpec, 762*0b57cec5SDimitry Andric ()); 763*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule, 764*0b57cec5SDimitry Andric GetObjectFileHeaderAddress, ()); 765*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule, 766*0b57cec5SDimitry Andric GetObjectFileEntryPointAddress, ()); 7675ffd83dbSDimitry Andric LLDB_REGISTER_STATIC_METHOD(uint32_t, SBModule, GetNumberAllocatedModules, 7685ffd83dbSDimitry Andric ()); 769*0b57cec5SDimitry Andric } 770*0b57cec5SDimitry Andric 771*0b57cec5SDimitry Andric } 772*0b57cec5SDimitry Andric } 773