-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add a way to fetch values for getters for an object through the VM Service(/DDS?) #46723
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
Comments
Fyi @annagrin |
Having https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#function surface whether a Function is a getter or not SGTM. I think DDC is able to internally disambiguate methods from getters because it needs to bind "this" when calling "load" on a Function but not on a getter. |
@annagrin I believe we could collect all the getters from the symbols data generated by DDC when we have it working but at the moment we don't have any markers for getters/setters/methods. They all just appear as functions. |
It looks like we have a couple of possible solutions: (1) Simple approach (keeping the code @DanTup posted in the issue, and making it more reliable)
Note that debug symbols work in ddc and dwds is currently in progress. (2) Improvement for efficiency As far as understand, currently all UIs are displaying instances in various places (watch window, variables, expression evaluation window, hover over) using the following logic: (@DanTup please correct me if I am wrong)
We could use a similar approach for properties: have a way to request properties on an instance, and push the implementation of this to dwds instead of the UI. For example, dwds could evaluate each property, or collect them into a map for evaluation, or maybe skip the evaluation altogether if it knows what JS code corresponds to dart code for the property. Note that on the web the evaluation of properties is potentially slower than @bkonyi does (1) or (2) seem reasonable from the vm service API (or DDS API) perspective? Approach (2) or any API that lets the UI get the properties in smallest number of API calls is preferable. From dwds/ddc side, both need debug symbols to implement properly (but @jacob314 has an idea for a workaround). Symbols work is currently in progress: |
Yep, that sounds right - although calling |
@DanTup thanks for confirmation! I added the implementation in dwds part of this issue to my 'object inspection' project. |
Adding some form of field to |
Thinking about this some more, would it be feasible to just use |
That's basically what we're doing today, and as long as the VM doesn't mind is sending lots of parallel requests for them, that's probably fine. The real issue is getting the list of getters to do that. We have to walk up the class hierarchy to get the getter from each level (and use So I guess the important part of the request is getting the list of getters for an instance efficiently (and without using private fields). |
@DanTup is this still something you're interested in? Are we encountering any performance issues with the current implementation? |
We have moved over to I haven't seen/had reports of performance issues (nor have I done any timing), although I suspect most people wouldn't raise issues if expanding objects is just a little slow. Whether this is the place to focus attention if we want to improve debugging performance though, I'm not sure - I suspect there are other things that would show up slower than this. |
Thanks for the feedback. I'm going to drop this to P3 then since it's not something that needs immediate attention. |
In VS Code's debug adapter and the new SDK DAP implementation, there is a setting that allows showing values of getters in debug tooltips/watch window/etc.. This works by walking up the class hierarchy getting all of the names of any getters at each level and then sending evaluate requests for each.
This code seems fragile and involves looking at an internal field to identify the getters (
f.json?['_kind'] == 'GetterFunction'
). It would be better to have a more official way to do this (and perhaps in a single request).sdk/pkg/dds/lib/src/dap/protocol_converter.dart
Lines 444 to 475 in 248e943
@bkonyi (I think @jacob314 may also have been interested in this?)
The text was updated successfully, but these errors were encountered: