add commands to change gdb session radices#202
Conversation
|
Sounds useful, thanks! What does this affect exactly? I noticed it seems to affect integer-typed variables in the Variables view, anything else? (And I was a bit surprised to see that the view appeared to update automatically, without sending an Initial thoughts:
|
|
@cwalther glad you found it useful! Here is a list of answers to all of the points. The output radix is a global setting. Basically it affects all variables/expressions everywhere. That includes the variables window, the watch window, the debug console, and hovering over expressions in text files.
Final Note: I am planning to add some granularity in a future PR, in which users can choose which expression/variable would they like to be viewed in a hex formatting. I just figured to add a global setting for now, since that is the "easy" part of it |
|
Now that I try it properly, I find that it does not work. Executing the command fails with an error notification “Failed to set output radix to hex: CodeExpectedError: Evaluation of expression without frameId is not supported.” Do you maybe have local changes to cdt-gdb-adapter that I don’t have? In fact, the line
But that applies to any debugger, not just the one from this extension where we know that the adapter can deal with this evaluate request. Also, the extension may be activated for other reasons, and it stays activated even when there is no cdt-gdb debug session anymore. |
|
OK, found the problem: it is that |
|
@cwalther I tested that using a couple of boards that I have. I don't have a test setup for host GDB testing unfortunately . That is why I didn't catch the error. Maybe that could be avoided using the |
|
Also, now that I try it properly in a Edit: Wait, we are in VS Code here, not in the adapter. So maybe the refresh can be done directly, without having the adapter send an event. Haven’t checked the API docs for that. |
|
The update happens after I do a single step. In other words, yes, we have to send another request afterwards to update all windows. The problem is that there is no "dummy" request in my mind that we can use for that. The invalidated event is an event sent from the adapter to the client, so I am not sure how can we use that. Update: after doing some research, I think the only way we could do it is basically add a feature in the adapter in which it sends an |
jreineckearm
left a comment
There was a problem hiding this comment.
See some minor comments inline.
@omarArm , given this is one of multiple planned changes, we probably should open an issue here that outlines the changes on the adapter and the vscode extension. To give reviewers insights in what's to come.
Regarding open questions of the conversation above:
I thought at first to add this to the context menu of different views.
Agree with the context menu for easy access (and as discussed internally). The global switch then would be context-insensitive. Couple of views where it would make sense: Variables, Watch, Source Editor. Happy to further discuss. As Omar writes, more PRs to come.
Should there be a when condition on having an active debug session of the right type?
Agreed, let's test more how this behaves in reality. I believe the activation events are "first time activation" after loading an extension. So, connect/disconnect may leave the commands available after all connections have closed.
OK, found the problem: it is that GDBDebugSessionBase.evaluateRequestcalls doEvaluateRequest with alwaysAllowCliCommand = false, in contrast to GDBTargetDebugSession. I wonder what the reason for that was. @thorstendb-ARM (eclipse-cdt-cloud/cdt-gdb-adapter#414)?
If I remember correctly, we (@thorstendb-ARM ) made these changes at a time where we started familiarizing with the code base. And we didn't want to make massively disruptive changes. Now that we understand things a little more, I am tempted to always allow undefined as value and use the global scope as specified in DAP. That should simplify the code and hopefully make some error messages go away. Could be in a different PR though as it impacts more than just the new feature here.
Invalidate event
Need to better understand this area and what triggers events. In general, we should limit heuristics based on detected commands.
I think the provided context can make a difference? For example like in when commands are echoed to the debug console. Let's capture this in the overall feature issue to create, @omarArm , and address separately.
|
OK, I’ll get out of the way for a bit while you have the internal discussions and until I get a better impression of the further planned changes (I shouldn’t spend all day on this anyway).
Yes, something like that was what I had in mind as a worst-case solution, or maybe a custom command sent to the adapter that only causes it to send an event back. But maybe there is a simpler way of triggering the effect of an I also noticed |
|
Thanks, @cwalther , your feedback is much appreciated as always. Will certainly ask for more in a bit.
I like that idea. It would also cover other operations that change the radix in the GDB client. |
jonahgraham
left a comment
There was a problem hiding this comment.
I think the only way we could do it is basically add a feature in the adapter in which it sends an invalidated event whenever a set command is provided via an evaluate request.
Sounds like a reasonable conclusion. I am fine for that to be in another PR.
|
See one review comment. Also, should we call the commands Functionality works with known limitations for now. So, I'd be good getting this in as an increment. But needs follow-up work to make easier to use:
I hope I have all involved issues now somehow linked to #201 |
cwalther
left a comment
There was a problem hiding this comment.
As long as the commands are only in the command palette, I am OK with not making them conditional on the debugger type – when a user chooses a palette command explicitly labeled with “CDT-GDB” while using a debugger that is not CDT-GDB, it’s their own fault if they get unpredictable results.
(And that also sidesteps the question of how to best make things conditional on any debugger based on cdt-gdb-adapter, not just those with type: gdb and type: gdbtarget, such as mine.)
This PR essentially solves the issue #203
Added two commands to change gdb session radix from decimal to hex and vice versa. The commands are available in the command palette under the names:
CDT: Set Output Radix to HexCDT: Set Output Radix to Decimal