-
Notifications
You must be signed in to change notification settings - Fork 135
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
Proposal: Support for reading registers #41
Comments
@andrewcrawley, @gregg-miskelly @pieandcakes This is great. Can I help to implement/prototype this in MIEngine? Not sure how to proceed |
I vote No ! Debug Adapter Protocol means High Level Language Debug Adapter protocol. High Level language is abstraction which allows to write code without dealing with architecture. Reading registers breaks this abstraction. Even Cuda is abstraction. I know that I can use java to program Arm. I have very little interest in where registers are in Arm, how GPU memory is addressed and which elements of CPU participate in hardware acceleration. There are better places to discuss driver debugging protocol |
@PavelSosin I totally disagree. All applications run on real hardware, and pretty much all real hardware has registers, memory and a processor. Debuggers are for real applications, not "high level languages". How does preventing viewing registers aid debugging? I think this proposal is very sensible. |
@PavelSosin Perhaps you misunderstand. This is an optional capability that only makes sense for certain Debug Adapters and only those adapters will advertise it. Clients GUIs do not even have to use it. No one else is affected. For instance, the Scripts window in VSCode is not for everyone and is not shown when debugging C/C++. Nothing to do with driver development. Some (millions) of us still have to use C/C++ but even those have little interest in seeing registers. But, when something goes wrong, or we need the absolute best performance, this is needed -- sometimes to give you those high-level abstracted languages. Rust is another language that can use it. Final note: There are millions of embedded/IoT developers who would just love VStudio/VSCode besides desktop developers. I noticed you also posted similar views in issue #42 Same deal. |
Btw, I have my own experimental extension to see registers. It is ugly and not performant. A hack really. But it works. I recently submitted a patch to MIEngine debug adapter, so somewhat familiar with the code and thus offering to help. It is still a proposal stage, we need a prototype to make sure. |
@andrewcrawley Trying to understand a bit. @gregg-miskelly his idea was that registers simply show up in the Variables window as a separate scope regardless of what part of the stack/frame you are looking at. So this proposal says simply what name a DA has decided to use/implement? If a client (UI) wants to know where registers exist and how to display them, this is the name they would look for. As of today, a DA can already add scopes/nesting (real or made-up). This proposal simply says the DA can advertise the root-name of a scope meant for 'processor' registers. Totally innocuous. |
Unfortunately, something ugly ans not aligned with other debuggers behavior can't pass through our UX. As it is known to me nobody in our Debugger team knows C++ and we have only one team responsible on Debugging features for all languages. We have only one team responsible on Editors too. They work strictly by Protocol definition. Everything has to be encapsulated in Protocol itself and client and server capabilities. Every debugger UI inherits 90% of capabilities from "abstract" debugger UI. Protocol standard should reflect abstract debugger UI communication with abstract debugging server. I don't expect that people developing Java debugging core jdt are specialists in WebUI. DAP for C++, DAP for Go and DAP for typescript are nonsense. We have only one LSP protocol which serves all languages and all editors. Language specific extensions are allowed but UI should be decoupled from server anyway. |
@PavelSosin I think you misunderstand this very modest proposal. Also, please pick a more open tone in the future. This proposal has the following impact: if you have a debug adapter, such as C++ debug adapter, where showing register values would be useful, AND if you want to plug into a debugger UI, such as Visual Studio, where there is a special window for showing registers, then this proposal is how the debug adapter and UI can communicate over which scope contains registers. This is all this does. If you own a debug adapter and you don't want to provide registers - not a problem. If you own a debugger UI and you don't want to display registers in a special way - not a problem either. |
@haneefdm this idea is a slight refinement to my original idea -- instead of showing it as a pseudo-variable, we can instead display them as a pseudo-scope. We can create the scope with the `expensive = true;`` to it will just show up in VS Code in an unobtrusive way. This proposal just lets us hookup to the registers Window in VS. |
Yes the scopes are a good choice for this IMO. Indeed, I seem to recall that one existing debug adapter that uses lldb already does exactly this. |
@gregg-miskelly Yes, I understood as that. For some reason, I thought you also said scopes or thats how I took it. Thank you for the specific line link to the schema. You all are awesome.
Did you mean the existing variables window? Looking to clarify. |
@haneefdm: VS has a "Registers" window that is separate from the "Variables" window - look at Debug -> Windows -> Registers. Here's an example: In this case, the window was populated via the following requests (I've snipped out the irrelevant messages):
You can see the extra "Registers" scope being returned in the first response. |
@andrewcrawley Thanks. Yes, I am familiar with the VS Registers window -- lived int for several months :-). That is exactly how I envisioned the scopes to show up from the adapter. May I ask the format used by these variables values? For instance, some could be FP registers, displaying as hex values is cumbersome. In the watch window I can set the format, but not elsewhere I am sure the following is not relevant to the DAP ... more of a UI/UX thing. We can create a separate window in the debug section of the sidebar in VSCode. It is getting crowded over there, so I was also thinking why not just stuff it the variables window. as a separate scope. Right now, we just have one scope called 'Locals' for C/C++. There are pros and cons to both ways. I've seen one C/C++ extension which puts 'Globals' in the variable windows. And, others have many Blocks and Closures in there as well. It is fine either way separate TreeView or add to the variables TreeView I have to think a bit more; locals get updated as you move up and down frames or switch threads. I did a hack to show registers in a separate window. You are thinking something like that? |
@haneefdm: Ah, sorry, I misunderstood what you were asking. The format of the register values is up to the adapter, since they're provided as strings. VS doesn't attempt to do any parsing, and none of the VS settings for hex vs decimal affect the output. For reference, here's the complete set of registers returned by vsdbg, which includes floats, 256-bit AVX registers, etc:
Showing the registers in the "Variables" section as a separate scope sounds fine to me. I believe this is the default behavior for scopes, so it would be the easiest option as well : ) |
Shouldn't it respect |
Thanks @andrewcrawley Since most of those windows/panels are actually created in VSCode core, we had some resistance to adding any more. It could be done in cpptools as well, where it could also take control of the formatting. Will discuss with the cpptools team for advice/ideas. But doing it in the DA makes the most sense to me ... as of yet. |
Now I gather what is the point. I hope there is no intention to build naked gdb as Debugger server core. Creation of Debugger server around https://github.com/microsoft/MIEngine makes sense. It is also usable in development for Linux. because Linux containers run in Cloud infrastructure en mass. But MIEngine based LSP server has to be implemented first! Otherwise developer will not have something to debug. Please, explain how you DAP request and response are mapped to MI, at least, roughly. Code authoring, debugging and CI should be integrated into the same Environment. |
@andrewcrawley I like this proposal because it is perfectly aligned with the original intent of scopes. Adding the word "Register" to the comment appears to be a very natural thing: The only slightly ugly issue comes with NLS: But by introducing a An alternative, cleaner approach would be to add a new optional |
Another thing I like about showing the registers as an additional scope in the Variables window is that registers values are relative to the current frame and all of the code to track/update that already exists. |
I like it too. "Registers" scope can be shown only if it exists. Are values in this scope mutable? |
@PavelSosin You mean can the user modify them. Yes, I believe so, with sometimes disastrous effects. Not sure what debuggers do if you are not at the top of the frame though. |
@weinand: The main concern I have with that approach is that it would be possible to flag more than one scope with If you want to go this route, it seems like we might as well define the other |
No need in arguments scope - arguments are always local variables. |
For me the capabilities is something that the debug adapter is capable of doing. Specifying the As for having multiple scopes of |
@andrewcrawley if it's OK with you, I will implement the IMO the issue of having multiple scopes flagged as "registers" is minor in comparison and I will address it in the attribute's documentation. As you suggested I will also add values for "arguments" and "locals". |
@weinand @andrewcrawley I must be missing something. Yes, the value of If you do the kind based approach, there are so many of those for all kinds of languages, I am not even sure how to enumerate them all. Locals/Globals/Arguments/Closures/Block/File-Static/Other. Either approach is fine but just wanted to bring it up. I am not worried of duplicates either |
@haneefdm you are correct that a client does not have to worry about the value of the However, DAP's approach to conveying "semantics" vs. "just strings" is as follows:
Introducing an additional attribute is less error prone than using the The scope "kind" is what I call an "open-ended enum". That means it is not a fixed set of all possible values but it only contains those few values that we can all agree on and we can add more values to it in the future. So for this proposal it would be sufficient to just have "registers" in the enum. |
One additional note -- we only need to add a new 'kind' value when there exists at least one client that has special handling of a particular scope type. For example, Visual Studio has a registers window so we need that one. If, in the future, some other debugger UI that wants to become a DAP client has a Globals window, we could add that kind value for that. But there is no reason to do so now since the enum can always be extended. |
Alright, sounds good to me! |
I think that Andre Weinand has real experience with application development for Arm architecture. Arm architecture is not similar to Intel architecture. Arm memory structure differs from Intel memory structure. Arm assembler is not like Intel assembler. Every high level language has own abstraction. Every programming language assumes own run-time with own low-level debugging protocol. I suppose it is not good idea to build Debugger client-server communication on Server-Client capabilities exchange. Debugger UI and Debugger Server simply know the language semantics and all language and architecture specific information could be sent via qualifiers. Function can be qualified as "function". Memory addresses can be qualified as "memory", Registers can be qualified as "register" or "register of kind". Operations - display, set, step, step-into, step-over, run, continue-to, set-breakpoint, clear-breakpoint, watch are universal. Stack and stack frame are also universal. It is strange to think how debugger can not to support them and every Server implementation must support them. validity of certain operation and qualifier combinations should be enabled or disabled by UI based on its knowledge of context and accepted or rejected by server based on its knowledge of context in run-time. UI displays values provided by server based |
@weinand I got ya, about scope kind enum stuff. Non-technical stuff below... @PavelSosin I will never ever claim to be an expert in anything. But I have some real experience with these things from bare metal (various CPUs) to high-level programming and their tools. Or else, I wouldn't be in this thread. I don't understand your characterization about what we are trying to do. I see it as a real-world need that I don't see changing anytime soon. When it does, everyone will adapt. Tools first. I hope you really look into the ecosystem these features serve, user profiles, CPUs/MCUs, IoT -- significant # of developers/products. Sorry, I can't quote numbers but just look around you and think about how those things were developed and debugged. If DAP and/or VSCode+extensions have no interest in including this class of users, then we are done. End of conversation. But, I see hope. VSCode is awesome and other tools can also leverage from this work on the DAP. |
@andrewcrawley @gregg-miskelly I've created PR #49 for the complete DAP change. |
@weinand |
The requested feature has been implemented in VisualStudio 2019: VS2019- registers window. Implementation in VSCode will be redundant. |
So your statement is: every DAP feature that is implemented in more than one client is redundant, right? |
We propose that adapters can present a set of CPU registers to the frontend by returning an additional scope in response to the
scopes
request. The name of this scope would be provided in the adapter'sCapabilities
to support frontends such as VS that show registers in a separate window. This allows adapters to localize the scope's name for display in VSCode while still allowing VS to find it:In the simplest form, the scope would contain one variable for each register, e.g.:
Additionally, VS supports categorization of registers, and allows individual categories to be shown / hidden. This could be supported via nesting, where the intermediate level variable provides the category name and contains the actual register values as children, e.g.:
CC: @gregg-miskelly
The text was updated successfully, but these errors were encountered: