Skip to content

Commit 7a39500

Browse files
committed
Fix vm-tracing-logging build
1 parent dbbdd75 commit 7a39500

4 files changed

Lines changed: 22 additions & 11 deletions

File tree

‎extra_tests/.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
snippets/whats_left_*.py
22
.cache/
33
cpython_tests_results.json
4-
4+
cpython_generated_slices.py

‎vm/src/frame.rs‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ enum UnwindReason {
7878
Continue,
7979
}
8080

81+
#[derive(Debug)]
8182
struct FrameState {
8283
// We need 1 stack per frame
8384
/// The main data frame of the stack machine
@@ -237,6 +238,17 @@ struct ExecutingFrame<'a> {
237238
state: &'a mut FrameState,
238239
}
239240

241+
impl fmt::Debug for ExecutingFrame<'_> {
242+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
243+
f.debug_struct("ExecutingFrame")
244+
.field("code", self.code)
245+
.field("scope", self.scope)
246+
.field("lasti", self.lasti)
247+
.field("state", self.state)
248+
.finish()
249+
}
250+
}
251+
240252
impl ExecutingFrame<'_> {
241253
fn run(&mut self, vm: &VirtualMachine) -> PyResult<ExecutionResult> {
242254
flame_guard!(format!("Frame::run({})", self.code.obj_name));
@@ -259,8 +271,8 @@ impl ExecutingFrame<'_> {
259271

260272
let new_traceback =
261273
PyTraceback::new(next, self.object.clone(), self.lasti(), loc.row());
274+
vm_trace!("Adding to traceback: {:?} {:?}", new_traceback, loc.row());
262275
exception.set_traceback(Some(new_traceback.into_ref(vm)));
263-
vm_trace!("Adding to traceback: {:?} {:?}", new_traceback, loc.row);
264276

265277
match self.unwind_blocks(vm, UnwindReason::Raising { exception }) {
266278
Ok(None) => {}
@@ -331,7 +343,7 @@ impl ExecutingFrame<'_> {
331343
trace!(" {:?}", frame);
332344
}
333345
*/
334-
trace!(" {:?}", self);
346+
trace!(" {:#?}", self);
335347
trace!(" Executing op code: {:?}", instruction);
336348
trace!("=======");
337349
}

‎vm/src/obj/objbuiltinfunc.rs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::fmt;
22

33
use super::objclassmethod::PyClassMethod;
4+
use crate::common::borrow::BorrowValue;
45
use crate::function::{PyFuncArgs, PyNativeFunc};
56
use crate::obj::objstr::PyStrRef;
67
use crate::obj::objtype::PyTypeRef;
@@ -69,7 +70,11 @@ impl PyValue for PyBuiltinFunction {
6970

7071
impl fmt::Debug for PyBuiltinFunction {
7172
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
72-
write!(f, "builtin function")
73+
let name = match &self.value.name {
74+
Some(s) => s.borrow_value(),
75+
None => "<unknown name>",
76+
};
77+
write!(f, "builtin function {}", name)
7378
}
7479
}
7580

‎vm/src/vm.rs‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -862,13 +862,7 @@ impl VirtualMachine {
862862
// This is only used in the vm for magic methods, which use a greatly simplified attribute lookup.
863863
match obj.get_class_attr(method_name) {
864864
Some(func) => {
865-
vm_trace!(
866-
"vm.call_method {:?} {:?} {:?} -> {:?}",
867-
obj,
868-
cls,
869-
method_name,
870-
func
871-
);
865+
vm_trace!("vm.call_method {:?} {:?} -> {:?}", obj, method_name, func);
872866
let wrapped = self.call_if_get_descriptor(func, obj.clone())?;
873867
self.invoke(&wrapped, args)
874868
}

0 commit comments

Comments
 (0)