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 @@ -2764,6 +2764,14 @@ case R_386_32: case R_386_PC32: default: + // FIXME: This asserts with this input: + // + // foo.cpp + // int main(int argc, char **argv) { return 0; } + // + // clang++.exe --target=i686-unknown-linux-gnu -g -c foo.cpp -o foo.o + // + // and running this on the foo.o module. assert(false && "unexpected relocation type"); } } else { Index: lldb/trunk/tools/lldb-test/lldb-test.cpp =================================================================== --- lldb/trunk/tools/lldb-test/lldb-test.cpp +++ lldb/trunk/tools/lldb-test/lldb-test.cpp @@ -10,11 +10,15 @@ #include "FormatUtil.h" #include "SystemInitializerTest.h" +#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" #include "lldb/Initialization/SystemLifetimeManager.h" +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/ClangASTImporter.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/StreamString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/CommandLine.h" @@ -30,6 +34,7 @@ namespace opts { cl::SubCommand ModuleSubcommand("module-sections", "Display LLDB Module Information"); +cl::SubCommand SymbolsSubcommand("symbols", "Dump symbols for an object file"); namespace module { cl::opt SectionContents("contents", @@ -38,10 +43,30 @@ cl::list InputFilenames(cl::Positional, cl::desc(""), cl::OneOrMore, cl::sub(ModuleSubcommand)); } // namespace module + +namespace symbols { +cl::list InputFilenames(cl::Positional, cl::desc(""), + cl::OneOrMore, cl::sub(SymbolsSubcommand)); +} } // namespace opts static llvm::ManagedStatic DebuggerLifetime; +static void dumpSymbols(Debugger &Dbg) { + for (const auto &File : opts::symbols::InputFilenames) { + ModuleSpec Spec{FileSpec(File, false)}; + Spec.GetSymbolFileSpec().SetFile(File, false); + + auto ModulePtr = std::make_shared(Spec); + + StreamString Stream; + ModulePtr->ParseAllDebugSymbols(); + ModulePtr->Dump(&Stream); + llvm::outs() << Stream.GetData() << "\n"; + llvm::outs().flush(); + } +} + static void dumpModules(Debugger &Dbg) { LinePrinter Printer(4, llvm::outs()); @@ -49,7 +74,7 @@ ModuleSpec Spec{FileSpec(File, false)}; Spec.GetSymbolFileSpec().SetFile(File, false); - auto ModulePtr = std::make_shared(Spec); + auto ModulePtr = std::make_shared(Spec); SectionList *Sections = ModulePtr->GetSectionList(); if (!Sections) { llvm::errs() << "Could not load sections for module " << File << "\n"; @@ -92,6 +117,8 @@ if (opts::ModuleSubcommand) dumpModules(*Dbg); + else if (opts::SymbolsSubcommand) + dumpSymbols(*Dbg); DebuggerLifetime->Terminate(); return 0;