1 //===-- SymbolFileDWARFDebugMap.cpp ----------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "SymbolFileDWARFDebugMap.h" 11 12 #include "lldb/Core/Module.h" 13 #include "lldb/Core/ModuleList.h" 14 #include "lldb/Core/PluginManager.h" 15 #include "lldb/Core/RegularExpression.h" 16 #include "lldb/Core/StreamFile.h" 17 #include "lldb/Core/Timer.h" 18 19 #include "lldb/Symbol/ClangExternalASTSourceCallbacks.h" 20 #include "lldb/Symbol/ObjectFile.h" 21 #include "lldb/Symbol/SymbolVendor.h" 22 #include "lldb/Symbol/VariableList.h" 23 24 #include "LogChannelDWARF.h" 25 #include "SymbolFileDWARF.h" 26 27 using namespace lldb; 28 using namespace lldb_private; 29 30 void 31 SymbolFileDWARFDebugMap::Initialize() 32 { 33 PluginManager::RegisterPlugin (GetPluginNameStatic(), 34 GetPluginDescriptionStatic(), 35 CreateInstance); 36 } 37 38 void 39 SymbolFileDWARFDebugMap::Terminate() 40 { 41 PluginManager::UnregisterPlugin (CreateInstance); 42 } 43 44 45 const char * 46 SymbolFileDWARFDebugMap::GetPluginNameStatic() 47 { 48 return "dwarf-debugmap"; 49 } 50 51 const char * 52 SymbolFileDWARFDebugMap::GetPluginDescriptionStatic() 53 { 54 return "DWARF and DWARF3 debug symbol file reader (debug map)."; 55 } 56 57 SymbolFile* 58 SymbolFileDWARFDebugMap::CreateInstance (ObjectFile* obj_file) 59 { 60 return new SymbolFileDWARFDebugMap (obj_file); 61 } 62 63 64 SymbolFileDWARFDebugMap::SymbolFileDWARFDebugMap (ObjectFile* ofile) : 65 SymbolFile(ofile), 66 m_flags(), 67 m_compile_unit_infos(), 68 m_func_indexes(), 69 m_glob_indexes(), 70 m_supports_DW_AT_APPLE_objc_complete_type (eLazyBoolCalculate) 71 { 72 } 73 74 75 SymbolFileDWARFDebugMap::~SymbolFileDWARFDebugMap() 76 { 77 } 78 79 void 80 SymbolFileDWARFDebugMap::InitializeObject() 81 { 82 // Install our external AST source callbacks so we can complete Clang types. 83 llvm::OwningPtr<clang::ExternalASTSource> ast_source_ap ( 84 new ClangExternalASTSourceCallbacks (SymbolFileDWARFDebugMap::CompleteTagDecl, 85 SymbolFileDWARFDebugMap::CompleteObjCInterfaceDecl, 86 NULL, 87 SymbolFileDWARFDebugMap::LayoutRecordType, 88 this)); 89 90 GetClangASTContext().SetExternalSource (ast_source_ap); 91 } 92 93 94 95 void 96 SymbolFileDWARFDebugMap::InitOSO () 97 { 98 if (m_flags.test(kHaveInitializedOSOs)) 99 return; 100 101 m_flags.set(kHaveInitializedOSOs); 102 // In order to get the abilities of this plug-in, we look at the list of 103 // N_OSO entries (object files) from the symbol table and make sure that 104 // these files exist and also contain valid DWARF. If we get any of that 105 // then we return the abilities of the first N_OSO's DWARF. 106 107 Symtab* symtab = m_obj_file->GetSymtab(); 108 if (symtab) 109 { 110 LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_MAP)); 111 112 std::vector<uint32_t> oso_indexes; 113 // StreamFile s(stdout); 114 // symtab->Dump(&s, NULL, eSortOrderNone); 115 116 // When a mach-o symbol is encoded, the n_type field is encoded in bits 117 // 23:16, and the n_desc field is encoded in bits 15:0. 118 // 119 // To find all N_OSO entries that are part of the DWARF + debug map 120 // we find only object file symbols with the flags value as follows: 121 // bits 23:16 == 0x66 (N_OSO) 122 // bits 15: 0 == 0x0001 (specifies this is a debug map object file) 123 const uint32_t k_oso_symbol_flags_value = 0x660001u; 124 125 const uint32_t oso_index_count = symtab->AppendSymbolIndexesWithTypeAndFlagsValue(eSymbolTypeObjectFile, k_oso_symbol_flags_value, oso_indexes); 126 127 if (oso_index_count > 0) 128 { 129 symtab->AppendSymbolIndexesWithType (eSymbolTypeCode, Symtab::eDebugYes, Symtab::eVisibilityAny, m_func_indexes); 130 symtab->AppendSymbolIndexesWithType (eSymbolTypeData, Symtab::eDebugYes, Symtab::eVisibilityAny, m_glob_indexes); 131 132 symtab->SortSymbolIndexesByValue(m_func_indexes, true); 133 symtab->SortSymbolIndexesByValue(m_glob_indexes, true); 134 135 m_compile_unit_infos.resize(oso_index_count); 136 // s.Printf("%s N_OSO symbols:\n", __PRETTY_FUNCTION__); 137 // symtab->Dump(&s, oso_indexes); 138 139 for (uint32_t i=0; i<oso_index_count; ++i) 140 { 141 m_compile_unit_infos[i].so_symbol = symtab->SymbolAtIndex(oso_indexes[i] - 1); 142 if (m_compile_unit_infos[i].so_symbol->GetSiblingIndex() == 0) 143 m_compile_unit_infos[i].so_symbol = symtab->SymbolAtIndex(oso_indexes[i] - 2); 144 m_compile_unit_infos[i].oso_symbol = symtab->SymbolAtIndex(oso_indexes[i]); 145 uint32_t sibling_idx = m_compile_unit_infos[i].so_symbol->GetSiblingIndex(); 146 assert (sibling_idx != 0); 147 assert (sibling_idx > i + 1); 148 m_compile_unit_infos[i].last_symbol = symtab->SymbolAtIndex (sibling_idx - 1); 149 m_compile_unit_infos[i].first_symbol_index = symtab->GetIndexForSymbol(m_compile_unit_infos[i].so_symbol); 150 m_compile_unit_infos[i].last_symbol_index = symtab->GetIndexForSymbol(m_compile_unit_infos[i].last_symbol); 151 152 if (log) 153 log->Printf("Initialized OSO 0x%8.8x: file=%s", i, m_compile_unit_infos[i].oso_symbol->GetName().GetCString()); 154 } 155 } 156 } 157 } 158 159 Module * 160 SymbolFileDWARFDebugMap::GetModuleByOSOIndex (uint32_t oso_idx) 161 { 162 const uint32_t cu_count = GetNumCompileUnits(); 163 if (oso_idx < cu_count) 164 return GetModuleByCompUnitInfo (&m_compile_unit_infos[oso_idx]); 165 return NULL; 166 } 167 168 Module * 169 SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo (CompileUnitInfo *comp_unit_info) 170 { 171 if (comp_unit_info->oso_module_sp.get() == NULL && comp_unit_info->symbol_file_supported) 172 { 173 Symbol *oso_symbol = comp_unit_info->oso_symbol; 174 if (oso_symbol) 175 { 176 FileSpec oso_file_spec(oso_symbol->GetMangled().GetName().AsCString(), true); 177 // Always create a new module for .o files. Why? Because we 178 // use the debug map, to add new sections to each .o file and 179 // even though a .o file might not have changed, the sections 180 // that get added to the .o file can change. 181 comp_unit_info->oso_module_sp.reset (new Module (oso_file_spec, 182 m_obj_file->GetModule()->GetArchitecture(), 183 NULL, 184 0)); 185 } 186 } 187 return comp_unit_info->oso_module_sp.get(); 188 } 189 190 191 bool 192 SymbolFileDWARFDebugMap::GetFileSpecForSO (uint32_t oso_idx, FileSpec &file_spec) 193 { 194 if (oso_idx < m_compile_unit_infos.size()) 195 { 196 if (!m_compile_unit_infos[oso_idx].so_file) 197 { 198 199 if (m_compile_unit_infos[oso_idx].so_symbol == NULL) 200 return false; 201 202 std::string so_path (m_compile_unit_infos[oso_idx].so_symbol->GetMangled().GetName().AsCString()); 203 if (m_compile_unit_infos[oso_idx].so_symbol[1].GetType() == eSymbolTypeSourceFile) 204 so_path += m_compile_unit_infos[oso_idx].so_symbol[1].GetMangled().GetName().AsCString(); 205 m_compile_unit_infos[oso_idx].so_file.SetFile(so_path.c_str(), true); 206 } 207 file_spec = m_compile_unit_infos[oso_idx].so_file; 208 return true; 209 } 210 return false; 211 } 212 213 214 215 ObjectFile * 216 SymbolFileDWARFDebugMap::GetObjectFileByOSOIndex (uint32_t oso_idx) 217 { 218 Module *oso_module = GetModuleByOSOIndex (oso_idx); 219 if (oso_module) 220 return oso_module->GetObjectFile(); 221 return NULL; 222 } 223 224 SymbolFileDWARF * 225 SymbolFileDWARFDebugMap::GetSymbolFile (const SymbolContext& sc) 226 { 227 CompileUnitInfo *comp_unit_info = GetCompUnitInfo (sc); 228 if (comp_unit_info) 229 return GetSymbolFileByCompUnitInfo (comp_unit_info); 230 return NULL; 231 } 232 233 ObjectFile * 234 SymbolFileDWARFDebugMap::GetObjectFileByCompUnitInfo (CompileUnitInfo *comp_unit_info) 235 { 236 Module *oso_module = GetModuleByCompUnitInfo (comp_unit_info); 237 if (oso_module) 238 return oso_module->GetObjectFile(); 239 return NULL; 240 } 241 242 243 uint32_t 244 SymbolFileDWARFDebugMap::GetCompUnitInfoIndex (const CompileUnitInfo *comp_unit_info) 245 { 246 if (!m_compile_unit_infos.empty()) 247 { 248 const CompileUnitInfo *first_comp_unit_info = &m_compile_unit_infos.front(); 249 const CompileUnitInfo *last_comp_unit_info = &m_compile_unit_infos.back(); 250 if (first_comp_unit_info <= comp_unit_info && comp_unit_info <= last_comp_unit_info) 251 return comp_unit_info - first_comp_unit_info; 252 } 253 return UINT32_MAX; 254 } 255 256 SymbolFileDWARF * 257 SymbolFileDWARFDebugMap::GetSymbolFileByOSOIndex (uint32_t oso_idx) 258 { 259 if (oso_idx < m_compile_unit_infos.size()) 260 return GetSymbolFileByCompUnitInfo (&m_compile_unit_infos[oso_idx]); 261 return NULL; 262 } 263 264 SymbolFileDWARF * 265 SymbolFileDWARFDebugMap::GetSymbolFileByCompUnitInfo (CompileUnitInfo *comp_unit_info) 266 { 267 if (comp_unit_info->oso_symbol_vendor == NULL && comp_unit_info->symbol_file_supported) 268 { 269 ObjectFile *oso_objfile = GetObjectFileByCompUnitInfo (comp_unit_info); 270 271 if (oso_objfile) 272 { 273 comp_unit_info->oso_symbol_vendor = oso_objfile->GetModule()->GetSymbolVendor(); 274 // SymbolFileDWARF *oso_dwarf = new SymbolFileDWARF(oso_objfile); 275 // comp_unit_info->oso_dwarf_sp.reset (oso_dwarf); 276 if (comp_unit_info->oso_symbol_vendor) 277 { 278 // Set a a pointer to this class to set our OSO DWARF file know 279 // that the DWARF is being used along with a debug map and that 280 // it will have the remapped sections that we do below. 281 SymbolFileDWARF *oso_symfile = (SymbolFileDWARF *)comp_unit_info->oso_symbol_vendor->GetSymbolFile(); 282 283 if (oso_symfile->GetNumCompileUnits() != 1) 284 { 285 oso_symfile->GetObjectFile()->GetModule()->ReportError ("DWARF for object file '%s' contains multiple translation units!", 286 oso_symfile->GetObjectFile()->GetFileSpec().GetFilename().AsCString()); 287 comp_unit_info->symbol_file_supported = false; 288 comp_unit_info->oso_module_sp.reset(); 289 comp_unit_info->oso_compile_unit_sp.reset(); 290 comp_unit_info->oso_symbol_vendor = NULL; 291 return NULL; 292 } 293 294 oso_symfile->SetDebugMapSymfile(this); 295 // Set the ID of the symbol file DWARF to the index of the OSO 296 // shifted left by 32 bits to provide a unique prefix for any 297 // UserID's that get created in the symbol file. 298 oso_symfile->SetID (((uint64_t)GetCompUnitInfoIndex(comp_unit_info) + 1ull) << 32ull); 299 comp_unit_info->debug_map_sections_sp.reset(new SectionList); 300 301 Symtab *exe_symtab = m_obj_file->GetSymtab(); 302 ModuleSP oso_module_sp (oso_objfile->GetModule()); 303 Symtab *oso_symtab = oso_objfile->GetSymtab(); 304 //#define DEBUG_OSO_DMAP // Do not check in with this defined... 305 #if defined(DEBUG_OSO_DMAP) 306 StreamFile s(stdout); 307 s << "OSO symtab:\n"; 308 oso_symtab->Dump(&s, NULL); 309 s << "OSO sections before:\n"; 310 oso_objfile->GetSectionList()->Dump(&s, NULL, true); 311 #endif 312 313 ///const uint32_t fun_resolve_flags = SymbolContext::Module | eSymbolContextCompUnit | eSymbolContextFunction; 314 //SectionList *oso_sections = oso_objfile->Sections(); 315 // Now we need to make sections that map from zero based object 316 // file addresses to where things eneded up in the main executable. 317 uint32_t oso_start_idx = exe_symtab->GetIndexForSymbol (comp_unit_info->oso_symbol); 318 assert (oso_start_idx != UINT32_MAX); 319 oso_start_idx += 1; 320 const uint32_t oso_end_idx = comp_unit_info->so_symbol->GetSiblingIndex(); 321 uint32_t sect_id = 0x10000; 322 for (uint32_t idx = oso_start_idx; idx < oso_end_idx; ++idx) 323 { 324 Symbol *exe_symbol = exe_symtab->SymbolAtIndex(idx); 325 if (exe_symbol) 326 { 327 if (exe_symbol->IsDebug() == false) 328 continue; 329 330 switch (exe_symbol->GetType()) 331 { 332 default: 333 break; 334 335 case eSymbolTypeCode: 336 { 337 // For each N_FUN, or function that we run into in the debug map 338 // we make a new section that we add to the sections found in the 339 // .o file. This new section has the file address set to what the 340 // addresses are in the .o file, and the load address is adjusted 341 // to match where it ended up in the final executable! We do this 342 // before we parse any dwarf info so that when it goes get parsed 343 // all section/offset addresses that get registered will resolve 344 // correctly to the new addresses in the main executable. 345 346 // First we find the original symbol in the .o file's symbol table 347 Symbol *oso_fun_symbol = oso_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(Mangled::ePreferMangled), eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny); 348 if (oso_fun_symbol) 349 { 350 // If we found the symbol, then we 351 SectionSP exe_fun_section (exe_symbol->GetAddress().GetSection()); 352 SectionSP oso_fun_section (oso_fun_symbol->GetAddress().GetSection()); 353 if (oso_fun_section) 354 { 355 // Now we create a section that we will add as a child of the 356 // section in which the .o symbol (the N_FUN) exists. 357 358 // We use the exe_symbol size because the one in the .o file 359 // will just be a symbol with no size, and the exe_symbol 360 // size will reflect any size changes (ppc has been known to 361 // shrink function sizes when it gets rid of jump islands that 362 // aren't needed anymore). 363 SectionSP oso_fun_section_sp (new Section (oso_fun_symbol->GetAddress().GetSection(), 364 oso_module_sp, // Module (the .o file) 365 sect_id++, // Section ID starts at 0x10000 and increments so the section IDs don't overlap with the standard mach IDs 366 exe_symbol->GetMangled().GetName(Mangled::ePreferMangled), // Name the section the same as the symbol for which is was generated! 367 eSectionTypeDebug, 368 oso_fun_symbol->GetAddress().GetOffset(), // File VM address offset in the current section 369 exe_symbol->GetByteSize(), // File size (we need the size from the executable) 370 0, 0, 0)); 371 372 oso_fun_section_sp->SetLinkedLocation (exe_fun_section, 373 exe_symbol->GetAddress().GetFileAddress() - exe_fun_section->GetFileAddress()); 374 oso_fun_section->GetChildren().AddSection(oso_fun_section_sp); 375 comp_unit_info->debug_map_sections_sp->AddSection(oso_fun_section_sp); 376 } 377 } 378 } 379 break; 380 381 case eSymbolTypeData: 382 { 383 // For each N_GSYM we remap the address for the global by making 384 // a new section that we add to the sections found in the .o file. 385 // This new section has the file address set to what the 386 // addresses are in the .o file, and the load address is adjusted 387 // to match where it ended up in the final executable! We do this 388 // before we parse any dwarf info so that when it goes get parsed 389 // all section/offset addresses that get registered will resolve 390 // correctly to the new addresses in the main executable. We 391 // initially set the section size to be 1 byte, but will need to 392 // fix up these addresses further after all globals have been 393 // parsed to span the gaps, or we can find the global variable 394 // sizes from the DWARF info as we are parsing. 395 396 // Next we find the non-stab entry that corresponds to the N_GSYM in the .o file 397 Symbol *oso_gsym_symbol = oso_symtab->FindFirstSymbolWithNameAndType (exe_symbol->GetMangled().GetName(), 398 eSymbolTypeData, 399 Symtab::eDebugNo, 400 Symtab::eVisibilityAny); 401 402 if (exe_symbol && oso_gsym_symbol && exe_symbol->ValueIsAddress() && oso_gsym_symbol->ValueIsAddress()) 403 { 404 // If we found the symbol, then we 405 SectionSP exe_gsym_section (exe_symbol->GetAddress().GetSection()); 406 SectionSP oso_gsym_section (oso_gsym_symbol->GetAddress().GetSection()); 407 if (oso_gsym_section) 408 { 409 SectionSP oso_gsym_section_sp (new Section (oso_gsym_symbol->GetAddress().GetSection(), 410 oso_module_sp, // Module (the .o file) 411 sect_id++, // Section ID starts at 0x10000 and increments so the section IDs don't overlap with the standard mach IDs 412 exe_symbol->GetMangled().GetName(Mangled::ePreferMangled), // Name the section the same as the symbol for which is was generated! 413 eSectionTypeDebug, 414 oso_gsym_symbol->GetAddress().GetOffset(), // File VM address offset in the current section 415 1, // We don't know the size of the global, just do the main address for now. 416 0, 0, 0)); 417 418 oso_gsym_section_sp->SetLinkedLocation (exe_gsym_section, 419 exe_symbol->GetAddress().GetFileAddress() - exe_gsym_section->GetFileAddress()); 420 oso_gsym_section->GetChildren().AddSection(oso_gsym_section_sp); 421 comp_unit_info->debug_map_sections_sp->AddSection(oso_gsym_section_sp); 422 } 423 } 424 } 425 break; 426 } 427 } 428 } 429 #if defined(DEBUG_OSO_DMAP) 430 s << "OSO sections after:\n"; 431 oso_objfile->GetSectionList()->Dump(&s, NULL, true); 432 #endif 433 } 434 } 435 } 436 if (comp_unit_info->oso_symbol_vendor) 437 return (SymbolFileDWARF *)comp_unit_info->oso_symbol_vendor->GetSymbolFile(); 438 return NULL; 439 } 440 441 uint32_t 442 SymbolFileDWARFDebugMap::CalculateAbilities () 443 { 444 // In order to get the abilities of this plug-in, we look at the list of 445 // N_OSO entries (object files) from the symbol table and make sure that 446 // these files exist and also contain valid DWARF. If we get any of that 447 // then we return the abilities of the first N_OSO's DWARF. 448 449 const uint32_t oso_index_count = GetNumCompileUnits(); 450 if (oso_index_count > 0) 451 { 452 const uint32_t dwarf_abilities = SymbolFile::CompileUnits | 453 SymbolFile::Functions | 454 SymbolFile::Blocks | 455 SymbolFile::GlobalVariables | 456 SymbolFile::LocalVariables | 457 SymbolFile::VariableTypes | 458 SymbolFile::LineTables; 459 460 for (uint32_t oso_idx=0; oso_idx<oso_index_count; ++oso_idx) 461 { 462 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); 463 if (oso_dwarf) 464 { 465 uint32_t oso_abilities = oso_dwarf->GetAbilities(); 466 if ((oso_abilities & dwarf_abilities) == dwarf_abilities) 467 return oso_abilities; 468 } 469 } 470 } 471 return 0; 472 } 473 474 uint32_t 475 SymbolFileDWARFDebugMap::GetNumCompileUnits() 476 { 477 InitOSO (); 478 return m_compile_unit_infos.size(); 479 } 480 481 482 CompUnitSP 483 SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) 484 { 485 CompUnitSP comp_unit_sp; 486 const uint32_t cu_count = GetNumCompileUnits(); 487 488 if (cu_idx < cu_count) 489 { 490 if (m_compile_unit_infos[cu_idx].oso_compile_unit_sp.get() == NULL && 491 m_compile_unit_infos[cu_idx].symbol_file_supported) 492 { 493 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (cu_idx); 494 if (oso_dwarf) 495 { 496 // There is only one compile unit for N_OSO entry right now, so 497 // it will always exist at index zero. 498 m_compile_unit_infos[cu_idx].oso_compile_unit_sp = m_compile_unit_infos[cu_idx].oso_symbol_vendor->GetCompileUnitAtIndex (0); 499 } 500 501 if (m_compile_unit_infos[cu_idx].oso_compile_unit_sp.get() == NULL) 502 { 503 // We weren't able to get the DWARF for this N_OSO entry (the 504 // .o file may be missing or not at the specified path), make 505 // one up as best we can from the debug map. We set the uid 506 // of the compile unit to the symbol index with the MSBit set 507 // so that it doesn't collide with any uid values from the DWARF 508 Symbol *so_symbol = m_compile_unit_infos[cu_idx].so_symbol; 509 if (so_symbol) 510 { 511 m_compile_unit_infos[cu_idx].oso_compile_unit_sp.reset(new CompileUnit (m_obj_file->GetModule(), 512 NULL, 513 so_symbol->GetMangled().GetName().AsCString(), 514 cu_idx, 515 eLanguageTypeUnknown)); 516 517 // Let our symbol vendor know about this compile unit 518 m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex (cu_idx, 519 m_compile_unit_infos[cu_idx].oso_compile_unit_sp); 520 } 521 } 522 } 523 comp_unit_sp = m_compile_unit_infos[cu_idx].oso_compile_unit_sp; 524 } 525 526 return comp_unit_sp; 527 } 528 529 SymbolFileDWARFDebugMap::CompileUnitInfo * 530 SymbolFileDWARFDebugMap::GetCompUnitInfo (const SymbolContext& sc) 531 { 532 const uint32_t cu_count = GetNumCompileUnits(); 533 for (uint32_t i=0; i<cu_count; ++i) 534 { 535 if (sc.comp_unit == m_compile_unit_infos[i].oso_compile_unit_sp.get()) 536 return &m_compile_unit_infos[i]; 537 } 538 return NULL; 539 } 540 541 size_t 542 SymbolFileDWARFDebugMap::ParseCompileUnitFunctions (const SymbolContext& sc) 543 { 544 SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 545 if (oso_dwarf) 546 return oso_dwarf->ParseCompileUnitFunctions (sc); 547 return 0; 548 } 549 550 bool 551 SymbolFileDWARFDebugMap::ParseCompileUnitLineTable (const SymbolContext& sc) 552 { 553 SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 554 if (oso_dwarf) 555 return oso_dwarf->ParseCompileUnitLineTable (sc); 556 return false; 557 } 558 559 bool 560 SymbolFileDWARFDebugMap::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList &support_files) 561 { 562 SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 563 if (oso_dwarf) 564 return oso_dwarf->ParseCompileUnitSupportFiles (sc, support_files); 565 return false; 566 } 567 568 569 size_t 570 SymbolFileDWARFDebugMap::ParseFunctionBlocks (const SymbolContext& sc) 571 { 572 SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 573 if (oso_dwarf) 574 return oso_dwarf->ParseFunctionBlocks (sc); 575 return 0; 576 } 577 578 579 size_t 580 SymbolFileDWARFDebugMap::ParseTypes (const SymbolContext& sc) 581 { 582 SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 583 if (oso_dwarf) 584 return oso_dwarf->ParseTypes (sc); 585 return 0; 586 } 587 588 589 size_t 590 SymbolFileDWARFDebugMap::ParseVariablesForContext (const SymbolContext& sc) 591 { 592 SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 593 if (oso_dwarf) 594 return oso_dwarf->ParseTypes (sc); 595 return 0; 596 } 597 598 599 600 Type* 601 SymbolFileDWARFDebugMap::ResolveTypeUID(lldb::user_id_t type_uid) 602 { 603 const uint64_t oso_idx = GetOSOIndexFromUserID (type_uid); 604 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); 605 if (oso_dwarf) 606 oso_dwarf->ResolveTypeUID (type_uid); 607 return NULL; 608 } 609 610 lldb::clang_type_t 611 SymbolFileDWARFDebugMap::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type) 612 { 613 // We have a struct/union/class/enum that needs to be fully resolved. 614 return NULL; 615 } 616 617 uint32_t 618 SymbolFileDWARFDebugMap::ResolveSymbolContext (const Address& exe_so_addr, uint32_t resolve_scope, SymbolContext& sc) 619 { 620 uint32_t resolved_flags = 0; 621 Symtab* symtab = m_obj_file->GetSymtab(); 622 if (symtab) 623 { 624 const addr_t exe_file_addr = exe_so_addr.GetFileAddress(); 625 sc.symbol = symtab->FindSymbolContainingFileAddress (exe_file_addr, &m_func_indexes[0], m_func_indexes.size()); 626 627 if (sc.symbol != NULL) 628 { 629 resolved_flags |= eSymbolContextSymbol; 630 631 uint32_t oso_idx = 0; 632 CompileUnitInfo* comp_unit_info = GetCompileUnitInfoForSymbolWithID (sc.symbol->GetID(), &oso_idx); 633 if (comp_unit_info) 634 { 635 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); 636 ObjectFile *oso_objfile = GetObjectFileByOSOIndex (oso_idx); 637 if (oso_dwarf && oso_objfile) 638 { 639 SectionList *oso_section_list = oso_objfile->GetSectionList(); 640 641 SectionSP oso_symbol_section_sp (oso_section_list->FindSectionContainingLinkedFileAddress (exe_file_addr, UINT32_MAX)); 642 643 if (oso_symbol_section_sp) 644 { 645 const addr_t linked_file_addr = oso_symbol_section_sp->GetLinkedFileAddress(); 646 Address oso_so_addr (oso_symbol_section_sp, exe_file_addr - linked_file_addr); 647 if (oso_so_addr.IsSectionOffset()) 648 resolved_flags |= oso_dwarf->ResolveSymbolContext (oso_so_addr, resolve_scope, sc); 649 } 650 } 651 } 652 } 653 } 654 return resolved_flags; 655 } 656 657 658 uint32_t 659 SymbolFileDWARFDebugMap::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) 660 { 661 uint32_t initial = sc_list.GetSize(); 662 const uint32_t cu_count = GetNumCompileUnits(); 663 664 FileSpec so_file_spec; 665 for (uint32_t i=0; i<cu_count; ++i) 666 { 667 if (GetFileSpecForSO (i, so_file_spec)) 668 { 669 // By passing false to the comparison we will be able to match 670 // and files given a filename only. If both file_spec and 671 // so_file_spec have directories, we will still do a full match. 672 if (FileSpec::Compare (file_spec, so_file_spec, false) == 0) 673 { 674 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (i); 675 if (oso_dwarf) 676 oso_dwarf->ResolveSymbolContext(file_spec, line, check_inlines, resolve_scope, sc_list); 677 } 678 } 679 } 680 return sc_list.GetSize() - initial; 681 } 682 683 uint32_t 684 SymbolFileDWARFDebugMap::PrivateFindGlobalVariables 685 ( 686 const ConstString &name, 687 const ClangNamespaceDecl *namespace_decl, 688 const std::vector<uint32_t> &indexes, // Indexes into the symbol table that match "name" 689 uint32_t max_matches, 690 VariableList& variables 691 ) 692 { 693 const uint32_t original_size = variables.GetSize(); 694 const size_t match_count = indexes.size(); 695 for (size_t i=0; i<match_count; ++i) 696 { 697 uint32_t oso_idx; 698 CompileUnitInfo* comp_unit_info = GetCompileUnitInfoForSymbolWithIndex (indexes[i], &oso_idx); 699 if (comp_unit_info) 700 { 701 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); 702 if (oso_dwarf) 703 { 704 if (oso_dwarf->FindGlobalVariables(name, namespace_decl, true, max_matches, variables)) 705 if (variables.GetSize() > max_matches) 706 break; 707 } 708 } 709 } 710 return variables.GetSize() - original_size; 711 } 712 713 uint32_t 714 SymbolFileDWARFDebugMap::FindGlobalVariables (const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, VariableList& variables) 715 { 716 717 // If we aren't appending the results to this list, then clear the list 718 if (!append) 719 variables.Clear(); 720 721 // Remember how many variables are in the list before we search in case 722 // we are appending the results to a variable list. 723 const uint32_t original_size = variables.GetSize(); 724 725 uint32_t total_matches = 0; 726 SymbolFileDWARF *oso_dwarf; 727 for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 728 { 729 const uint32_t oso_matches = oso_dwarf->FindGlobalVariables (name, 730 namespace_decl, 731 true, 732 max_matches, 733 variables); 734 if (oso_matches > 0) 735 { 736 total_matches += oso_matches; 737 738 // Are we getting all matches? 739 if (max_matches == UINT32_MAX) 740 continue; // Yep, continue getting everything 741 742 // If we have found enough matches, lets get out 743 if (max_matches >= total_matches) 744 break; 745 746 // Update the max matches for any subsequent calls to find globals 747 // in any other object files with DWARF 748 max_matches -= oso_matches; 749 } 750 } 751 // Return the number of variable that were appended to the list 752 return variables.GetSize() - original_size; 753 } 754 755 756 uint32_t 757 SymbolFileDWARFDebugMap::FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables) 758 { 759 // If we aren't appending the results to this list, then clear the list 760 if (!append) 761 variables.Clear(); 762 763 // Remember how many variables are in the list before we search in case 764 // we are appending the results to a variable list. 765 const uint32_t original_size = variables.GetSize(); 766 767 uint32_t total_matches = 0; 768 SymbolFileDWARF *oso_dwarf; 769 for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 770 { 771 const uint32_t oso_matches = oso_dwarf->FindGlobalVariables (regex, 772 true, 773 max_matches, 774 variables); 775 if (oso_matches > 0) 776 { 777 total_matches += oso_matches; 778 779 // Are we getting all matches? 780 if (max_matches == UINT32_MAX) 781 continue; // Yep, continue getting everything 782 783 // If we have found enough matches, lets get out 784 if (max_matches >= total_matches) 785 break; 786 787 // Update the max matches for any subsequent calls to find globals 788 // in any other object files with DWARF 789 max_matches -= oso_matches; 790 } 791 } 792 // Return the number of variable that were appended to the list 793 return variables.GetSize() - original_size; 794 } 795 796 797 int 798 SymbolFileDWARFDebugMap::SymbolContainsSymbolWithIndex (uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info) 799 { 800 const uint32_t symbol_idx = *symbol_idx_ptr; 801 802 if (symbol_idx < comp_unit_info->first_symbol_index) 803 return -1; 804 805 if (symbol_idx <= comp_unit_info->last_symbol_index) 806 return 0; 807 808 return 1; 809 } 810 811 812 int 813 SymbolFileDWARFDebugMap::SymbolContainsSymbolWithID (user_id_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info) 814 { 815 const user_id_t symbol_id = *symbol_idx_ptr; 816 817 if (symbol_id < comp_unit_info->so_symbol->GetID()) 818 return -1; 819 820 if (symbol_id <= comp_unit_info->last_symbol->GetID()) 821 return 0; 822 823 return 1; 824 } 825 826 827 SymbolFileDWARFDebugMap::CompileUnitInfo* 828 SymbolFileDWARFDebugMap::GetCompileUnitInfoForSymbolWithIndex (uint32_t symbol_idx, uint32_t *oso_idx_ptr) 829 { 830 const uint32_t oso_index_count = m_compile_unit_infos.size(); 831 CompileUnitInfo *comp_unit_info = NULL; 832 if (oso_index_count) 833 { 834 comp_unit_info = (CompileUnitInfo*)bsearch(&symbol_idx, 835 &m_compile_unit_infos[0], 836 m_compile_unit_infos.size(), 837 sizeof(CompileUnitInfo), 838 (ComparisonFunction)SymbolContainsSymbolWithIndex); 839 } 840 841 if (oso_idx_ptr) 842 { 843 if (comp_unit_info != NULL) 844 *oso_idx_ptr = comp_unit_info - &m_compile_unit_infos[0]; 845 else 846 *oso_idx_ptr = UINT32_MAX; 847 } 848 return comp_unit_info; 849 } 850 851 SymbolFileDWARFDebugMap::CompileUnitInfo* 852 SymbolFileDWARFDebugMap::GetCompileUnitInfoForSymbolWithID (user_id_t symbol_id, uint32_t *oso_idx_ptr) 853 { 854 const uint32_t oso_index_count = m_compile_unit_infos.size(); 855 CompileUnitInfo *comp_unit_info = NULL; 856 if (oso_index_count) 857 { 858 comp_unit_info = (CompileUnitInfo*)::bsearch (&symbol_id, 859 &m_compile_unit_infos[0], 860 m_compile_unit_infos.size(), 861 sizeof(CompileUnitInfo), 862 (ComparisonFunction)SymbolContainsSymbolWithID); 863 } 864 865 if (oso_idx_ptr) 866 { 867 if (comp_unit_info != NULL) 868 *oso_idx_ptr = comp_unit_info - &m_compile_unit_infos[0]; 869 else 870 *oso_idx_ptr = UINT32_MAX; 871 } 872 return comp_unit_info; 873 } 874 875 876 static void 877 RemoveFunctionsWithModuleNotEqualTo (const ModuleSP &module_sp, SymbolContextList &sc_list, uint32_t start_idx) 878 { 879 // We found functions in .o files. Not all functions in the .o files 880 // will have made it into the final output file. The ones that did 881 // make it into the final output file will have a section whose module 882 // matches the module from the ObjectFile for this SymbolFile. When 883 // the modules don't match, then we have something that was in a 884 // .o file, but doesn't map to anything in the final executable. 885 uint32_t i=start_idx; 886 while (i < sc_list.GetSize()) 887 { 888 SymbolContext sc; 889 sc_list.GetContextAtIndex(i, sc); 890 if (sc.function) 891 { 892 const SectionSP section_sp (sc.function->GetAddressRange().GetBaseAddress().GetSection()); 893 if (section_sp->GetModule() != module_sp) 894 { 895 sc_list.RemoveContextAtIndex(i); 896 continue; 897 } 898 } 899 ++i; 900 } 901 } 902 903 uint32_t 904 SymbolFileDWARFDebugMap::FindFunctions(const ConstString &name, const ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list) 905 { 906 Timer scoped_timer (__PRETTY_FUNCTION__, 907 "SymbolFileDWARFDebugMap::FindFunctions (name = %s)", 908 name.GetCString()); 909 910 uint32_t initial_size = 0; 911 if (append) 912 initial_size = sc_list.GetSize(); 913 else 914 sc_list.Clear(); 915 916 uint32_t oso_idx = 0; 917 SymbolFileDWARF *oso_dwarf; 918 while ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx++)) != NULL) 919 { 920 uint32_t sc_idx = sc_list.GetSize(); 921 if (oso_dwarf->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, true, sc_list)) 922 { 923 RemoveFunctionsWithModuleNotEqualTo (m_obj_file->GetModule(), sc_list, sc_idx); 924 } 925 } 926 927 return sc_list.GetSize() - initial_size; 928 } 929 930 931 uint32_t 932 SymbolFileDWARFDebugMap::FindFunctions (const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list) 933 { 934 Timer scoped_timer (__PRETTY_FUNCTION__, 935 "SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')", 936 regex.GetText()); 937 938 uint32_t initial_size = 0; 939 if (append) 940 initial_size = sc_list.GetSize(); 941 else 942 sc_list.Clear(); 943 944 uint32_t oso_idx = 0; 945 SymbolFileDWARF *oso_dwarf; 946 while ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx++)) != NULL) 947 { 948 uint32_t sc_idx = sc_list.GetSize(); 949 950 if (oso_dwarf->FindFunctions(regex, include_inlines, true, sc_list)) 951 { 952 RemoveFunctionsWithModuleNotEqualTo (m_obj_file->GetModule(), sc_list, sc_idx); 953 } 954 } 955 956 return sc_list.GetSize() - initial_size; 957 } 958 959 TypeSP 960 SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx) 961 { 962 TypeSP type_sp; 963 SymbolFileDWARF *oso_dwarf; 964 for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 965 { 966 type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext (die_decl_ctx); 967 if (type_sp) 968 break; 969 } 970 return type_sp; 971 } 972 973 974 975 bool 976 SymbolFileDWARFDebugMap::Supports_DW_AT_APPLE_objc_complete_type (SymbolFileDWARF *skip_dwarf_oso) 977 { 978 if (m_supports_DW_AT_APPLE_objc_complete_type == eLazyBoolCalculate) 979 { 980 m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolNo; 981 SymbolFileDWARF *oso_dwarf; 982 for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 983 { 984 if (skip_dwarf_oso != oso_dwarf && oso_dwarf->Supports_DW_AT_APPLE_objc_complete_type(NULL)) 985 { 986 m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes; 987 break; 988 } 989 } 990 } 991 return m_supports_DW_AT_APPLE_objc_complete_type == eLazyBoolYes; 992 } 993 994 TypeSP 995 SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die, 996 const ConstString &type_name, 997 bool must_be_implementation) 998 { 999 TypeSP type_sp; 1000 SymbolFileDWARF *oso_dwarf; 1001 for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 1002 { 1003 type_sp = oso_dwarf->FindCompleteObjCDefinitionTypeForDIE (die, type_name, must_be_implementation); 1004 if (type_sp) 1005 break; 1006 } 1007 return type_sp; 1008 } 1009 1010 uint32_t 1011 SymbolFileDWARFDebugMap::FindTypes 1012 ( 1013 const SymbolContext& sc, 1014 const ConstString &name, 1015 const ClangNamespaceDecl *namespace_decl, 1016 bool append, 1017 uint32_t max_matches, 1018 TypeList& types 1019 ) 1020 { 1021 if (!append) 1022 types.Clear(); 1023 1024 const uint32_t initial_types_size = types.GetSize(); 1025 SymbolFileDWARF *oso_dwarf; 1026 1027 if (sc.comp_unit) 1028 { 1029 oso_dwarf = GetSymbolFile (sc); 1030 if (oso_dwarf) 1031 return oso_dwarf->FindTypes (sc, name, namespace_decl, append, max_matches, types); 1032 } 1033 else 1034 { 1035 uint32_t oso_idx = 0; 1036 while ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx++)) != NULL) 1037 oso_dwarf->FindTypes (sc, name, namespace_decl, append, max_matches, types); 1038 } 1039 1040 return types.GetSize() - initial_types_size; 1041 } 1042 1043 // 1044 //uint32_t 1045 //SymbolFileDWARFDebugMap::FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, Type::Encoding encoding, lldb::user_id_t udt_uid, TypeList& types) 1046 //{ 1047 // SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 1048 // if (oso_dwarf) 1049 // return oso_dwarf->FindTypes (sc, regex, append, max_matches, encoding, udt_uid, types); 1050 // return 0; 1051 //} 1052 1053 1054 ClangNamespaceDecl 1055 SymbolFileDWARFDebugMap::FindNamespace (const lldb_private::SymbolContext& sc, 1056 const lldb_private::ConstString &name, 1057 const ClangNamespaceDecl *parent_namespace_decl) 1058 { 1059 ClangNamespaceDecl matching_namespace; 1060 SymbolFileDWARF *oso_dwarf; 1061 1062 if (sc.comp_unit) 1063 { 1064 oso_dwarf = GetSymbolFile (sc); 1065 if (oso_dwarf) 1066 matching_namespace = oso_dwarf->FindNamespace (sc, name, parent_namespace_decl); 1067 } 1068 else 1069 { 1070 for (uint32_t oso_idx = 0; 1071 ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); 1072 ++oso_idx) 1073 { 1074 matching_namespace = oso_dwarf->FindNamespace (sc, name, parent_namespace_decl); 1075 1076 if (matching_namespace) 1077 break; 1078 } 1079 } 1080 1081 return matching_namespace; 1082 } 1083 1084 //------------------------------------------------------------------ 1085 // PluginInterface protocol 1086 //------------------------------------------------------------------ 1087 const char * 1088 SymbolFileDWARFDebugMap::GetPluginName() 1089 { 1090 return "SymbolFileDWARFDebugMap"; 1091 } 1092 1093 const char * 1094 SymbolFileDWARFDebugMap::GetShortPluginName() 1095 { 1096 return GetPluginNameStatic(); 1097 } 1098 1099 uint32_t 1100 SymbolFileDWARFDebugMap::GetPluginVersion() 1101 { 1102 return 1; 1103 } 1104 1105 void 1106 SymbolFileDWARFDebugMap::SetCompileUnit (SymbolFileDWARF *oso_dwarf, const CompUnitSP &cu_sp) 1107 { 1108 const uint32_t cu_count = GetNumCompileUnits(); 1109 for (uint32_t cu_idx=0; cu_idx<cu_count; ++cu_idx) 1110 { 1111 if (m_compile_unit_infos[cu_idx].oso_symbol_vendor && 1112 m_compile_unit_infos[cu_idx].oso_symbol_vendor->GetSymbolFile() == oso_dwarf) 1113 { 1114 if (m_compile_unit_infos[cu_idx].oso_compile_unit_sp) 1115 { 1116 assert (m_compile_unit_infos[cu_idx].oso_compile_unit_sp.get() == cu_sp.get()); 1117 } 1118 else 1119 { 1120 m_compile_unit_infos[cu_idx].oso_compile_unit_sp = cu_sp; 1121 m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(cu_idx, cu_sp); 1122 } 1123 } 1124 } 1125 } 1126 1127 1128 void 1129 SymbolFileDWARFDebugMap::CompleteTagDecl (void *baton, clang::TagDecl *decl) 1130 { 1131 SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton; 1132 clang_type_t clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl); 1133 if (clang_type) 1134 { 1135 SymbolFileDWARF *oso_dwarf; 1136 1137 for (uint32_t oso_idx = 0; ((oso_dwarf = symbol_file_dwarf->GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 1138 { 1139 if (oso_dwarf->HasForwardDeclForClangType (clang_type)) 1140 { 1141 oso_dwarf->ResolveClangOpaqueTypeDefinition (clang_type); 1142 return; 1143 } 1144 } 1145 } 1146 } 1147 1148 void 1149 SymbolFileDWARFDebugMap::CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *decl) 1150 { 1151 SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton; 1152 clang_type_t clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl); 1153 if (clang_type) 1154 { 1155 SymbolFileDWARF *oso_dwarf; 1156 1157 for (uint32_t oso_idx = 0; ((oso_dwarf = symbol_file_dwarf->GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 1158 { 1159 if (oso_dwarf->HasForwardDeclForClangType (clang_type)) 1160 { 1161 oso_dwarf->ResolveClangOpaqueTypeDefinition (clang_type); 1162 return; 1163 } 1164 } 1165 } 1166 } 1167 1168 bool 1169 SymbolFileDWARFDebugMap::LayoutRecordType (void *baton, 1170 const clang::RecordDecl *record_decl, 1171 uint64_t &size, 1172 uint64_t &alignment, 1173 llvm::DenseMap <const clang::FieldDecl *, uint64_t> &field_offsets, 1174 llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets, 1175 llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets) 1176 { 1177 SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton; 1178 SymbolFileDWARF *oso_dwarf; 1179 for (uint32_t oso_idx = 0; ((oso_dwarf = symbol_file_dwarf->GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 1180 { 1181 if (oso_dwarf->LayoutRecordType (record_decl, size, alignment, field_offsets, base_offsets, vbase_offsets)) 1182 return true; 1183 } 1184 return false; 1185 } 1186 1187 1188 1189 clang::DeclContext* 1190 SymbolFileDWARFDebugMap::GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) 1191 { 1192 const uint64_t oso_idx = GetOSOIndexFromUserID (type_uid); 1193 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); 1194 if (oso_dwarf) 1195 return oso_dwarf->GetClangDeclContextContainingTypeUID (type_uid); 1196 return NULL; 1197 } 1198 1199 clang::DeclContext* 1200 SymbolFileDWARFDebugMap::GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) 1201 { 1202 const uint64_t oso_idx = GetOSOIndexFromUserID (type_uid); 1203 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); 1204 if (oso_dwarf) 1205 return oso_dwarf->GetClangDeclContextForTypeUID (sc, type_uid); 1206 return NULL; 1207 } 1208 1209 1210