Skip to content

Merge 799bd79cc5dbf88a4ad91bb57e71ce3578cd5b63 into 5.5 #2957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 68 additions & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,8 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(
const SourceLocationSpec &src_location_spec,
SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
const FileSpec &file_spec = src_location_spec.GetFileSpec();
const uint32_t line = src_location_spec.GetLine().getValueOr(0);
const bool check_inlines = src_location_spec.GetCheckInlines();
const uint32_t prev_size = sc_list.GetSize();
if (resolve_scope & eSymbolContextCompUnit) {
Expand All @@ -1973,7 +1975,72 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(
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(src_location_spec, resolve_scope, sc_list);
SymbolContext sc(m_objfile_sp->GetModule());
sc.comp_unit = dc_cu;
uint32_t file_idx = UINT32_MAX;

// If we are looking for inline functions only and we don't find it
// in the support files, we are done.
if (check_inlines) {
file_idx =
sc.comp_unit->GetSupportFiles().FindFileIndex(1, file_spec, true);
if (file_idx == UINT32_MAX)
continue;
}

if (line != 0) {
LineTable *line_table = sc.comp_unit->GetLineTable();

if (line_table != nullptr && line != 0) {
// We will have already looked up the file index if we are
// searching for inline entries.
if (!check_inlines)
file_idx = sc.comp_unit->GetSupportFiles().FindFileIndex(
1, file_spec, true);

if (file_idx != UINT32_MAX) {
uint32_t found_line;
uint16_t found_column;
uint32_t line_idx = line_table->FindLineEntryIndexByFileIndex(
0, file_idx, src_location_spec, &sc.line_entry);
found_line = sc.line_entry.line;
found_column = sc.line_entry.column;

while (line_idx != UINT32_MAX) {
sc.function = nullptr;
sc.block = nullptr;
if (resolve_scope &
(eSymbolContextFunction | eSymbolContextBlock)) {
const lldb::addr_t file_vm_addr =
sc.line_entry.range.GetBaseAddress().GetFileAddress();
if (file_vm_addr != LLDB_INVALID_ADDRESS) {
ResolveFunctionAndBlock(
file_vm_addr, resolve_scope & eSymbolContextBlock, sc);
}
}

SourceLocationSpec found_location_spec(
file_spec, found_line, found_column,
/*check_inlines=*/false, /*exact=*/true);
sc_list.Append(sc);
line_idx = line_table->FindLineEntryIndexByFileIndex(
line_idx + 1, file_idx, found_location_spec,
&sc.line_entry);
}
}
} else if (file_spec_matches_cu_file_spec && !check_inlines) {
// only append the context if we aren't looking for inline call
// sites by file and line and if the file spec matches that of
// the compile unit
sc_list.Append(sc);
}
} else if (file_spec_matches_cu_file_spec && !check_inlines) {
// only append the context if we aren't looking for inline call
// sites by file and line and if the file spec matches that of
// the compile unit
sc_list.Append(sc);
}

if (!check_inlines)
break;
}
Expand Down
24 changes: 10 additions & 14 deletions lldb/source/Symbol/CompileUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,18 +254,6 @@ void CompileUnit::ResolveSymbolContext(
if (!file_spec_matches_cu_file_spec && !check_inlines)
return;

SymbolContext sc(GetModule());
sc.comp_unit = this;

if (line == 0) {
if (file_spec_matches_cu_file_spec && !check_inlines) {
// only append the context if we aren't looking for inline call sites by
// file and line and if the file spec matches that of the compile unit
sc_list.Append(sc);
}
return;
}

uint32_t file_idx =
GetSupportFiles().FindFileIndex(0, file_spec, true);
while (file_idx != UINT32_MAX) {
Expand All @@ -277,15 +265,23 @@ void CompileUnit::ResolveSymbolContext(
if (num_file_indexes == 0)
return;

LineTable *line_table = sc.comp_unit->GetLineTable();
SymbolContext sc(GetModule());
sc.comp_unit = this;

if (line_table == nullptr) {
if (line == 0) {
if (file_spec_matches_cu_file_spec && !check_inlines) {
// only append the context if we aren't looking for inline call sites by
// file and line and if the file spec matches that of the compile unit
sc_list.Append(sc);
}
return;
}

LineTable *line_table = sc.comp_unit->GetLineTable();

if (line_table == nullptr)
return;

uint32_t line_idx;
LineEntry line_entry;

Expand Down
119 changes: 0 additions & 119 deletions lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s

This file was deleted.