1*0b57cec5SDimitry Andric //===-- SBModule.cpp --------------------------------------------*- C++ -*-===// 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 78*0b57cec5SDimitry Andric SBModule::~SBModule() {} 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) { 248*0b57cec5SDimitry Andric module_sp->GetDescription(&strm); 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); 404*0b57cec5SDimitry Andric module_sp->FindFunctions(ConstString(name), nullptr, type, symbols_ok, 4059dba64beSDimitry Andric 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; 4209dba64beSDimitry Andric module_sp->FindGlobalVariables(ConstString(name), nullptr, max_matches, 4219dba64beSDimitry Andric variable_list); 4229dba64beSDimitry Andric const uint32_t match_count = variable_list.GetSize(); 423*0b57cec5SDimitry Andric if (match_count > 0) { 424*0b57cec5SDimitry Andric for (uint32_t i = 0; i < match_count; ++i) { 425*0b57cec5SDimitry Andric lldb::ValueObjectSP valobj_sp; 426*0b57cec5SDimitry Andric TargetSP target_sp(target.GetSP()); 427*0b57cec5SDimitry Andric valobj_sp = ValueObjectVariable::Create( 428*0b57cec5SDimitry Andric target_sp.get(), variable_list.GetVariableAtIndex(i)); 429*0b57cec5SDimitry Andric if (valobj_sp) 430*0b57cec5SDimitry Andric sb_value_list.Append(SBValue(valobj_sp)); 431*0b57cec5SDimitry Andric } 432*0b57cec5SDimitry Andric } 433*0b57cec5SDimitry Andric } 434*0b57cec5SDimitry Andric 435*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_value_list); 436*0b57cec5SDimitry Andric } 437*0b57cec5SDimitry Andric 438*0b57cec5SDimitry Andric lldb::SBValue SBModule::FindFirstGlobalVariable(lldb::SBTarget &target, 439*0b57cec5SDimitry Andric const char *name) { 440*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBValue, SBModule, FindFirstGlobalVariable, 441*0b57cec5SDimitry Andric (lldb::SBTarget &, const char *), target, name); 442*0b57cec5SDimitry Andric 443*0b57cec5SDimitry Andric SBValueList sb_value_list(FindGlobalVariables(target, name, 1)); 444*0b57cec5SDimitry Andric if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0) 445*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0)); 446*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(SBValue()); 447*0b57cec5SDimitry Andric } 448*0b57cec5SDimitry Andric 449*0b57cec5SDimitry Andric lldb::SBType SBModule::FindFirstType(const char *name_cstr) { 450*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBType, SBModule, FindFirstType, (const char *), 451*0b57cec5SDimitry Andric name_cstr); 452*0b57cec5SDimitry Andric 453*0b57cec5SDimitry Andric SBType sb_type; 454*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 455*0b57cec5SDimitry Andric if (name_cstr && module_sp) { 456*0b57cec5SDimitry Andric SymbolContext sc; 457*0b57cec5SDimitry Andric const bool exact_match = false; 458*0b57cec5SDimitry Andric ConstString name(name_cstr); 459*0b57cec5SDimitry Andric 460*0b57cec5SDimitry Andric sb_type = SBType(module_sp->FindFirstType(sc, name, exact_match)); 461*0b57cec5SDimitry Andric 462*0b57cec5SDimitry Andric if (!sb_type.IsValid()) { 4639dba64beSDimitry Andric auto type_system_or_err = 464*0b57cec5SDimitry Andric module_sp->GetTypeSystemForLanguage(eLanguageTypeC); 4659dba64beSDimitry Andric if (auto err = type_system_or_err.takeError()) { 4669dba64beSDimitry Andric llvm::consumeError(std::move(err)); 4679dba64beSDimitry Andric return LLDB_RECORD_RESULT(SBType()); 4689dba64beSDimitry Andric } 4699dba64beSDimitry Andric sb_type = SBType(type_system_or_err->GetBuiltinTypeByName(name)); 470*0b57cec5SDimitry Andric } 471*0b57cec5SDimitry Andric } 472*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_type); 473*0b57cec5SDimitry Andric } 474*0b57cec5SDimitry Andric 475*0b57cec5SDimitry Andric lldb::SBType SBModule::GetBasicType(lldb::BasicType type) { 476*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBType, SBModule, GetBasicType, (lldb::BasicType), 477*0b57cec5SDimitry Andric type); 478*0b57cec5SDimitry Andric 479*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 480*0b57cec5SDimitry Andric if (module_sp) { 4819dba64beSDimitry Andric auto type_system_or_err = 482*0b57cec5SDimitry Andric module_sp->GetTypeSystemForLanguage(eLanguageTypeC); 4839dba64beSDimitry Andric if (auto err = type_system_or_err.takeError()) { 4849dba64beSDimitry Andric llvm::consumeError(std::move(err)); 4859dba64beSDimitry Andric } else { 4869dba64beSDimitry Andric return LLDB_RECORD_RESULT( 4879dba64beSDimitry Andric SBType(type_system_or_err->GetBasicTypeFromAST(type))); 4889dba64beSDimitry Andric } 489*0b57cec5SDimitry Andric } 490*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(SBType()); 491*0b57cec5SDimitry Andric } 492*0b57cec5SDimitry Andric 493*0b57cec5SDimitry Andric lldb::SBTypeList SBModule::FindTypes(const char *type) { 494*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBTypeList, SBModule, FindTypes, (const char *), 495*0b57cec5SDimitry Andric type); 496*0b57cec5SDimitry Andric 497*0b57cec5SDimitry Andric SBTypeList retval; 498*0b57cec5SDimitry Andric 499*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 500*0b57cec5SDimitry Andric if (type && module_sp) { 501*0b57cec5SDimitry Andric TypeList type_list; 502*0b57cec5SDimitry Andric const bool exact_match = false; 503*0b57cec5SDimitry Andric ConstString name(type); 504*0b57cec5SDimitry Andric llvm::DenseSet<SymbolFile *> searched_symbol_files; 5059dba64beSDimitry Andric module_sp->FindTypes(name, exact_match, UINT32_MAX, searched_symbol_files, 5069dba64beSDimitry Andric type_list); 507*0b57cec5SDimitry Andric 5089dba64beSDimitry Andric if (type_list.Empty()) { 5099dba64beSDimitry Andric auto type_system_or_err = 5109dba64beSDimitry Andric module_sp->GetTypeSystemForLanguage(eLanguageTypeC); 5119dba64beSDimitry Andric if (auto err = type_system_or_err.takeError()) { 5129dba64beSDimitry Andric llvm::consumeError(std::move(err)); 5139dba64beSDimitry Andric } else { 5149dba64beSDimitry Andric CompilerType compiler_type = 5159dba64beSDimitry Andric type_system_or_err->GetBuiltinTypeByName(name); 5169dba64beSDimitry Andric if (compiler_type) 5179dba64beSDimitry Andric retval.Append(SBType(compiler_type)); 5189dba64beSDimitry Andric } 5199dba64beSDimitry Andric } else { 5209dba64beSDimitry Andric for (size_t idx = 0; idx < type_list.GetSize(); idx++) { 521*0b57cec5SDimitry Andric TypeSP type_sp(type_list.GetTypeAtIndex(idx)); 522*0b57cec5SDimitry Andric if (type_sp) 523*0b57cec5SDimitry Andric retval.Append(SBType(type_sp)); 524*0b57cec5SDimitry Andric } 525*0b57cec5SDimitry Andric } 526*0b57cec5SDimitry Andric } 527*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(retval); 528*0b57cec5SDimitry Andric } 529*0b57cec5SDimitry Andric 530*0b57cec5SDimitry Andric lldb::SBType SBModule::GetTypeByID(lldb::user_id_t uid) { 531*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBType, SBModule, GetTypeByID, (lldb::user_id_t), 532*0b57cec5SDimitry Andric uid); 533*0b57cec5SDimitry Andric 534*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 535*0b57cec5SDimitry Andric if (module_sp) { 5369dba64beSDimitry Andric if (SymbolFile *symfile = module_sp->GetSymbolFile()) { 5379dba64beSDimitry Andric Type *type_ptr = symfile->ResolveTypeUID(uid); 538*0b57cec5SDimitry Andric if (type_ptr) 539*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(SBType(type_ptr->shared_from_this())); 540*0b57cec5SDimitry Andric } 541*0b57cec5SDimitry Andric } 542*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(SBType()); 543*0b57cec5SDimitry Andric } 544*0b57cec5SDimitry Andric 545*0b57cec5SDimitry Andric lldb::SBTypeList SBModule::GetTypes(uint32_t type_mask) { 546*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBTypeList, SBModule, GetTypes, (uint32_t), 547*0b57cec5SDimitry Andric type_mask); 548*0b57cec5SDimitry Andric 549*0b57cec5SDimitry Andric SBTypeList sb_type_list; 550*0b57cec5SDimitry Andric 551*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 552*0b57cec5SDimitry Andric if (!module_sp) 553*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_type_list); 5549dba64beSDimitry Andric SymbolFile *symfile = module_sp->GetSymbolFile(); 5559dba64beSDimitry Andric if (!symfile) 556*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_type_list); 557*0b57cec5SDimitry Andric 558*0b57cec5SDimitry Andric TypeClass type_class = static_cast<TypeClass>(type_mask); 559*0b57cec5SDimitry Andric TypeList type_list; 5609dba64beSDimitry Andric symfile->GetTypes(nullptr, type_class, type_list); 561*0b57cec5SDimitry Andric sb_type_list.m_opaque_up->Append(type_list); 562*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_type_list); 563*0b57cec5SDimitry Andric } 564*0b57cec5SDimitry Andric 565*0b57cec5SDimitry Andric SBSection SBModule::FindSection(const char *sect_name) { 566*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(lldb::SBSection, SBModule, FindSection, (const char *), 567*0b57cec5SDimitry Andric sect_name); 568*0b57cec5SDimitry Andric 569*0b57cec5SDimitry Andric SBSection sb_section; 570*0b57cec5SDimitry Andric 571*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 572*0b57cec5SDimitry Andric if (sect_name && module_sp) { 573*0b57cec5SDimitry Andric // Give the symbol vendor a chance to add to the unified section list. 5749dba64beSDimitry Andric module_sp->GetSymbolFile(); 575*0b57cec5SDimitry Andric SectionList *section_list = module_sp->GetSectionList(); 576*0b57cec5SDimitry Andric if (section_list) { 577*0b57cec5SDimitry Andric ConstString const_sect_name(sect_name); 578*0b57cec5SDimitry Andric SectionSP section_sp(section_list->FindSectionByName(const_sect_name)); 579*0b57cec5SDimitry Andric if (section_sp) { 580*0b57cec5SDimitry Andric sb_section.SetSP(section_sp); 581*0b57cec5SDimitry Andric } 582*0b57cec5SDimitry Andric } 583*0b57cec5SDimitry Andric } 584*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_section); 585*0b57cec5SDimitry Andric } 586*0b57cec5SDimitry Andric 587*0b57cec5SDimitry Andric lldb::ByteOrder SBModule::GetByteOrder() { 588*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBModule, GetByteOrder); 589*0b57cec5SDimitry Andric 590*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 591*0b57cec5SDimitry Andric if (module_sp) 592*0b57cec5SDimitry Andric return module_sp->GetArchitecture().GetByteOrder(); 593*0b57cec5SDimitry Andric return eByteOrderInvalid; 594*0b57cec5SDimitry Andric } 595*0b57cec5SDimitry Andric 596*0b57cec5SDimitry Andric const char *SBModule::GetTriple() { 597*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(const char *, SBModule, GetTriple); 598*0b57cec5SDimitry Andric 599*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 600*0b57cec5SDimitry Andric if (module_sp) { 601*0b57cec5SDimitry Andric std::string triple(module_sp->GetArchitecture().GetTriple().str()); 602*0b57cec5SDimitry Andric // Unique the string so we don't run into ownership issues since the const 603*0b57cec5SDimitry Andric // strings put the string into the string pool once and the strings never 604*0b57cec5SDimitry Andric // comes out 605*0b57cec5SDimitry Andric ConstString const_triple(triple.c_str()); 606*0b57cec5SDimitry Andric return const_triple.GetCString(); 607*0b57cec5SDimitry Andric } 608*0b57cec5SDimitry Andric return nullptr; 609*0b57cec5SDimitry Andric } 610*0b57cec5SDimitry Andric 611*0b57cec5SDimitry Andric uint32_t SBModule::GetAddressByteSize() { 612*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBModule, GetAddressByteSize); 613*0b57cec5SDimitry Andric 614*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 615*0b57cec5SDimitry Andric if (module_sp) 616*0b57cec5SDimitry Andric return module_sp->GetArchitecture().GetAddressByteSize(); 617*0b57cec5SDimitry Andric return sizeof(void *); 618*0b57cec5SDimitry Andric } 619*0b57cec5SDimitry Andric 620*0b57cec5SDimitry Andric uint32_t SBModule::GetVersion(uint32_t *versions, uint32_t num_versions) { 621*0b57cec5SDimitry Andric LLDB_RECORD_METHOD(uint32_t, SBModule, GetVersion, (uint32_t *, uint32_t), 622*0b57cec5SDimitry Andric versions, num_versions); 623*0b57cec5SDimitry Andric 624*0b57cec5SDimitry Andric llvm::VersionTuple version; 625*0b57cec5SDimitry Andric if (ModuleSP module_sp = GetSP()) 626*0b57cec5SDimitry Andric version = module_sp->GetVersion(); 627*0b57cec5SDimitry Andric uint32_t result = 0; 628*0b57cec5SDimitry Andric if (!version.empty()) 629*0b57cec5SDimitry Andric ++result; 630*0b57cec5SDimitry Andric if (version.getMinor()) 631*0b57cec5SDimitry Andric ++result; 632*0b57cec5SDimitry Andric if(version.getSubminor()) 633*0b57cec5SDimitry Andric ++result; 634*0b57cec5SDimitry Andric 635*0b57cec5SDimitry Andric if (!versions) 636*0b57cec5SDimitry Andric return result; 637*0b57cec5SDimitry Andric 638*0b57cec5SDimitry Andric if (num_versions > 0) 639*0b57cec5SDimitry Andric versions[0] = version.empty() ? UINT32_MAX : version.getMajor(); 640*0b57cec5SDimitry Andric if (num_versions > 1) 641*0b57cec5SDimitry Andric versions[1] = version.getMinor().getValueOr(UINT32_MAX); 642*0b57cec5SDimitry Andric if (num_versions > 2) 643*0b57cec5SDimitry Andric versions[2] = version.getSubminor().getValueOr(UINT32_MAX); 644*0b57cec5SDimitry Andric for (uint32_t i = 3; i < num_versions; ++i) 645*0b57cec5SDimitry Andric versions[i] = UINT32_MAX; 646*0b57cec5SDimitry Andric return result; 647*0b57cec5SDimitry Andric } 648*0b57cec5SDimitry Andric 649*0b57cec5SDimitry Andric lldb::SBFileSpec SBModule::GetSymbolFileSpec() const { 650*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule, 651*0b57cec5SDimitry Andric GetSymbolFileSpec); 652*0b57cec5SDimitry Andric 653*0b57cec5SDimitry Andric lldb::SBFileSpec sb_file_spec; 654*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 655*0b57cec5SDimitry Andric if (module_sp) { 6569dba64beSDimitry Andric if (SymbolFile *symfile = module_sp->GetSymbolFile()) 6579dba64beSDimitry Andric sb_file_spec.SetFileSpec(symfile->GetObjectFile()->GetFileSpec()); 658*0b57cec5SDimitry Andric } 659*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_file_spec); 660*0b57cec5SDimitry Andric } 661*0b57cec5SDimitry Andric 662*0b57cec5SDimitry Andric lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const { 663*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBModule, 664*0b57cec5SDimitry Andric GetObjectFileHeaderAddress); 665*0b57cec5SDimitry Andric 666*0b57cec5SDimitry Andric lldb::SBAddress sb_addr; 667*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 668*0b57cec5SDimitry Andric if (module_sp) { 669*0b57cec5SDimitry Andric ObjectFile *objfile_ptr = module_sp->GetObjectFile(); 670*0b57cec5SDimitry Andric if (objfile_ptr) 671*0b57cec5SDimitry Andric sb_addr.ref() = objfile_ptr->GetBaseAddress(); 672*0b57cec5SDimitry Andric } 673*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_addr); 674*0b57cec5SDimitry Andric } 675*0b57cec5SDimitry Andric 676*0b57cec5SDimitry Andric lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const { 677*0b57cec5SDimitry Andric LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBModule, 678*0b57cec5SDimitry Andric GetObjectFileEntryPointAddress); 679*0b57cec5SDimitry Andric 680*0b57cec5SDimitry Andric lldb::SBAddress sb_addr; 681*0b57cec5SDimitry Andric ModuleSP module_sp(GetSP()); 682*0b57cec5SDimitry Andric if (module_sp) { 683*0b57cec5SDimitry Andric ObjectFile *objfile_ptr = module_sp->GetObjectFile(); 684*0b57cec5SDimitry Andric if (objfile_ptr) 685*0b57cec5SDimitry Andric sb_addr.ref() = objfile_ptr->GetEntryPointAddress(); 686*0b57cec5SDimitry Andric } 687*0b57cec5SDimitry Andric return LLDB_RECORD_RESULT(sb_addr); 688*0b57cec5SDimitry Andric } 689*0b57cec5SDimitry Andric 690*0b57cec5SDimitry Andric namespace lldb_private { 691*0b57cec5SDimitry Andric namespace repro { 692*0b57cec5SDimitry Andric 693*0b57cec5SDimitry Andric template <> 694*0b57cec5SDimitry Andric void RegisterMethods<SBModule>(Registry &R) { 695*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBModule, ()); 696*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBModule, (const lldb::SBModuleSpec &)); 697*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBModule, (const lldb::SBModule &)); 698*0b57cec5SDimitry Andric LLDB_REGISTER_CONSTRUCTOR(SBModule, (lldb::SBProcess &, lldb::addr_t)); 699*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const lldb::SBModule &, 700*0b57cec5SDimitry Andric SBModule, operator=,(const lldb::SBModule &)); 701*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBModule, IsValid, ()); 702*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, SBModule, operator bool, ()); 703*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(void, SBModule, Clear, ()); 704*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetFileSpec, ()); 705*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetPlatformFileSpec, 706*0b57cec5SDimitry Andric ()); 707*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(bool, SBModule, SetPlatformFileSpec, 708*0b57cec5SDimitry Andric (const lldb::SBFileSpec &)); 709*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModule, GetRemoteInstallFileSpec, 710*0b57cec5SDimitry Andric ()); 711*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(bool, SBModule, SetRemoteInstallFileSpec, 712*0b57cec5SDimitry Andric (lldb::SBFileSpec &)); 713*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(const char *, SBModule, GetUUIDString, ()); 714*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, 715*0b57cec5SDimitry Andric SBModule, operator==,(const lldb::SBModule &)); 716*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(bool, 717*0b57cec5SDimitry Andric SBModule, operator!=,(const lldb::SBModule &)); 718*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBAddress, SBModule, ResolveFileAddress, 719*0b57cec5SDimitry Andric (lldb::addr_t)); 720*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBModule, 721*0b57cec5SDimitry Andric ResolveSymbolContextForAddress, 722*0b57cec5SDimitry Andric (const lldb::SBAddress &, uint32_t)); 723*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(bool, SBModule, GetDescription, (lldb::SBStream &)); 724*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(uint32_t, SBModule, GetNumCompileUnits, ()); 725*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBCompileUnit, SBModule, GetCompileUnitAtIndex, 726*0b57cec5SDimitry Andric (uint32_t)); 727*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindCompileUnits, 728*0b57cec5SDimitry Andric (const lldb::SBFileSpec &)); 729*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(size_t, SBModule, GetNumSymbols, ()); 730*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSymbol, SBModule, GetSymbolAtIndex, (size_t)); 731*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSymbol, SBModule, FindSymbol, 732*0b57cec5SDimitry Andric (const char *, lldb::SymbolType)); 733*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindSymbols, 734*0b57cec5SDimitry Andric (const char *, lldb::SymbolType)); 735*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(size_t, SBModule, GetNumSections, ()); 736*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, GetSectionAtIndex, 737*0b57cec5SDimitry Andric (size_t)); 738*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindFunctions, 739*0b57cec5SDimitry Andric (const char *, uint32_t)); 740*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBValueList, SBModule, FindGlobalVariables, 741*0b57cec5SDimitry Andric (lldb::SBTarget &, const char *, uint32_t)); 742*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBValue, SBModule, FindFirstGlobalVariable, 743*0b57cec5SDimitry Andric (lldb::SBTarget &, const char *)); 744*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBType, SBModule, FindFirstType, (const char *)); 745*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetBasicType, 746*0b57cec5SDimitry Andric (lldb::BasicType)); 747*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBTypeList, SBModule, FindTypes, (const char *)); 748*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetTypeByID, 749*0b57cec5SDimitry Andric (lldb::user_id_t)); 750*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBTypeList, SBModule, GetTypes, (uint32_t)); 751*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, FindSection, 752*0b57cec5SDimitry Andric (const char *)); 753*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(lldb::ByteOrder, SBModule, GetByteOrder, ()); 754*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(const char *, SBModule, GetTriple, ()); 755*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(uint32_t, SBModule, GetAddressByteSize, ()); 756*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD(uint32_t, SBModule, GetVersion, 757*0b57cec5SDimitry Andric (uint32_t *, uint32_t)); 758*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetSymbolFileSpec, 759*0b57cec5SDimitry Andric ()); 760*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule, 761*0b57cec5SDimitry Andric GetObjectFileHeaderAddress, ()); 762*0b57cec5SDimitry Andric LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule, 763*0b57cec5SDimitry Andric GetObjectFileEntryPointAddress, ()); 764*0b57cec5SDimitry Andric } 765*0b57cec5SDimitry Andric 766*0b57cec5SDimitry Andric } 767*0b57cec5SDimitry Andric } 768