4

My DDD data display window is overcrowded because every object is listed with its static data members as well as its instance data members.

Is there an option to hide these?

EDIT: Even better, can I take an array slice and display, for each element, only x y and z members?

spraff
  • 32,570
  • 22
  • 121
  • 229

1 Answers1

0

You might write a pretty printer for your code.

Example:

namespace Test {
    struct Filter {
        static unsigned a;
        static unsigned b;
        static unsigned c;
        // ,,,
        unsigned x;
        unsigned y;
        unsigned z;

        Filter()
        : x(1), y(2), z(3)
        {}
    };

    unsigned Filter::a;
    unsigned Filter::b;
    unsigned Filter::c;
}

int main() {
    Test::Filter value;
    return 0;
}

With this pretty printer

@printers.register_pretty_printer
class TestFilter:
    "Pretty Printer for Test::Filter"
    regex = re.compile('^Test::Filter$')

    @printers.static
    def supports(typename):
        return TestFilter.regex.search(typename)

    def __init__(self, typename, value):
        self.typename = typename
        self.value = value

    def to_string(self):
        x = self.value['x']
        y = self.value['y']
        z = self.value['z']
        return '(Test::Filter) x=%d, y=%d, z=%d' % (x, y, z)

Having the return on line 27 and running gdb -q Test -ex 'b 27' -ex 'r' -ex 'p value' -ex 'c' -ex 'q' will give:

$1 = (Test::Filter) x=1, y=2, z=3

For further instructions have a look at pretty printing boost::mpl::string<...> types in gdb

Community
  • 1
  • 1