Skip to content

Commit fdede92

Browse files
authored
[lldb][DWARF] Sort ranges list in dwarf 5. (llvm#91343)
Dwarf 5 says "There is no requirement that the entries be ordered in any particular way" in 2.17.3 Non-Contiguous Address Ranges for rnglist. Some places assume the ranges are already sorted but it's not. For example, when [parsing function info](https://github.com/llvm/llvm-project/blob/bc8a42762057d7036f6871211e62b1c3efb2738a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp#L922-L927), it validates low and hi address of the function: GetMinRangeBase returns the first range entry base and GetMaxRangeEnd returns the last range end. If low >= hi, it stops parsing this function. This causes missing inline stack frames for those functions. This change fixes it and updates the test `lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists.s` so that two ranges in `.debug_rnglists` are out of order and `image lookup -v -s lookup_rnglists` is still able to produce sorted ranges for the inner block.
1 parent fa9e90f commit fdede92

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,7 @@ DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) {
10621062
ranges.Append(DWARFRangeList::Entry(llvm_range.LowPC,
10631063
llvm_range.HighPC - llvm_range.LowPC));
10641064
}
1065+
ranges.Sort();
10651066
return ranges;
10661067
}
10671068

lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ lookup_rnglists2:
124124
.Lrnglists_table_base0:
125125
.long .Ldebug_ranges0-.Lrnglists_table_base0
126126
.Ldebug_ranges0:
127-
.byte 4 # DW_RLE_offset_pair
128-
.uleb128 .Lblock1_begin-rnglists # starting offset
129-
.uleb128 .Lblock1_end-rnglists # ending offset
130127
.byte 4 # DW_RLE_offset_pair
131128
.uleb128 .Lblock2_begin-rnglists # starting offset
132129
.uleb128 .Lblock2_end-rnglists # ending offset
130+
.byte 4 # DW_RLE_offset_pair
131+
.uleb128 .Lblock1_begin-rnglists # starting offset
132+
.uleb128 .Lblock1_end-rnglists # ending offset
133133
.byte 0 # DW_RLE_end_of_list
134134
.Ldebug_rnglist_table_end0:
135135

0 commit comments

Comments
 (0)