You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to select in which format I see the values of local and watched variables in the debugger. It would be preferred to have a generic setting but be able to change it per variable.
The way that it is now I often need to use a exteral dec-to-hex converter and copy the values from VS Code. Being able to see them in hex directly in the debugger would be a great help!
I mostly debug C/C++ programs but I imagine that this is generic for all languages.
VSCode Version: 1.12.2
OS Version: Linux Ubuntu 16.04 LTS
Steps to Reproduce:
Start debugging
Add a watched variable or two.
Set a breakpoint and run
When stopping at the breakpoint, take a look at the values of the watched and local variables. They are all given in decimal values (except pointers that are hex).
I suggest to raise this request against the debugger extension you are using since the format of values id provided by the extension. VS Code does not have generic support for value formats.
I use gdb as debugger and there are commands for gdb to view variables as hex but how do I set-up VSCode to use those commands?
I guess this is not the place to ask such questions though.
As a said in my previous comment: VS Code does not have generic support for value formatting (e.g. to view variables in hex). This functionality must come from the debug extension that you are using.
The debugger frontend knows nothing about data types like integers, floats, or doubles. It only shows strings and leaves the formatting of these strings to the backend.
We've made this "crazy" design decision to keep the Debug Adapter Protocol simple.
I am not sure if it works previously in VS Code, but in VS Code version 1.19.1 and in VS, you can use postfixes in Watch window to show numbers in hex format, for example:
Variable,h - show value of Variable in hex
Variable,o - show value as base 8 number
Unfortunately I didn't find any option to show numbers as hex in Variables window.
Reacted by George Sapkin, Dave Herron, Anita Govindarajan, Vasyl Vavrychuk, Travis LaGrone, Loris Degioanni, Angela Hilfe!, talpachen, Mitchell Berry, Venkatraman Srikanth and 17 more
I took a guess and tried to add a watch with the formVariable,x and it showed the values in hex as expected! This is on VS-insiders 1.27.0 and using the gdb debugger.
Reacted by Serge Chernetsov, Brent Wilson, zoltan.ban, Daniel Sanz Ausin, Dan Bechard, Pedro Díaz, Kimitake, JM, qvoid, Sina and 15 more
Reacted by Mitch Talmadge, youssef-smarto, Suyash Mahar and ashish agrawal
Reacted by Mitch Talmadge, youssef-smarto, Felipe M. da Silva, Robert Curtin and ashish agrawal
A debugger front-end that works "only with strings" could support a feature that recognizes which strings can be parsed as decimal numbers and optionally prints a hexadecimal representation next to or instead of the decimal string. A front-end does not need to be told types or anything by a back-end to recognize and convert common formats.
* context menu items can be contributed to the Variables view. See https://code.visualstudio.com/updates/v1_49#_contributable-context-menu-for-variables-view
Hello!
Is this feature availaible out of the box? Or should i configure it?
Activity
Numinel commentedon Jun 13, 2017
I really want to view hex values too. Seems like a small thing to add to the otherwise very good VSCode.
weinand commentedon Jun 13, 2017
I suggest to raise this request against the debugger extension you are using since the format of values id provided by the extension. VS Code does not have generic support for value formats.
Numinel commentedon Jun 13, 2017
I use gdb as debugger and there are commands for gdb to view variables as hex but how do I set-up VSCode to use those commands?
I guess this is not the place to ask such questions though.
weinand commentedon Jun 13, 2017
As a said in my previous comment: VS Code does not have generic support for value formatting (e.g. to view variables in hex). This functionality must come from the debug extension that you are using.
fordp2002 commentedon Aug 7, 2017
I think it would be crazy to have to implement this over and over in every debugger!
weinand commentedon Aug 7, 2017
The debugger frontend knows nothing about data types like integers, floats, or doubles. It only shows strings and leaves the formatting of these strings to the backend.
We've made this "crazy" design decision to keep the Debug Adapter Protocol simple.
10 remaining items
ankol commentedon Jan 19, 2018
I am not sure if it works previously in VS Code, but in VS Code version 1.19.1 and in VS, you can use postfixes in Watch window to show numbers in hex format, for example:
Variable,h - show value of Variable in hex
Variable,o - show value as base 8 number
Unfortunately I didn't find any option to show numbers as hex in Variables window.
lix2ng commentedon Aug 10, 2018
Even a global setting for hex display in the (mouse hovering) object inspector is very helpful.
Think someone doing buffer manipulations in JS.
hoffmael commentedon Aug 17, 2018
I took a guess and tried to add a watch with the form
Variable,xand it showed the values in hex as expected! This is on VS-insiders 1.27.0 and using the gdb debugger.felixcollins commentedon May 1, 2019
another work around.... cast to void* eg "(void*)myinteger"
This worked for me using gdb and open ocd for esp32. "myinteger,x" did not work.
digitalall commentedon Sep 6, 2019
i need this feature, pls dev it
dgmelski commentedon Sep 12, 2019
A debugger front-end that works "only with strings" could support a feature that recognizes which strings can be parsed as decimal numbers and optionally prints a hexadecimal representation next to or instead of the decimal string. A front-end does not need to be told types or anything by a back-end to recognize and convert common formats.
heartacker commentedon Aug 13, 2020
any update?
Trass3r commentedon Aug 26, 2020
Nice trick. Works because of gdb's
naturalformat: https://sourceware.org/gdb/current/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html#The-_002dvar_002dset_002dformat-CommandThat's a https://github.com/microsoft/vscode-cpptools specific feature inspired by VS.
weinand commentedon Nov 5, 2020
Since VS Code 1.50 we have added functionality that enables debug extensions to implement data formats for variables:
AlexanderNarbekov commentedon Nov 16, 2020
Hello!
Is this feature availaible out of the box? Or should i configure it?
weinand commentedon Nov 16, 2020
@yaNePonedelnik Debug extensions must support this. I suggest to file feature requests against the debug extensions you are using.
AlexanderNarbekov commentedon Nov 16, 2020
Andre Weinand (@weinand) Thank you for your reply