mib created this revision.
mib added a reviewer: JDevlieghere.
mib added a project: LLDB.
mib requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: lldb-commits, sstefan1.
This patch refactors a good part of the code base turning FileSpec+Line
pairs into a SourceLocationSpec argument.
This change is required for a following patch that will add handling of the
column line information when doing symbol resolution.
Signed-off-by: Med Ismail Bennani <[email protected]>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D100965
Files:
lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
lldb/include/lldb/Core/AddressResolverFileLine.h
lldb/include/lldb/Symbol/CompileUnit.h
lldb/include/lldb/Symbol/LineTable.h
lldb/include/lldb/Symbol/SymbolFile.h
lldb/source/API/SBThread.cpp
lldb/source/Breakpoint/Breakpoint.cpp
lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
lldb/source/Core/AddressResolverFileLine.cpp
lldb/source/Core/Module.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
lldb/source/Symbol/CompileUnit.cpp
lldb/source/Symbol/LineTable.cpp
lldb/source/Symbol/SymbolFile.cpp
lldb/unittests/Symbol/TestLineEntry.cpp
Index: lldb/unittests/Symbol/TestLineEntry.cpp
===================================================================
--- lldb/unittests/Symbol/TestLineEntry.cpp
+++ lldb/unittests/Symbol/TestLineEntry.cpp
@@ -64,9 +64,10 @@
if (sc_comp_units.GetSize() == 0)
return llvm::createStringError(llvm::inconvertibleErrorCode(),
"No comp unit found on the test object.");
+
sc_comp_units[0].comp_unit->ResolveSymbolContext(
- file_spec, line, check_inlines, exact, eSymbolContextLineEntry,
- sc_line_entries);
+ SourceLocationSpec(file_spec, line), check_inlines, exact,
+ eSymbolContextLineEntry, sc_line_entries);
if (sc_line_entries.GetSize() == 0)
return llvm::createStringError(llvm::inconvertibleErrorCode(),
"No line entry found on the test object.");
Index: lldb/source/Symbol/SymbolFile.cpp
===================================================================
--- lldb/source/Symbol/SymbolFile.cpp
+++ lldb/source/Symbol/SymbolFile.cpp
@@ -97,10 +97,9 @@
return type_system_or_err;
}
-uint32_t SymbolFile::ResolveSymbolContext(const FileSpec &file_spec,
- uint32_t line, bool check_inlines,
- lldb::SymbolContextItem resolve_scope,
- SymbolContextList &sc_list) {
+uint32_t SymbolFile::ResolveSymbolContext(
+ const SourceLocationSpec &src_location_spec, bool check_inlines,
+ lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
return 0;
}
Index: lldb/source/Symbol/LineTable.cpp
===================================================================
--- lldb/source/Symbol/LineTable.cpp
+++ lldb/source/Symbol/LineTable.cpp
@@ -304,7 +304,8 @@
uint32_t LineTable::FindLineEntryIndexByFileIndex(
uint32_t start_idx, const std::vector<uint32_t> &file_indexes,
- uint32_t line, bool exact, LineEntry *line_entry_ptr) {
+ SourceLocationSpec src_location_spec, bool exact,
+ LineEntry *line_entry_ptr) {
const size_t count = m_entries.size();
size_t best_match = UINT32_MAX;
@@ -324,6 +325,8 @@
// after and
// if they're not in the same function, don't return a match.
+ uint32_t line = src_location_spec.GetLine();
+
if (m_entries[idx].line < line) {
continue;
} else if (m_entries[idx].line == line) {
@@ -346,10 +349,9 @@
return UINT32_MAX;
}
-uint32_t LineTable::FindLineEntryIndexByFileIndex(uint32_t start_idx,
- uint32_t file_idx,
- uint32_t line, bool exact,
- LineEntry *line_entry_ptr) {
+uint32_t LineTable::FindLineEntryIndexByFileIndex(
+ uint32_t start_idx, uint32_t file_idx, SourceLocationSpec src_location_spec,
+ bool exact, LineEntry *line_entry_ptr) {
const size_t count = m_entries.size();
size_t best_match = UINT32_MAX;
@@ -368,6 +370,8 @@
// after and
// if they're not in the same function, don't return a match.
+ uint32_t line = src_location_spec.GetLine();
+
if (m_entries[idx].line < line) {
continue;
} else if (m_entries[idx].line == line) {
Index: lldb/source/Symbol/CompileUnit.cpp
===================================================================
--- lldb/source/Symbol/CompileUnit.cpp
+++ lldb/source/Symbol/CompileUnit.cpp
@@ -224,18 +224,21 @@
if (file_indexes.empty())
return UINT32_MAX;
+ // TODO: Handle column information
+ SourceLocationSpec src_location_spec(*file_spec_ptr, line);
LineTable *line_table = GetLineTable();
if (line_table)
return line_table->FindLineEntryIndexByFileIndex(
- start_idx, file_indexes, line, exact, line_entry_ptr);
+ start_idx, file_indexes, src_location_spec, exact, line_entry_ptr);
return UINT32_MAX;
}
-void CompileUnit::ResolveSymbolContext(const FileSpec &file_spec,
- uint32_t line, bool check_inlines,
- bool exact,
- SymbolContextItem resolve_scope,
- SymbolContextList &sc_list) {
+void CompileUnit::ResolveSymbolContext(
+ const SourceLocationSpec &src_location_spec, bool check_inlines, bool exact,
+ SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
+ const FileSpec file_spec = src_location_spec.GetFileSpec();
+ const uint32_t line = src_location_spec.GetLine();
+
// First find all of the file indexes that match our "file_spec". If
// "file_spec" has an empty directory, then only compare the basenames when
// finding file indexes
@@ -288,21 +291,22 @@
// table function that searches for a line entries that match a single
// support file index
line_idx = line_table->FindLineEntryIndexByFileIndex(
- 0, file_indexes.front(), line, exact, &line_entry);
+ 0, file_indexes.front(), src_location_spec, exact, &line_entry);
} else {
// We found multiple support files that match "file_spec" so use the
// line table function that searches for a line entries that match a
// multiple support file indexes.
- line_idx = line_table->FindLineEntryIndexByFileIndex(0, file_indexes, line,
- exact, &line_entry);
+ line_idx = line_table->FindLineEntryIndexByFileIndex(
+ 0, file_indexes, src_location_spec, exact, &line_entry);
}
// If "exact == true", then "found_line" will be the same as "line". If
// "exact == false", the "found_line" will be the closest line entry
// with a line number greater than "line" and we will use this for our
// subsequent line exact matches below.
- uint32_t found_line = line_entry.line;
-
+ SourceLocationSpec found_entry(line_entry.file, line_entry.line,
+ line_entry.column);
+
while (line_idx != UINT32_MAX) {
// If they only asked for the line entry, then we're done, we can
// just copy that over. But if they wanted more than just the line
@@ -317,10 +321,10 @@
sc_list.Append(sc);
if (num_file_indexes == 1)
line_idx = line_table->FindLineEntryIndexByFileIndex(
- line_idx + 1, file_indexes.front(), found_line, true, &line_entry);
+ line_idx + 1, file_indexes.front(), found_entry, true, &line_entry);
else
line_idx = line_table->FindLineEntryIndexByFileIndex(
- line_idx + 1, file_indexes, found_line, true, &line_entry);
+ line_idx + 1, file_indexes, found_entry, true, &line_entry);
}
}
Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
===================================================================
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -104,11 +104,10 @@
lldb::SymbolContextItem resolve_scope,
lldb_private::SymbolContext &sc) override;
- uint32_t
- ResolveSymbolContext(const lldb_private::FileSpec &file_spec, uint32_t line,
- bool check_inlines,
- lldb::SymbolContextItem resolve_scope,
- lldb_private::SymbolContextList &sc_list) override;
+ uint32_t ResolveSymbolContext(
+ const lldb_private::SourceLocationSpec &src_location_spec,
+ bool check_inlines, lldb::SymbolContextItem resolve_scope,
+ lldb_private::SymbolContextList &sc_list) override;
void
FindGlobalVariables(lldb_private::ConstString name,
Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -784,10 +784,13 @@
}
uint32_t SymbolFilePDB::ResolveSymbolContext(
- const lldb_private::FileSpec &file_spec, uint32_t line, bool check_inlines,
- SymbolContextItem resolve_scope, lldb_private::SymbolContextList &sc_list) {
+ const lldb_private::SourceLocationSpec &src_location_spec,
+ bool check_inlines, SymbolContextItem resolve_scope,
+ lldb_private::SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
const size_t old_size = sc_list.GetSize();
+ const FileSpec &file_spec = src_location_spec.GetFileSpec();
+ const uint32_t line = src_location_spec.GetLine();
if (resolve_scope & lldb::eSymbolContextCompUnit) {
// Locate all compilation units with line numbers referencing the specified
// file. For example, if `file_spec` is <vector>, then this should return
Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
===================================================================
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
@@ -120,7 +120,7 @@
uint32_t ResolveSymbolContext(const Address &so_addr,
lldb::SymbolContextItem resolve_scope,
SymbolContext &sc) override;
- uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line,
+ uint32_t ResolveSymbolContext(const SourceLocationSpec &src_location_spec,
bool check_inlines,
lldb::SymbolContextItem resolve_scope,
SymbolContextList &sc_list) override;
Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -1001,7 +1001,7 @@
}
uint32_t SymbolFileNativePDB::ResolveSymbolContext(
- const FileSpec &file_spec, uint32_t line, bool check_inlines,
+ const SourceLocationSpec &src_location_spec, bool check_inlines,
lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
return 0;
}
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -97,11 +97,10 @@
uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr,
lldb::SymbolContextItem resolve_scope,
lldb_private::SymbolContext &sc) override;
- uint32_t
- ResolveSymbolContext(const lldb_private::FileSpec &file_spec, uint32_t line,
- bool check_inlines,
- lldb::SymbolContextItem resolve_scope,
- lldb_private::SymbolContextList &sc_list) override;
+ uint32_t ResolveSymbolContext(
+ const lldb_private::SourceLocationSpec &src_location_spec,
+ bool check_inlines, lldb::SymbolContextItem resolve_scope,
+ lldb_private::SymbolContextList &sc_list) override;
void
FindGlobalVariables(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext &parent_decl_ctx,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -806,7 +806,7 @@
}
uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext(
- const FileSpec &file_spec, uint32_t line, bool check_inlines,
+ const SourceLocationSpec &src_location_spec, bool check_inlines,
SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
const uint32_t initial = sc_list.GetSize();
@@ -820,12 +820,13 @@
if (!resolve) {
FileSpec so_file_spec;
if (GetFileSpecForSO(i, so_file_spec))
- resolve = FileSpec::Match(file_spec, so_file_spec);
+ resolve =
+ FileSpec::Match(src_location_spec.GetFileSpec(), so_file_spec);
}
if (resolve) {
SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(i);
if (oso_dwarf)
- oso_dwarf->ResolveSymbolContext(file_spec, line, check_inlines,
+ oso_dwarf->ResolveSymbolContext(src_location_spec, check_inlines,
resolve_scope, sc_list);
}
}
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -161,11 +161,10 @@
lldb::SymbolContextItem resolve_scope,
lldb_private::SymbolContext &sc) override;
- uint32_t
- ResolveSymbolContext(const lldb_private::FileSpec &file_spec, uint32_t line,
- bool check_inlines,
- lldb::SymbolContextItem resolve_scope,
- lldb_private::SymbolContextList &sc_list) override;
+ uint32_t ResolveSymbolContext(
+ const lldb_private::SourceLocationSpec &src_location_spec,
+ bool check_inlines, lldb::SymbolContextItem resolve_scope,
+ lldb_private::SymbolContextList &sc_list) override;
void
FindGlobalVariables(lldb_private::ConstString name,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1959,11 +1959,9 @@
return resolved;
}
-uint32_t SymbolFileDWARF::ResolveSymbolContext(const FileSpec &file_spec,
- uint32_t line,
- bool check_inlines,
- SymbolContextItem resolve_scope,
- SymbolContextList &sc_list) {
+uint32_t SymbolFileDWARF::ResolveSymbolContext(
+ const SourceLocationSpec &src_location_spec, bool check_inlines,
+ SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
const uint32_t prev_size = sc_list.GetSize();
if (resolve_scope & eSymbolContextCompUnit) {
@@ -1973,10 +1971,10 @@
if (!dc_cu)
continue;
- bool file_spec_matches_cu_file_spec =
- FileSpec::Match(file_spec, dc_cu->GetPrimaryFile());
+ bool file_spec_matches_cu_file_spec = FileSpec::Match(
+ src_location_spec.GetFileSpec(), dc_cu->GetPrimaryFile());
if (check_inlines || file_spec_matches_cu_file_spec) {
- dc_cu->ResolveSymbolContext(file_spec, line, check_inlines, false,
+ dc_cu->ResolveSymbolContext(src_location_spec, check_inlines, false,
resolve_scope, sc_list);
if (!check_inlines)
break;
Index: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
===================================================================
--- lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
+++ lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
@@ -101,7 +101,7 @@
lldb::SymbolContextItem resolve_scope,
SymbolContext &sc) override;
- uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line,
+ uint32_t ResolveSymbolContext(const SourceLocationSpec &src_location_spec,
bool check_inlines,
lldb::SymbolContextItem resolve_scope,
SymbolContextList &sc_list) override;
Index: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -278,7 +278,7 @@
}
uint32_t SymbolFileBreakpad::ResolveSymbolContext(
- const FileSpec &file_spec, uint32_t line, bool check_inlines,
+ const SourceLocationSpec &src_location_spec, bool check_inlines,
lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (!(resolve_scope & eSymbolContextCompUnit))
@@ -287,7 +287,7 @@
uint32_t old_size = sc_list.GetSize();
for (size_t i = 0, size = GetNumCompileUnits(); i < size; ++i) {
CompileUnit &cu = *GetCompileUnitAtIndex(i);
- cu.ResolveSymbolContext(file_spec, line, check_inlines,
+ cu.ResolveSymbolContext(src_location_spec, check_inlines,
/*exact*/ false, resolve_scope, sc_list);
}
return sc_list.GetSize() - old_size;
Index: lldb/source/Core/Module.cpp
===================================================================
--- lldb/source/Core/Module.cpp
+++ lldb/source/Core/Module.cpp
@@ -599,8 +599,9 @@
const uint32_t initial_count = sc_list.GetSize();
if (SymbolFile *symbols = GetSymbolFile())
- symbols->ResolveSymbolContext(file_spec, line, check_inlines, resolve_scope,
- sc_list);
+ // TODO: Handle SourceLocationSpec column information
+ symbols->ResolveSymbolContext(SourceLocationSpec(file_spec, line),
+ check_inlines, resolve_scope, sc_list);
return sc_list.GetSize() - initial_count;
}
Index: lldb/source/Core/AddressResolverFileLine.cpp
===================================================================
--- lldb/source/Core/AddressResolverFileLine.cpp
+++ lldb/source/Core/AddressResolverFileLine.cpp
@@ -31,7 +31,7 @@
AddressResolverFileLine::AddressResolverFileLine(const FileSpec &file_spec,
uint32_t line_no,
bool check_inlines)
- : AddressResolver(), m_file_spec(file_spec), m_line_number(line_no),
+ : AddressResolver(), m_src_location_spec(file_spec, line_no),
m_inlines(check_inlines) {}
AddressResolverFileLine::~AddressResolverFileLine() {}
@@ -44,7 +44,8 @@
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- cu->ResolveSymbolContext(m_file_spec, m_line_number, m_inlines, false,
+ // TODO: Handle SourceLocationSpec column information
+ cu->ResolveSymbolContext(m_src_location_spec, m_inlines, false,
eSymbolContextEverything, sc_list);
uint32_t sc_list_size = sc_list.GetSize();
for (uint32_t i = 0; i < sc_list_size; i++) {
@@ -65,8 +66,9 @@
"error: Unable to resolve address at file address 0x%" PRIx64
" for %s:%d\n",
line_start.GetFileAddress(),
- m_file_spec.GetFilename().AsCString("<Unknown>"),
- m_line_number);
+ m_src_location_spec.GetFileSpec().GetFilename().AsCString(
+ "<Unknown>"),
+ m_src_location_spec.GetLine());
}
}
}
@@ -78,6 +80,8 @@
}
void AddressResolverFileLine::GetDescription(Stream *s) {
- s->Printf("File and line address - file: \"%s\" line: %u",
- m_file_spec.GetFilename().AsCString("<Unknown>"), m_line_number);
+ s->Printf(
+ "File and line address - file: \"%s\" line: %u",
+ m_src_location_spec.GetFileSpec().GetFilename().AsCString("<Unknown>"),
+ m_src_location_spec.GetLine());
}
Index: lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
===================================================================
--- lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
@@ -108,9 +108,10 @@
for (uint32_t i = 0; i < num_matches; i++) {
SymbolContextList sc_list;
const bool search_inlines = false;
-
- cu->ResolveSymbolContext(cu_file_spec, line_matches[i], search_inlines,
- m_exact_match, eSymbolContextEverything, sc_list);
+ // TODO: Handle SourceLocationSpec column information
+ SourceLocationSpec src_location_spec(cu_file_spec, line_matches[i]);
+ cu->ResolveSymbolContext(src_location_spec, search_inlines, m_exact_match,
+ eSymbolContextEverything, sc_list);
// Find all the function names:
if (!m_function_names.empty()) {
std::vector<size_t> sc_to_remove;
Index: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
===================================================================
--- lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -24,9 +24,19 @@
uint32_t column, lldb::addr_t offset, bool check_inlines,
bool skip_prologue, bool exact_match)
: BreakpointResolver(bkpt, BreakpointResolver::FileLineResolver, offset),
- m_file_spec(file_spec), m_line_number(line_no), m_column(column),
- m_inlines(check_inlines), m_skip_prologue(skip_prologue),
- m_exact_match(exact_match) {}
+ m_location_spec(file_spec, line_no, column), m_inlines(check_inlines),
+ m_skip_prologue(skip_prologue), m_exact_match(exact_match) {}
+
+BreakpointResolverFileLine::BreakpointResolverFileLine(
+ const BreakpointSP &bkpt, const SourceLocationSpec location_spec,
+ lldb::addr_t offset, bool check_inlines, bool skip_prologue,
+ bool exact_match)
+ : BreakpointResolverFileLine(bkpt, location_spec.GetFileSpec(),
+ location_spec.GetLine(), 0, offset,
+ check_inlines, skip_prologue, exact_match) {
+ if (location_spec.HasColumn())
+ m_location_spec = location_spec;
+}
BreakpointResolver *BreakpointResolverFileLine::CreateFromStructuredData(
const BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict,
@@ -96,11 +106,16 @@
new StructuredData::Dictionary());
options_dict_sp->AddStringItem(GetKey(OptionNames::FileName),
- m_file_spec.GetPath());
+ m_location_spec.GetFileSpec().GetPath());
options_dict_sp->AddIntegerItem(GetKey(OptionNames::LineNumber),
- m_line_number);
- options_dict_sp->AddIntegerItem(GetKey(OptionNames::Column),
- m_column);
+ m_location_spec.GetLine());
+
+ llvm::Optional<uint16_t> column = m_location_spec.GetColumn();
+ if (!column)
+ options_dict_sp->AddIntegerItem(GetKey(OptionNames::Column), 0);
+ else
+ options_dict_sp->AddIntegerItem(GetKey(OptionNames::Column), *column);
+
options_dict_sp->AddBooleanItem(GetKey(OptionNames::Inlines), m_inlines);
options_dict_sp->AddBooleanItem(GetKey(OptionNames::SkipPrologue),
m_skip_prologue);
@@ -124,7 +139,7 @@
llvm::StringRef relative_path;
if (is_relative)
- relative_path = m_file_spec.GetDirectory().GetStringRef();
+ relative_path = m_location_spec.GetFileSpec().GetDirectory().GetStringRef();
Log * log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
for(uint32_t i = 0; i < sc_list.GetSize(); ++i) {
@@ -191,12 +206,13 @@
// But only do this calculation if the line number we found in the SC
// was different from the one requested in the source file. If we actually
// found an exact match it must be valid.
-
- if (m_line_number == sc.line_entry.line)
+
+ if (m_location_spec.GetLine() == sc.line_entry.line)
continue;
const int decl_line_is_too_late_fudge = 1;
- if (line && m_line_number < line - decl_line_is_too_late_fudge) {
+ if (line &&
+ m_location_spec.GetLine() < line - decl_line_is_too_late_fudge) {
LLDB_LOG(log, "removing symbol context at {0}:{1}", file, line);
sc_list.RemoveContextAtIndex(i);
--i;
@@ -224,8 +240,12 @@
// file. So we go through the match list and pull out the sets that have the
// same file spec in their line_entry and treat each set separately.
- FileSpec search_file_spec = m_file_spec;
- const bool is_relative = m_file_spec.IsRelative();
+ const uint32_t line = m_location_spec.GetLine();
+ const uint16_t column =
+ m_location_spec.HasColumn() ? *m_location_spec.GetColumn() : 0;
+
+ FileSpec search_file_spec = m_location_spec.GetFileSpec();
+ const bool is_relative = search_file_spec.IsRelative();
if (is_relative)
search_file_spec.GetDirectory().Clear();
@@ -234,20 +254,20 @@
CompUnitSP cu_sp(context.module_sp->GetCompileUnitAtIndex(i));
if (cu_sp) {
if (filter.CompUnitPasses(*cu_sp))
- cu_sp->ResolveSymbolContext(search_file_spec, m_line_number, m_inlines,
- m_exact_match, eSymbolContextEverything,
- sc_list);
+ cu_sp->ResolveSymbolContext(m_location_spec, m_inlines, m_exact_match,
+ eSymbolContextEverything, sc_list);
}
}
FilterContexts(sc_list, is_relative);
StreamString s;
- s.Printf("for %s:%d ", m_file_spec.GetFilename().AsCString("<Unknown>"),
- m_line_number);
+ s.Printf("for %s:%d ",
+ m_location_spec.GetFileSpec().GetFilename().AsCString("<Unknown>"),
+ line);
- SetSCMatchesByLine(filter, sc_list, m_skip_prologue, s.GetString(),
- m_line_number, m_column);
+ SetSCMatchesByLine(filter, sc_list, m_skip_prologue, s.GetString(), line,
+ column);
return Searcher::eCallbackReturnContinue;
}
@@ -257,10 +277,11 @@
}
void BreakpointResolverFileLine::GetDescription(Stream *s) {
- s->Printf("file = '%s', line = %u, ", m_file_spec.GetPath().c_str(),
- m_line_number);
- if (m_column)
- s->Printf("column = %u, ", m_column);
+ s->Printf("file = '%s', line = %u, ",
+ m_location_spec.GetFileSpec().GetPath().c_str(),
+ m_location_spec.GetLine());
+ if (m_location_spec.HasColumn())
+ s->Printf("column = %u, ", *m_location_spec.GetColumn());
s->Printf("exact_match = %d", m_exact_match);
}
@@ -269,8 +290,8 @@
lldb::BreakpointResolverSP
BreakpointResolverFileLine::CopyForBreakpoint(BreakpointSP &breakpoint) {
lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileLine(
- breakpoint, m_file_spec, m_line_number, m_column, GetOffset(), m_inlines,
- m_skip_prologue, m_exact_match));
+ breakpoint, m_location_spec, GetOffset(), m_inlines, m_skip_prologue,
+ m_exact_match));
return ret_sp;
}
Index: lldb/source/Breakpoint/Breakpoint.cpp
===================================================================
--- lldb/source/Breakpoint/Breakpoint.cpp
+++ lldb/source/Breakpoint/Breakpoint.cpp
@@ -980,9 +980,12 @@
if (m_resolver_sp) {
BreakpointResolverFileLine *resolverFileLine =
dyn_cast<BreakpointResolverFileLine>(m_resolver_sp.get());
+
+ // TODO: Handle SourceLocationSpec column information
if (resolverFileLine &&
- resolverFileLine->m_file_spec.GetFilename() == filename &&
- resolverFileLine->m_line_number == line_number) {
+ resolverFileLine->m_location_spec.GetFileSpec().GetFilename() ==
+ filename &&
+ resolverFileLine->m_location_spec.GetLine() == line_number) {
return true;
}
}
Index: lldb/source/API/SBThread.cpp
===================================================================
--- lldb/source/API/SBThread.cpp
+++ lldb/source/API/SBThread.cpp
@@ -846,10 +846,12 @@
const bool check_inlines = true;
const bool exact = false;
+ SourceLocationSpec src_location_spec(step_file_spec, line);
+
SymbolContextList sc_list;
- frame_sc.comp_unit->ResolveSymbolContext(step_file_spec, line,
- check_inlines, exact,
- eSymbolContextLineEntry, sc_list);
+ frame_sc.comp_unit->ResolveSymbolContext(src_location_spec, check_inlines,
+ exact, eSymbolContextLineEntry,
+ sc_list);
const uint32_t num_matches = sc_list.GetSize();
if (num_matches > 0) {
SymbolContext sc;
Index: lldb/include/lldb/Symbol/SymbolFile.h
===================================================================
--- lldb/include/lldb/Symbol/SymbolFile.h
+++ lldb/include/lldb/Symbol/SymbolFile.h
@@ -18,6 +18,7 @@
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Utility/SourceLocationSpec.h"
#include "lldb/Utility/XcodeSDK.h"
#include "lldb/lldb-private.h"
#include "llvm/ADT/DenseSet.h"
@@ -209,10 +210,9 @@
virtual uint32_t ResolveSymbolContext(const Address &so_addr,
lldb::SymbolContextItem resolve_scope,
SymbolContext &sc) = 0;
- virtual uint32_t ResolveSymbolContext(const FileSpec &file_spec,
- uint32_t line, bool check_inlines,
- lldb::SymbolContextItem resolve_scope,
- SymbolContextList &sc_list);
+ virtual uint32_t ResolveSymbolContext(
+ const SourceLocationSpec &src_location_spec, bool check_inlines,
+ lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list);
virtual void DumpClangAST(Stream &s) {}
virtual void FindGlobalVariables(ConstString name,
Index: lldb/include/lldb/Symbol/LineTable.h
===================================================================
--- lldb/include/lldb/Symbol/LineTable.h
+++ lldb/include/lldb/Symbol/LineTable.h
@@ -14,6 +14,7 @@
#include "lldb/Core/Section.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Utility/RangeMap.h"
+#include "lldb/Utility/SourceLocationSpec.h"
#include "lldb/lldb-private.h"
#include <vector>
@@ -137,8 +138,8 @@
/// CompileUnit::GetSupportFiles()
/// FileSpecList::FindFileIndex (uint32_t, const FileSpec &) const
///
- /// \param[in] line
- /// The source line to match.
+ /// \param[in] src_location_spec
+ /// The source location specifier to match.
///
/// \param[in] exact
/// If true, match only if you find a line entry exactly matching \a line.
@@ -156,12 +157,14 @@
/// \see CompileUnit::GetSupportFiles()
/// \see FileSpecList::FindFileIndex (uint32_t, const FileSpec &) const
uint32_t FindLineEntryIndexByFileIndex(uint32_t start_idx, uint32_t file_idx,
- uint32_t line, bool exact,
- LineEntry *line_entry_ptr);
-
- uint32_t FindLineEntryIndexByFileIndex(
- uint32_t start_idx, const std::vector<uint32_t> &file_indexes,
- uint32_t line, bool exact, LineEntry *line_entry_ptr);
+ SourceLocationSpec src_location_spec,
+ bool exact, LineEntry *line_entry_ptr);
+
+ uint32_t
+ FindLineEntryIndexByFileIndex(uint32_t start_idx,
+ const std::vector<uint32_t> &file_indexes,
+ SourceLocationSpec src_location_spec,
+ bool exact, LineEntry *line_entry_ptr);
size_t FineLineEntriesForFileIndex(uint32_t file_idx, bool append,
SymbolContextList &sc_list);
Index: lldb/include/lldb/Symbol/CompileUnit.h
===================================================================
--- lldb/include/lldb/Symbol/CompileUnit.h
+++ lldb/include/lldb/Symbol/CompileUnit.h
@@ -15,6 +15,7 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SourceModule.h"
+#include "lldb/Utility/SourceLocationSpec.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/UserID.h"
#include "lldb/lldb-enumerations.h"
@@ -345,18 +346,12 @@
/// Resolve symbol contexts by file and line.
///
- /// Given a file in \a file_spec, and a line number, find all instances and
+ /// Given a file in \a src_location_spec, find all instances and
/// append them to the supplied symbol context list \a sc_list.
///
- /// \param[in] file_spec
- /// A file specification. If \a file_spec contains no directory
- /// information, only the basename will be used when matching
- /// contexts. If the directory in \a file_spec is valid, a
- /// complete file specification match will be performed.
- ///
- /// \param[in] line
- /// The line number to match against the compile unit's line
- /// tables.
+ /// \param[in] src_location_spec
+ /// The \a src_location_spec containing the \a file_spec, the line and the
+ /// column of the symbol to look for.
///
/// \param[in] check_inlines
/// If \b true this function will also match any inline
@@ -382,7 +377,7 @@
/// entries appended to.
///
/// \see enum SymbolContext::Scope
- void ResolveSymbolContext(const FileSpec &file_spec, uint32_t line,
+ void ResolveSymbolContext(const SourceLocationSpec &src_location_spec,
bool check_inlines, bool exact,
lldb::SymbolContextItem resolve_scope,
SymbolContextList &sc_list);
Index: lldb/include/lldb/Core/AddressResolverFileLine.h
===================================================================
--- lldb/include/lldb/Core/AddressResolverFileLine.h
+++ lldb/include/lldb/Core/AddressResolverFileLine.h
@@ -11,7 +11,7 @@
#include "lldb/Core/AddressResolver.h"
#include "lldb/Core/SearchFilter.h"
-#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/SourceLocationSpec.h"
#include "lldb/lldb-defines.h"
#include <stdint.h>
@@ -42,8 +42,8 @@
void GetDescription(Stream *s) override;
protected:
- FileSpec m_file_spec; // This is the file spec we are looking for.
- uint32_t m_line_number; // This is the line number that we are looking for.
+ SourceLocationSpec m_src_location_spec; // This contains the file spec and
+ // line we are looking for.
bool m_inlines; // This determines whether the resolver looks for inlined
// functions or not.
Index: lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
===================================================================
--- lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
+++ lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
@@ -11,6 +11,8 @@
#include "lldb/Breakpoint/BreakpointResolver.h"
+#include "lldb/Utility/SourceLocationSpec.h"
+
namespace lldb_private {
/// \class BreakpointResolverFileLine BreakpointResolverFileLine.h
@@ -21,9 +23,14 @@
class BreakpointResolverFileLine : public BreakpointResolver {
public:
BreakpointResolverFileLine(const lldb::BreakpointSP &bkpt,
- const FileSpec &resolver,
- uint32_t line_no, uint32_t column,
- lldb::addr_t m_offset, bool check_inlines,
+ const FileSpec &resolver, uint32_t line_no,
+ uint32_t column, lldb::addr_t offset,
+ bool check_inlines, bool skip_prologue,
+ bool exact_match);
+
+ BreakpointResolverFileLine(const lldb::BreakpointSP &bkpt,
+ const SourceLocationSpec location_spec,
+ lldb::addr_t offset, bool check_inlines,
bool skip_prologue, bool exact_match);
static BreakpointResolver *
@@ -60,9 +67,7 @@
void FilterContexts(SymbolContextList &sc_list, bool is_relative);
friend class Breakpoint;
- FileSpec m_file_spec; ///< This is the file spec we are looking for.
- uint32_t m_line_number; ///< This is the line number that we are looking for.
- uint32_t m_column; ///< This is the column that we are looking for.
+ SourceLocationSpec m_location_spec;
bool m_inlines; ///< This determines whether the resolver looks for inlined
///< functions or not.
bool m_skip_prologue;
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits