我正在使用 gdb 调试 C++ 代码。有些东西正在摇晃,所以我点击“backtrace full”进行检查。不幸的是,一些成员变量是包含const static字段的类的实例。有很多const static领域。此外,这些const static字段本身就是所述类的实例:
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);
...
}
Run Code Online (Sandbox Code Playgroud)
(我真正的代码是一个字体格式化类,带有粗体、斜体、黑色、红色等预设)
结果是 gdb 感觉需要吐出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 '\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 typ