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 oso_objfile->GetSectionList()->Finalize(); // Now that we're done adding sections, finalize to build fast-lookup caches 430 comp_unit_info->debug_map_sections_sp->Finalize(); 431 #if defined(DEBUG_OSO_DMAP) 432 s << "OSO sections after:\n"; 433 oso_objfile->GetSectionList()->Dump(&s, NULL, true); 434 #endif 435 } 436 } 437 } 438 if (comp_unit_info->oso_symbol_vendor) 439 return (SymbolFileDWARF *)comp_unit_info->oso_symbol_vendor->GetSymbolFile(); 440 return NULL; 441 } 442 443 uint32_t 444 SymbolFileDWARFDebugMap::CalculateAbilities () 445 { 446 // In order to get the abilities of this plug-in, we look at the list of 447 // N_OSO entries (object files) from the symbol table and make sure that 448 // these files exist and also contain valid DWARF. If we get any of that 449 // then we return the abilities of the first N_OSO's DWARF. 450 451 const uint32_t oso_index_count = GetNumCompileUnits(); 452 if (oso_index_count > 0) 453 { 454 const uint32_t dwarf_abilities = SymbolFile::CompileUnits | 455 SymbolFile::Functions | 456 SymbolFile::Blocks | 457 SymbolFile::GlobalVariables | 458 SymbolFile::LocalVariables | 459 SymbolFile::VariableTypes | 460 SymbolFile::LineTables; 461 462 for (uint32_t oso_idx=0; oso_idx<oso_index_count; ++oso_idx) 463 { 464 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); 465 if (oso_dwarf) 466 { 467 uint32_t oso_abilities = oso_dwarf->GetAbilities(); 468 if ((oso_abilities & dwarf_abilities) == dwarf_abilities) 469 return oso_abilities; 470 } 471 } 472 } 473 return 0; 474 } 475 476 uint32_t 477 SymbolFileDWARFDebugMap::GetNumCompileUnits() 478 { 479 InitOSO (); 480 return m_compile_unit_infos.size(); 481 } 482 483 484 CompUnitSP 485 SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) 486 { 487 CompUnitSP comp_unit_sp; 488 const uint32_t cu_count = GetNumCompileUnits(); 489 490 if (cu_idx < cu_count) 491 { 492 if (m_compile_unit_infos[cu_idx].oso_compile_unit_sp.get() == NULL && 493 m_compile_unit_infos[cu_idx].symbol_file_supported) 494 { 495 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (cu_idx); 496 if (oso_dwarf) 497 { 498 // There is only one compile unit for N_OSO entry right now, so 499 // it will always exist at index zero. 500 m_compile_unit_infos[cu_idx].oso_compile_unit_sp = m_compile_unit_infos[cu_idx].oso_symbol_vendor->GetCompileUnitAtIndex (0); 501 } 502 503 if (m_compile_unit_infos[cu_idx].oso_compile_unit_sp.get() == NULL) 504 { 505 // We weren't able to get the DWARF for this N_OSO entry (the 506 // .o file may be missing or not at the specified path), make 507 // one up as best we can from the debug map. We set the uid 508 // of the compile unit to the symbol index with the MSBit set 509 // so that it doesn't collide with any uid values from the DWARF 510 Symbol *so_symbol = m_compile_unit_infos[cu_idx].so_symbol; 511 if (so_symbol) 512 { 513 m_compile_unit_infos[cu_idx].oso_compile_unit_sp.reset(new CompileUnit (m_obj_file->GetModule(), 514 NULL, 515 so_symbol->GetMangled().GetName().AsCString(), 516 cu_idx, 517 eLanguageTypeUnknown)); 518 519 // Let our symbol vendor know about this compile unit 520 m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex (cu_idx, 521 m_compile_unit_infos[cu_idx].oso_compile_unit_sp); 522 } 523 } 524 } 525 comp_unit_sp = m_compile_unit_infos[cu_idx].oso_compile_unit_sp; 526 } 527 528 return comp_unit_sp; 529 } 530 531 SymbolFileDWARFDebugMap::CompileUnitInfo * 532 SymbolFileDWARFDebugMap::GetCompUnitInfo (const SymbolContext& sc) 533 { 534 const uint32_t cu_count = GetNumCompileUnits(); 535 for (uint32_t i=0; i<cu_count; ++i) 536 { 537 if (sc.comp_unit == m_compile_unit_infos[i].oso_compile_unit_sp.get()) 538 return &m_compile_unit_infos[i]; 539 } 540 return NULL; 541 } 542 543 size_t 544 SymbolFileDWARFDebugMap::ParseCompileUnitFunctions (const SymbolContext& sc) 545 { 546 SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 547 if (oso_dwarf) 548 return oso_dwarf->ParseCompileUnitFunctions (sc); 549 return 0; 550 } 551 552 bool 553 SymbolFileDWARFDebugMap::ParseCompileUnitLineTable (const SymbolContext& sc) 554 { 555 SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 556 if (oso_dwarf) 557 return oso_dwarf->ParseCompileUnitLineTable (sc); 558 return false; 559 } 560 561 bool 562 SymbolFileDWARFDebugMap::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList &support_files) 563 { 564 SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 565 if (oso_dwarf) 566 return oso_dwarf->ParseCompileUnitSupportFiles (sc, support_files); 567 return false; 568 } 569 570 571 size_t 572 SymbolFileDWARFDebugMap::ParseFunctionBlocks (const SymbolContext& sc) 573 { 574 SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 575 if (oso_dwarf) 576 return oso_dwarf->ParseFunctionBlocks (sc); 577 return 0; 578 } 579 580 581 size_t 582 SymbolFileDWARFDebugMap::ParseTypes (const SymbolContext& sc) 583 { 584 SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 585 if (oso_dwarf) 586 return oso_dwarf->ParseTypes (sc); 587 return 0; 588 } 589 590 591 size_t 592 SymbolFileDWARFDebugMap::ParseVariablesForContext (const SymbolContext& sc) 593 { 594 SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 595 if (oso_dwarf) 596 return oso_dwarf->ParseTypes (sc); 597 return 0; 598 } 599 600 601 602 Type* 603 SymbolFileDWARFDebugMap::ResolveTypeUID(lldb::user_id_t type_uid) 604 { 605 const uint64_t oso_idx = GetOSOIndexFromUserID (type_uid); 606 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); 607 if (oso_dwarf) 608 oso_dwarf->ResolveTypeUID (type_uid); 609 return NULL; 610 } 611 612 lldb::clang_type_t 613 SymbolFileDWARFDebugMap::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type) 614 { 615 // We have a struct/union/class/enum that needs to be fully resolved. 616 return NULL; 617 } 618 619 uint32_t 620 SymbolFileDWARFDebugMap::ResolveSymbolContext (const Address& exe_so_addr, uint32_t resolve_scope, SymbolContext& sc) 621 { 622 uint32_t resolved_flags = 0; 623 Symtab* symtab = m_obj_file->GetSymtab(); 624 if (symtab) 625 { 626 const addr_t exe_file_addr = exe_so_addr.GetFileAddress(); 627 sc.symbol = symtab->FindSymbolContainingFileAddress (exe_file_addr, &m_func_indexes[0], m_func_indexes.size()); 628 629 if (sc.symbol != NULL) 630 { 631 resolved_flags |= eSymbolContextSymbol; 632 633 uint32_t oso_idx = 0; 634 CompileUnitInfo* comp_unit_info = GetCompileUnitInfoForSymbolWithID (sc.symbol->GetID(), &oso_idx); 635 if (comp_unit_info) 636 { 637 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); 638 ObjectFile *oso_objfile = GetObjectFileByOSOIndex (oso_idx); 639 if (oso_dwarf && oso_objfile) 640 { 641 SectionList *oso_section_list = oso_objfile->GetSectionList(); 642 643 SectionSP oso_symbol_section_sp (oso_section_list->FindSectionContainingLinkedFileAddress (exe_file_addr, UINT32_MAX)); 644 645 if (oso_symbol_section_sp) 646 { 647 const addr_t linked_file_addr = oso_symbol_section_sp->GetLinkedFileAddress(); 648 Address oso_so_addr (oso_symbol_section_sp, exe_file_addr - linked_file_addr); 649 if (oso_so_addr.IsSectionOffset()) 650 resolved_flags |= oso_dwarf->ResolveSymbolContext (oso_so_addr, resolve_scope, sc); 651 } 652 } 653 } 654 } 655 } 656 return resolved_flags; 657 } 658 659 660 uint32_t 661 SymbolFileDWARFDebugMap::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) 662 { 663 uint32_t initial = sc_list.GetSize(); 664 const uint32_t cu_count = GetNumCompileUnits(); 665 666 FileSpec so_file_spec; 667 for (uint32_t i=0; i<cu_count; ++i) 668 { 669 if (GetFileSpecForSO (i, so_file_spec)) 670 { 671 // By passing false to the comparison we will be able to match 672 // and files given a filename only. If both file_spec and 673 // so_file_spec have directories, we will still do a full match. 674 if (FileSpec::Compare (file_spec, so_file_spec, false) == 0) 675 { 676 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (i); 677 if (oso_dwarf) 678 oso_dwarf->ResolveSymbolContext(file_spec, line, check_inlines, resolve_scope, sc_list); 679 } 680 } 681 } 682 return sc_list.GetSize() - initial; 683 } 684 685 uint32_t 686 SymbolFileDWARFDebugMap::PrivateFindGlobalVariables 687 ( 688 const ConstString &name, 689 const ClangNamespaceDecl *namespace_decl, 690 const std::vector<uint32_t> &indexes, // Indexes into the symbol table that match "name" 691 uint32_t max_matches, 692 VariableList& variables 693 ) 694 { 695 const uint32_t original_size = variables.GetSize(); 696 const size_t match_count = indexes.size(); 697 for (size_t i=0; i<match_count; ++i) 698 { 699 uint32_t oso_idx; 700 CompileUnitInfo* comp_unit_info = GetCompileUnitInfoForSymbolWithIndex (indexes[i], &oso_idx); 701 if (comp_unit_info) 702 { 703 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); 704 if (oso_dwarf) 705 { 706 if (oso_dwarf->FindGlobalVariables(name, namespace_decl, true, max_matches, variables)) 707 if (variables.GetSize() > max_matches) 708 break; 709 } 710 } 711 } 712 return variables.GetSize() - original_size; 713 } 714 715 uint32_t 716 SymbolFileDWARFDebugMap::FindGlobalVariables (const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, VariableList& variables) 717 { 718 719 // If we aren't appending the results to this list, then clear the list 720 if (!append) 721 variables.Clear(); 722 723 // Remember how many variables are in the list before we search in case 724 // we are appending the results to a variable list. 725 const uint32_t original_size = variables.GetSize(); 726 727 uint32_t total_matches = 0; 728 SymbolFileDWARF *oso_dwarf; 729 for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 730 { 731 const uint32_t oso_matches = oso_dwarf->FindGlobalVariables (name, 732 namespace_decl, 733 true, 734 max_matches, 735 variables); 736 if (oso_matches > 0) 737 { 738 total_matches += oso_matches; 739 740 // Are we getting all matches? 741 if (max_matches == UINT32_MAX) 742 continue; // Yep, continue getting everything 743 744 // If we have found enough matches, lets get out 745 if (max_matches >= total_matches) 746 break; 747 748 // Update the max matches for any subsequent calls to find globals 749 // in any other object files with DWARF 750 max_matches -= oso_matches; 751 } 752 } 753 // Return the number of variable that were appended to the list 754 return variables.GetSize() - original_size; 755 } 756 757 758 uint32_t 759 SymbolFileDWARFDebugMap::FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables) 760 { 761 // If we aren't appending the results to this list, then clear the list 762 if (!append) 763 variables.Clear(); 764 765 // Remember how many variables are in the list before we search in case 766 // we are appending the results to a variable list. 767 const uint32_t original_size = variables.GetSize(); 768 769 uint32_t total_matches = 0; 770 SymbolFileDWARF *oso_dwarf; 771 for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 772 { 773 const uint32_t oso_matches = oso_dwarf->FindGlobalVariables (regex, 774 true, 775 max_matches, 776 variables); 777 if (oso_matches > 0) 778 { 779 total_matches += oso_matches; 780 781 // Are we getting all matches? 782 if (max_matches == UINT32_MAX) 783 continue; // Yep, continue getting everything 784 785 // If we have found enough matches, lets get out 786 if (max_matches >= total_matches) 787 break; 788 789 // Update the max matches for any subsequent calls to find globals 790 // in any other object files with DWARF 791 max_matches -= oso_matches; 792 } 793 } 794 // Return the number of variable that were appended to the list 795 return variables.GetSize() - original_size; 796 } 797 798 799 int 800 SymbolFileDWARFDebugMap::SymbolContainsSymbolWithIndex (uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info) 801 { 802 const uint32_t symbol_idx = *symbol_idx_ptr; 803 804 if (symbol_idx < comp_unit_info->first_symbol_index) 805 return -1; 806 807 if (symbol_idx <= comp_unit_info->last_symbol_index) 808 return 0; 809 810 return 1; 811 } 812 813 814 int 815 SymbolFileDWARFDebugMap::SymbolContainsSymbolWithID (user_id_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info) 816 { 817 const user_id_t symbol_id = *symbol_idx_ptr; 818 819 if (symbol_id < comp_unit_info->so_symbol->GetID()) 820 return -1; 821 822 if (symbol_id <= comp_unit_info->last_symbol->GetID()) 823 return 0; 824 825 return 1; 826 } 827 828 829 SymbolFileDWARFDebugMap::CompileUnitInfo* 830 SymbolFileDWARFDebugMap::GetCompileUnitInfoForSymbolWithIndex (uint32_t symbol_idx, uint32_t *oso_idx_ptr) 831 { 832 const uint32_t oso_index_count = m_compile_unit_infos.size(); 833 CompileUnitInfo *comp_unit_info = NULL; 834 if (oso_index_count) 835 { 836 comp_unit_info = (CompileUnitInfo*)bsearch(&symbol_idx, 837 &m_compile_unit_infos[0], 838 m_compile_unit_infos.size(), 839 sizeof(CompileUnitInfo), 840 (ComparisonFunction)SymbolContainsSymbolWithIndex); 841 } 842 843 if (oso_idx_ptr) 844 { 845 if (comp_unit_info != NULL) 846 *oso_idx_ptr = comp_unit_info - &m_compile_unit_infos[0]; 847 else 848 *oso_idx_ptr = UINT32_MAX; 849 } 850 return comp_unit_info; 851 } 852 853 SymbolFileDWARFDebugMap::CompileUnitInfo* 854 SymbolFileDWARFDebugMap::GetCompileUnitInfoForSymbolWithID (user_id_t symbol_id, uint32_t *oso_idx_ptr) 855 { 856 const uint32_t oso_index_count = m_compile_unit_infos.size(); 857 CompileUnitInfo *comp_unit_info = NULL; 858 if (oso_index_count) 859 { 860 comp_unit_info = (CompileUnitInfo*)::bsearch (&symbol_id, 861 &m_compile_unit_infos[0], 862 m_compile_unit_infos.size(), 863 sizeof(CompileUnitInfo), 864 (ComparisonFunction)SymbolContainsSymbolWithID); 865 } 866 867 if (oso_idx_ptr) 868 { 869 if (comp_unit_info != NULL) 870 *oso_idx_ptr = comp_unit_info - &m_compile_unit_infos[0]; 871 else 872 *oso_idx_ptr = UINT32_MAX; 873 } 874 return comp_unit_info; 875 } 876 877 878 static void 879 RemoveFunctionsWithModuleNotEqualTo (const ModuleSP &module_sp, SymbolContextList &sc_list, uint32_t start_idx) 880 { 881 // We found functions in .o files. Not all functions in the .o files 882 // will have made it into the final output file. The ones that did 883 // make it into the final output file will have a section whose module 884 // matches the module from the ObjectFile for this SymbolFile. When 885 // the modules don't match, then we have something that was in a 886 // .o file, but doesn't map to anything in the final executable. 887 uint32_t i=start_idx; 888 while (i < sc_list.GetSize()) 889 { 890 SymbolContext sc; 891 sc_list.GetContextAtIndex(i, sc); 892 if (sc.function) 893 { 894 const SectionSP section_sp (sc.function->GetAddressRange().GetBaseAddress().GetSection()); 895 if (section_sp->GetModule() != module_sp) 896 { 897 sc_list.RemoveContextAtIndex(i); 898 continue; 899 } 900 } 901 ++i; 902 } 903 } 904 905 uint32_t 906 SymbolFileDWARFDebugMap::FindFunctions(const ConstString &name, const ClangNamespaceDecl *namespace_decl, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list) 907 { 908 Timer scoped_timer (__PRETTY_FUNCTION__, 909 "SymbolFileDWARFDebugMap::FindFunctions (name = %s)", 910 name.GetCString()); 911 912 uint32_t initial_size = 0; 913 if (append) 914 initial_size = sc_list.GetSize(); 915 else 916 sc_list.Clear(); 917 918 uint32_t oso_idx = 0; 919 SymbolFileDWARF *oso_dwarf; 920 while ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx++)) != NULL) 921 { 922 uint32_t sc_idx = sc_list.GetSize(); 923 if (oso_dwarf->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, true, sc_list)) 924 { 925 RemoveFunctionsWithModuleNotEqualTo (m_obj_file->GetModule(), sc_list, sc_idx); 926 } 927 } 928 929 return sc_list.GetSize() - initial_size; 930 } 931 932 933 uint32_t 934 SymbolFileDWARFDebugMap::FindFunctions (const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list) 935 { 936 Timer scoped_timer (__PRETTY_FUNCTION__, 937 "SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')", 938 regex.GetText()); 939 940 uint32_t initial_size = 0; 941 if (append) 942 initial_size = sc_list.GetSize(); 943 else 944 sc_list.Clear(); 945 946 uint32_t oso_idx = 0; 947 SymbolFileDWARF *oso_dwarf; 948 while ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx++)) != NULL) 949 { 950 uint32_t sc_idx = sc_list.GetSize(); 951 952 if (oso_dwarf->FindFunctions(regex, include_inlines, true, sc_list)) 953 { 954 RemoveFunctionsWithModuleNotEqualTo (m_obj_file->GetModule(), sc_list, sc_idx); 955 } 956 } 957 958 return sc_list.GetSize() - initial_size; 959 } 960 961 TypeSP 962 SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx) 963 { 964 TypeSP type_sp; 965 SymbolFileDWARF *oso_dwarf; 966 for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 967 { 968 type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext (die_decl_ctx); 969 if (type_sp) 970 break; 971 } 972 return type_sp; 973 } 974 975 976 977 bool 978 SymbolFileDWARFDebugMap::Supports_DW_AT_APPLE_objc_complete_type (SymbolFileDWARF *skip_dwarf_oso) 979 { 980 if (m_supports_DW_AT_APPLE_objc_complete_type == eLazyBoolCalculate) 981 { 982 m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolNo; 983 SymbolFileDWARF *oso_dwarf; 984 for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 985 { 986 if (skip_dwarf_oso != oso_dwarf && oso_dwarf->Supports_DW_AT_APPLE_objc_complete_type(NULL)) 987 { 988 m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes; 989 break; 990 } 991 } 992 } 993 return m_supports_DW_AT_APPLE_objc_complete_type == eLazyBoolYes; 994 } 995 996 TypeSP 997 SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die, 998 const ConstString &type_name, 999 bool must_be_implementation) 1000 { 1001 TypeSP type_sp; 1002 SymbolFileDWARF *oso_dwarf; 1003 for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 1004 { 1005 type_sp = oso_dwarf->FindCompleteObjCDefinitionTypeForDIE (die, type_name, must_be_implementation); 1006 if (type_sp) 1007 break; 1008 } 1009 return type_sp; 1010 } 1011 1012 uint32_t 1013 SymbolFileDWARFDebugMap::FindTypes 1014 ( 1015 const SymbolContext& sc, 1016 const ConstString &name, 1017 const ClangNamespaceDecl *namespace_decl, 1018 bool append, 1019 uint32_t max_matches, 1020 TypeList& types 1021 ) 1022 { 1023 if (!append) 1024 types.Clear(); 1025 1026 const uint32_t initial_types_size = types.GetSize(); 1027 SymbolFileDWARF *oso_dwarf; 1028 1029 if (sc.comp_unit) 1030 { 1031 oso_dwarf = GetSymbolFile (sc); 1032 if (oso_dwarf) 1033 return oso_dwarf->FindTypes (sc, name, namespace_decl, append, max_matches, types); 1034 } 1035 else 1036 { 1037 uint32_t oso_idx = 0; 1038 while ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx++)) != NULL) 1039 oso_dwarf->FindTypes (sc, name, namespace_decl, append, max_matches, types); 1040 } 1041 1042 return types.GetSize() - initial_types_size; 1043 } 1044 1045 // 1046 //uint32_t 1047 //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) 1048 //{ 1049 // SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); 1050 // if (oso_dwarf) 1051 // return oso_dwarf->FindTypes (sc, regex, append, max_matches, encoding, udt_uid, types); 1052 // return 0; 1053 //} 1054 1055 1056 ClangNamespaceDecl 1057 SymbolFileDWARFDebugMap::FindNamespace (const lldb_private::SymbolContext& sc, 1058 const lldb_private::ConstString &name, 1059 const ClangNamespaceDecl *parent_namespace_decl) 1060 { 1061 ClangNamespaceDecl matching_namespace; 1062 SymbolFileDWARF *oso_dwarf; 1063 1064 if (sc.comp_unit) 1065 { 1066 oso_dwarf = GetSymbolFile (sc); 1067 if (oso_dwarf) 1068 matching_namespace = oso_dwarf->FindNamespace (sc, name, parent_namespace_decl); 1069 } 1070 else 1071 { 1072 for (uint32_t oso_idx = 0; 1073 ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); 1074 ++oso_idx) 1075 { 1076 matching_namespace = oso_dwarf->FindNamespace (sc, name, parent_namespace_decl); 1077 1078 if (matching_namespace) 1079 break; 1080 } 1081 } 1082 1083 return matching_namespace; 1084 } 1085 1086 //------------------------------------------------------------------ 1087 // PluginInterface protocol 1088 //------------------------------------------------------------------ 1089 const char * 1090 SymbolFileDWARFDebugMap::GetPluginName() 1091 { 1092 return "SymbolFileDWARFDebugMap"; 1093 } 1094 1095 const char * 1096 SymbolFileDWARFDebugMap::GetShortPluginName() 1097 { 1098 return GetPluginNameStatic(); 1099 } 1100 1101 uint32_t 1102 SymbolFileDWARFDebugMap::GetPluginVersion() 1103 { 1104 return 1; 1105 } 1106 1107 void 1108 SymbolFileDWARFDebugMap::SetCompileUnit (SymbolFileDWARF *oso_dwarf, const CompUnitSP &cu_sp) 1109 { 1110 const uint32_t cu_count = GetNumCompileUnits(); 1111 for (uint32_t cu_idx=0; cu_idx<cu_count; ++cu_idx) 1112 { 1113 if (m_compile_unit_infos[cu_idx].oso_symbol_vendor && 1114 m_compile_unit_infos[cu_idx].oso_symbol_vendor->GetSymbolFile() == oso_dwarf) 1115 { 1116 if (m_compile_unit_infos[cu_idx].oso_compile_unit_sp) 1117 { 1118 assert (m_compile_unit_infos[cu_idx].oso_compile_unit_sp.get() == cu_sp.get()); 1119 } 1120 else 1121 { 1122 m_compile_unit_infos[cu_idx].oso_compile_unit_sp = cu_sp; 1123 m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(cu_idx, cu_sp); 1124 } 1125 } 1126 } 1127 } 1128 1129 1130 void 1131 SymbolFileDWARFDebugMap::CompleteTagDecl (void *baton, clang::TagDecl *decl) 1132 { 1133 SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton; 1134 clang_type_t clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl); 1135 if (clang_type) 1136 { 1137 SymbolFileDWARF *oso_dwarf; 1138 1139 for (uint32_t oso_idx = 0; ((oso_dwarf = symbol_file_dwarf->GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 1140 { 1141 if (oso_dwarf->HasForwardDeclForClangType (clang_type)) 1142 { 1143 oso_dwarf->ResolveClangOpaqueTypeDefinition (clang_type); 1144 return; 1145 } 1146 } 1147 } 1148 } 1149 1150 void 1151 SymbolFileDWARFDebugMap::CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *decl) 1152 { 1153 SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton; 1154 clang_type_t clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl); 1155 if (clang_type) 1156 { 1157 SymbolFileDWARF *oso_dwarf; 1158 1159 for (uint32_t oso_idx = 0; ((oso_dwarf = symbol_file_dwarf->GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 1160 { 1161 if (oso_dwarf->HasForwardDeclForClangType (clang_type)) 1162 { 1163 oso_dwarf->ResolveClangOpaqueTypeDefinition (clang_type); 1164 return; 1165 } 1166 } 1167 } 1168 } 1169 1170 bool 1171 SymbolFileDWARFDebugMap::LayoutRecordType (void *baton, 1172 const clang::RecordDecl *record_decl, 1173 uint64_t &size, 1174 uint64_t &alignment, 1175 llvm::DenseMap <const clang::FieldDecl *, uint64_t> &field_offsets, 1176 llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets, 1177 llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets) 1178 { 1179 SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton; 1180 SymbolFileDWARF *oso_dwarf; 1181 for (uint32_t oso_idx = 0; ((oso_dwarf = symbol_file_dwarf->GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) 1182 { 1183 if (oso_dwarf->LayoutRecordType (record_decl, size, alignment, field_offsets, base_offsets, vbase_offsets)) 1184 return true; 1185 } 1186 return false; 1187 } 1188 1189 1190 1191 clang::DeclContext* 1192 SymbolFileDWARFDebugMap::GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) 1193 { 1194 const uint64_t oso_idx = GetOSOIndexFromUserID (type_uid); 1195 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); 1196 if (oso_dwarf) 1197 return oso_dwarf->GetClangDeclContextContainingTypeUID (type_uid); 1198 return NULL; 1199 } 1200 1201 clang::DeclContext* 1202 SymbolFileDWARFDebugMap::GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) 1203 { 1204 const uint64_t oso_idx = GetOSOIndexFromUserID (type_uid); 1205 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); 1206 if (oso_dwarf) 1207 return oso_dwarf->GetClangDeclContextForTypeUID (sc, type_uid); 1208 return NULL; 1209 } 1210 1211 1212