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