请考虑以下结构:
/* Complex Structure */
typedef struct
{
char_t s4_1 [15];
int_t s4_2;
} struct4_st;
typedef struct
{
char_t s3_1 [15];
int_t s3_2;
} struct3_st;
typedef struct
{
struct3_st s2_1;
struct4_st s2_2;
} struct2_st;
typedef struct
{
int_t s1_1;
char_t s1_2;
struct2_st s1_3;
} struct1_st;
struct sample
{
int_t sample1;
int_t sample2;
char_t sample3[20];
struct1_st sample4;
} test;
如果我在包含该结构的函数上放置一个断点,我可以以 pretty-print 格式打印该结构的参数。
我的要求是:
我想使用 GDB 输出来编写代码来填充这些结构。
是否有任何高级命令可以将每个结构成员放在单独的行上,例如:
gdb$ <command> test
所需输出:
test.sample1=1
test.sample2=2;
test.sample3="hello"
test.sample4.s1_1=3
test.sample4.s1_2='t'
谢谢。
最佳答案
gdb 中没有内置命令可以执行此操作。
如果您的 gdb 支持 Python,那么您自己编写它并不太难。
关于c - 使用 GDB 打印复杂结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17968549/