-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add "source code reference" to Variable
#372
Comments
Variable
Variable
This proposal makes sense to me. Two suggested tweaks:
|
Glad to hear that! So what is the usual process to get something added to DAP/Visual Studio Code? |
On 2nd thought: A similar mechanism might also be useful for the pretty printers of C++ std::fstream or Python file object. Sometimes those paths might also point to directories and not files (e.g., Pythons PurePath) Not sure if it makes sense to also cover those use cases with the same DAP extensions, though. What do you think? If this use case should also be covered by the same DAP extension, I think it makes sense to
|
I think there is definitely interest in this, we discussed something similar in #368. I'll add this to the March milestone and we can discuss more when @connor4312 is back. My only feedback is that I think we should be using the I'll point out that for a vscode-specific short term solution, if your debug adapter maps the description to an absolute path + line number, or adds a "fake" metadata child property pointing to the location, then link detection for the variable will work and the user can cmd+click it to go to that location. |
Hm... maybe I am misreading that other request... But my understanding from that thread is that it was closed as a duplicate of #343? And #343 was about "link the place the variable was defined" which is different from this request here, i.e. "link the place the value was defined which this variable currently refers to"...
Thank you! Please let me know if there is anything I can help with |
Oh, right. I completely missed
|
Well in #368 we were talking about the same case (the definition of a function that some variable points at) and I just wasn't drawing a distinction between the two different cases that you are talking about. You make a good point that they are not quite the same. |
@roblourens what is the usual process? I would love to be able to make some progress on this. Should I try to draft a PR including all the feedback I received in this commit so far? Do you usually expect to see reference implementations together with a Pull Request against the spec? |
Sorry for the late followup. Let's merge this into #343 |
TLDR: I would like to have a "go to source location" button in my debugger's variable view. This button would not take me to the source location where the variable was defined, but would take me to the source location associated with the variable's current value. E.g., for C/C++/Rust/Go/Javascript/Typescript... function pointers, it would take me to the place in the source code where that function is defined.
This is not a duplicate of #343. With #343 the source code location would refer to the place of the variable definition, which is different from the place where the variable points to
The problem/use case
Many languages (C, C++, Rust, Go, Python, Javascript, TypeScript, ...) have function pointers or some other type of "function references". The current debugging experience for such function pointers is acceptable but not ideal.
E.g., a C++ function pointer is currently displayed as
If I now want to go to the definition of the function which
f
points to, I need to read the source location ("at func-ptr-example.cpp:3:14") from the value's description and navigate there manually. This is cumbersome, if I am inspecting many function pointers. Furthermore, for longer function names, theat <location>
part of the description is usually hidden, because it doesn't fit into the line.Besides raw function pointers, C++ and Rust (and probably many other languages) have types which allow introspection at runtime: In C++, there is std::source_location, std::stacktrace. In Rust, there is std::backtrace. Currently, libc++
std::source_location
(see libc++ implementation) is displayed asAgain, I currently have to manually navigate to the location in that file which is cumbersome if I am inspecting many
std::source_location
s or a completestd::backtrace
.Preferred solution from a user point of view
As a user of any DAP frontend, I would like to have some "Go to source location" button/hyperlink directly next to my function pointers/
std::source_location
variables inside the variable view. As a VS Code user, I could imagine e.g. a new button similar to the existing "View Binary Data" (see screenshot). Clicking this new "Go to source code reference" button should take me directly to the correct source location in my editor.Debug adapters could then associate source code locations with function pointers or variables of any other, arbitrary type. E.g., for C++'s
std::function
, I could then extend the existing pretty printer from lldb to also expose a source code reference.Proposed change to Debug Adapter Protocol
Extend the Variable type with a new
sourceCodeReference
defined aswith
The text was updated successfully, but these errors were encountered: