Skip to content

Commit ca47b8d

Browse files
authored
Merge pull request #2918 from medismailben/apple/stable/20210107
Revert "[lldb] Use CompileUnit::ResolveSymbolContext in SymbolFileDWARF"
2 parents 14a0ee7 + 3f0f7e2 commit ca47b8d

File tree

3 files changed

+77
-134
lines changed

3 files changed

+77
-134
lines changed

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,8 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(
19521952
const SourceLocationSpec &src_location_spec,
19531953
SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
19541954
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1955+
const FileSpec &file_spec = src_location_spec.GetFileSpec();
1956+
const uint32_t line = src_location_spec.GetLine().getValueOr(0);
19551957
const bool check_inlines = src_location_spec.GetCheckInlines();
19561958
const uint32_t prev_size = sc_list.GetSize();
19571959
if (resolve_scope & eSymbolContextCompUnit) {
@@ -1964,7 +1966,71 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(
19641966
bool file_spec_matches_cu_file_spec = FileSpec::Match(
19651967
src_location_spec.GetFileSpec(), dc_cu->GetPrimaryFile());
19661968
if (check_inlines || file_spec_matches_cu_file_spec) {
1967-
dc_cu->ResolveSymbolContext(src_location_spec, resolve_scope, sc_list);
1969+
SymbolContext sc(m_objfile_sp->GetModule());
1970+
sc.comp_unit = dc_cu;
1971+
uint32_t file_idx = UINT32_MAX;
1972+
1973+
// If we are looking for inline functions only and we don't find it
1974+
// in the support files, we are done.
1975+
if (check_inlines) {
1976+
file_idx =
1977+
sc.comp_unit->GetSupportFiles().FindFileIndex(1, file_spec, true);
1978+
if (file_idx == UINT32_MAX)
1979+
continue;
1980+
}
1981+
1982+
if (line != 0) {
1983+
LineTable *line_table = sc.comp_unit->GetLineTable();
1984+
1985+
if (line_table != nullptr && line != 0) {
1986+
// We will have already looked up the file index if we are
1987+
// searching for inline entries.
1988+
if (!check_inlines)
1989+
file_idx = sc.comp_unit->GetSupportFiles().FindFileIndex(
1990+
1, file_spec, true);
1991+
1992+
if (file_idx != UINT32_MAX) {
1993+
uint32_t found_line;
1994+
uint16_t found_column;
1995+
uint32_t line_idx = line_table->FindLineEntryIndexByFileIndex(
1996+
0, file_idx, src_location_spec, &sc.line_entry);
1997+
found_line = sc.line_entry.line;
1998+
found_column - sc.line_entry.column;
1999+
2000+
while (line_idx != UINT32_MAX) {
2001+
sc.function = nullptr;
2002+
sc.block = nullptr;
2003+
if (resolve_scope &
2004+
(eSymbolContextFunction | eSymbolContextBlock)) {
2005+
const lldb::addr_t file_vm_addr =
2006+
sc.line_entry.range.GetBaseAddress().GetFileAddress();
2007+
if (file_vm_addr != LLDB_INVALID_ADDRESS) {
2008+
ResolveFunctionAndBlock(
2009+
file_vm_addr, resolve_scope & eSymbolContextBlock, sc);
2010+
}
2011+
}
2012+
2013+
SourceLocationSpec found_location_spec(
2014+
file_spec, found_line, found_column,
2015+
/*check_inlines=*/false, /*exact=*/true) sc_list.Append(sc);
2016+
line_idx = line_table->FindLineEntryIndexByFileIndex(
2017+
line_idx + 1, file_idx, found_location_spec,
2018+
&sc.line_entry);
2019+
}
2020+
}
2021+
} else if (file_spec_matches_cu_file_spec && !check_inlines) {
2022+
// only append the context if we aren't looking for inline call
2023+
// sites by file and line and if the file spec matches that of
2024+
// the compile unit
2025+
sc_list.Append(sc);
2026+
}
2027+
} else if (file_spec_matches_cu_file_spec && !check_inlines) {
2028+
// only append the context if we aren't looking for inline call
2029+
// sites by file and line and if the file spec matches that of
2030+
// the compile unit
2031+
sc_list.Append(sc);
2032+
}
2033+
19682034
if (!check_inlines)
19692035
break;
19702036
}

lldb/source/Symbol/CompileUnit.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -254,18 +254,6 @@ void CompileUnit::ResolveSymbolContext(
254254
if (!file_spec_matches_cu_file_spec && !check_inlines)
255255
return;
256256

257-
SymbolContext sc(GetModule());
258-
sc.comp_unit = this;
259-
260-
if (line == 0) {
261-
if (file_spec_matches_cu_file_spec && !check_inlines) {
262-
// only append the context if we aren't looking for inline call sites by
263-
// file and line and if the file spec matches that of the compile unit
264-
sc_list.Append(sc);
265-
}
266-
return;
267-
}
268-
269257
uint32_t file_idx =
270258
GetSupportFiles().FindFileIndex(0, file_spec, true);
271259
while (file_idx != UINT32_MAX) {
@@ -277,15 +265,23 @@ void CompileUnit::ResolveSymbolContext(
277265
if (num_file_indexes == 0)
278266
return;
279267

280-
LineTable *line_table = sc.comp_unit->GetLineTable();
268+
SymbolContext sc(GetModule());
269+
sc.comp_unit = this;
281270

282-
if (line_table == nullptr) {
271+
if (line == 0) {
283272
if (file_spec_matches_cu_file_spec && !check_inlines) {
273+
// only append the context if we aren't looking for inline call sites by
274+
// file and line and if the file spec matches that of the compile unit
284275
sc_list.Append(sc);
285276
}
286277
return;
287278
}
288279

280+
LineTable *line_table = sc.comp_unit->GetLineTable();
281+
282+
if (line_table == nullptr)
283+
return;
284+
289285
uint32_t line_idx;
290286
LineEntry line_entry;
291287

lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)