Dump all allocs when dumping locals

上级 897b563e
...@@ -1621,41 +1621,52 @@ fn unsize_into( ...@@ -1621,41 +1621,52 @@ fn unsize_into(
pub fn dump_local(&self, lvalue: Lvalue) { pub fn dump_local(&self, lvalue: Lvalue) {
// Debug output // Debug output
if let Lvalue::Local { frame, local } = lvalue { match lvalue {
let mut allocs = Vec::new(); Lvalue::Local { frame, local } => {
let mut msg = format!("{:?}", local); let mut allocs = Vec::new();
if frame != self.cur_frame() { let mut msg = format!("{:?}", local);
write!(msg, " ({} frames up)", self.cur_frame() - frame).unwrap(); if frame != self.cur_frame() {
} write!(msg, " ({} frames up)", self.cur_frame() - frame).unwrap();
write!(msg, ":").unwrap();
match self.stack[frame].get_local(local) {
Err(EvalError{ kind: EvalErrorKind::DeadLocal, ..} ) => {
write!(msg, " is dead").unwrap();
} }
Err(err) => { write!(msg, ":").unwrap();
panic!("Failed to access local: {:?}", err);
match self.stack[frame].get_local(local) {
Err(EvalError{ kind: EvalErrorKind::DeadLocal, ..} ) => {
write!(msg, " is dead").unwrap();
}
Err(err) => {
panic!("Failed to access local: {:?}", err);
}
Ok(Value::ByRef(PtrAndAlign{ ptr, aligned })) => match ptr.into_inner_primval() {
PrimVal::Ptr(ptr) => {
write!(msg, " by {}ref:", if aligned { "" } else { "unaligned " }).unwrap();
allocs.push(ptr.alloc_id);
},
ptr => write!(msg, " integral by ref: {:?}", ptr).unwrap(),
},
Ok(Value::ByVal(val)) => {
write!(msg, " {:?}", val).unwrap();
if let PrimVal::Ptr(ptr) = val { allocs.push(ptr.alloc_id); }
}
Ok(Value::ByValPair(val1, val2)) => {
write!(msg, " ({:?}, {:?})", val1, val2).unwrap();
if let PrimVal::Ptr(ptr) = val1 { allocs.push(ptr.alloc_id); }
if let PrimVal::Ptr(ptr) = val2 { allocs.push(ptr.alloc_id); }
}
} }
Ok(Value::ByRef(PtrAndAlign{ ptr, aligned })) => match ptr.into_inner_primval() {
trace!("{}", msg);
self.memory.dump_allocs(allocs);
}
Lvalue::Ptr { ptr: PtrAndAlign { ptr, aligned }, .. } => {
match ptr.into_inner_primval() {
PrimVal::Ptr(ptr) => { PrimVal::Ptr(ptr) => {
write!(msg, " by {}ref:", if aligned { "" } else { "unaligned " }).unwrap(); trace!("by {}ref:", if aligned { "" } else { "unaligned " });
allocs.push(ptr.alloc_id); self.memory.dump_alloc(ptr.alloc_id);
}, },
ptr => write!(msg, " integral by ref: {:?}", ptr).unwrap(), ptr => trace!(" integral by ref: {:?}", ptr),
},
Ok(Value::ByVal(val)) => {
write!(msg, " {:?}", val).unwrap();
if let PrimVal::Ptr(ptr) = val { allocs.push(ptr.alloc_id); }
}
Ok(Value::ByValPair(val1, val2)) => {
write!(msg, " ({:?}, {:?})", val1, val2).unwrap();
if let PrimVal::Ptr(ptr) = val1 { allocs.push(ptr.alloc_id); }
if let PrimVal::Ptr(ptr) = val2 { allocs.push(ptr.alloc_id); }
} }
} }
trace!("{}", msg);
self.memory.dump_allocs(allocs);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册