Skip to content

See values in dec or hex in the debugger #28025

Closed

Description

@staffann

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

Activity

  1. Numinel commented on Jun 13, 2017

    @Numinel

    I really want to view hex values too. Seems like a small thing to add to the otherwise very good VSCode.

  2. weinand commented on Jun 13, 2017

    @weinand
    Contributor

    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.

  3. Numinel commented on Jun 13, 2017

    @Numinel

    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.

  4. weinand commented on Jun 13, 2017

    @weinand
    Contributor

    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.

  5. fordp2002 commented on Aug 7, 2017

    @fordp2002

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

  6. weinand commented on Aug 7, 2017

    @weinand
    Contributor

    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.

  7. 10 remaining items

  8. ankol commented on Jan 19, 2018

    @ankol

    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.

  9. lix2ng commented on Aug 10, 2018

    @lix2ng

    Even a global setting for hex display in the (mouse hovering) object inspector is very helpful.
    Think someone doing buffer manipulations in JS.

  10. hoffmael commented on Aug 17, 2018

    @hoffmael

    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

  11. felixcollins commented on May 1, 2019

    @felixcollins

    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.

  12. digitalall commented on Sep 6, 2019

    @digitalall

    i need this feature, pls dev it

  13. dgmelski commented on Sep 12, 2019

    @dgmelski

    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.

  14. heartacker commented on Aug 13, 2020

    @heartacker
    Contributor

    any update?

  15. Trass3r commented on Aug 26, 2020

    @Trass3r

    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.

  16. weinand commented on Nov 5, 2020

    @weinand
    Contributor

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

  17. removed this from the Backlog milestone on Nov 5, 2020
  18. AlexanderNarbekov commented on Nov 16, 2020

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

  19. weinand commented on Nov 16, 2020

    @weinand
    Contributor

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

  20. AlexanderNarbekov commented on Nov 16, 2020

    @AlexanderNarbekov

    Andre Weinand (@weinand) Thank you for your reply

  21. locked and limited conversation to collaborators on Dec 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

debugDebug viewlet, configurations, breakpoints, adapter issuesfeature-requestRequest for new features or functionality

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions