Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cider Dap - Variables displaying #2357

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

Cider Dap - Variables displaying #2357

wants to merge 23 commits into from

Conversation

smd21
Copy link
Contributor

@smd21 smd21 commented Nov 19, 2024

bad branch name (oops)
This branch adds the following functionality to the VSCode Cider debugger:

  1. Displaying accurate port values
  2. Continue requests now behave according to the spec by informing VSCode why the debugger was stopped
  3. Cells (scopes) displayed now only shows the cells for the current component, rather then every cell in the environment
  4. Small json tweaks (name, publisher, etc)

Copy link
Collaborator

@EclecticGriffin EclecticGriffin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very exciting! Left some notes, on a bunch of things. Please request a re-review when you're ready

Comment on lines +154 to +155

//let thread2 = &adapter.create_thread(String::from("Thread 1"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete if we don't need

Comment on lines +164 to +167
// server.send_event(Event::Thread(ThreadEventBody {
// reason: types::ThreadEventReason::Started,
// thread_id: thread2.id,
// }))?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete if we don't need

@@ -354,7 +351,7 @@ fn run_server<R: Read, W: Write>(
let rsp = req.success(ResponseBody::Scopes(ScopesResponse {
scopes: adapter.get_scopes(frame_id),
}));
info!(logger, "responded with {rsp:?}");
//info!(logger, "responded with {rsp:?}");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete or uncomment

@@ -77,6 +86,7 @@ pub struct Debugger<C: AsRef<Context> + Clone> {
program_context: C,
debugging_context: DebuggingContext,
_source_map: Option<SourceMap>,
is_running: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a comment for how this field is used with respect to the debugger

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell it isn't actually used anywhere?

@@ -175,6 +198,28 @@ impl<C: AsRef<Context> + Clone> Debugger<C> {
.collect_vec();
self.manipulate_breakpoint(Command::Delete(parsed_bp_ids));
}

pub fn cont(&mut self) -> StoppedReason {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you point out this should really return a result type. If you don't want to
handle that at least unwrap the error from self.do_continue rather than
dropping it on the floor

// component idx -> global cell idx
self.interpreter.env().iter_cmpt_cells(cmp_idx)
}
pub fn get_components(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some documentation here and with the above method

self.stack_frames.clone()
}

pub fn clone_stack(&self) -> Vec<StackFrame> {
/// creates call stack where each frame is a component
fn create_stack(&mut self) -> Vec<StackFrame> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing as the only place you call this drops the return, I think this method
doesn't actually need to return anything

Comment on lines +152 to +153
let frames = components.map(|(idx, comp)| {
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I love a good iterator, I think this would be more clear as a for loop
which directly pushes the frame onto stack_frames rather than relying on the
iterator being consumed by extends

indexed_variables: None,
memory_reference: None,
.map(|(nam, val)| {
let valu = match val.as_option() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than a match you should be able to do something like
val.as_option().map(|x| x.val().to_u64().unwrap()).unwrap_or_default()

let mut out_vec = vec![];
let cell_names = self.debugger.get_cells();
let component = self.frames_to_cmpts.get(&frame).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going to use get(...).unwrap() might as well use direct indexing

Suggested change
let component = self.frames_to_cmpts.get(&frame).unwrap();
let component = self.frames_to_cmpts[&frame];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants