Fix vm-tracing-logging build

This commit is contained in:
Noah
2020-09-26 22:48:16 -05:00
parent dbbdd75b31
commit 7a39500aed
4 changed files with 22 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
snippets/whats_left_*.py
.cache/
cpython_tests_results.json
cpython_generated_slices.py

View File

@@ -78,6 +78,7 @@ enum UnwindReason {
Continue,
}
#[derive(Debug)]
struct FrameState {
// We need 1 stack per frame
/// The main data frame of the stack machine
@@ -237,6 +238,17 @@ struct ExecutingFrame<'a> {
state: &'a mut FrameState,
}
impl fmt::Debug for ExecutingFrame<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("ExecutingFrame")
.field("code", self.code)
.field("scope", self.scope)
.field("lasti", self.lasti)
.field("state", self.state)
.finish()
}
}
impl ExecutingFrame<'_> {
fn run(&mut self, vm: &VirtualMachine) -> PyResult<ExecutionResult> {
flame_guard!(format!("Frame::run({})", self.code.obj_name));
@@ -259,8 +271,8 @@ impl ExecutingFrame<'_> {
let new_traceback =
PyTraceback::new(next, self.object.clone(), self.lasti(), loc.row());
vm_trace!("Adding to traceback: {:?} {:?}", new_traceback, loc.row());
exception.set_traceback(Some(new_traceback.into_ref(vm)));
vm_trace!("Adding to traceback: {:?} {:?}", new_traceback, loc.row);
match self.unwind_blocks(vm, UnwindReason::Raising { exception }) {
Ok(None) => {}
@@ -331,7 +343,7 @@ impl ExecutingFrame<'_> {
trace!(" {:?}", frame);
}
*/
trace!(" {:?}", self);
trace!(" {:#?}", self);
trace!(" Executing op code: {:?}", instruction);
trace!("=======");
}

View File

@@ -1,6 +1,7 @@
use std::fmt;
use super::objclassmethod::PyClassMethod;
use crate::common::borrow::BorrowValue;
use crate::function::{PyFuncArgs, PyNativeFunc};
use crate::obj::objstr::PyStrRef;
use crate::obj::objtype::PyTypeRef;
@@ -69,7 +70,11 @@ impl PyValue for PyBuiltinFunction {
impl fmt::Debug for PyBuiltinFunction {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "builtin function")
let name = match &self.value.name {
Some(s) => s.borrow_value(),
None => "<unknown name>",
};
write!(f, "builtin function {}", name)
}
}

View File

@@ -862,13 +862,7 @@ impl VirtualMachine {
// This is only used in the vm for magic methods, which use a greatly simplified attribute lookup.
match obj.get_class_attr(method_name) {
Some(func) => {
vm_trace!(
"vm.call_method {:?} {:?} {:?} -> {:?}",
obj,
cls,
method_name,
func
);
vm_trace!("vm.call_method {:?} {:?} -> {:?}", obj, method_name, func);
let wrapped = self.call_if_get_descriptor(func, obj.clone())?;
self.invoke(&wrapped, args)
}