Sometimes it is useful to format value in other way (radix, length) than default. While debugging with WinGDB
you can specify the format of value displayed in Watch-Window.
At the moment WinGDB does support formatting of integer values only, although in the future we intend to support
also float and memory specifiers.
To get properly formatted value use appropriate format specifiers.
Formatter | Description |
! | Raw |
b | Binary |
d | Decimal signed |
i | Decimal signed |
u | Decimal unsigned |
o | Octal |
x | Hexadecimal lower-case |
X | Hexadecimal upper-case |
You can also force length of formatted value.
Length specifier | Description |
c | Character |
b | Byte |
h | Short |
l | Long |
ll | Long long |
Adding formatted values to watch window is easy. Just insert a correct expression, number or variable, then coma and format specifier.
Sample:
llx-3
means:
ll - Long long length specifier
x - Hexadecimal lower-case format specifier
-3 - group from left to right, 3 characters in group
Sample:
hx2
means:
h - Short length specifier
x - Hexadecimal lower-case format specifier
2 - group from right to left, 2 characters in group
You don't have to remember all those specifiers. For comfortable adding of new formatted watches use Add watch command. It is available in main menu:
or by just right-clicking in context-menu of watch window:
Following dialog will appear
You can easily choose format specifier (field Format), length (field Length) and the way value will
be grouped (fields Group and Group Size). Field Formatter is read-only and changes dynamically
as you modify above fields.
As value (field Expression / Number / Variable) you can set any string which is correct from GDB point of view.
If you are not sure, whether formatter is correct, then use button Test. If value is formatted in expected way
then use "Add Watch" button.
To clear test values use button Clear.