Skip to content

Commit

Permalink
Merge pull request #323 from rocallahan/range_is_end
Browse files Browse the repository at this point in the history
Make Range::is_end explicit so that we can represent DWARF5 ranges wi…
  • Loading branch information
philipc authored Aug 31, 2018
2 parents ccbf294 + 0d9f897 commit 45f4f34
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/rnglists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,6 @@ impl Range {
/// This should only be called for raw ranges.
#[inline]
pub fn add_base_address(&mut self, base_address: u64, address_size: u8) {
debug_assert!(!self.is_end());
debug_assert!(!self.is_base_address(address_size));
let mask = !0 >> (64 - address_size * 8);
self.begin = base_address.wrapping_add(self.begin) & mask;
self.end = base_address.wrapping_add(self.end) & mask;
Expand Down Expand Up @@ -546,6 +544,8 @@ mod tests {
.L8(7).L32(0x2010c00).uleb(0x100)
// An OffsetPair that starts at 0.
.L8(4).uleb(0).uleb(1)
// An OffsetPair that starts and ends at 0.
.L8(4).uleb(0).uleb(0)
// An OffsetPair that ends at -1.
.L8(5).L32(0)
.L8(4).uleb(0).uleb(0xffffffff)
Expand Down Expand Up @@ -623,6 +623,15 @@ mod tests {
}))
);

// A range that starts and ends at 0.
assert_eq!(
ranges.next(),
Ok(Some(Range {
begin: 0x02000000,
end: 0x02000000,
}))
);

// A range that ends at -1.
assert_eq!(
ranges.next(),
Expand Down Expand Up @@ -671,6 +680,8 @@ mod tests {
.L8(7).L64(0x2010c00).uleb(0x100)
// An OffsetPair that starts at 0.
.L8(4).uleb(0).uleb(1)
// An OffsetPair that starts and ends at 0.
.L8(4).uleb(0).uleb(0)
// An OffsetPair that ends at -1.
.L8(5).L64(0)
.L8(4).uleb(0).uleb(0xffffffff)
Expand Down Expand Up @@ -748,6 +759,15 @@ mod tests {
}))
);

// A range that starts and ends at 0.
assert_eq!(
ranges.next(),
Ok(Some(Range {
begin: 0x02000000,
end: 0x02000000,
}))
);

// A range that ends at -1.
assert_eq!(
ranges.next(),
Expand Down

0 comments on commit 45f4f34

Please sign in to comment.