GDB/C++ - 如何在回溯时隐藏常量静态字段?

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

我正在使用 gdb 调试 C++ 代码。有些东西在摇晃,所以我点击“backtrace full”进行检查。不幸的是,一些成员变量是包含 const static 字段的 class 的实例。有很多 const static 字段。此外,这些 const static 字段本身就是上述 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);
   ...
   }

(我的真实代码是字体格式 class,带有粗体、斜体、黑色、红色等预设)

结果是 gdb 感觉需要吐出所述 class 的每个成员的每个 const static 字段(以及每个成员的每个成员,等等)。这会导致许多屏幕显示相同的 const static 字段:

gdb 文字墙:

 mItems = std::vector of length 0, capacity 0, activeFormat = {
            _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 255 '7', g = 255 '7', b = 255 '7', 
            a = 255 '7', format = 0 '[=12=]0', flags = 0 '[=12=]0', padding = "[=12=]0", static FORMAT_NONE = 0 '[=12=]0', 
            static FORMAT_BOLD = 1 '[=12=]1', static FORMAT_ITALIC = 2 '[=12=]2', static FORMAT_UNDERLINE = 4 '[=12=]4', 
            static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', 
            static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', static bold = {
              _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 255 '7', g = 255 '7', b = 255 '7', 
              a = 255 '7', format = 1 '[=12=]1', flags = 0 '[=12=]0', padding = "[=12=]0", static FORMAT_NONE = 0 '[=12=]0', 
              static FORMAT_BOLD = 1 '[=12=]1', static FORMAT_ITALIC = 2 '[=12=]2', static FORMAT_UNDERLINE = 4 '[=12=]4', 
              static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', 
              static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', static bold = <same as static member of an already seen type>, static italic = {
                _vptr.sttfont_format = 0x555555590898 <vtable for sttfont_format+16>, r = 255 '7', g = 255 '7', b = 255 '7', 
                a = 255 '7', format = 2 '[=12=]2', flags = 0 '[=12=]0', padding = "[=12=]0", static FORMAT_NONE = 0 '[=12=]0', 
                static FORMAT_BOLD = 1 '[=12=]1', static FORMAT_ITALIC = 2 '[=12=]2', static FORMAT_UNDERLINE = 4 '[=12=]4', 
                static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', 
                static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', 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 '7', g = 255 '7', b = 255 '7', 
                  a = 255 '7', format = 4 '[=12=]4', flags = 0 '[=12=]0', padding = "[=12=]0", static FORMAT_NONE = 0 '[=12=]0', 
                  static FORMAT_BOLD = 1 '[=12=]1', static FORMAT_ITALIC = 2 '[=12=]2', static FORMAT_UNDERLINE = 4 '[=12=]4', 
                  static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', 
                  static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', 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 '7', g = 255 '7', b = 255 '7', 
                    a = 255 '7', format = 8 '\b', flags = 0 '[=12=]0', padding = "[=12=]0", static FORMAT_NONE = 0 '[=12=]0', 
                    static FORMAT_BOLD = 1 '[=12=]1', static FORMAT_ITALIC = 2 '[=12=]2', static FORMAT_UNDERLINE = 4 '[=12=]4', 
                    static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', 
                    static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', 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 '7', g = 0 '[=12=]0', b = 0 '[=12=]0', 
                      a = 255 '7', format = 0 '[=12=]0', flags = 1 '[=12=]1', padding = "[=12=]0", static FORMAT_NONE = 0 '[=12=]0', 
                      static FORMAT_BOLD = 1 '[=12=]1', static FORMAT_ITALIC = 2 '[=12=]2', static FORMAT_UNDERLINE = 4 '[=12=]4', 
                      static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', 
                      static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', 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 '[=12=]0', g = 255 '7', b = 0 '[=12=]0', 
                        a = 255 '7', format = 0 '[=12=]0', flags = 1 '[=12=]1', padding = "[=12=]0", static FORMAT_NONE = 0 '[=12=]0', 
                        static FORMAT_BOLD = 1 '[=12=]1', static FORMAT_ITALIC = 2 '[=12=]2', static FORMAT_UNDERLINE = 4 '[=12=]4', 
                        static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', 
                        static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', 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 '[=12=]0', g = 0 '[=12=]0', 
                          b = 255 '7', a = 255 '7', format = 0 '[=12=]0', flags = 1 '[=12=]1', padding = "[=12=]0", 
                          static FORMAT_NONE = 0 '[=12=]0', static FORMAT_BOLD = 1 '[=12=]1', static FORMAT_ITALIC = 2 '[=12=]2', 
                          static FORMAT_UNDERLINE = 4 '[=12=]4', static FORMAT_STRIKETHROUGH = 8 '\b', 
                          static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', 
                          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 '7', g = 255 '7', 
                            b = 0 '[=12=]0', a = 255 '7', format = 0 '[=12=]0', flags = 1 '[=12=]1', padding = "[=12=]0", 
                            static FORMAT_NONE = 0 '[=12=]0', static FORMAT_BOLD = 1 '[=12=]1', static FORMAT_ITALIC = 2 '[=12=]2', 
                            static FORMAT_UNDERLINE = 4 '[=12=]4', static FORMAT_STRIKETHROUGH = 8 '\b', 
                            static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', 
                            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 '[=12=]0', g = 0 '[=12=]0', b = 0 '[=12=]0', a = 255 '7', format = 0 '[=12=]0', flags = 1 '[=12=]1', padding = "[=12=]0", static FORMAT_NONE = 0 '[=12=]0', static FORMAT_BOLD = 1 '[=12=]1', 
                              static FORMAT_ITALIC = 2 '[=12=]2', static FORMAT_UNDERLINE = 4 '[=12=]4', static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', 
                              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 '7', g = 255 '7', b = 255 '7', a = 255 '7', format = 0 '[=12=]0', flags = 1 '[=12=]1', padding = "[=12=]0", static FORMAT_NONE = 0 '[=12=]0', 
                                static FORMAT_BOLD = 1 '[=12=]1', static FORMAT_ITALIC = 2 '[=12=]2', static FORMAT_UNDERLINE = 4 '[=12=]4', static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', 
                                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 '7', g = 0 '[=12=]0', b = 255 '7', a = 255 '7', format = 0 '[=12=]0', 
                                  flags = 1 '[=12=]1', padding = "[=12=]0", static FORMAT_NONE = 0 '[=12=]0', static FORMAT_BOLD = 1 '[=12=]1', static FORMAT_ITALIC = 2 '[=12=]2', static FORMAT_UNDERLINE = 4 '[=12=]4', static FORMAT_STRIKETHROUGH = 8 '\b', 
                                  static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', 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 '[=12=]0', g = 255 '7', b = 255 '7', a = 255 '7', format = 0 '[=12=]0', flags = 1 '[=12=]1', padding = "[=12=]0", static FORMAT_NONE = 0 '[=12=]0', 
                                    static FORMAT_BOLD = 1 '[=12=]1', static FORMAT_ITALIC = 2 '[=12=]2', static FORMAT_UNDERLINE = 4 '[=12=]4', static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', 
                                    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 '0', g = 128 '0', b = 128 '0', a = 255 '7', format = 0 '[=12=]0', flags = 1 '[=12=]1', padding = "[=12=]0", static FORMAT_NONE = 0 '[=12=]0', 
                                      static FORMAT_BOLD = 1 '[=12=]1', static FORMAT_ITALIC = 2 '[=12=]2', static FORMAT_UNDERLINE = 4 '[=12=]4', static FORMAT_STRIKETHROUGH = 8 '\b', static FORMAT_RENDER_EVEN_IF_CALLBACK_EXISTS = 128 '0', static FORMAT_FLAGS_COLOUR_SET = 1 '[=12=]1', 
                                      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>}}

我的问题很简单:如何从 gdb 的 backtrace full 命令中抑制 const static 字段? 或者甚至只删除所有静态字段。干杯!

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

(gdb) set print static off