Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 370
user1762934 Avatar asked Mar 07 '17 10:03

user1762934


People also ask

How do I show variables in debug mode?

Hover over a variable to see its value. When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.

How do I see the hex file in Visual Studio Code?

Open the file/image/whatever you want to display in hex mode in Visual Studio Code, then press Ctrl + Shift + Alt + H . That's it. Or press Ctrl + P then input Show hexdump from path to open a file in hex mode directly.

How can I see debug logs in VS code?

You can find other debug logs you've downloaded with Visual Studio Code in the . sfdx/tools/debug/logs folder. Right-click any line in the debug log, then choose SFDX: Launch Apex Replay Debugger with Current File.


3 Answers

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:

Suffixes used in VSCode's Watch pane

like image 152
Ashley Miller Avatar answered Oct 17 '22 15:10

Ashley Miller


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.

like image 11
Greg Terrell Avatar answered Oct 17 '22 15:10

Greg Terrell


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:

Watch window with .toString

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.

like image 9
some Avatar answered Oct 17 '22 14:10

some