vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Format variables output when debugging

Open josesimoes opened this issue 9 years ago • 12 comments

It would be nice to be able to choose the format of the variables when in debug. Right now the output seems to be fixed as decimal. Sometimes is convenient to see the value in hexa or binary. (this is applicable for both the variables list output and for the "mouse over" display)

josesimoes avatar Oct 31 '16 16:10 josesimoes

Are you debugging with the windows debugger, gdb, or lldb? If it is the windows debugger, you can use a format specifier to change the format. For example, to see the value in binary, use "value,b" in the watch window. For lldb and gdb, this is currently only supported in the debug console with -exec.

jacdavis avatar Oct 31 '16 16:10 jacdavis

@jacdavis I'm using gdb. Could you please add this as a suggestion for future enhancement?

josesimoes avatar Oct 31 '16 16:10 josesimoes

It turns out, gdb has a few format specifiers of its own. They are 'h', (or 'x') for hex and 'o' for octal.

jacdavis avatar Oct 31 '16 16:10 jacdavis

Got you. Question: isn't easier to 'just' format the output (according to the user preference) when actually outputting to the screen rather then having to go and config gdb to output the variable with this or that format?

josesimoes avatar Oct 31 '16 16:10 josesimoes

Any update on this? Can you guys move it to the higher priority list?

nilanjan avatar May 17 '17 14:05 nilanjan

I filed a suggestion with vscode but was told that it was something that was related to the extension. This issue seems to cover my request, but I enclose my original text:

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).

staffann avatar Jun 13 '17 17:06 staffann

Is there any timeline for this feature implementation in GUI local var display?

nilanjan avatar Jun 30 '17 14:06 nilanjan

"watch" variables binary representation would be very useful

aenima1891 avatar Oct 01 '19 08:10 aenima1891

In professional tools when I right click on watch item I can set formats:

image

or Image

So that would be nice. I believe this issue has enough upvotes.

mrx23dot avatar Jul 09 '24 08:07 mrx23dot

Looking at this comment:

@yaNePonedelnik Debug extensions must support this. I suggest to file feature requests against the debug extensions you are using.

So it seems that the VSCode changes are already in?

leonardopsantos avatar Dec 04 '24 20:12 leonardopsantos

Is there any update on this issue? Is there a timeline to implement that feature?

To set the representation of "watch" variables is a mean feature while debugging. For this it doesn't matter if debugging a windows/linux program or embedded firmware. Without the ability to configure the representation in different numeric formats, debugging is nearly impossible. This renders VS Code unusable, and you look for other, more viable IDEs. But I don't think this is the intention...

afr-TT avatar Mar 19 '25 07:03 afr-TT

Just finished reading through a bunch of threads. Sad it's still not implemented. I'd expect majority users who use c/c++ deal with hex about 80% of the time. Just installed the Ashling RISC V extension and now unable to view hex lol. Looks like it's back to Ashling/Eclipse based ones.

pranavtriguna avatar May 21 '25 20:05 pranavtriguna

If you are using GDB for debugging, you can set the variable display format by entering -exec set output-radix 16/10/8/2 in the debugging console.

dingzhou-beck avatar Jul 03 '25 07:07 dingzhou-beck

If you are using GDB for debugging, you can set the variable display format by entering -exec set output-radix 16/10/8/2 in the debugging console.

Note though there is seems to be a bug that doing so breaks the context menu - https://github.com/microsoft/vscode-cpptools/issues/13742

studgeek avatar Aug 13 '25 19:08 studgeek

Other related bugs with many votes that show general interest in this:

  • https://github.com/microsoft/vscode-cpptools/issues/557
  • https://github.com/microsoft/vscode-cpptools/issues/7281
  • https://github.com/microsoft/vscode-cpptools/issues/6521

studgeek avatar Aug 13 '25 19:08 studgeek

In current state cppdbg seems to show an octal value after the decimal values in locals and watch. It would be very nice if we could at least change that to showing the hex value after decimal values.

studgeek avatar Aug 13 '25 19:08 studgeek