Index: lldb/trunk/source/Core/Module.cpp =================================================================== --- lldb/trunk/source/Core/Module.cpp +++ lldb/trunk/source/Core/Module.cpp @@ -1500,6 +1500,9 @@ // we don't have to do anything. return; } + + // Cleare the current symtab as we are going to replace it with a new one + obj_file->ClearSymtab(); // The symbol file might be a directory bundle ("/tmp/a.out.dSYM") instead // of a full path to the symbol file within the bundle Index: lldb/trunk/source/Host/common/Symbols.cpp =================================================================== --- lldb/trunk/source/Host/common/Symbols.cpp +++ lldb/trunk/source/Host/common/Symbols.cpp @@ -175,7 +175,7 @@ "LocateExecutableSymbolFileDsym (file = %s, arch = %s, uuid = %p)", exec_fspec ? exec_fspec->GetFilename().AsCString ("") : "", arch ? arch->GetArchitectureName() : "", - (void*)uuid); + (const void*)uuid); FileSpec symbol_fspec; // First try and find the dSYM in the same directory as the executable or in @@ -198,7 +198,7 @@ "LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)", exec_fspec ? exec_fspec->GetFilename().AsCString ("") : "", arch ? arch->GetArchitectureName() : "", - (void*)uuid); + (const void*)uuid); FileSpec objfile_fspec; ModuleSpecList module_specs; @@ -219,7 +219,11 @@ FileSpec Symbols::LocateExecutableSymbolFile (const ModuleSpec &module_spec) { - const char *symbol_filename = module_spec.GetSymbolFileSpec().GetFilename().AsCString(); + FileSpec symbol_file_spec = module_spec.GetSymbolFileSpec(); + if (symbol_file_spec.IsAbsolute() && symbol_file_spec.Exists()) + return symbol_file_spec; + + const char *symbol_filename = symbol_file_spec.GetFilename().AsCString(); if (symbol_filename && symbol_filename[0]) { FileSpecList debug_file_search_paths (Target::GetDefaultDebugFileSearchPaths()); Index: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp =================================================================== --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -905,8 +905,17 @@ AddressClass ObjectFileELF::GetAddressClass (addr_t file_addr) { - auto res = ObjectFile::GetAddressClass (file_addr); + Symtab* symtab = GetSymtab(); + if (!symtab) + return eAddressClassUnknown; + + // The address class is determined based on the symtab. Ask it from the object file what + // contains the symtab information. + ObjectFile* symtab_objfile = symtab->GetObjectFile(); + if (symtab_objfile != nullptr && symtab_objfile != this) + return symtab_objfile->GetAddressClass(file_addr); + auto res = ObjectFile::GetAddressClass (file_addr); if (res != eAddressClassCode) return res; @@ -1976,7 +1985,6 @@ m_address_class_map[symbol.st_value] = eAddressClassData; } } - continue; } } @@ -2031,9 +2039,13 @@ } } - // If the symbol section we've found has no data (SHT_NOBITS), then check the module section - // list. This can happen if we're parsing the debug file and it has no .text section, for example. - if (symbol_section_sp && (symbol_section_sp->GetFileSize() == 0)) + // symbol_value_offset may contain 0 for ARM symbols or -1 for + // THUMB symbols. See above for more details. + uint64_t symbol_value = symbol.st_value + symbol_value_offset; + if (symbol_section_sp && CalculateType() != ObjectFile::Type::eTypeObjectFile) + symbol_value -= symbol_section_sp->GetFileAddress(); + + if (symbol_section_sp) { ModuleSP module_sp(GetModule()); if (module_sp) @@ -2051,11 +2063,6 @@ } } - // symbol_value_offset may contain 0 for ARM symbols or -1 for - // THUMB symbols. See above for more details. - uint64_t symbol_value = symbol.st_value + symbol_value_offset; - if (symbol_section_sp && CalculateType() != ObjectFile::Type::eTypeObjectFile) - symbol_value -= symbol_section_sp->GetFileAddress(); bool is_global = symbol.getBinding() == STB_GLOBAL; uint32_t flags = symbol.st_other << 8 | symbol.st_info | additional_flags; bool is_mangled = symbol_name ? (symbol_name[0] == '_' && symbol_name[1] == 'Z') : false; @@ -2563,8 +2570,6 @@ uint64_t symbol_id = 0; lldb_private::Mutex::Locker locker(module_sp->GetMutex()); - m_symtab_ap.reset(new Symtab(this)); - // Sharable objects and dynamic executables usually have 2 distinct symbol // tables, one named ".symtab", and the other ".dynsym". The dynsym is a smaller // version of the symtab that only contains global symbols. The information found @@ -2578,7 +2583,10 @@ symtab = section_list->FindSectionByType (eSectionTypeELFDynamicSymbols, true).get(); } if (symtab) + { + m_symtab_ap.reset(new Symtab(symtab->GetObjectFile())); symbol_id += ParseSymbolTable (m_symtab_ap.get(), symbol_id, symtab); + } // DT_JMPREL // If present, this entry's d_ptr member holds the address of relocation @@ -2598,10 +2606,19 @@ user_id_t reloc_id = reloc_section->GetID(); const ELFSectionHeaderInfo *reloc_header = GetSectionHeaderByIndex(reloc_id); assert(reloc_header); + + if (m_symtab_ap == nullptr) + m_symtab_ap.reset(new Symtab(reloc_section->GetObjectFile())); ParseTrampolineSymbols (m_symtab_ap.get(), symbol_id, reloc_header, reloc_id); } } + + // If we still don't have any symtab then create an empty instance to avoid do the section + // lookup next time. + if (m_symtab_ap == nullptr) + m_symtab_ap.reset(new Symtab(this)); + m_symtab_ap->CalculateSymbolSizes(); } Index: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -115,6 +115,7 @@ if (symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, m_code_indexes)) { symtab->SortSymbolIndexesByValue(m_code_indexes, true); + abilities |= Functions; } if (symtab->AppendSymbolIndexesWithType(eSymbolTypeData, m_data_indexes))