print pointers more compactly when they are too big
This commit is contained in:
parent
c427438d24
commit
19eb9345df
6 changed files with 53 additions and 27 deletions
|
@ -168,15 +168,21 @@ pub enum LitToConstError {
|
|||
#[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
pub struct AllocId(pub u64);
|
||||
|
||||
impl fmt::Debug for AllocId {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Display::fmt(self, fmt)
|
||||
impl fmt::Display for AllocId {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if f.alternate() {
|
||||
write!(f, "a{}", self.0)
|
||||
} else {
|
||||
write!(f, "alloc{}", self.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for AllocId {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "alloc{}", self.0)
|
||||
// We also want the `Debug` output to be readable as it is used by `derive(Debug)` for
|
||||
// all the Miri types.
|
||||
impl fmt::Debug for AllocId {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Display::fmt(self, fmt)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -119,15 +119,31 @@ pub struct Pointer<Tag = (), Id = AllocId> {
|
|||
|
||||
static_assert_size!(Pointer, 16);
|
||||
|
||||
impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Debug for Pointer<Tag, Id> {
|
||||
impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Display for Pointer<Tag, Id> {
|
||||
default fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}+0x{:x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag)
|
||||
if f.alternate() {
|
||||
write!(f, "{:#?}+0x{:x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag)
|
||||
} else {
|
||||
write!(f, "{:?}+0x{:x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Specialization for no tag
|
||||
impl<Id: fmt::Debug> fmt::Debug for Pointer<(), Id> {
|
||||
impl<Id: fmt::Debug> fmt::Display for Pointer<(), Id> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}+0x{:x}", self.alloc_id, self.offset.bytes())
|
||||
if f.alternate() {
|
||||
write!(f, "{:#?}+0x{:x}", self.alloc_id, self.offset.bytes())
|
||||
} else {
|
||||
write!(f, "{:?}+0x{:x}", self.alloc_id, self.offset.bytes())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We also want the `Debug` output to be readable as it is used by `derive(Debug)` for
|
||||
// all the Miri types.
|
||||
impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Debug for Pointer<Tag, Id> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Display::fmt(self, fmt)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -726,6 +726,10 @@ fn write_allocation_bytes<Tag: Copy + Debug, Extra>(
|
|||
let relocation_width = |bytes| bytes * 3;
|
||||
let ptr = Pointer::new_with_tag(target_id, offset, tag);
|
||||
let mut target = format!("{:?}", ptr);
|
||||
if target.len() > relocation_width(ptr_size.bytes_usize() - 1) {
|
||||
// This is too long, try to save some space.
|
||||
target = format!("{:#?}", ptr);
|
||||
}
|
||||
if ((i - line_start) + ptr_size).bytes_usize() > BYTES_PER_LINE {
|
||||
// This branch handles the situation where a relocation starts in the current line
|
||||
// but ends in the next one.
|
||||
|
|
|
@ -30,19 +30,19 @@ fn main() -> () {
|
|||
}
|
||||
|
||||
alloc0 (static: FOO, size: 8, align: 4) {
|
||||
╾alloc17+0x0 (4 ptr bytes)╼ 03 00 00 00 │ ╾──╼....
|
||||
╾─a17+0x0─╼ 03 00 00 00 │ ╾──╼....
|
||||
}
|
||||
|
||||
alloc17 (size: 48, align: 4) {
|
||||
0x00 │ 00 00 00 00 __ __ __ __ ╾alloc4+0x0 (4 ptr bytes)╼ 00 00 00 00 │ ....░░░░╾──╼....
|
||||
0x10 │ 00 00 00 00 __ __ __ __ ╾alloc8+0x0 (4 ptr bytes)╼ 02 00 00 00 │ ....░░░░╾──╼....
|
||||
0x20 │ 01 00 00 00 2a 00 00 00 ╾alloc13+0x0 (4 ptr bytes)╼ 03 00 00 00 │ ....*...╾──╼....
|
||||
0x00 │ 00 00 00 00 __ __ __ __ ╾─a4+0x0──╼ 00 00 00 00 │ ....░░░░╾──╼....
|
||||
0x10 │ 00 00 00 00 __ __ __ __ ╾─a8+0x0──╼ 02 00 00 00 │ ....░░░░╾──╼....
|
||||
0x20 │ 01 00 00 00 2a 00 00 00 ╾─a13+0x0─╼ 03 00 00 00 │ ....*...╾──╼....
|
||||
}
|
||||
|
||||
alloc4 (size: 0, align: 4) {}
|
||||
|
||||
alloc8 (size: 16, align: 4) {
|
||||
╾alloc7+0x0 (4 ptr bytes)╼ 03 00 00 00 ╾alloc9+0x0 (4 ptr bytes)╼ 03 00 00 00 │ ╾──╼....╾──╼....
|
||||
╾─a7+0x0──╼ 03 00 00 00 ╾─a9+0x0──╼ 03 00 00 00 │ ╾──╼....╾──╼....
|
||||
}
|
||||
|
||||
alloc7 (size: 3, align: 1) {
|
||||
|
@ -54,8 +54,8 @@ alloc9 (size: 3, align: 1) {
|
|||
}
|
||||
|
||||
alloc13 (size: 24, align: 4) {
|
||||
0x00 │ ╾alloc12+0x0 (4 ptr bytes)╼ 03 00 00 00 ╾alloc14+0x0 (4 ptr bytes)╼ 03 00 00 00 │ ╾──╼....╾──╼....
|
||||
0x10 │ ╾alloc15+0x0 (4 ptr bytes)╼ 04 00 00 00 │ ╾──╼....
|
||||
0x00 │ ╾─a12+0x0─╼ 03 00 00 00 ╾─a14+0x0─╼ 03 00 00 00 │ ╾──╼....╾──╼....
|
||||
0x10 │ ╾─a15+0x0─╼ 04 00 00 00 │ ╾──╼....
|
||||
}
|
||||
|
||||
alloc12 (size: 3, align: 1) {
|
||||
|
|
|
@ -30,19 +30,19 @@ fn main() -> () {
|
|||
}
|
||||
|
||||
alloc0 (static: FOO, size: 8, align: 4) {
|
||||
╾alloc21+0x0 (4 ptr bytes)╼ 03 00 00 00 │ ╾──╼....
|
||||
╾─a21+0x0─╼ 03 00 00 00 │ ╾──╼....
|
||||
}
|
||||
|
||||
alloc21 (size: 48, align: 4) {
|
||||
0x00 │ 00 00 00 00 __ __ __ __ ╾alloc4+0x0 (4 ptr bytes)╼ 00 00 00 00 │ ....░░░░╾──╼....
|
||||
0x10 │ 00 00 00 00 __ __ __ __ ╾alloc9+0x0 (4 ptr bytes)╼ 02 00 00 00 │ ....░░░░╾──╼....
|
||||
0x20 │ 01 00 00 00 2a 00 00 00 ╾alloc19+0x0 (4 ptr bytes)╼ 03 00 00 00 │ ....*...╾──╼....
|
||||
0x00 │ 00 00 00 00 __ __ __ __ ╾─a4+0x0──╼ 00 00 00 00 │ ....░░░░╾──╼....
|
||||
0x10 │ 00 00 00 00 __ __ __ __ ╾─a9+0x0──╼ 02 00 00 00 │ ....░░░░╾──╼....
|
||||
0x20 │ 01 00 00 00 2a 00 00 00 ╾─a19+0x0─╼ 03 00 00 00 │ ....*...╾──╼....
|
||||
}
|
||||
|
||||
alloc4 (size: 0, align: 4) {}
|
||||
|
||||
alloc9 (size: 8, align: 4) {
|
||||
╾alloc7+0x0 (4 ptr bytes)╼ ╾alloc8+0x0 (4 ptr bytes)╼ │ ╾──╼╾──╼
|
||||
╾─a7+0x0──╼ ╾─a8+0x0──╼ │ ╾──╼╾──╼
|
||||
}
|
||||
|
||||
alloc7 (size: 1, align: 1) {
|
||||
|
@ -54,7 +54,7 @@ alloc8 (size: 1, align: 1) {
|
|||
}
|
||||
|
||||
alloc19 (size: 12, align: 4) {
|
||||
╾alloc15+0x3 (4 ptr bytes)╼ ╾alloc16+0x0 (4 ptr bytes)╼ ╾alloc18+0x2 (4 ptr bytes)╼ │ ╾──╼╾──╼╾──╼
|
||||
╾─a15+0x3─╼ ╾─a16+0x0─╼ ╾─a18+0x2─╼ │ ╾──╼╾──╼╾──╼
|
||||
}
|
||||
|
||||
alloc15 (size: 4, align: 1) {
|
||||
|
|
|
@ -30,20 +30,20 @@ fn main() -> () {
|
|||
}
|
||||
|
||||
alloc0 (static: FOO, size: 4, align: 4) {
|
||||
╾alloc9+0x0 (4 ptr bytes)╼ │ ╾──╼
|
||||
╾─a9+0x0──╼ │ ╾──╼
|
||||
}
|
||||
|
||||
alloc9 (size: 168, align: 1) {
|
||||
0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................
|
||||
0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾alloc4+0x0 (4 ptr bytes)╼ │ ............╾──╼
|
||||
0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾─a4+0x0──╼ │ ............╾──╼
|
||||
0x20 │ 01 ef cd ab 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
|
||||
0x30 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
|
||||
0x40 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
|
||||
0x50 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
|
||||
0x60 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
|
||||
0x70 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
|
||||
0x80 │ 00 00 00 00 00 00 00 00 00 00 ╾alloc6+0x0 (4 ptr bytes)╼ 00 00 │ ..........╾──╼..
|
||||
0x90 │ ╾alloc7+0x63 (4 ptr bytes)╼ 00 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............
|
||||
0x80 │ 00 00 00 00 00 00 00 00 00 00 ╾─a6+0x0──╼ 00 00 │ ..........╾──╼..
|
||||
0x90 │ ╾─a7+0x63─╼ 00 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............
|
||||
0xa0 │ 00 00 00 00 00 00 00 00 │ ........
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue