Natvis format specifiers seem to be missing some features

We have fairly complex data structures, that are difficult to visualize in a debugger. So natvis is essential and I'm super happy, that it is supported.

But some basic features, I just can't seem to get to work.

One of the major requirements (and seemingly simplest to provide), is displaying a hex-string in <DisplayString>.

I need to display at least a few bytes from the beginning of a given byte array (usually vector<byte>) as a hex string for easy identification, like:
40aef34b….
or similar.

But the Jetbrains implementation of natvis doesn't seem to honour the “no-prefix” modifier or I'm not using it correctly. The above hex-string would stubbornly display as
0x400xae0xf30x4b
which is utterly unreadable.

A simple made-up example for this behaviour would be:
        <DisplayString>
              data={((std::byte)160),xb}
        </DisplayString>

…will display 0xa0, instead of just a0.
x, xb, h, hb all seem to be equivalent.

Is there anything I can do about this?

EDIT: meanwhile I discovered, that “xb” does work, but only for pure integer values. So it seems to be a bug, as is doesn't apply to char std::byte or similar types.

A common use case for “xb” would be displaying a uuid.
I can hack myself around this for now, by pre-assembling an int from a number of bytes and then displaying that.
 

0

请先登录再写评论。