[lldb] Refactor argument group by SourceLocationSpec (NFCI)
This patch refactors a good part of the code base turning the usual FileSpec, Line, Column, CheckInlines, ExactMatch arguments into a SourceLocationSpec object. This change is required for a following patch that will add handling of the column line information when doing symbol resolution. Differential Revision: https://reviews.llvm.org/D100965 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
@@ -20,20 +20,17 @@ using namespace lldb_private;
|
||||
|
||||
// BreakpointResolverFileLine:
|
||||
BreakpointResolverFileLine::BreakpointResolverFileLine(
|
||||
const BreakpointSP &bkpt, const FileSpec &file_spec, uint32_t line_no,
|
||||
uint32_t column, lldb::addr_t offset, bool check_inlines,
|
||||
bool skip_prologue, bool exact_match)
|
||||
const BreakpointSP &bkpt, lldb::addr_t offset, bool skip_prologue,
|
||||
const SourceLocationSpec &location_spec)
|
||||
: 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(location_spec), m_skip_prologue(skip_prologue) {}
|
||||
|
||||
BreakpointResolver *BreakpointResolverFileLine::CreateFromStructuredData(
|
||||
const BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict,
|
||||
Status &error) {
|
||||
llvm::StringRef filename;
|
||||
uint32_t line_no;
|
||||
uint32_t column;
|
||||
uint32_t line;
|
||||
uint16_t column;
|
||||
bool check_inlines;
|
||||
bool skip_prologue;
|
||||
bool exact_match;
|
||||
@@ -49,7 +46,7 @@ BreakpointResolver *BreakpointResolverFileLine::CreateFromStructuredData(
|
||||
}
|
||||
|
||||
success = options_dict.GetValueForKeyAsInteger(
|
||||
GetKey(OptionNames::LineNumber), line_no);
|
||||
GetKey(OptionNames::LineNumber), line);
|
||||
if (!success) {
|
||||
error.SetErrorString("BRFL::CFSD: Couldn't find line number entry.");
|
||||
return nullptr;
|
||||
@@ -83,11 +80,13 @@ BreakpointResolver *BreakpointResolverFileLine::CreateFromStructuredData(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FileSpec file_spec(filename);
|
||||
SourceLocationSpec location_spec(FileSpec(filename), line, column,
|
||||
check_inlines, exact_match);
|
||||
if (!location_spec)
|
||||
return nullptr;
|
||||
|
||||
return new BreakpointResolverFileLine(bkpt, file_spec, line_no, column,
|
||||
offset, check_inlines, skip_prologue,
|
||||
exact_match);
|
||||
return new BreakpointResolverFileLine(bkpt, offset, skip_prologue,
|
||||
location_spec);
|
||||
}
|
||||
|
||||
StructuredData::ObjectSP
|
||||
@@ -95,17 +94,19 @@ BreakpointResolverFileLine::SerializeToStructuredData() {
|
||||
StructuredData::DictionarySP options_dict_sp(
|
||||
new StructuredData::Dictionary());
|
||||
|
||||
options_dict_sp->AddStringItem(GetKey(OptionNames::FileName),
|
||||
m_file_spec.GetPath());
|
||||
options_dict_sp->AddIntegerItem(GetKey(OptionNames::LineNumber),
|
||||
m_line_number);
|
||||
options_dict_sp->AddIntegerItem(GetKey(OptionNames::Column),
|
||||
m_column);
|
||||
options_dict_sp->AddBooleanItem(GetKey(OptionNames::Inlines), m_inlines);
|
||||
options_dict_sp->AddBooleanItem(GetKey(OptionNames::SkipPrologue),
|
||||
m_skip_prologue);
|
||||
options_dict_sp->AddStringItem(GetKey(OptionNames::FileName),
|
||||
m_location_spec.GetFileSpec().GetPath());
|
||||
options_dict_sp->AddIntegerItem(GetKey(OptionNames::LineNumber),
|
||||
m_location_spec.GetLine().getValueOr(0));
|
||||
options_dict_sp->AddIntegerItem(
|
||||
GetKey(OptionNames::Column),
|
||||
m_location_spec.GetColumn().getValueOr(LLDB_INVALID_COLUMN_NUMBER));
|
||||
options_dict_sp->AddBooleanItem(GetKey(OptionNames::Inlines),
|
||||
m_location_spec.GetCheckInlines());
|
||||
options_dict_sp->AddBooleanItem(GetKey(OptionNames::ExactMatch),
|
||||
m_exact_match);
|
||||
m_location_spec.GetExactMatch());
|
||||
|
||||
return WrapOptionsDict(options_dict_sp);
|
||||
}
|
||||
@@ -119,12 +120,12 @@ BreakpointResolverFileLine::SerializeToStructuredData() {
|
||||
// inlined into.
|
||||
void BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list,
|
||||
bool is_relative) {
|
||||
if (m_exact_match)
|
||||
if (m_location_spec.GetExactMatch())
|
||||
return; // Nothing to do. Contexts are precise.
|
||||
|
||||
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 +192,13 @@ void BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list,
|
||||
// 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 +226,11 @@ Searcher::CallbackReturn BreakpointResolverFileLine::SearchCallback(
|
||||
// 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().getValueOr(0);
|
||||
const llvm::Optional<uint16_t> column = m_location_spec.GetColumn();
|
||||
|
||||
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,8 +239,7 @@ Searcher::CallbackReturn BreakpointResolverFileLine::SearchCallback(
|
||||
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,
|
||||
cu_sp->ResolveSymbolContext(m_location_spec, eSymbolContextEverything,
|
||||
sc_list);
|
||||
}
|
||||
}
|
||||
@@ -243,11 +247,12 @@ Searcher::CallbackReturn BreakpointResolverFileLine::SearchCallback(
|
||||
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,11 +262,13 @@ lldb::SearchDepth BreakpointResolverFileLine::GetDepth() {
|
||||
}
|
||||
|
||||
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("exact_match = %d", m_exact_match);
|
||||
s->Printf("file = '%s', line = %u, ",
|
||||
m_location_spec.GetFileSpec().GetPath().c_str(),
|
||||
m_location_spec.GetLine().getValueOr(0));
|
||||
auto column = m_location_spec.GetColumn();
|
||||
if (column)
|
||||
s->Printf("column = %u, ", *column);
|
||||
s->Printf("exact_match = %d", m_location_spec.GetExactMatch());
|
||||
}
|
||||
|
||||
void BreakpointResolverFileLine::Dump(Stream *s) const {}
|
||||
@@ -269,8 +276,7 @@ void BreakpointResolverFileLine::Dump(Stream *s) const {}
|
||||
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, GetOffset(), m_skip_prologue, m_location_spec));
|
||||
|
||||
return ret_sp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user