Skip to content

Commit 1fd0b41

Browse files
authored
[lldb/DWARF] Remove "range lower than function low_pc" check (#132395)
The check is not correct for discontinuous functions, as one of the blocks could very well begin before the function entry point. To catch dead-stripped ranges, I check whether the functions is after the first known code address. I don't print any error in this case as that is a common/expected situation. This avoids many errors like: ``` error: ld-linux-x86-64.so.2 0x00085f3b: adding range [0x0000000000001ae8-0x0000000000001b07) which has a base that is less than the function's low PC 0x000000000001cfb0. Please file a bug and attach the file at the start of this error message ``` when debugging binaries on debian trixie because the dynamic linker (ld-linux) contains discontinuous functions. If the block ranges is not a subrange of the enclosing block then this will range will currently be added to the outer block as well (i.e., we get the same behavior that's currently possible for non-subrange blocks larger than function_low_pc). However, this code path is buggy and I'd like to change that (#117725).
1 parent a99e055 commit 1fd0b41

File tree

4 files changed

+24
-351
lines changed

4 files changed

+24
-351
lines changed

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ bool SymbolFileDWARF::ParseDebugMacros(CompileUnit &comp_unit) {
13231323

13241324
size_t SymbolFileDWARF::ParseBlocksRecursive(CompileUnit &comp_unit,
13251325
Block *parent_block, DWARFDIE die,
1326-
addr_t subprogram_low_pc) {
1326+
addr_t function_file_addr) {
13271327
size_t blocks_added = 0;
13281328
for (; die; die = die.GetSibling()) {
13291329
dw_tag_t tag = die.Tag();
@@ -1346,19 +1346,9 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(CompileUnit &comp_unit,
13461346
decl_line, decl_column, call_file, call_line,
13471347
call_column, nullptr)) {
13481348
for (const llvm::DWARFAddressRange &range : ranges) {
1349-
if (!range.valid())
1350-
continue;
1351-
if (range.LowPC >= subprogram_low_pc)
1352-
block->AddRange(Block::Range(range.LowPC - subprogram_low_pc,
1349+
if (range.valid() && range.LowPC >= m_first_code_address)
1350+
block->AddRange(Block::Range(range.LowPC - function_file_addr,
13531351
range.HighPC - range.LowPC));
1354-
else {
1355-
GetObjectFile()->GetModule()->ReportError(
1356-
"{0:x8}: adding range [{1:x16}-{2:x16}) which has a base "
1357-
"that is less than the function's low PC {3:x16}. Please file "
1358-
"a bug and attach the file at the "
1359-
"start of this error message",
1360-
block->GetID(), range.LowPC, range.HighPC, subprogram_low_pc);
1361-
}
13621352
}
13631353
block->FinalizeRanges();
13641354

@@ -1386,7 +1376,7 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(CompileUnit &comp_unit,
13861376

13871377
if (die.HasChildren()) {
13881378
blocks_added += ParseBlocksRecursive(
1389-
comp_unit, block, die.GetFirstChild(), subprogram_low_pc);
1379+
comp_unit, block, die.GetFirstChild(), function_file_addr);
13901380
}
13911381
}
13921382
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ class SymbolFileDWARF : public SymbolFileCommon {
391391
Function *ParseFunction(CompileUnit &comp_unit, const DWARFDIE &die);
392392

393393
size_t ParseBlocksRecursive(CompileUnit &comp_unit, Block *parent_block,
394-
DWARFDIE die, lldb::addr_t subprogram_low_pc);
394+
DWARFDIE die, lldb::addr_t function_file_addr);
395395

396396
size_t ParseTypes(const SymbolContext &sc, const DWARFDIE &die,
397397
bool parse_siblings, bool parse_children);

lldb/test/Shell/SymbolFile/DWARF/range-lower-then-low-pc.s

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

0 commit comments

Comments
 (0)