Table of Contents

Value formatters

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.

Format specifiers

To get properly formatted value use appropriate format specifiers.

FormatterDescription
!Raw
bBinary
dDecimal signed
iDecimal signed
uDecimal unsigned
oOctal
xHexadecimal lower-case
XHexadecimal upper-case

Length specifiers

You can also force length of formatted value.

Length specifierDescription
cCharacter
bByte
hShort
lLong
llLong long

Grouping

In some cases long values are easier to read when divided into groups. Therefore WinGDB does implement grouping of debugged values. You can specify how many characters should have each group and from which side value should be divided.

In specifier groups are represented as positive number (if grouping should be performed from right to left) or as negative number (if grouping should be performed from left to right).

Adding formatted values

Adding formatted values to watch window is easy. Just insert a correct expression, number or variable, then coma and format specifier.

{expression | number | variable} , {formatter}


How to properly build formatter:
  • Optional length specifier
  • Optional format specifier
  • Optional grouping specification
  • Add watch command

    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

    Add watch dialog

    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:

    Add watch command

    or by just right-clicking in context-menu of watch window:

    Add watch command

    Following dialog will appear

    Add watch command

    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.

    Table of Contents


    Copyright (C) 2008-2019 SOFT-ERG. All rights reserved.