jwnhy created this revision. jwnhy added reviewers: Michael137, DavidSpickett, JDevlieghere. Herald added a project: All. jwnhy requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
This patch resolves an issue that lldb not be able to match the correct range of certain address. This issue caused by other compilers like gcc generates "empty ranges" like [address, address) in the DIE. These "empty ranges" cause lldb matches address with these ranges unintentionally and causes unpredictable result. (In #61942, a variable dispearred due to this issue) This patch resolves this issue by discarding these "empty ranges" during the parsing of debugging information. Another approach in fixing this might be changing the logic of "FindEntryThatContains" and let it try harder if met "empty ranges". Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D147606 Files: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1314,10 +1314,11 @@ for (size_t i = 0; i < num_ranges; ++i) { const DWARFRangeList::Entry &range = ranges.GetEntryRef(i); const addr_t range_base = range.GetRangeBase(); - if (range_base >= subprogram_low_pc) - block->AddRange(Block::Range(range_base - subprogram_low_pc, + if (range_base >= subprogram_low_pc) { + if (range.IsValid()) + block->AddRange(Block::Range(range_base - subprogram_low_pc, range.GetByteSize())); - else { + } else { GetObjectFile()->GetModule()->ReportError( "{0:x8}: adding range [{1:x16}-{2:x16}) which has a base " "that is less than the function's low PC {3:x16}. Please file " Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -1065,8 +1065,9 @@ DWARFRangeList ranges; for (const llvm::DWARFAddressRange &llvm_range : *llvm_ranges) { - ranges.Append(DWARFRangeList::Entry(llvm_range.LowPC, - llvm_range.HighPC - llvm_range.LowPC)); + if (llvm_range.HighPC - llvm_range.LowPC > 0) + ranges.Append(DWARFRangeList::Entry(llvm_range.LowPC, + llvm_range.HighPC - llvm_range.LowPC)); } return ranges; }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1314,10 +1314,11 @@ for (size_t i = 0; i < num_ranges; ++i) { const DWARFRangeList::Entry &range = ranges.GetEntryRef(i); const addr_t range_base = range.GetRangeBase(); - if (range_base >= subprogram_low_pc) - block->AddRange(Block::Range(range_base - subprogram_low_pc, + if (range_base >= subprogram_low_pc) { + if (range.IsValid()) + block->AddRange(Block::Range(range_base - subprogram_low_pc, range.GetByteSize())); - else { + } else { GetObjectFile()->GetModule()->ReportError( "{0:x8}: adding range [{1:x16}-{2:x16}) which has a base " "that is less than the function's low PC {3:x16}. Please file " Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -1065,8 +1065,9 @@ DWARFRangeList ranges; for (const llvm::DWARFAddressRange &llvm_range : *llvm_ranges) { - ranges.Append(DWARFRangeList::Entry(llvm_range.LowPC, - llvm_range.HighPC - llvm_range.LowPC)); + if (llvm_range.HighPC - llvm_range.LowPC > 0) + ranges.Append(DWARFRangeList::Entry(llvm_range.LowPC, + llvm_range.HighPC - llvm_range.LowPC)); } return ranges; }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits