summaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectSource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands/CommandObjectSource.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectSource.cpp82
1 files changed, 35 insertions, 47 deletions
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp
index 78c8bc8119267..19a554fb290a0 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -14,18 +14,14 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/SourceManager.h"
#include "lldb/Host/OptionParser.h"
-#include "lldb/Interpreter/CommandCompletions.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
-#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/StackFrame.h"
-#include "lldb/Target/TargetList.h"
#include "lldb/Utility/FileSpec.h"
using namespace lldb;
@@ -111,7 +107,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed {
uint32_t start_line;
uint32_t end_line;
uint32_t num_lines;
- STLStringArray modules;
+ std::vector<std::string> modules;
};
public:
@@ -146,12 +142,6 @@ protected:
Target *target = m_exe_ctx.GetTargetPtr();
uint32_t num_matches = 0;
- bool has_path = false;
- if (file_spec) {
- assert(file_spec.GetFilename().AsCString());
- has_path = (file_spec.GetDirectory().AsCString() != nullptr);
- }
-
// Dump all the line entries for the file in the list.
ConstString last_module_file_name;
uint32_t num_scs = sc_list.GetSize();
@@ -168,9 +158,7 @@ protected:
if (module_list.GetSize() &&
module_list.GetIndexForModule(module) == LLDB_INVALID_INDEX32)
continue;
- if (file_spec &&
- !lldb_private::FileSpec::Equal(file_spec, line_entry.file,
- has_path))
+ if (!FileSpec::Match(file_spec, line_entry.file))
continue;
if (start_line > 0 && line_entry.line < start_line)
continue;
@@ -180,8 +168,7 @@ protected:
continue;
// Print a new header if the module changed.
- ConstString module_file_name =
- module->GetFileSpec().GetFilename();
+ ConstString module_file_name = module->GetFileSpec().GetFilename();
assert(module_file_name);
if (module_file_name != last_module_file_name) {
if (num_matches > 0)
@@ -227,8 +214,7 @@ protected:
// Dump all matching lines at or above start_line for the file in the
// CU.
ConstString file_spec_name = file_spec.GetFilename();
- ConstString module_file_name =
- module->GetFileSpec().GetFilename();
+ ConstString module_file_name = module->GetFileSpec().GetFilename();
bool cu_header_printed = false;
uint32_t line = start_line;
while (true) {
@@ -253,13 +239,13 @@ protected:
num_matches++;
if (num_lines > 0 && num_matches > num_lines)
break;
- assert(lldb_private::FileSpec::Equal(cu_file_spec, line_entry.file,
- has_path));
+ assert(cu_file_spec == line_entry.file);
if (!cu_header_printed) {
if (num_matches > 0)
strm << "\n\n";
strm << "Lines found for file " << file_spec_name
- << " in compilation unit " << cu->GetFilename() << " in `"
+ << " in compilation unit "
+ << cu->GetPrimaryFile().GetFilename() << " in `"
<< module_file_name << "\n";
cu_header_printed = true;
}
@@ -345,9 +331,8 @@ protected:
if (target->GetSectionLoadList().ResolveLoadAddress(addr, so_addr)) {
ModuleSP module_sp(so_addr.GetModule());
// Check to make sure this module is in our list.
- if (module_sp &&
- module_list.GetIndexForModule(module_sp.get()) !=
- LLDB_INVALID_INDEX32) {
+ if (module_sp && module_list.GetIndexForModule(module_sp.get()) !=
+ LLDB_INVALID_INDEX32) {
SymbolContext sc;
sc.Clear(true);
if (module_sp->ResolveSymbolContextForAddress(
@@ -401,8 +386,8 @@ protected:
// If we didn't find any functions with that name, try searching for
// symbols that line up exactly with function addresses.
SymbolContextList sc_list_symbols;
- module_list.FindFunctionSymbols(
- name, eFunctionNameTypeAuto, sc_list_symbols);
+ module_list.FindFunctionSymbols(name, eFunctionNameTypeAuto,
+ sc_list_symbols);
size_t num_symbol_matches = sc_list_symbols.GetSize();
for (size_t i = 0; i < num_symbol_matches; i++) {
SymbolContext sc;
@@ -712,7 +697,7 @@ class CommandObjectSourceList : public CommandObjectParsed {
lldb::addr_t address;
uint32_t start_line;
uint32_t num_lines;
- STLStringArray modules;
+ std::vector<std::string> modules;
bool show_bp_locs;
bool reverse;
};
@@ -875,7 +860,7 @@ protected:
// passed to the various ModuleList::Find* calls, which would either be a
// vector of string names or a ModuleSpecList.
void FindMatchingFunctions(Target *target, ConstString name,
- SymbolContextList &sc_list) {
+ SymbolContextList &sc_list) {
// Displaying the source for a symbol:
bool include_inlines = true;
bool include_symbols = false;
@@ -892,9 +877,9 @@ protected:
ModuleSpec module_spec(module_file_spec);
matching_modules.Clear();
target->GetImages().FindModules(module_spec, matching_modules);
- matching_modules.FindFunctions(
- name, eFunctionNameTypeAuto, include_symbols, include_inlines,
- sc_list);
+ matching_modules.FindFunctions(name, eFunctionNameTypeAuto,
+ include_symbols, include_inlines,
+ sc_list);
}
}
} else {
@@ -949,7 +934,7 @@ protected:
// symbols that line up exactly with function addresses.
SymbolContextList sc_list_symbols;
FindMatchingFunctionSymbols(target, name, sc_list_symbols);
- size_t num_symbol_matches =sc_list_symbols.GetSize();
+ size_t num_symbol_matches = sc_list_symbols.GetSize();
for (size_t i = 0; i < num_symbol_matches; i++) {
SymbolContext sc;
@@ -1081,7 +1066,8 @@ protected:
if (m_options.show_bp_locs) {
m_breakpoint_locations.Clear();
const bool show_inlines = true;
- m_breakpoint_locations.Reset(*sc.comp_unit, 0, show_inlines);
+ m_breakpoint_locations.Reset(sc.comp_unit->GetPrimaryFile(), 0,
+ show_inlines);
SearchFilterForUnconstrainedSearches target_search_filter(
target->shared_from_this());
target_search_filter.Search(m_breakpoint_locations);
@@ -1110,8 +1096,8 @@ protected:
? sc.line_entry.column
: 0;
target->GetSourceManager().DisplaySourceLinesWithLineNumbers(
- sc.comp_unit, sc.line_entry.line, column, lines_to_back_up,
- m_options.num_lines - lines_to_back_up, "->",
+ sc.comp_unit->GetPrimaryFile(), sc.line_entry.line, column,
+ lines_to_back_up, m_options.num_lines - lines_to_back_up, "->",
&result.GetOutputStream(), GetBreakpointLocations());
result.SetStatus(eReturnStatusSuccessFinishResult);
}
@@ -1194,18 +1180,18 @@ protected:
if (num_matches > 1) {
bool got_multiple = false;
- FileSpec *test_cu_spec = nullptr;
+ CompileUnit *test_cu = nullptr;
for (unsigned i = 0; i < num_matches; i++) {
SymbolContext sc;
sc_list.GetContextAtIndex(i, sc);
if (sc.comp_unit) {
- if (test_cu_spec) {
- if (test_cu_spec != static_cast<FileSpec *>(sc.comp_unit))
+ if (test_cu) {
+ if (test_cu != sc.comp_unit)
got_multiple = true;
break;
} else
- test_cu_spec = sc.comp_unit;
+ test_cu = sc.comp_unit;
}
}
if (got_multiple) {
@@ -1222,7 +1208,8 @@ protected:
if (sc.comp_unit) {
if (m_options.show_bp_locs) {
const bool show_inlines = true;
- m_breakpoint_locations.Reset(*sc.comp_unit, 0, show_inlines);
+ m_breakpoint_locations.Reset(sc.comp_unit->GetPrimaryFile(), 0,
+ show_inlines);
SearchFilterForUnconstrainedSearches target_search_filter(
target->shared_from_this());
target_search_filter.Search(m_breakpoint_locations);
@@ -1233,9 +1220,9 @@ protected:
m_options.num_lines = 10;
const uint32_t column = 0;
target->GetSourceManager().DisplaySourceLinesWithLineNumbers(
- sc.comp_unit, m_options.start_line, column,
- 0, m_options.num_lines,
- "", &result.GetOutputStream(), GetBreakpointLocations());
+ sc.comp_unit->GetPrimaryFile(), m_options.start_line, column, 0,
+ m_options.num_lines, "", &result.GetOutputStream(),
+ GetBreakpointLocations());
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
@@ -1265,10 +1252,11 @@ protected:
CommandObjectMultiwordSource::CommandObjectMultiwordSource(
CommandInterpreter &interpreter)
- : CommandObjectMultiword(interpreter, "source", "Commands for examining "
- "source code described by "
- "debug information for the "
- "current target process.",
+ : CommandObjectMultiword(interpreter, "source",
+ "Commands for examining "
+ "source code described by "
+ "debug information for the "
+ "current target process.",
"source <subcommand> [<subcommand-options>]") {
LoadSubCommand("info",
CommandObjectSP(new CommandObjectSourceInfo(interpreter)));