mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
debuggable
This commit is contained in:
committed by
Jeong, YunWon
parent
5ba677cd36
commit
75e790836a
@@ -234,14 +234,14 @@ impl CodeInfo {
|
||||
eprintln!("===BLOCK {}===", block.0);
|
||||
}
|
||||
let block = &self.blocks[block];
|
||||
for i in &block.instructions {
|
||||
let instr = &i.instr;
|
||||
let effect = instr.stack_effect(i.arg, false);
|
||||
for ins in &block.instructions {
|
||||
let instr = &ins.instr;
|
||||
let effect = instr.stack_effect(ins.arg, false);
|
||||
if DEBUG {
|
||||
let display_arg = if i.target == BlockIdx::NULL {
|
||||
i.arg
|
||||
let display_arg = if ins.target == BlockIdx::NULL {
|
||||
ins.arg
|
||||
} else {
|
||||
OpArg(i.target.0)
|
||||
OpArg(ins.target.0)
|
||||
};
|
||||
let instr_display = instr.display(display_arg, self);
|
||||
eprint!("{instr_display}: {depth} {effect:+} => ");
|
||||
@@ -256,18 +256,18 @@ impl CodeInfo {
|
||||
// we don't want to worry about Break/Continue, they use unwinding to jump to
|
||||
// their targets and as such the stack size is taken care of in frame.rs by setting
|
||||
// it back to the level it was at when SetupLoop was run
|
||||
if i.target != BlockIdx::NULL
|
||||
if ins.target != BlockIdx::NULL
|
||||
&& !matches!(
|
||||
instr,
|
||||
Instruction::Continue { .. } | Instruction::Break { .. }
|
||||
)
|
||||
{
|
||||
let effect = instr.stack_effect(i.arg, true);
|
||||
let effect = instr.stack_effect(ins.arg, true);
|
||||
let target_depth = depth.checked_add_signed(effect).unwrap();
|
||||
if target_depth > maxdepth {
|
||||
maxdepth = target_depth
|
||||
}
|
||||
stackdepth_push(&mut stack, &mut start_depths, i.target, target_depth);
|
||||
stackdepth_push(&mut stack, &mut start_depths, ins.target, target_depth);
|
||||
}
|
||||
depth = new_depth;
|
||||
if instr.unconditional_branch() {
|
||||
|
||||
@@ -486,7 +486,10 @@ impl ExecutingFrame<'_> {
|
||||
) -> FrameResult {
|
||||
vm.check_signals()?;
|
||||
|
||||
flame_guard!(format!("Frame::execute_instruction({:?})", instruction));
|
||||
flame_guard!(format!(
|
||||
"Frame::execute_instruction({})",
|
||||
instruction.display(arg, &self.code.code).to_string()
|
||||
));
|
||||
|
||||
#[cfg(feature = "vm-tracing-logging")]
|
||||
{
|
||||
@@ -497,7 +500,10 @@ impl ExecutingFrame<'_> {
|
||||
}
|
||||
*/
|
||||
trace!(" {:#?}", self);
|
||||
trace!(" Executing op code: {:?}", instruction);
|
||||
trace!(
|
||||
" Executing op code: {}",
|
||||
instruction.display(arg, &self.code.code).to_string()
|
||||
);
|
||||
trace!("=======");
|
||||
}
|
||||
|
||||
@@ -1926,6 +1932,7 @@ impl ExecutingFrame<'_> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller] // not a real track_caller but pop_value is not very useful
|
||||
fn pop_value(&mut self) -> PyObjectRef {
|
||||
match self.state.stack.pop() {
|
||||
Some(x) => x,
|
||||
@@ -1959,6 +1966,7 @@ impl ExecutingFrame<'_> {
|
||||
|
||||
#[cold]
|
||||
#[inline(never)]
|
||||
#[track_caller]
|
||||
fn fatal(&self, msg: &'static str) -> ! {
|
||||
dbg!(self);
|
||||
panic!("{}", msg)
|
||||
|
||||
Reference in New Issue
Block a user