Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

See values in dec or hex in the debugger #28025

Closed
staffann opened this issue Jun 5, 2017 · 25 comments
Closed

See values in dec or hex in the debugger #28025

staffann opened this issue Jun 5, 2017 · 25 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality

Comments

@staffann
Copy link

staffann commented Jun 5, 2017

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:

  1. Start debugging
  2. Add a watched variable or two.
  3. Set a breakpoint and run
  4. 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).
@kieferrm kieferrm added the debug Debug viewlet, configurations, breakpoints, adapter issues label Jun 5, 2017
@weinand weinand added the feature-request Request for new features or functionality label Jun 5, 2017
@isidorn isidorn added this to the Backlog milestone Jun 6, 2017
@Numinel
Copy link

Numinel commented 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
Copy link
Contributor

weinand commented 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.

@weinand weinand closed this as completed Jun 13, 2017
@weinand weinand reopened this Jun 13, 2017
@Numinel
Copy link

Numinel commented 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
Copy link
Contributor

weinand commented 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
Copy link

I think it would be crazy to have to implement this over and over in every debugger!

@weinand
Copy link
Contributor

weinand commented 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.

@weinand
Copy link
Contributor

weinand commented Aug 7, 2017

I keep this issue open because I see a need for a customisable debugger frontend UI for changing the format of values/variables.

This UI could be similar to the "exception" configuration options in the breakpoints view. The backend (Debug Adapter) could provide a set of labels (and IDs) which are shown in the debugger UI without interpretation (e.g. as a context menu action on a variable). The IDs are passed back to the Debug Adapter and determine how values are formatted.

@fordp2002
Copy link

Thanks for looking at this again. VS Code is great because it does less rather than more and leaves a lot to plug-ins. I think this is a case VS Code to step up and implement this feature. The simple way CS Code works made me expect to have a prefix or post-fix to the variable name to implement this.

@weinand
Copy link
Contributor

weinand commented Aug 7, 2017

Just to be clear: my proposal from above does not suggest to let VS Code do the formatting (because it can not). It just proposes to make it easy for debug adapters to get their formatting implementation behind some VS Code provided UI.

@fordp2002
Copy link

fordp2002 commented Aug 7, 2017

I have no idea how vs code works behind the scenes and as long as we get a uniform way to format the contents of variables the detail is not critical. I have never seen an IDE that is as flexible as I would like. I would like to be able to select on a per variable basis one or more display formats.

So I could have my_byte and it shows "255 0xFF"

@akaroml
Copy link
Member

akaroml commented Aug 9, 2017

Hi @weinand ,

By checking the vscode debug protocol, I found this:

	export interface ValueFormat {
		/** Display the value in hex. */
		hex?: boolean;
	}

This comes with a VariablesRequest. So the debug client can actually tell the adapter to show values in hex format. We are trying to respond to this option. But I cannot find the UI entry to turn that on. Is this still work in progress or can you share more background on this?

@weinand
Copy link
Contributor

weinand commented Aug 9, 2017

Yes, these format options are not yet surfaced in VS Code (but they probably are in VS).

That's the reason for my comment from above:

I keep this issue open because I see a need for a customisable debugger frontend UI for changing the format of values/variables.

@akaroml
Copy link
Member

akaroml commented Aug 9, 2017

Thank you for the info. Then we are in the right direction. Inside the adapter, we support formatting options such as showing integers in hex format.

@ankol
Copy link

ankol commented 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
Copy link

lix2ng commented 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
Copy link

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.

image

@felixcollins
Copy link

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
Copy link

i need this feature, pls dev it

@dgmelski
Copy link

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
Copy link
Contributor

any update?

@Trass3r
Copy link

Trass3r commented Aug 26, 2020

another work around.... cast to void* eg "(void*)myinteger"

Nice trick. Works because of gdb's natural format: https://sourceware.org/gdb/current/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html#The-_002dvar_002dset_002dformat-Command

This worked for me using gdb and open ocd for esp32. "myinteger,x" did not work.

That's a https://github.com/microsoft/vscode-cpptools specific feature inspired by VS.

@weinand
Copy link
Contributor

weinand commented Nov 5, 2020

Since VS Code 1.50 we have added functionality that enables debug extensions to implement data formats for variables:

@weinand weinand closed this as completed Nov 5, 2020
@weinand weinand removed this from the Backlog milestone Nov 5, 2020
@AlexanderNarbekov
Copy link

* 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?

@weinand
Copy link
Contributor

weinand commented Nov 16, 2020

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

@AlexanderNarbekov
Copy link

@weinand Thank you for your reply

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

17 participants