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

DAP: introduce Rdbg Trace Inspector #916

Closed
wants to merge 1 commit into from

Conversation

ono-max
Copy link
Member

@ono-max ono-max commented Mar 6, 2023

We'll introduce a new feature Rdbg Trace Inspector. This is useful when tracing in VS Code.

Untitled.Project.4.-.HD.1080p.mov

How to use it

  1. Click on "Start Trace" in TRACE view
  2. Execute the program

That's it! You can check the location and returned value by clicking the trace log.

How to choose events

On the default, line, call, and return events are selected.

If you want to change the default, click "more items", then choose events in the context menu.

Screen.Recording.2023-02-27.at.18.03.30.mov

@st0012
Copy link
Member

st0012 commented Mar 6, 2023

I've been wanting this feature for a while, this looks super cool 🎉
Quick question: how can we select the even type with this UI (e.g. exclude the line events)? From the video I don't see an option to do so. It'd be helpful to skip some events in large codebases. And it'd be great if we can include raise events too.
Also, is it possible to have some protocol tests for it?

@ono-max
Copy link
Member Author

ono-max commented Mar 6, 2023

how can we select the even type with this UI (e.g. exclude the line events)?

We can select the option as follows:

Screen.Recording.2023-02-27.at.18.03.30.mov

@ono-max
Copy link
Member Author

ono-max commented Mar 6, 2023

Also, is it possible to have some protocol tests for it?

Yeah, I think that we can add tests.

@@ -148,6 +148,78 @@ def skip_with_pattern?(tp)
end
end

class MultiTracer < Tracer
MAX_LENGTH = 4000
Copy link
Collaborator

Choose a reason for hiding this comment

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

LENGTH -> RECORDS

Copy link
Collaborator

Choose a reason for hiding this comment

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

or LOGS if you u se @log

@@ -148,6 +148,78 @@ def skip_with_pattern?(tp)
end
end

class MultiTracer < Tracer
Copy link
Collaborator

Choose a reason for hiding this comment

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

# Now it is only for DAP

@tracer = TracePoint.new(*@evts){|tp|
next if skip?(tp)

call_identifier_str =
Copy link
Collaborator

Choose a reason for hiding this comment

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

cut off to the method

when 'return'
evts << :return
evts << :c_return
evts << :b_return
Copy link
Collaborator

Choose a reason for hiding this comment

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

else
raise "unknown trace type #{evt}"

when 'enable'
events = req.dig('arguments', 'events')
evts = []
events.each{|evt|
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another idea:

EVENTS = {'line' => [:line], ...}

def ...
  evts = []
  events.each{|evt| evts.concat EVENTS[evt]}
  ...

or

  evts = events.flat_map{|evt| EVENTS[evt]}

But the current code makes sense because it is easy to read.

end
}
@ui.respond req, {}
when 'logs'
Copy link
Collaborator

@ko1 ko1 Mar 7, 2023

Choose a reason for hiding this comment

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

other subcommands are verbs so I recommend to use collect (a verb word)

@ono-max ono-max force-pushed the trace-inspector branch 2 times, most recently from d198e27 to 6d9078d Compare March 8, 2023 15:54
@ono-max ono-max requested a review from ko1 March 8, 2023 16:51
@st0012
Copy link
Member

st0012 commented Mar 9, 2023

Yeah, I think that we can add tests.

@ono-max Thanks. Could we first have some tests in the same PR?

@ono-max
Copy link
Member Author

ono-max commented Mar 11, 2023

I'll try it, but I'm not sure if I can add tests in the same PR because I'm busy right now. There is a possibility they are added in the other PR. Sorry.

@ono-max ono-max force-pushed the trace-inspector branch 4 times, most recently from af8d49f to 35bab9d Compare March 27, 2023 06:54
@ono-max ono-max closed this May 5, 2023
@ono-max ono-max deleted the trace-inspector branch May 5, 2023 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants