Skip to content

Commit 813a25a

Browse files
committed
Reland "[lldb] Use CompileUnit::ResolveSymbolContext in SymbolFileDWARF"
This patch relands changes introduced in b7c987b and aligns it with llvm.org. This should also fix the test failure in `dwarf5-debug_line-file-index.s`. rdar://83444992 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 9de71a3 commit 813a25a

File tree

2 files changed

+15
-78
lines changed

2 files changed

+15
-78
lines changed

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

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,8 +1971,6 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(
19711971
const SourceLocationSpec &src_location_spec,
19721972
SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
19731973
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1974-
const FileSpec &file_spec = src_location_spec.GetFileSpec();
1975-
const uint32_t line = src_location_spec.GetLine().getValueOr(0);
19761974
const bool check_inlines = src_location_spec.GetCheckInlines();
19771975
const uint32_t prev_size = sc_list.GetSize();
19781976
if (resolve_scope & eSymbolContextCompUnit) {
@@ -1985,72 +1983,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(
19851983
bool file_spec_matches_cu_file_spec = FileSpec::Match(
19861984
src_location_spec.GetFileSpec(), dc_cu->GetPrimaryFile());
19871985
if (check_inlines || file_spec_matches_cu_file_spec) {
1988-
SymbolContext sc(m_objfile_sp->GetModule());
1989-
sc.comp_unit = dc_cu;
1990-
uint32_t file_idx = UINT32_MAX;
1991-
1992-
// If we are looking for inline functions only and we don't find it
1993-
// in the support files, we are done.
1994-
if (check_inlines) {
1995-
file_idx =
1996-
sc.comp_unit->GetSupportFiles().FindFileIndex(1, file_spec, true);
1997-
if (file_idx == UINT32_MAX)
1998-
continue;
1999-
}
2000-
2001-
if (line != 0) {
2002-
LineTable *line_table = sc.comp_unit->GetLineTable();
2003-
2004-
if (line_table != nullptr && line != 0) {
2005-
// We will have already looked up the file index if we are
2006-
// searching for inline entries.
2007-
if (!check_inlines)
2008-
file_idx = sc.comp_unit->GetSupportFiles().FindFileIndex(
2009-
1, file_spec, true);
2010-
2011-
if (file_idx != UINT32_MAX) {
2012-
uint32_t found_line;
2013-
uint16_t found_column;
2014-
uint32_t line_idx = line_table->FindLineEntryIndexByFileIndex(
2015-
0, file_idx, src_location_spec, &sc.line_entry);
2016-
found_line = sc.line_entry.line;
2017-
found_column = sc.line_entry.column;
2018-
2019-
while (line_idx != UINT32_MAX) {
2020-
sc.function = nullptr;
2021-
sc.block = nullptr;
2022-
if (resolve_scope &
2023-
(eSymbolContextFunction | eSymbolContextBlock)) {
2024-
const lldb::addr_t file_vm_addr =
2025-
sc.line_entry.range.GetBaseAddress().GetFileAddress();
2026-
if (file_vm_addr != LLDB_INVALID_ADDRESS) {
2027-
ResolveFunctionAndBlock(
2028-
file_vm_addr, resolve_scope & eSymbolContextBlock, sc);
2029-
}
2030-
}
2031-
2032-
SourceLocationSpec found_location_spec(
2033-
file_spec, found_line, found_column,
2034-
/*check_inlines=*/false, /*exact=*/true);
2035-
sc_list.Append(sc);
2036-
line_idx = line_table->FindLineEntryIndexByFileIndex(
2037-
line_idx + 1, file_idx, found_location_spec,
2038-
&sc.line_entry);
2039-
}
2040-
}
2041-
} else if (file_spec_matches_cu_file_spec && !check_inlines) {
2042-
// only append the context if we aren't looking for inline call
2043-
// sites by file and line and if the file spec matches that of
2044-
// the compile unit
2045-
sc_list.Append(sc);
2046-
}
2047-
} else if (file_spec_matches_cu_file_spec && !check_inlines) {
2048-
// only append the context if we aren't looking for inline call
2049-
// sites by file and line and if the file spec matches that of
2050-
// the compile unit
2051-
sc_list.Append(sc);
2052-
}
2053-
1986+
dc_cu->ResolveSymbolContext(src_location_spec, resolve_scope, sc_list);
20541987
if (!check_inlines)
20551988
break;
20561989
}

lldb/source/Symbol/CompileUnit.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,18 @@ 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+
257269
uint32_t file_idx =
258270
GetSupportFiles().FindFileIndex(0, file_spec, true);
259271
while (file_idx != UINT32_MAX) {
@@ -265,23 +277,15 @@ void CompileUnit::ResolveSymbolContext(
265277
if (num_file_indexes == 0)
266278
return;
267279

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

271-
if (line == 0) {
282+
if (line_table == nullptr) {
272283
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
275284
sc_list.Append(sc);
276285
}
277286
return;
278287
}
279288

280-
LineTable *line_table = sc.comp_unit->GetLineTable();
281-
282-
if (line_table == nullptr)
283-
return;
284-
285289
uint32_t line_idx;
286290
LineEntry line_entry;
287291

0 commit comments

Comments
 (0)