mirror of
https://github.com/nushell/nushell.git
synced 2025-07-09 02:48:17 +02:00
Add IR support to the debugger (#13345)
# Description This adds tracing for each individual instruction to the `Debugger` trait. Register contents can be inspected both when entering and leaving an instruction, and if an instruction produced an error, a reference to the error is also available. It's not the full `EvalContext` but it's most of the important parts for getting an idea of what's going on. Added support for all of this to the `Profiler` / `debug profile` as well, and the output is quite incredible - super verbose, but you can see every instruction that's executed and also what the result was if it's an instruction that has a clearly defined output (many do). # User-Facing Changes - Added `--instructions` to `debug profile`, which adds the `pc` and `instruction` columns to the output. - `--expr` only works in AST mode, and `--instructions` only works in IR mode. In the wrong mode, the output for those columns is just blank. # Tests + Formatting All passing. # After Submitting - [ ] release notes
This commit is contained in:
@ -184,11 +184,20 @@ fn eval_ir_block_impl<D: DebugContext>(
|
||||
let instruction = &ir_block.instructions[pc];
|
||||
let span = &ir_block.spans[pc];
|
||||
let ast = &ir_block.ast[pc];
|
||||
log::trace!(
|
||||
"{pc:-4}: {}",
|
||||
instruction.display(ctx.engine_state, ctx.data)
|
||||
|
||||
D::enter_instruction(ctx.engine_state, ir_block, pc, ctx.registers);
|
||||
|
||||
let result = eval_instruction::<D>(ctx, instruction, span, ast);
|
||||
|
||||
D::leave_instruction(
|
||||
ctx.engine_state,
|
||||
ir_block,
|
||||
pc,
|
||||
ctx.registers,
|
||||
result.as_ref().err(),
|
||||
);
|
||||
match eval_instruction::<D>(ctx, instruction, span, ast) {
|
||||
|
||||
match result {
|
||||
Ok(InstructionResult::Continue) => {
|
||||
pc += 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user