c++gdb

GDB/C++ - How to hide const static fields when backtracing?


I'm debugging c++ code with gdb. Something is throwing a wobbly, so I hit "backtrace full" to inspect. Unfortunately some of the member variables are instances of class that contain const static fields. There are a lot of const static fields. In addition, these const static fields are themselves instances of said class:

class foo {
public:
   int val;
   foo(int _val) : val(_val) {}

   static const foo FOO_5 = foo(5);
   static const foo FOO_6 = foo(6);
   static const foo FOO_7 = foo(7);
   ...
   }

(My real code is a font formatting class with presets for bold, italic, black, red, etc)

The result is gdb feeling the need to spit out every const static field of every member of said class (and every member of each memeber, etc). This results in many screens full of the same const static fields being displayed:

Wall of gdb text:

 mItems = std::vector of length 0, capacity 0, activeFormat = {
            _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 255 '\377', g = 255 '\377', b = 255 '\377', 
            a = 255 '\377', format = 0 '\000', flags = 0 '\000', padding = "\000", static FORMAT_NONE = 0 '\000', 
            static FORMAT_BOLD = 1 '\001', static FORMAT_ITALIC = 2 '\002', static FORMAT_UNDERLINE = 4 '\004', 
            static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', 
            static FORMAT_FLAGS_COLOUR_SET = 1 '\001', static bold = {
              _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 255 '\377', g = 255 '\377', b = 255 '\377', 
              a = 255 '\377', format = 1 '\001', flags = 0 '\000', padding = "\000", static FORMAT_NONE = 0 '\000', 
              static FORMAT_BOLD = 1 '\001', static FORMAT_ITALIC = 2 '\002', static FORMAT_UNDERLINE = 4 '\004', 
              static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', 
              static FORMAT_FLAGS_COLOUR_SET = 1 '\001', static bold = <same as static member of an already seen type>, static italic = {
                _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 255 '\377', g = 255 '\377', b = 255 '\377', 
                a = 255 '\377', format = 2 '\002', flags = 0 '\000', padding = "\000", static FORMAT_NONE = 0 '\000', 
                static FORMAT_BOLD = 1 '\001', static FORMAT_ITALIC = 2 '\002', static FORMAT_UNDERLINE = 4 '\004', 
                static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', 
                static FORMAT_FLAGS_COLOUR_SET = 1 '\001', static bold = <same as static member of an already seen type>, 
                static italic = <same as static member of an already seen type>, static underline = {
                  _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 255 '\377', g = 255 '\377', b = 255 '\377', 
                  a = 255 '\377', format = 4 '\004', flags = 0 '\000', padding = "\000", static FORMAT_NONE = 0 '\000', 
                  static FORMAT_BOLD = 1 '\001', static FORMAT_ITALIC = 2 '\002', static FORMAT_UNDERLINE = 4 '\004', 
                  static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', 
                  static FORMAT_FLAGS_COLOUR_SET = 1 '\001', static bold = <same as static member of an already seen type>, 
                  static italic = <same as static member of an already seen type>, 
                  static underline = <same as static member of an already seen type>, static strikethrough = {
                    _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 255 '\377', g = 255 '\377', b = 255 '\377', 
                    a = 255 '\377', format = 8 '\b', flags = 0 '\000', padding = "\000", static FORMAT_NONE = 0 '\000', 
                    static FORMAT_BOLD = 1 '\001', static FORMAT_ITALIC = 2 '\002', static FORMAT_UNDERLINE = 4 '\004', 
                    static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', 
                    static FORMAT_FLAGS_COLOUR_SET = 1 '\001', static bold = <same as static member of an already seen type>, 
                    static italic = <same as static member of an already seen type>, 
                    static underline = <same as static member of an already seen type>, 
                    static strikethrough = <same as static member of an already seen type>, static red = {
                      _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 255 '\377', g = 0 '\000', b = 0 '\000', 
                      a = 255 '\377', format = 0 '\000', flags = 1 '\001', padding = "\000", static FORMAT_NONE = 0 '\000', 
                      static FORMAT_BOLD = 1 '\001', static FORMAT_ITALIC = 2 '\002', static FORMAT_UNDERLINE = 4 '\004', 
                      static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', 
                      static FORMAT_FLAGS_COLOUR_SET = 1 '\001', static bold = <same as static member of an already seen type>, 
                      static italic = <same as static member of an already seen type>, 
                      static underline = <same as static member of an already seen type>, 
                      static strikethrough = <same as static member of an already seen type>, 
                      static red = <same as static member of an already seen type>, static green = {
                        _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 0 '\000', g = 255 '\377', b = 0 '\000', 
                        a = 255 '\377', format = 0 '\000', flags = 1 '\001', padding = "\000", static FORMAT_NONE = 0 '\000', 
                        static FORMAT_BOLD = 1 '\001', static FORMAT_ITALIC = 2 '\002', static FORMAT_UNDERLINE = 4 '\004', 
                        static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', 
                        static FORMAT_FLAGS_COLOUR_SET = 1 '\001', static bold = <same as static member of an already seen type>, 
                        static italic = <same as static member of an already seen type>, 
                        static underline = <same as static member of an already seen type>, 
                        static strikethrough = <same as static member of an already seen type>, 
                        static red = <same as static member of an already seen type>, 
                        static green = <same as static member of an already seen type>, static blue = {
                          _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 0 '\000', g = 0 '\000', 
                          b = 255 '\377', a = 255 '\377', format = 0 '\000', flags = 1 '\001', padding = "\000", 
                          static FORMAT_NONE = 0 '\000', static FORMAT_BOLD = 1 '\001', static FORMAT_ITALIC = 2 '\002', 
                          static FORMAT_UNDERLINE = 4 '\004', static FORMAT_STRIKETHROUGH = 8 '\b', 
                          static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', static FORMAT_FLAGS_COLOUR_SET = 1 '\001', 
                          static bold = <same as static member of an already seen type>, 
                          static italic = <same as static member of an already seen type>, 
                          static underline = <same as static member of an already seen type>, 
                          static strikethrough = <same as static member of an already seen type>, 
                          static red = <same as static member of an already seen type>, 
                          static green = <same as static member of an already seen type>, 
                          static blue = <same as static member of an already seen type>, static yellow = {
                            _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 255 '\377', g = 255 '\377', 
                            b = 0 '\000', a = 255 '\377', format = 0 '\000', flags = 1 '\001', padding = "\000", 
                            static FORMAT_NONE = 0 '\000', static FORMAT_BOLD = 1 '\001', static FORMAT_ITALIC = 2 '\002', 
                            static FORMAT_UNDERLINE = 4 '\004', static FORMAT_STRIKETHROUGH = 8 '\b', 
                            static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', static FORMAT_FLAGS_COLOUR_SET = 1 '\001', 
                            static bold = <same as static member of an already seen type>, 
                            static italic = <same as static member of an already seen type>, 
                            static underline = <same as static member of an already seen type>, 
                            static strikethrough = <same as static member of an already seen type>, 
                            static red = <same as static member of an already seen type>, 
--Type <RET> for more, q to quit, c to continue without paging--
                            y seen type>, static blue = <same as static member of an already seen type>, static yellow = <same as static member of an already seen type>, static black = {
                              _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 0 '\000', g = 0 '\000', b = 0 '\000', a = 255 '\377', format = 0 '\000', flags = 1 '\001', padding = "\000", static FORMAT_NONE = 0 '\000', static FORMAT_BOLD = 1 '\001', 
                              static FORMAT_ITALIC = 2 '\002', static FORMAT_UNDERLINE = 4 '\004', static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', static FORMAT_FLAGS_COLOUR_SET = 1 '\001', 
                              static bold = <same as static member of an already seen type>, static italic = <same as static member of an already seen type>, static underline = <same as static member of an already seen type>, 
                              static strikethrough = <same as static member of an already seen type>, static red = <same as static member of an already seen type>, static green = <same as static member of an already seen type>, 
                              static blue = <same as static member of an already seen type>, static yellow = <same as static member of an already seen type>, static black = <same as static member of an already seen type>, static white = {
                                _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 255 '\377', g = 255 '\377', b = 255 '\377', a = 255 '\377', format = 0 '\000', flags = 1 '\001', padding = "\000", static FORMAT_NONE = 0 '\000', 
                                static FORMAT_BOLD = 1 '\001', static FORMAT_ITALIC = 2 '\002', static FORMAT_UNDERLINE = 4 '\004', static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', static FORMAT_FLAGS_COLOUR_SET = 1 '\001', 
                                static bold = <same as static member of an already seen type>, static italic = <same as static member of an already seen type>, static underline = <same as static member of an already seen type>, 
                                static strikethrough = <same as static member of an already seen type>, static red = <same as static member of an already seen type>, static green = <same as static member of an already seen type>, 
                                static blue = <same as static member of an already seen type>, static yellow = <same as static member of an already seen type>, static black = <same as static member of an already seen type>, 
                                static white = <same as static member of an already seen type>, static magenta = {_vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 255 '\377', g = 0 '\000', b = 255 '\377', a = 255 '\377', format = 0 '\000', 
                                  flags = 1 '\001', padding = "\000", static FORMAT_NONE = 0 '\000', static FORMAT_BOLD = 1 '\001', static FORMAT_ITALIC = 2 '\002', static FORMAT_UNDERLINE = 4 '\004', static FORMAT_STRIKETHROUGH = 8 '\b', 
                                  static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', static FORMAT_FLAGS_COLOUR_SET = 1 '\001', static bold = <same as static member of an already seen type>, static italic = <same as static member of an already seen type>, 
                                  static underline = <same as static member of an already seen type>, static strikethrough = <same as static member of an already seen type>, static red = <same as static member of an already seen type>, 
                                  static green = <same as static member of an already seen type>, static blue = <same as static member of an already seen type>, static yellow = <same as static member of an already seen type>, 
                                  static black = <same as static member of an already seen type>, static white = <same as static member of an already seen type>, static magenta = <same as static member of an already seen type>, static cyan = {
                                    _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 0 '\000', g = 255 '\377', b = 255 '\377', a = 255 '\377', format = 0 '\000', flags = 1 '\001', padding = "\000", static FORMAT_NONE = 0 '\000', 
                                    static FORMAT_BOLD = 1 '\001', static FORMAT_ITALIC = 2 '\002', static FORMAT_UNDERLINE = 4 '\004', static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', static FORMAT_FLAGS_COLOUR_SET = 1 '\001', 
                                    static bold = <same as static member of an already seen type>, static italic = <same as static member of an already seen type>, static underline = <same as static member of an already seen type>, 
                                    static strikethrough = <same as static member of an already seen type>, static red = <same as static member of an already seen type>, static green = <same as static member of an already seen type>, 
                                    static blue = <same as static member of an already seen type>, static yellow = <same as static member of an already seen type>, static black = <same as static member of an already seen type>, 
                                    static white = <same as static member of an already seen type>, static magenta = <same as static member of an already seen type>, static cyan = <same as static member of an already seen type>, static grey = {
                                      _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 128 '\200', g = 128 '\200', b = 128 '\200', a = 255 '\377', format = 0 '\000', flags = 1 '\001', padding = "\000", static FORMAT_NONE = 0 '\000', 
                                      static FORMAT_BOLD = 1 '\001', static FORMAT_ITALIC = 2 '\002', static FORMAT_UNDERLINE = 4 '\004', static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '\200', static FORMAT_FLAGS_COLOUR_SET = 1 '\001', 
                                      static bold = <same as static member of an already seen type>, static italic = <same as static member of an already seen type>, static underline = <same as static member of an already seen type>, 
                                      static strikethrough = <same as static member of an already seen type>, static red = <same as static member of an already seen type>, static green = <same as static member of an already seen type>, 
                                      static blue = <same as static member of an already seen type>, static yellow = <same as static member of an already seen type>, static black = <same as static member of an already seen type>, 
                                      static white = <same as static member of an already seen type>, static magenta = <same as static member of an already seen type>, static cyan = <same as static member of an already seen type>, 
                                      static grey = <same as static member of an already seen type>, static reset = {<No data fields>}}, static reset = <same as static member of an already seen type>}, static grey = <same as static member of an already seen type>, 
                                  static reset = <same as static member of an already seen type>}, static cyan = <same as static member of an already seen type>, static grey = <same as static member of an already seen type>, 
                                static reset = <same as static member of an already seen type>}, static magenta = <same as static member of an already seen type>, static cyan = <same as static member of an already seen type>, 
                              static grey = <same as static member of an already seen type>, static reset = <same as static member of an already seen type>}, static white = <same as static member of an already seen type>, 
                            static magenta = <same as static member of an already seen type>, static cyan = <same as static member of an already seen type>, static grey = <same as static member of an already seen type>, 
                            static reset = <same as static member of an already seen type>}, static black = <same as static member of an already seen type>, static white = <same as static member of an already seen type>, 
                          static magenta = <same as static member of an already seen type>, static cyan = <same as static member of an already seen type>, static grey = <same as static member of an already seen type>, 
                          static reset = <same as static member of an already seen type>}, static yellow = <same as static member of an already seen type>, static black = <same as static member of an already seen type>, 
                        static white = <same as static member of an already seen type>, static magenta = <same as static member of an already seen type>, static cyan = <same as static member of an already seen type>, static grey = <same as static member of an already seen type>, 
                        static reset = <same as static member of an already seen type>}, static blue = <same as static member of an already seen type>, static yellow = <same as static member of an already seen type>, static black = <same as static member of an already seen type>, 
                      static white = <same as static member of an already seen type>, static magenta = <same as static member of an already seen type>, static cyan = <same as static member of an already seen type>, static grey = <same as static member of an already seen type>, 
                      static reset = <same as static member of an already seen type>}, static green = <same as static member of an already seen type>, static blue = <same as static member of an already seen type>, static yellow = <same as static member of an already seen type>, 
                    static black = <same as static member of an already seen type>, static white = <same as static member of an already seen type>, static magenta = <same as static member of an already seen type>, static cyan = <same as static member of an already seen type>, 
                    static grey = <same as static member of an already seen type>, static reset = <same as static member of an already seen type>}, static red = <same as static member of an already seen type>, static green = <same as static member of an already seen type>, 
                  static blue = <same as static member of an already seen type>, static yellow = <same as static member of an already seen type>, static black = <same as static member of an already seen type>, static white = <same as static member of an already seen type>, 
                  static magenta = <same as static member of an already seen type>, static cyan = <same as static member of an already seen type>, static grey = <same as static member of an already seen type>, static reset = <same as static member of an already seen type>}, 
                static strikethrough = <same as static member of an already seen type>, static red = <same as static member of an already seen type>, static green = <same as static member of an already seen type>, static blue = <same as static member of an already seen type>, 
                static yellow = <same as static member of an already seen type>, static black = <same as static member of an already seen type>, static white = <same as static member of an already seen type>, static magenta = <same as static member of an already seen type>, 
                static cyan = <same as static member of an already seen type>, static grey = <same as static member of an already seen type>, static reset = <same as static member of an already seen type>}, static underline = <same as static member of an already seen type>, 
              static strikethrough = <same as static member of an already seen type>, static red = <same as static member of an already seen type>, static green = <same as static member of an already seen type>, static blue = <same as static member of an already seen type>, 
              static yellow = <same as static member of an already seen type>, static black = <same as static member of an already seen type>, static white = <same as static member of an already seen type>, static magenta = <same as static member of an already seen type>, 
              static cyan = <same as static member of an already seen type>, static grey = <same as static member of an already seen type>, static reset = <same as static member of an already seen type>}, static italic = <same as static member of an already seen type>, 
            static underline = <same as static member of an already seen type>, static strikethrough = <same as static member of an already seen type>, static red = <same as static member of an already seen type>, static green = <same as static member of an already seen type>, 
            static blue = <same as static member of an already seen type>, static yellow = <same as static member of an already seen type>, static black = <same as static member of an already seen type>, static white = <same as static member of an already seen type>, 
            static magenta = <same as static member of an already seen type>, static cyan = <same as static member of an already seen type>, static grey = <same as static member of an already seen type>, static reset = <same as static member of an already seen type>}}

My question is simple: How do I suppress const static fields from gdb's backtrace full command? Or even just remove all static fields. Cheers!


Solution

  • How do I suppress const static fields from gdb's backtrace full command?

    (gdb) set print static off