'VSCode display hex values for variables in debug mode
Is VSCode able to display hex values for local variables in debug mode ? I have been searching for a way to make this happen but with no success.
Solution 1:[1]
I know this is an old thread, but it was at the top of my Google search so I thought I'd add some new information, which I found in the issues thread linked by Burt_Harris.
You can't seem to change the formatting of values displayed in the Locals pane or in tooltips, but you can force the formatting on variables in the Watch pane by appending ,x to the variable name.
Other formats exist, such as ,b for binary, ,o for octal. I believe it's based on the GDB display modifiers uses (e.g. display/x myVariable)
Suffixes used in VSCode's Watch pane:

Solution 2:[2]
It has been a while since last activity on this, but I found by looking through links from this thread on the Cortex-Debug github (Issues) a solution for me. From the (GDB) Debug Console use -exec set output-radix 16 for hex, set it to 10 for decimal.
Solution 3:[3]
I was looking for the same thing and ended up here, and I saw that the feature request has been denied at this time.
But then it hit me: In the watch window, you can add an expression, and Number have a toString method, where you can choose what radix (2-36) to convert the number to. And it works:
Instead of just watching value, watch value.toString(16) for hex.
I tried to add more methods to the Number prototype in my code (I wanted a grouped display), but unfortunately it is only shown as "[Object object]".
I know that this is not exactly what you where looking for, but it is something that works without any plugins.
Solution 4:[4]
You can't currently, but there are feature requests outstanding for this. According to VSCode core developers, this needs to be implemented in the specific debugger extension for the environment you are debugging.
Links to known related debugger extension feature requests listed below:
Vote your preferences by adding thumbs-up to the feature request
Solution 5:[5]
Golang
As @some said, you can add an expression in the watch. Here is the expression you would have to add to display a slice of bytes as a hex string:
call hex.EncodeToString(mySliceOfBytes)
Solution 6:[6]
This answer applies to GDB debugging.
For an active debug session, type the following in the debug console:
-exec set output-radix 16
To apply this every time the debugger runs, add text "set output-radix 16" in the "setupCommands" section of launch.json
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{ "text": "set output-radix 16" }
]
Solution 7:[7]
actually you could open debug console and using hex() function to convert values
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bernd-L |
| Solution 2 | BurnsBA |
| Solution 3 | some |
| Solution 4 | |
| Solution 5 | braincoke |
| Solution 6 | BurnsBA |
| Solution 7 | sutungpo |

