1254721Semaste//===-- SBModule.cpp --------------------------------------------*- C++ -*-===// 2254721Semaste// 3254721Semaste// The LLVM Compiler Infrastructure 4254721Semaste// 5254721Semaste// This file is distributed under the University of Illinois Open Source 6254721Semaste// License. See LICENSE.TXT for details. 7254721Semaste// 8254721Semaste//===----------------------------------------------------------------------===// 9254721Semaste 10254721Semaste#include "lldb/API/SBModule.h" 11254721Semaste#include "lldb/API/SBAddress.h" 12254721Semaste#include "lldb/API/SBFileSpec.h" 13254721Semaste#include "lldb/API/SBModuleSpec.h" 14254721Semaste#include "lldb/API/SBProcess.h" 15254721Semaste#include "lldb/API/SBStream.h" 16254721Semaste#include "lldb/API/SBSymbolContextList.h" 17254721Semaste#include "lldb/Core/Module.h" 18254721Semaste#include "lldb/Core/Log.h" 19254721Semaste#include "lldb/Core/Section.h" 20254721Semaste#include "lldb/Core/StreamString.h" 21254721Semaste#include "lldb/Core/ValueObjectList.h" 22254721Semaste#include "lldb/Core/ValueObjectVariable.h" 23254721Semaste#include "lldb/Symbol/ObjectFile.h" 24254721Semaste#include "lldb/Symbol/SymbolVendor.h" 25254721Semaste#include "lldb/Symbol/Symtab.h" 26254721Semaste#include "lldb/Symbol/VariableList.h" 27254721Semaste#include "lldb/Target/Target.h" 28254721Semaste 29254721Semasteusing namespace lldb; 30254721Semasteusing namespace lldb_private; 31254721Semaste 32254721Semaste 33254721SemasteSBModule::SBModule () : 34254721Semaste m_opaque_sp () 35254721Semaste{ 36254721Semaste} 37254721Semaste 38254721SemasteSBModule::SBModule (const lldb::ModuleSP& module_sp) : 39254721Semaste m_opaque_sp (module_sp) 40254721Semaste{ 41254721Semaste} 42254721Semaste 43254721SemasteSBModule::SBModule(const SBModuleSpec &module_spec) : 44254721Semaste m_opaque_sp () 45254721Semaste{ 46254721Semaste ModuleSP module_sp; 47254721Semaste Error error = ModuleList::GetSharedModule (*module_spec.m_opaque_ap, 48254721Semaste module_sp, 49254721Semaste NULL, 50254721Semaste NULL, 51254721Semaste NULL); 52254721Semaste if (module_sp) 53254721Semaste SetSP(module_sp); 54254721Semaste} 55254721Semaste 56254721SemasteSBModule::SBModule(const SBModule &rhs) : 57254721Semaste m_opaque_sp (rhs.m_opaque_sp) 58254721Semaste{ 59254721Semaste} 60254721Semaste 61254721SemasteSBModule::SBModule (lldb::SBProcess &process, lldb::addr_t header_addr) : 62254721Semaste m_opaque_sp () 63254721Semaste{ 64254721Semaste ProcessSP process_sp (process.GetSP()); 65254721Semaste if (process_sp) 66254721Semaste { 67254721Semaste m_opaque_sp = process_sp->ReadModuleFromMemory (FileSpec(), header_addr); 68254721Semaste if (m_opaque_sp) 69254721Semaste { 70254721Semaste Target &target = process_sp->GetTarget(); 71254721Semaste bool changed = false; 72269024Semaste m_opaque_sp->SetLoadAddress(target, 0, true, changed); 73254721Semaste target.GetImages().Append(m_opaque_sp); 74254721Semaste } 75254721Semaste } 76254721Semaste} 77254721Semaste 78254721Semasteconst SBModule & 79254721SemasteSBModule::operator = (const SBModule &rhs) 80254721Semaste{ 81254721Semaste if (this != &rhs) 82254721Semaste m_opaque_sp = rhs.m_opaque_sp; 83254721Semaste return *this; 84254721Semaste} 85254721Semaste 86254721SemasteSBModule::~SBModule () 87254721Semaste{ 88254721Semaste} 89254721Semaste 90254721Semastebool 91254721SemasteSBModule::IsValid () const 92254721Semaste{ 93254721Semaste return m_opaque_sp.get() != NULL; 94254721Semaste} 95254721Semaste 96254721Semastevoid 97254721SemasteSBModule::Clear() 98254721Semaste{ 99254721Semaste m_opaque_sp.reset(); 100254721Semaste} 101254721Semaste 102254721SemasteSBFileSpec 103254721SemasteSBModule::GetFileSpec () const 104254721Semaste{ 105254721Semaste Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 106254721Semaste 107254721Semaste SBFileSpec file_spec; 108254721Semaste ModuleSP module_sp (GetSP ()); 109254721Semaste if (module_sp) 110254721Semaste file_spec.SetFileSpec(module_sp->GetFileSpec()); 111254721Semaste 112254721Semaste if (log) 113254721Semaste { 114254721Semaste log->Printf ("SBModule(%p)::GetFileSpec () => SBFileSpec(%p)", 115254721Semaste module_sp.get(), file_spec.get()); 116254721Semaste } 117254721Semaste 118254721Semaste return file_spec; 119254721Semaste} 120254721Semaste 121254721Semastelldb::SBFileSpec 122254721SemasteSBModule::GetPlatformFileSpec () const 123254721Semaste{ 124254721Semaste Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 125254721Semaste 126254721Semaste SBFileSpec file_spec; 127254721Semaste ModuleSP module_sp (GetSP ()); 128254721Semaste if (module_sp) 129254721Semaste file_spec.SetFileSpec(module_sp->GetPlatformFileSpec()); 130254721Semaste 131254721Semaste if (log) 132254721Semaste { 133254721Semaste log->Printf ("SBModule(%p)::GetPlatformFileSpec () => SBFileSpec(%p)", 134254721Semaste module_sp.get(), file_spec.get()); 135254721Semaste } 136254721Semaste 137254721Semaste return file_spec; 138254721Semaste 139254721Semaste} 140254721Semaste 141254721Semastebool 142254721SemasteSBModule::SetPlatformFileSpec (const lldb::SBFileSpec &platform_file) 143254721Semaste{ 144254721Semaste bool result = false; 145254721Semaste Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 146254721Semaste 147254721Semaste ModuleSP module_sp (GetSP ()); 148254721Semaste if (module_sp) 149254721Semaste { 150254721Semaste module_sp->SetPlatformFileSpec(*platform_file); 151254721Semaste result = true; 152254721Semaste } 153254721Semaste 154254721Semaste if (log) 155254721Semaste { 156254721Semaste log->Printf ("SBModule(%p)::SetPlatformFileSpec (SBFileSpec(%p (%s)) => %i", 157254721Semaste module_sp.get(), 158254721Semaste platform_file.get(), 159254721Semaste platform_file->GetPath().c_str(), 160254721Semaste result); 161254721Semaste } 162254721Semaste return result; 163254721Semaste} 164254721Semaste 165263367Semastelldb::SBFileSpec 166263367SemasteSBModule::GetRemoteInstallFileSpec () 167263367Semaste{ 168263367Semaste SBFileSpec sb_file_spec; 169263367Semaste ModuleSP module_sp (GetSP ()); 170263367Semaste if (module_sp) 171263367Semaste sb_file_spec.SetFileSpec (module_sp->GetRemoteInstallFileSpec()); 172263367Semaste return sb_file_spec; 173263367Semaste} 174254721Semaste 175263367Semastebool 176263367SemasteSBModule::SetRemoteInstallFileSpec (lldb::SBFileSpec &file) 177263367Semaste{ 178263367Semaste ModuleSP module_sp (GetSP ()); 179263367Semaste if (module_sp) 180263367Semaste { 181263367Semaste module_sp->SetRemoteInstallFileSpec(file.ref()); 182263367Semaste return true; 183263367Semaste } 184263367Semaste return false; 185263367Semaste} 186254721Semaste 187263367Semaste 188254721Semasteconst uint8_t * 189254721SemasteSBModule::GetUUIDBytes () const 190254721Semaste{ 191254721Semaste Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 192254721Semaste 193254721Semaste const uint8_t *uuid_bytes = NULL; 194254721Semaste ModuleSP module_sp (GetSP ()); 195254721Semaste if (module_sp) 196254721Semaste uuid_bytes = (const uint8_t *)module_sp->GetUUID().GetBytes(); 197254721Semaste 198254721Semaste if (log) 199254721Semaste { 200254721Semaste if (uuid_bytes) 201254721Semaste { 202254721Semaste StreamString s; 203254721Semaste module_sp->GetUUID().Dump (&s); 204254721Semaste log->Printf ("SBModule(%p)::GetUUIDBytes () => %s", module_sp.get(), s.GetData()); 205254721Semaste } 206254721Semaste else 207254721Semaste log->Printf ("SBModule(%p)::GetUUIDBytes () => NULL", module_sp.get()); 208254721Semaste } 209254721Semaste return uuid_bytes; 210254721Semaste} 211254721Semaste 212254721Semaste 213254721Semasteconst char * 214254721SemasteSBModule::GetUUIDString () const 215254721Semaste{ 216254721Semaste Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 217254721Semaste 218254721Semaste static char uuid_string_buffer[80]; 219254721Semaste const char *uuid_c_string = NULL; 220254721Semaste std::string uuid_string; 221254721Semaste ModuleSP module_sp (GetSP ()); 222254721Semaste if (module_sp) 223254721Semaste uuid_string = module_sp->GetUUID().GetAsString(); 224254721Semaste 225254721Semaste if (!uuid_string.empty()) 226254721Semaste { 227254721Semaste strncpy (uuid_string_buffer, uuid_string.c_str(), sizeof (uuid_string_buffer)); 228254721Semaste uuid_c_string = uuid_string_buffer; 229254721Semaste } 230254721Semaste 231254721Semaste if (log) 232254721Semaste { 233254721Semaste if (!uuid_string.empty()) 234254721Semaste { 235254721Semaste StreamString s; 236254721Semaste module_sp->GetUUID().Dump (&s); 237254721Semaste log->Printf ("SBModule(%p)::GetUUIDString () => %s", module_sp.get(), s.GetData()); 238254721Semaste } 239254721Semaste else 240254721Semaste log->Printf ("SBModule(%p)::GetUUIDString () => NULL", module_sp.get()); 241254721Semaste } 242254721Semaste return uuid_c_string; 243254721Semaste} 244254721Semaste 245254721Semaste 246254721Semastebool 247254721SemasteSBModule::operator == (const SBModule &rhs) const 248254721Semaste{ 249254721Semaste if (m_opaque_sp) 250254721Semaste return m_opaque_sp.get() == rhs.m_opaque_sp.get(); 251254721Semaste return false; 252254721Semaste} 253254721Semaste 254254721Semastebool 255254721SemasteSBModule::operator != (const SBModule &rhs) const 256254721Semaste{ 257254721Semaste if (m_opaque_sp) 258254721Semaste return m_opaque_sp.get() != rhs.m_opaque_sp.get(); 259254721Semaste return false; 260254721Semaste} 261254721Semaste 262254721SemasteModuleSP 263254721SemasteSBModule::GetSP () const 264254721Semaste{ 265254721Semaste return m_opaque_sp; 266254721Semaste} 267254721Semaste 268254721Semastevoid 269254721SemasteSBModule::SetSP (const ModuleSP &module_sp) 270254721Semaste{ 271254721Semaste m_opaque_sp = module_sp; 272254721Semaste} 273254721Semaste 274254721SemasteSBAddress 275254721SemasteSBModule::ResolveFileAddress (lldb::addr_t vm_addr) 276254721Semaste{ 277254721Semaste lldb::SBAddress sb_addr; 278254721Semaste ModuleSP module_sp (GetSP ()); 279254721Semaste if (module_sp) 280254721Semaste { 281254721Semaste Address addr; 282254721Semaste if (module_sp->ResolveFileAddress (vm_addr, addr)) 283254721Semaste sb_addr.ref() = addr; 284254721Semaste } 285254721Semaste return sb_addr; 286254721Semaste} 287254721Semaste 288254721SemasteSBSymbolContext 289254721SemasteSBModule::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope) 290254721Semaste{ 291254721Semaste SBSymbolContext sb_sc; 292254721Semaste ModuleSP module_sp (GetSP ()); 293254721Semaste if (module_sp && addr.IsValid()) 294254721Semaste module_sp->ResolveSymbolContextForAddress (addr.ref(), resolve_scope, *sb_sc); 295254721Semaste return sb_sc; 296254721Semaste} 297254721Semaste 298254721Semastebool 299254721SemasteSBModule::GetDescription (SBStream &description) 300254721Semaste{ 301254721Semaste Stream &strm = description.ref(); 302254721Semaste 303254721Semaste ModuleSP module_sp (GetSP ()); 304254721Semaste if (module_sp) 305254721Semaste { 306254721Semaste module_sp->GetDescription (&strm); 307254721Semaste } 308254721Semaste else 309254721Semaste strm.PutCString ("No value"); 310254721Semaste 311254721Semaste return true; 312254721Semaste} 313254721Semaste 314254721Semasteuint32_t 315254721SemasteSBModule::GetNumCompileUnits() 316254721Semaste{ 317254721Semaste ModuleSP module_sp (GetSP ()); 318254721Semaste if (module_sp) 319254721Semaste { 320254721Semaste return module_sp->GetNumCompileUnits (); 321254721Semaste } 322254721Semaste return 0; 323254721Semaste} 324254721Semaste 325254721SemasteSBCompileUnit 326254721SemasteSBModule::GetCompileUnitAtIndex (uint32_t index) 327254721Semaste{ 328254721Semaste SBCompileUnit sb_cu; 329254721Semaste ModuleSP module_sp (GetSP ()); 330254721Semaste if (module_sp) 331254721Semaste { 332254721Semaste CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex (index); 333254721Semaste sb_cu.reset(cu_sp.get()); 334254721Semaste } 335254721Semaste return sb_cu; 336254721Semaste} 337254721Semaste 338254721Semastestatic Symtab * 339254721SemasteGetUnifiedSymbolTable (const lldb::ModuleSP& module_sp) 340254721Semaste{ 341254721Semaste if (module_sp) 342254721Semaste { 343254721Semaste SymbolVendor *symbols = module_sp->GetSymbolVendor(); 344254721Semaste if (symbols) 345254721Semaste return symbols->GetSymtab(); 346254721Semaste } 347254721Semaste return NULL; 348254721Semaste} 349254721Semaste 350254721Semastesize_t 351254721SemasteSBModule::GetNumSymbols () 352254721Semaste{ 353254721Semaste ModuleSP module_sp (GetSP ()); 354254721Semaste if (module_sp) 355254721Semaste { 356254721Semaste Symtab *symtab = GetUnifiedSymbolTable (module_sp); 357254721Semaste if (symtab) 358254721Semaste return symtab->GetNumSymbols(); 359254721Semaste } 360254721Semaste return 0; 361254721Semaste} 362254721Semaste 363254721SemasteSBSymbol 364254721SemasteSBModule::GetSymbolAtIndex (size_t idx) 365254721Semaste{ 366254721Semaste SBSymbol sb_symbol; 367254721Semaste ModuleSP module_sp (GetSP ()); 368254721Semaste Symtab *symtab = GetUnifiedSymbolTable (module_sp); 369254721Semaste if (symtab) 370254721Semaste sb_symbol.SetSymbol(symtab->SymbolAtIndex (idx)); 371254721Semaste return sb_symbol; 372254721Semaste} 373254721Semaste 374254721Semastelldb::SBSymbol 375254721SemasteSBModule::FindSymbol (const char *name, 376254721Semaste lldb::SymbolType symbol_type) 377254721Semaste{ 378254721Semaste SBSymbol sb_symbol; 379254721Semaste if (name && name[0]) 380254721Semaste { 381254721Semaste ModuleSP module_sp (GetSP ()); 382254721Semaste Symtab *symtab = GetUnifiedSymbolTable (module_sp); 383254721Semaste if (symtab) 384254721Semaste sb_symbol.SetSymbol(symtab->FindFirstSymbolWithNameAndType(ConstString(name), symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny)); 385254721Semaste } 386254721Semaste return sb_symbol; 387254721Semaste} 388254721Semaste 389254721Semaste 390254721Semastelldb::SBSymbolContextList 391254721SemasteSBModule::FindSymbols (const char *name, lldb::SymbolType symbol_type) 392254721Semaste{ 393254721Semaste SBSymbolContextList sb_sc_list; 394254721Semaste if (name && name[0]) 395254721Semaste { 396254721Semaste ModuleSP module_sp (GetSP ()); 397254721Semaste Symtab *symtab = GetUnifiedSymbolTable (module_sp); 398254721Semaste if (symtab) 399254721Semaste { 400254721Semaste std::vector<uint32_t> matching_symbol_indexes; 401254721Semaste const size_t num_matches = symtab->FindAllSymbolsWithNameAndType(ConstString(name), symbol_type, matching_symbol_indexes); 402254721Semaste if (num_matches) 403254721Semaste { 404254721Semaste SymbolContext sc; 405254721Semaste sc.module_sp = module_sp; 406254721Semaste SymbolContextList &sc_list = *sb_sc_list; 407254721Semaste for (size_t i=0; i<num_matches; ++i) 408254721Semaste { 409254721Semaste sc.symbol = symtab->SymbolAtIndex (matching_symbol_indexes[i]); 410254721Semaste if (sc.symbol) 411254721Semaste sc_list.Append(sc); 412254721Semaste } 413254721Semaste } 414254721Semaste } 415254721Semaste } 416254721Semaste return sb_sc_list; 417254721Semaste 418254721Semaste} 419254721Semaste 420254721Semaste 421254721Semaste 422254721Semastesize_t 423254721SemasteSBModule::GetNumSections () 424254721Semaste{ 425254721Semaste ModuleSP module_sp (GetSP ()); 426254721Semaste if (module_sp) 427254721Semaste { 428254721Semaste // Give the symbol vendor a chance to add to the unified section list. 429254721Semaste module_sp->GetSymbolVendor(); 430254721Semaste SectionList *section_list = module_sp->GetSectionList(); 431254721Semaste if (section_list) 432254721Semaste return section_list->GetSize(); 433254721Semaste } 434254721Semaste return 0; 435254721Semaste} 436254721Semaste 437254721SemasteSBSection 438254721SemasteSBModule::GetSectionAtIndex (size_t idx) 439254721Semaste{ 440254721Semaste SBSection sb_section; 441254721Semaste ModuleSP module_sp (GetSP ()); 442254721Semaste if (module_sp) 443254721Semaste { 444254721Semaste // Give the symbol vendor a chance to add to the unified section list. 445254721Semaste module_sp->GetSymbolVendor(); 446254721Semaste SectionList *section_list = module_sp->GetSectionList (); 447254721Semaste 448254721Semaste if (section_list) 449254721Semaste sb_section.SetSP(section_list->GetSectionAtIndex (idx)); 450254721Semaste } 451254721Semaste return sb_section; 452254721Semaste} 453254721Semaste 454254721Semastelldb::SBSymbolContextList 455254721SemasteSBModule::FindFunctions (const char *name, 456254721Semaste uint32_t name_type_mask) 457254721Semaste{ 458254721Semaste lldb::SBSymbolContextList sb_sc_list; 459254721Semaste ModuleSP module_sp (GetSP ()); 460254721Semaste if (name && module_sp) 461254721Semaste { 462254721Semaste const bool append = true; 463254721Semaste const bool symbols_ok = true; 464254721Semaste const bool inlines_ok = true; 465254721Semaste module_sp->FindFunctions (ConstString(name), 466254721Semaste NULL, 467254721Semaste name_type_mask, 468254721Semaste symbols_ok, 469254721Semaste inlines_ok, 470254721Semaste append, 471254721Semaste *sb_sc_list); 472254721Semaste } 473254721Semaste return sb_sc_list; 474254721Semaste} 475254721Semaste 476254721Semaste 477254721SemasteSBValueList 478254721SemasteSBModule::FindGlobalVariables (SBTarget &target, const char *name, uint32_t max_matches) 479254721Semaste{ 480254721Semaste SBValueList sb_value_list; 481254721Semaste ModuleSP module_sp (GetSP ()); 482254721Semaste if (name && module_sp) 483254721Semaste { 484254721Semaste VariableList variable_list; 485254721Semaste const uint32_t match_count = module_sp->FindGlobalVariables (ConstString (name), 486254721Semaste NULL, 487254721Semaste false, 488254721Semaste max_matches, 489254721Semaste variable_list); 490254721Semaste 491254721Semaste if (match_count > 0) 492254721Semaste { 493254721Semaste for (uint32_t i=0; i<match_count; ++i) 494254721Semaste { 495254721Semaste lldb::ValueObjectSP valobj_sp; 496254721Semaste TargetSP target_sp (target.GetSP()); 497254721Semaste valobj_sp = ValueObjectVariable::Create (target_sp.get(), variable_list.GetVariableAtIndex(i)); 498254721Semaste if (valobj_sp) 499254721Semaste sb_value_list.Append(SBValue(valobj_sp)); 500254721Semaste } 501254721Semaste } 502254721Semaste } 503254721Semaste 504254721Semaste return sb_value_list; 505254721Semaste} 506254721Semaste 507254721Semastelldb::SBValue 508254721SemasteSBModule::FindFirstGlobalVariable (lldb::SBTarget &target, const char *name) 509254721Semaste{ 510254721Semaste SBValueList sb_value_list(FindGlobalVariables(target, name, 1)); 511254721Semaste if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0) 512254721Semaste return sb_value_list.GetValueAtIndex(0); 513254721Semaste return SBValue(); 514254721Semaste} 515254721Semaste 516254721Semastelldb::SBType 517254721SemasteSBModule::FindFirstType (const char *name_cstr) 518254721Semaste{ 519254721Semaste SBType sb_type; 520254721Semaste ModuleSP module_sp (GetSP ()); 521254721Semaste if (name_cstr && module_sp) 522254721Semaste { 523254721Semaste SymbolContext sc; 524254721Semaste const bool exact_match = false; 525254721Semaste ConstString name(name_cstr); 526254721Semaste 527254721Semaste sb_type = SBType (module_sp->FindFirstType(sc, name, exact_match)); 528254721Semaste 529254721Semaste if (!sb_type.IsValid()) 530254721Semaste sb_type = SBType (ClangASTContext::GetBasicType (module_sp->GetClangASTContext().getASTContext(), name)); 531254721Semaste } 532254721Semaste return sb_type; 533254721Semaste} 534254721Semaste 535254721Semastelldb::SBType 536254721SemasteSBModule::GetBasicType(lldb::BasicType type) 537254721Semaste{ 538254721Semaste ModuleSP module_sp (GetSP ()); 539254721Semaste if (module_sp) 540254721Semaste return SBType (ClangASTContext::GetBasicType (module_sp->GetClangASTContext().getASTContext(), type)); 541254721Semaste return SBType(); 542254721Semaste} 543254721Semaste 544254721Semastelldb::SBTypeList 545254721SemasteSBModule::FindTypes (const char *type) 546254721Semaste{ 547254721Semaste SBTypeList retval; 548254721Semaste 549254721Semaste ModuleSP module_sp (GetSP ()); 550254721Semaste if (type && module_sp) 551254721Semaste { 552254721Semaste SymbolContext sc; 553254721Semaste TypeList type_list; 554254721Semaste const bool exact_match = false; 555254721Semaste ConstString name(type); 556254721Semaste const uint32_t num_matches = module_sp->FindTypes (sc, 557254721Semaste name, 558254721Semaste exact_match, 559254721Semaste UINT32_MAX, 560254721Semaste type_list); 561254721Semaste 562254721Semaste if (num_matches > 0) 563254721Semaste { 564254721Semaste for (size_t idx = 0; idx < num_matches; idx++) 565254721Semaste { 566254721Semaste TypeSP type_sp (type_list.GetTypeAtIndex(idx)); 567254721Semaste if (type_sp) 568254721Semaste retval.Append(SBType(type_sp)); 569254721Semaste } 570254721Semaste } 571254721Semaste else 572254721Semaste { 573254721Semaste SBType sb_type(ClangASTContext::GetBasicType (module_sp->GetClangASTContext().getASTContext(), name)); 574254721Semaste if (sb_type.IsValid()) 575254721Semaste retval.Append(sb_type); 576254721Semaste } 577254721Semaste } 578254721Semaste 579254721Semaste return retval; 580254721Semaste} 581254721Semaste 582269024Semastelldb::SBType 583269024SemasteSBModule::GetTypeByID (lldb::user_id_t uid) 584269024Semaste{ 585269024Semaste ModuleSP module_sp (GetSP ()); 586269024Semaste if (module_sp) 587269024Semaste { 588269024Semaste SymbolVendor* vendor = module_sp->GetSymbolVendor(); 589269024Semaste if (vendor) 590269024Semaste { 591269024Semaste Type *type_ptr = vendor->ResolveTypeUID(uid); 592269024Semaste if (type_ptr) 593269024Semaste return SBType(type_ptr->shared_from_this()); 594269024Semaste } 595269024Semaste } 596269024Semaste return SBType(); 597269024Semaste} 598269024Semaste 599254721Semastelldb::SBTypeList 600254721SemasteSBModule::GetTypes (uint32_t type_mask) 601254721Semaste{ 602254721Semaste SBTypeList sb_type_list; 603254721Semaste 604254721Semaste ModuleSP module_sp (GetSP ()); 605254721Semaste if (module_sp) 606254721Semaste { 607254721Semaste SymbolVendor* vendor = module_sp->GetSymbolVendor(); 608254721Semaste if (vendor) 609254721Semaste { 610254721Semaste TypeList type_list; 611254721Semaste vendor->GetTypes (NULL, type_mask, type_list); 612254721Semaste sb_type_list.m_opaque_ap->Append(type_list); 613254721Semaste } 614254721Semaste } 615254721Semaste return sb_type_list; 616254721Semaste} 617254721Semaste 618254721SemasteSBSection 619254721SemasteSBModule::FindSection (const char *sect_name) 620254721Semaste{ 621254721Semaste SBSection sb_section; 622254721Semaste 623254721Semaste ModuleSP module_sp (GetSP ()); 624254721Semaste if (sect_name && module_sp) 625254721Semaste { 626254721Semaste // Give the symbol vendor a chance to add to the unified section list. 627254721Semaste module_sp->GetSymbolVendor(); 628254721Semaste SectionList *section_list = module_sp->GetSectionList(); 629254721Semaste if (section_list) 630254721Semaste { 631254721Semaste ConstString const_sect_name(sect_name); 632254721Semaste SectionSP section_sp (section_list->FindSectionByName(const_sect_name)); 633254721Semaste if (section_sp) 634254721Semaste { 635254721Semaste sb_section.SetSP (section_sp); 636254721Semaste } 637254721Semaste } 638254721Semaste } 639254721Semaste return sb_section; 640254721Semaste} 641254721Semaste 642254721Semastelldb::ByteOrder 643254721SemasteSBModule::GetByteOrder () 644254721Semaste{ 645254721Semaste ModuleSP module_sp (GetSP ()); 646254721Semaste if (module_sp) 647254721Semaste return module_sp->GetArchitecture().GetByteOrder(); 648254721Semaste return eByteOrderInvalid; 649254721Semaste} 650254721Semaste 651254721Semasteconst char * 652254721SemasteSBModule::GetTriple () 653254721Semaste{ 654254721Semaste ModuleSP module_sp (GetSP ()); 655254721Semaste if (module_sp) 656254721Semaste { 657254721Semaste std::string triple (module_sp->GetArchitecture().GetTriple().str()); 658254721Semaste // Unique the string so we don't run into ownership issues since 659254721Semaste // the const strings put the string into the string pool once and 660254721Semaste // the strings never comes out 661254721Semaste ConstString const_triple (triple.c_str()); 662254721Semaste return const_triple.GetCString(); 663254721Semaste } 664254721Semaste return NULL; 665254721Semaste} 666254721Semaste 667254721Semasteuint32_t 668254721SemasteSBModule::GetAddressByteSize() 669254721Semaste{ 670254721Semaste ModuleSP module_sp (GetSP ()); 671254721Semaste if (module_sp) 672254721Semaste return module_sp->GetArchitecture().GetAddressByteSize(); 673254721Semaste return sizeof(void*); 674254721Semaste} 675254721Semaste 676254721Semaste 677254721Semasteuint32_t 678254721SemasteSBModule::GetVersion (uint32_t *versions, uint32_t num_versions) 679254721Semaste{ 680254721Semaste ModuleSP module_sp (GetSP ()); 681254721Semaste if (module_sp) 682254721Semaste return module_sp->GetVersion(versions, num_versions); 683254721Semaste else 684254721Semaste { 685254721Semaste if (versions && num_versions) 686254721Semaste { 687254721Semaste for (uint32_t i=0; i<num_versions; ++i) 688254721Semaste versions[i] = UINT32_MAX; 689254721Semaste } 690254721Semaste return 0; 691254721Semaste } 692254721Semaste} 693254721Semaste 694