From 864df078ec9f0d9940435bfd0c1379e6da0a21de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 24 Jan 2024 12:21:44 -0500 Subject: [PATCH 1/5] feat: Allow retrieving the call stack --- acvm-repo/acvm/src/pwg/brillig.rs | 4 ++ acvm-repo/brillig_vm/src/lib.rs | 10 +++++ tooling/debugger/src/context.rs | 65 ++++++++++++++++++++++++++++++- tooling/debugger/src/dap.rs | 4 +- tooling/debugger/src/repl.rs | 2 +- 5 files changed, 81 insertions(+), 4 deletions(-) diff --git a/acvm-repo/acvm/src/pwg/brillig.rs b/acvm-repo/acvm/src/pwg/brillig.rs index 0db38c776e2..f32fbf23710 100644 --- a/acvm-repo/acvm/src/pwg/brillig.rs +++ b/acvm-repo/acvm/src/pwg/brillig.rs @@ -128,6 +128,10 @@ impl<'b, B: BlackBoxFunctionSolver> BrilligSolver<'b, B> { self.vm.write_memory_at(ptr, value); } + pub fn get_call_stack(&self) -> Vec { + self.vm.get_call_stack() + } + pub(super) fn solve(&mut self) -> Result { let status = self.vm.process_opcodes(); self.handle_vm_status(status) diff --git a/acvm-repo/brillig_vm/src/lib.rs b/acvm-repo/brillig_vm/src/lib.rs index 38a562e65a1..bfc5fbf1dee 100644 --- a/acvm-repo/brillig_vm/src/lib.rs +++ b/acvm-repo/brillig_vm/src/lib.rs @@ -176,6 +176,16 @@ impl<'a, B: BlackBoxFunctionSolver> VM<'a, B> { self.memory.write(ptr, value); } + /// Returns the VM's current call stack, including the actual program + /// counter in the last position of the returned vector. + pub fn get_call_stack(&self) -> Vec { + self.call_stack + .iter() + .map(|v| v.to_usize()) + .chain(std::iter::once(self.program_counter)) + .collect() + } + /// Process a single opcode and modify the program counter. pub fn process_opcode(&mut self) -> VMStatus { let opcode = &self.bytecode[self.program_counter]; diff --git a/tooling/debugger/src/context.rs b/tooling/debugger/src/context.rs index 3cababe7605..95dbd6ba460 100644 --- a/tooling/debugger/src/context.rs +++ b/tooling/debugger/src/context.rs @@ -78,6 +78,21 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { } } + pub(super) fn get_call_stack(&self) -> Vec { + let ip = self.acvm.instruction_pointer(); + if ip >= self.get_opcodes().len() { + vec![] + } else if let Some(ref solver) = self.brillig_solver { + solver + .get_call_stack() + .iter() + .map(|pc| OpcodeLocation::Brillig { acir_index: ip, brillig_index: *pc }) + .collect() + } else { + vec![OpcodeLocation::Acir(ip)] + } + } + pub(super) fn is_source_location_in_debug_module(&self, location: &Location) -> bool { self.debug_artifact .file_map @@ -123,6 +138,21 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { .unwrap_or(vec![]) } + /// Returns the current call stack with expanded source locations. In + /// general, the matching between opcode location and source location is 1 + /// to 1, but due to the compiler inlining functions a single opcode + /// location may expand to multiple source locations. + pub(super) fn get_source_call_stack(&self) -> Vec<(OpcodeLocation, Location)> { + self.get_call_stack() + .iter() + .flat_map(|opcode_location| { + self.get_source_location_for_opcode_location(opcode_location) + .into_iter() + .map(|source_location| (*opcode_location, source_location)) + }) + .collect() + } + fn get_opcodes_sizes(&self) -> Vec { self.get_opcodes() .iter() @@ -362,7 +392,8 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { } } - pub(super) fn next(&mut self) -> DebugCommandResult { + /// Steps debugging execution until the next source location + pub(super) fn next_into(&mut self) -> DebugCommandResult { let start_location = self.get_current_source_location(); loop { let result = self.step_into_opcode(); @@ -376,6 +407,38 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { } } + /// Steps debugging execution until the next source location at the same (or + /// less) call stack depth (eg. don't dive into function calls) + pub(super) fn next_over(&mut self) -> DebugCommandResult { + let start_call_stack = self.get_source_call_stack(); + loop { + let result = self.next_into(); + if !matches!(result, DebugCommandResult::Ok) { + return result; + } + let new_call_stack = self.get_source_call_stack(); + if new_call_stack.len() <= start_call_stack.len() { + return DebugCommandResult::Ok; + } + } + } + + /// Steps debugging execution until the next source location with a smaller + /// call stack depth (eg. returning from the current function) + pub(super) fn next_out(&mut self) -> DebugCommandResult { + let start_call_stack = self.get_source_call_stack(); + loop { + let result = self.next_into(); + if !matches!(result, DebugCommandResult::Ok) { + return result; + } + let new_call_stack = self.get_source_call_stack(); + if new_call_stack.len() < start_call_stack.len() { + return DebugCommandResult::Ok; + } + } + } + pub(super) fn cont(&mut self) -> DebugCommandResult { loop { let result = self.step_into_opcode(); diff --git a/tooling/debugger/src/dap.rs b/tooling/debugger/src/dap.rs index 2de7dac77d8..30d52890214 100644 --- a/tooling/debugger/src/dap.rs +++ b/tooling/debugger/src/dap.rs @@ -132,7 +132,7 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { // source location to show when first starting the debugger, but // maybe the default behavior should be to start executing until the // first breakpoint set. - _ = self.context.next(); + _ = self.context.next_into(); } self.server.send_event(Event::Initialized)?; @@ -316,7 +316,7 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { } fn handle_next(&mut self, req: Request) -> Result<(), ServerError> { - let result = self.context.next(); + let result = self.context.next_into(); eprintln!("INFO: stepped by statement with result {result:?}"); self.server.respond(req.ack()?)?; self.handle_execution_result(result) diff --git a/tooling/debugger/src/repl.rs b/tooling/debugger/src/repl.rs index 1ba5391b0cf..57976bdf5ac 100644 --- a/tooling/debugger/src/repl.rs +++ b/tooling/debugger/src/repl.rs @@ -199,7 +199,7 @@ impl<'a, B: BlackBoxFunctionSolver> ReplDebugger<'a, B> { fn next(&mut self) { if self.validate_in_progress() { - let result = self.context.next(); + let result = self.context.next_into(); self.handle_debug_command_result(result); } } From f064575e99723daf1e41c431e291bdbb1433b06f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 24 Jan 2024 12:26:10 -0500 Subject: [PATCH 2/5] feat: Add stack trace and improved stepping commands to debugger REPL --- tooling/debugger/src/repl.rs | 80 +++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/tooling/debugger/src/repl.rs b/tooling/debugger/src/repl.rs index 57976bdf5ac..772bf25a66b 100644 --- a/tooling/debugger/src/repl.rs +++ b/tooling/debugger/src/repl.rs @@ -83,6 +83,38 @@ impl<'a, B: BlackBoxFunctionSolver> ReplDebugger<'a, B> { } } + fn show_stack_frame(&self, index: usize, location: &OpcodeLocation) { + let opcodes = self.context.get_opcodes(); + match location { + OpcodeLocation::Acir(ip) => { + println!("Frame #{index}, opcode {}: {}", ip, opcodes[*ip]) + } + OpcodeLocation::Brillig { acir_index, brillig_index } => { + let Opcode::Brillig(ref brillig) = opcodes[*acir_index] else { + unreachable!("Brillig location does not contain a Brillig block"); + }; + println!( + "Frame #{index}, opcode {}.{}: {:?}", + acir_index, brillig_index, brillig.bytecode[*brillig_index] + ); + } + } + let locations = self.context.get_source_location_for_opcode_location(location); + print_source_code_location(self.debug_artifact, &locations); + } + + pub fn show_current_call_stack(&self) { + let call_stack = self.context.get_call_stack(); + if call_stack.is_empty() { + println!("Finished execution. Call stack empty."); + return; + } + + for (i, frame_location) in call_stack.iter().enumerate() { + self.show_stack_frame(i, frame_location); + } + } + fn display_opcodes(&self) { let opcodes = self.context.get_opcodes(); let current_opcode_location = self.context.get_current_opcode_location(); @@ -197,13 +229,27 @@ impl<'a, B: BlackBoxFunctionSolver> ReplDebugger<'a, B> { } } - fn next(&mut self) { + fn next_into(&mut self) { if self.validate_in_progress() { let result = self.context.next_into(); self.handle_debug_command_result(result); } } + fn next_over(&mut self) { + if self.validate_in_progress() { + let result = self.context.next_over(); + self.handle_debug_command_result(result); + } + } + + fn next_out(&mut self) { + if self.validate_in_progress() { + let result = self.context.next_out(); + self.handle_debug_command_result(result); + } + } + fn cont(&mut self) { if self.validate_in_progress() { println!("(Continuing execution...)"); @@ -375,11 +421,31 @@ pub fn run( command! { "step until a new source location is reached", () => || { - ref_context.borrow_mut().next(); + ref_context.borrow_mut().next_into(); Ok(CommandStatus::Done) } }, ) + .add( + "over", + command! { + "step until a new source location is reached without diving into function calls", + () => || { + ref_context.borrow_mut().next_over(); + Ok(CommandStatus::Done) + } + } + ) + .add( + "out", + command! { + "step until a new source location is reached and the current stack frame is finished", + () => || { + ref_context.borrow_mut().next_out(); + Ok(CommandStatus::Done) + } + } + ) .add( "continue", command! { @@ -500,6 +566,16 @@ pub fn run( } }, ) + .add( + "stacktrace", + command! { + "display the current stack trace", + () => || { + ref_context.borrow().show_current_call_stack(); + Ok(CommandStatus::Done) + } + }, + ) .add( "vars", command! { From 485b019352c236c46d0b20d40aa4ea5e16fa9c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 24 Jan 2024 12:26:51 -0500 Subject: [PATCH 3/5] feat: Allow inspecting variables and stack trace in DAP mode --- tooling/debugger/src/dap.rs | 209 ++++++++++++++++++++++++++++-------- 1 file changed, 166 insertions(+), 43 deletions(-) diff --git a/tooling/debugger/src/dap.rs b/tooling/debugger/src/dap.rs index 30d52890214..17ff81c52f0 100644 --- a/tooling/debugger/src/dap.rs +++ b/tooling/debugger/src/dap.rs @@ -4,6 +4,7 @@ use std::str::FromStr; use acvm::acir::circuit::{Circuit, OpcodeLocation}; use acvm::acir::native_types::WitnessMap; +use acvm::brillig_vm::Registers; use acvm::BlackBoxFunctionSolver; use codespan_reporting::files::{Files, SimpleFile}; @@ -18,12 +19,12 @@ use dap::requests::{Command, Request, SetBreakpointsArguments}; use dap::responses::{ ContinueResponse, DisassembleResponse, ResponseBody, ScopesResponse, SetBreakpointsResponse, SetExceptionBreakpointsResponse, SetInstructionBreakpointsResponse, StackTraceResponse, - ThreadsResponse, + ThreadsResponse, VariablesResponse, }; use dap::server::Server; use dap::types::{ - Breakpoint, DisassembledInstruction, Source, StackFrame, SteppingGranularity, - StoppedEventReason, Thread, + Breakpoint, DisassembledInstruction, Scope, Source, StackFrame, SteppingGranularity, + StoppedEventReason, Thread, Variable, }; use nargo::artifacts::debug::DebugArtifact; @@ -41,6 +42,24 @@ pub struct DapSession<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> { source_breakpoints: BTreeMap>, } +enum ScopeReferences { + Locals = 1, + WitnessMap = 2, + BrilligRegisters = 3, + InvalidScope = 0, +} + +impl From for ScopeReferences { + fn from(value: i64) -> Self { + match value { + 1 => Self::Locals, + 2 => Self::WitnessMap, + 3 => Self::BrilligRegisters, + _ => Self::InvalidScope, + } + } +} + // BTreeMap impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { @@ -176,7 +195,7 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { args.granularity.as_ref().unwrap_or(&SteppingGranularity::Statement); match granularity { SteppingGranularity::Instruction => self.handle_step(req)?, - _ => self.handle_next(req)?, + _ => self.handle_next_into(req)?, } } Command::StepOut(ref args) => { @@ -184,7 +203,7 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { args.granularity.as_ref().unwrap_or(&SteppingGranularity::Statement); match granularity { SteppingGranularity::Instruction => self.handle_step(req)?, - _ => self.handle_next(req)?, + _ => self.handle_next_out(req)?, } } Command::Next(ref args) => { @@ -192,18 +211,17 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { args.granularity.as_ref().unwrap_or(&SteppingGranularity::Statement); match granularity { SteppingGranularity::Instruction => self.handle_step(req)?, - _ => self.handle_next(req)?, + _ => self.handle_next_over(req)?, } } Command::Continue(_) => { self.handle_continue(req)?; } Command::Scopes(_) => { - // FIXME: this needs a proper implementation when we can - // show the parameters and variables - self.server.respond( - req.success(ResponseBody::Scopes(ScopesResponse { scopes: vec![] })), - )?; + self.handle_scopes(req)?; + } + Command::Variables(ref _args) => { + self.handle_variables(req)?; } _ => { eprintln!("ERROR: unhandled command: {:?}", req.command); @@ -213,37 +231,40 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { Ok(()) } + fn build_stack_trace(&self) -> Vec { + self.context + .get_source_call_stack() + .iter() + .enumerate() + .map(|(index, (opcode_location, source_location))| { + let line_number = + self.debug_artifact.location_line_number(*source_location).unwrap(); + let column_number = + self.debug_artifact.location_column_number(*source_location).unwrap(); + StackFrame { + id: index as i64, + name: format!("frame #{index}"), + source: Some(Source { + path: self.debug_artifact.file_map[&source_location.file] + .path + .to_str() + .map(String::from), + ..Source::default() + }), + line: line_number as i64, + column: column_number as i64, + instruction_pointer_reference: Some(opcode_location.to_string()), + ..StackFrame::default() + } + }) + .collect::>() + .into_iter() + .rev() + .collect() + } + fn handle_stack_trace(&mut self, req: Request) -> Result<(), ServerError> { - let opcode_location = self.context.get_current_opcode_location(); - let source_location = self.context.get_current_source_location(); - let frames = match source_location { - None => vec![], - Some(locations) => locations - .iter() - .enumerate() - .map(|(index, location)| { - let line_number = self.debug_artifact.location_line_number(*location).unwrap(); - let column_number = - self.debug_artifact.location_column_number(*location).unwrap(); - let ip_reference = opcode_location.map(|location| location.to_string()); - StackFrame { - id: index as i64, - name: format!("frame #{index}"), - source: Some(Source { - path: self.debug_artifact.file_map[&location.file] - .path - .to_str() - .map(String::from), - ..Source::default() - }), - line: line_number as i64, - column: column_number as i64, - instruction_pointer_reference: ip_reference, - ..StackFrame::default() - } - }) - .collect(), - }; + let frames = self.build_stack_trace(); let total_frames = Some(frames.len() as i64); self.server.respond(req.success(ResponseBody::StackTrace(StackTraceResponse { stack_frames: frames, @@ -315,9 +336,23 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { self.handle_execution_result(result) } - fn handle_next(&mut self, req: Request) -> Result<(), ServerError> { + fn handle_next_into(&mut self, req: Request) -> Result<(), ServerError> { let result = self.context.next_into(); - eprintln!("INFO: stepped by statement with result {result:?}"); + eprintln!("INFO: stepped into by statement with result {result:?}"); + self.server.respond(req.ack()?)?; + self.handle_execution_result(result) + } + + fn handle_next_out(&mut self, req: Request) -> Result<(), ServerError> { + let result = self.context.next_out(); + eprintln!("INFO: stepped out by statement with result {result:?}"); + self.server.respond(req.ack()?)?; + self.handle_execution_result(result) + } + + fn handle_next_over(&mut self, req: Request) -> Result<(), ServerError> { + let result = self.context.next_over(); + eprintln!("INFO: stepped over by statement with result {result:?}"); self.server.respond(req.ack()?)?; self.handle_execution_result(result) } @@ -548,6 +583,94 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { )?; Ok(()) } + + fn handle_scopes(&mut self, req: Request) -> Result<(), ServerError> { + self.server.respond(req.success(ResponseBody::Scopes(ScopesResponse { + scopes: vec![ + Scope { + name: String::from("Locals"), + variables_reference: ScopeReferences::Locals as i64, + ..Scope::default() + }, + Scope { + name: String::from("Witness Map"), + variables_reference: ScopeReferences::WitnessMap as i64, + ..Scope::default() + }, + Scope { + name: String::from("Brillig Registers"), + variables_reference: ScopeReferences::BrilligRegisters as i64, + ..Scope::default() + }, + ], + })))?; + Ok(()) + } + + fn build_local_variables(&self) -> Vec { + let mut variables: Vec<_> = self + .context + .get_variables() + .iter() + .map(|(name, value, _var_type)| Variable { + name: String::from(*name), + value: format!("{:?}", *value), + ..Variable::default() + }) + .collect(); + variables.sort_by(|a, b| a.name.partial_cmp(&b.name).unwrap()); + variables + } + + fn build_witness_map(&self) -> Vec { + self.context + .get_witness_map() + .clone() + .into_iter() + .map(|(witness, value)| Variable { + name: format!("_{}", witness.witness_index()), + value: format!("{value:?}"), + ..Variable::default() + }) + .collect() + } + + fn build_brillig_registers(&self) -> Vec { + self.context + .get_brillig_registers() + .unwrap_or(&Registers { inner: vec![] }) + .inner + .iter() + .enumerate() + .map(|(index, value)| Variable { + name: format!("R{index}"), + value: format!("{value:?}"), + ..Variable::default() + }) + .collect() + } + + fn handle_variables(&mut self, req: Request) -> Result<(), ServerError> { + let Command::Variables(ref args) = req.command else { + unreachable!("handle_variables called on a different request"); + }; + let scope: ScopeReferences = args.variables_reference.into(); + let variables: Vec<_> = match scope { + ScopeReferences::Locals => self.build_local_variables(), + ScopeReferences::WitnessMap => self.build_witness_map(), + ScopeReferences::BrilligRegisters => self.build_brillig_registers(), + _ => { + eprintln!( + "handle_variables with an unknown variables_reference {}", + args.variables_reference + ); + vec![] + } + }; + self.server + .respond(req.success(ResponseBody::Variables(VariablesResponse { variables })))?; + Ok(()) + } } pub fn run_session( From 2555720a265e42807d794610584aba3c234f3e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 8 Feb 2024 16:01:25 -0500 Subject: [PATCH 4/5] chore: Rename some variables and address code review comments --- acvm-repo/brillig_vm/src/lib.rs | 2 +- tooling/debugger/src/context.rs | 11 +++++++---- tooling/debugger/src/dap.rs | 2 -- tooling/debugger/src/repl.rs | 7 +++++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/acvm-repo/brillig_vm/src/lib.rs b/acvm-repo/brillig_vm/src/lib.rs index bfc5fbf1dee..d04399a8e6b 100644 --- a/acvm-repo/brillig_vm/src/lib.rs +++ b/acvm-repo/brillig_vm/src/lib.rs @@ -181,7 +181,7 @@ impl<'a, B: BlackBoxFunctionSolver> VM<'a, B> { pub fn get_call_stack(&self) -> Vec { self.call_stack .iter() - .map(|v| v.to_usize()) + .map(|program_counter| program_counter.to_usize()) .chain(std::iter::once(self.program_counter)) .collect() } diff --git a/tooling/debugger/src/context.rs b/tooling/debugger/src/context.rs index 95dbd6ba460..f1f7afcf841 100644 --- a/tooling/debugger/src/context.rs +++ b/tooling/debugger/src/context.rs @@ -79,17 +79,20 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { } pub(super) fn get_call_stack(&self) -> Vec { - let ip = self.acvm.instruction_pointer(); - if ip >= self.get_opcodes().len() { + let instruction_pointer = self.acvm.instruction_pointer(); + if instruction_pointer >= self.get_opcodes().len() { vec![] } else if let Some(ref solver) = self.brillig_solver { solver .get_call_stack() .iter() - .map(|pc| OpcodeLocation::Brillig { acir_index: ip, brillig_index: *pc }) + .map(|program_counter| OpcodeLocation::Brillig { + acir_index: instruction_pointer, + brillig_index: *program_counter, + }) .collect() } else { - vec![OpcodeLocation::Acir(ip)] + vec![OpcodeLocation::Acir(instruction_pointer)] } } diff --git a/tooling/debugger/src/dap.rs b/tooling/debugger/src/dap.rs index 17ff81c52f0..57bb36d7875 100644 --- a/tooling/debugger/src/dap.rs +++ b/tooling/debugger/src/dap.rs @@ -257,8 +257,6 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { ..StackFrame::default() } }) - .collect::>() - .into_iter() .rev() .collect() } diff --git a/tooling/debugger/src/repl.rs b/tooling/debugger/src/repl.rs index 772bf25a66b..f7e4f40346d 100644 --- a/tooling/debugger/src/repl.rs +++ b/tooling/debugger/src/repl.rs @@ -86,8 +86,11 @@ impl<'a, B: BlackBoxFunctionSolver> ReplDebugger<'a, B> { fn show_stack_frame(&self, index: usize, location: &OpcodeLocation) { let opcodes = self.context.get_opcodes(); match location { - OpcodeLocation::Acir(ip) => { - println!("Frame #{index}, opcode {}: {}", ip, opcodes[*ip]) + OpcodeLocation::Acir(instruction_pointer) => { + println!( + "Frame #{index}, opcode {}: {}", + instruction_pointer, opcodes[*instruction_pointer] + ) } OpcodeLocation::Brillig { acir_index, brillig_index } => { let Opcode::Brillig(ref brillig) = opcodes[*acir_index] else { From a049c0d17bbd4c3c96210a82a2740e03ba8942f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 8 Feb 2024 16:17:36 -0500 Subject: [PATCH 5/5] fix: Remove Brillig registers display in DAP mode --- tooling/debugger/src/dap.rs | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/tooling/debugger/src/dap.rs b/tooling/debugger/src/dap.rs index c90032d6289..dd9a30d50da 100644 --- a/tooling/debugger/src/dap.rs +++ b/tooling/debugger/src/dap.rs @@ -4,7 +4,6 @@ use std::str::FromStr; use acvm::acir::circuit::{Circuit, OpcodeLocation}; use acvm::acir::native_types::WitnessMap; -use acvm::brillig_vm::Registers; use acvm::BlackBoxFunctionSolver; use codespan_reporting::files::{Files, SimpleFile}; @@ -45,7 +44,6 @@ pub struct DapSession<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> { enum ScopeReferences { Locals = 1, WitnessMap = 2, - BrilligRegisters = 3, InvalidScope = 0, } @@ -54,7 +52,6 @@ impl From for ScopeReferences { match value { 1 => Self::Locals, 2 => Self::WitnessMap, - 3 => Self::BrilligRegisters, _ => Self::InvalidScope, } } @@ -595,11 +592,6 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { variables_reference: ScopeReferences::WitnessMap as i64, ..Scope::default() }, - Scope { - name: String::from("Brillig Registers"), - variables_reference: ScopeReferences::BrilligRegisters as i64, - ..Scope::default() - }, ], })))?; Ok(()) @@ -633,21 +625,6 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { .collect() } - fn build_brillig_registers(&self) -> Vec { - self.context - .get_brillig_registers() - .unwrap_or(&Registers { inner: vec![] }) - .inner - .iter() - .enumerate() - .map(|(index, value)| Variable { - name: format!("R{index}"), - value: format!("{value:?}"), - ..Variable::default() - }) - .collect() - } - fn handle_variables(&mut self, req: Request) -> Result<(), ServerError> { let Command::Variables(ref args) = req.command else { unreachable!("handle_variables called on a different request"); @@ -656,7 +633,6 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> { let variables: Vec<_> = match scope { ScopeReferences::Locals => self.build_local_variables(), ScopeReferences::WitnessMap => self.build_witness_map(), - ScopeReferences::BrilligRegisters => self.build_brillig_registers(), _ => { eprintln!( "handle_variables with an unknown variables_reference {}",