views:

97

answers:

2

Is there a way in Visual Studio, either through it's native features or a plugin, to show an integer/long/char variable in the debugger window as a bit array? For example, rather than seeing 5 or 0x5 I'd like to see 101. As a bonus feature I'd like to see them left-padded with the correct amount of zeroes, so that the total width of the field is equal to the actual amount of bits the type is.

(I know I can convert with calc.exe but that's a pain when debugging bit manipulations).

+2  A: 

Here complete list of format specifiers but no bits there. http://msdn.microsoft.com/en-us/library/75w45ekt(VS.80).aspx

By the way, it is simple to convert hex (x format) or octal (o format) in mind. Just place before eyes simple table of octal or hex symbols. After the day you'll on fly convert 5A->1011010

Dewfy
ACtually I find it easier to use hex; it's a lot easier to find bit 7 in 0xA6D0 than in 1010011011010000.
MSalters
Dewfy
It's not hard to convert one value, but the few times a year I need to do it, I find it rather cumbersome to think of the correct and fastest series of bit operations on a value to come to a certain result. Therefore I write the start and end situations down and think of the steps to take from there. Also I find for example bit shifting a lot easier in binary as in hex. Maybe I'm just missing some tricks to do so?
Roel
A: 

If you're using managed C++ you can write a simple Visualizer just like the built-in ones for char* (to see the string as html, xml or the raw string).

Too bad it's not supported for native (I guess it's for security reasons)

Francis Boivin
Actually it's possible to write debugger visualizers for unmanaged types also (I wrote some for a few boost classes) but (although I haven't tried) that would, as far as I can tell, *replace* the currently displayed value. Also I don't know if, for unmanaged code visualizers, one can write them for build-in types. I can try. Thanks.
Roel