I need to add a watch in hexadecimal format in CLion.
ltoa(variable, 16) doesn't work, at least, on my system.
In Java/Python, I can have a workaround: write a custom toString()/__str__ for my class and have it displayed the way I need. gdb has p/x. How do I do it in CLion?
Edit: ltoa(variable, 16) works if I define ltoa in my code, as it's not always present in standard library.
...after refining the formulation, I see it.
I wrote my own
char *lltoa(long long value, int radix)function. I can use it in watches now.Update: in the respective feature request, Chris White found a workaround on OS X with lldb:
This makes ALL the variables of this type display in hex.
Update 2: My first workaround is pretty dirty, here's a better one.
You can assign formats to more specific types. The debugger keeps track of type inheritance. So, adding a
hexformat touint8_twill not affectunsigned char. You can fine-tune the displays.You can assign formats to structs also. Here's an example from my
.lldbinit: