Changeset View
Changeset View
Standalone View
Standalone View
tools/lldb-test/lldb-test.cpp
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | cl::opt<bool> SectionDependentModules("dep-modules", | ||||
cl::desc("Dump each dependent module"), | cl::desc("Dump each dependent module"), | ||||
cl::sub(ObjectFileSubcommand)); | cl::sub(ObjectFileSubcommand)); | ||||
cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input files>"), | cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input files>"), | ||||
cl::OneOrMore, | cl::OneOrMore, | ||||
cl::sub(ObjectFileSubcommand)); | cl::sub(ObjectFileSubcommand)); | ||||
} // namespace object | } // namespace object | ||||
namespace symbols { | namespace symbols { | ||||
static cl::list<std::string> InputFilenames(cl::Positional, | static cl::opt<std::string> InputFile(cl::Positional, cl::desc("<input file>"), | ||||
cl::desc("<input files>"), | cl::Required, cl::sub(SymbolsSubcommand)); | ||||
cl::OneOrMore, | |||||
cl::sub(SymbolsSubcommand)); | static cl::opt<std::string> | ||||
SymbolPath("symbol-file", | |||||
cl::desc("The file from which to fetch symbol information."), | |||||
cl::value_desc("file"), cl::sub(SymbolsSubcommand)); | |||||
enum class FindType { | enum class FindType { | ||||
None, | None, | ||||
Function, | Function, | ||||
Block, | Block, | ||||
Namespace, | Namespace, | ||||
Type, | Type, | ||||
Variable, | Variable, | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 574 Lines • ▼ Show 20 Lines | |||||
int opts::symbols::dumpSymbols(Debugger &Dbg) { | int opts::symbols::dumpSymbols(Debugger &Dbg) { | ||||
auto ActionOr = getAction(); | auto ActionOr = getAction(); | ||||
if (!ActionOr) { | if (!ActionOr) { | ||||
logAllUnhandledErrors(ActionOr.takeError(), WithColor::error(), ""); | logAllUnhandledErrors(ActionOr.takeError(), WithColor::error(), ""); | ||||
return 1; | return 1; | ||||
} | } | ||||
auto Action = *ActionOr; | auto Action = *ActionOr; | ||||
int HadErrors = 0; | outs() << "Module: " << InputFile << "\n"; | ||||
for (const auto &File : InputFilenames) { | ModuleSpec Spec{FileSpec(InputFile)}; | ||||
outs() << "Module: " << File << "\n"; | StringRef Symbols = SymbolPath.empty() ? InputFile : SymbolPath; | ||||
ModuleSpec Spec{FileSpec(File)}; | Spec.GetSymbolFileSpec().SetFile(Symbols, FileSpec::Style::native); | ||||
Spec.GetSymbolFileSpec().SetFile(File, FileSpec::Style::native); | |||||
auto ModulePtr = std::make_shared<lldb_private::Module>(Spec); | auto ModulePtr = std::make_shared<lldb_private::Module>(Spec); | ||||
SymbolVendor *Vendor = ModulePtr->GetSymbolVendor(); | SymbolVendor *Vendor = ModulePtr->GetSymbolVendor(); | ||||
if (!Vendor) { | if (!Vendor) { | ||||
WithColor::error() << "Module has no symbol vendor.\n"; | WithColor::error() << "Module has no symbol vendor.\n"; | ||||
HadErrors = 1; | return 1; | ||||
continue; | |||||
} | } | ||||
if (Error E = Action(*ModulePtr)) { | if (Error E = Action(*ModulePtr)) { | ||||
WithColor::error() << toString(std::move(E)) << "\n"; | WithColor::error() << toString(std::move(E)) << "\n"; | ||||
HadErrors = 1; | return 1; | ||||
} | } | ||||
outs().flush(); | return 0; | ||||
} | |||||
return HadErrors; | |||||
} | } | ||||
static void dumpSectionList(LinePrinter &Printer, const SectionList &List, bool is_subsection) { | static void dumpSectionList(LinePrinter &Printer, const SectionList &List, bool is_subsection) { | ||||
size_t Count = List.GetNumSections(0); | size_t Count = List.GetNumSections(0); | ||||
if (Count == 0) { | if (Count == 0) { | ||||
Printer.formatLine("There are no {0}sections", is_subsection ? "sub" : ""); | Printer.formatLine("There are no {0}sections", is_subsection ? "sub" : ""); | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 269 Lines • Show Last 20 Lines |