Don't skip empty location ranges
This causes dwarfdump to panic when printing a location list containing an empty range,
because LocListIter returns fewer entries than RawLocListIter.
@@ -471,11 +471,6 @@ impl<R: Reader> LocListIter<R> {
}
};
- if range.begin == range.end {
- // An empty location list entry, skip it.
- continue;
- }
-
if range.begin > range.end {
self.raw.input.empty();
return Err(Error::InvalidLocationAddressRange);
@@ -589,6 +584,16 @@ mod tests {
);
// An empty location range followed by a normal location.
+ assert_eq!(
+ locations.next(),
+ Ok(Some(LocationListEntry {
+ range: Range {
+ begin: 0x02010600,
+ end: 0x02010600,
+ },
+ data: Expression(EndianBuf::new(&[4, 0, 0, 0], LittleEndian)),
+ }))
+ );
assert_eq!(
locations.next(),
Ok(Some(LocationListEntry {
@@ -600,7 +605,7 @@ mod tests {
}))
);
- // An empty location range followed by a normal location.
+ // A normal location.
assert_eq!(
locations.next(),
Ok(Some(LocationListEntry {
@@ -612,7 +617,7 @@ mod tests {
}))
);
- // An empty location range followed by a normal location.
+ // A normal location.
assert_eq!(
locations.next(),
Ok(Some(LocationListEntry {
@@ -742,6 +747,16 @@ mod tests {
);
// An empty location range followed by a normal location.
+ assert_eq!(
+ locations.next(),
+ Ok(Some(LocationListEntry {
+ range: Range {
+ begin: 0x02010600,
+ end: 0x02010600,
+ },
+ data: Expression(EndianBuf::new(&[4, 0, 0, 0], LittleEndian)),
+ }))
+ );
assert_eq!(
locations.next(),
Ok(Some(LocationListEntry {
@@ -753,7 +768,7 @@ mod tests {
}))
);
- // An empty location range followed by a normal location.
+ // A normal location.
assert_eq!(
locations.next(),
Ok(Some(LocationListEntry {
@@ -765,7 +780,7 @@ mod tests {
}))
);
- // An empty location range followed by a normal location.
+ // A normal location.
assert_eq!(
locations.next(),
Ok(Some(LocationListEntry {
@@ -883,6 +898,16 @@ mod tests {
);
// An empty location range followed by a normal location.
+ assert_eq!(
+ locations.next(),
+ Ok(Some(LocationListEntry {
+ range: Range {
+ begin: 0x02010600,
+ end: 0x02010600,
+ },
+ data: Expression(EndianBuf::new(&[4, 0, 0, 0], LittleEndian)),
+ }))
+ );
assert_eq!(
locations.next(),
Ok(Some(LocationListEntry {
@@ -988,6 +1013,16 @@ mod tests {
);
// An empty location range followed by a normal location.
+ assert_eq!(
+ locations.next(),
+ Ok(Some(LocationListEntry {
+ range: Range {
+ begin: 0x02010600,
+ end: 0x02010600,
+ },
+ data: Expression(EndianBuf::new(&[4, 0, 0, 0], LittleEndian)),
+ }))
+ );
assert_eq!(
locations.next(),
Ok(Some(LocationListEntry {
