c - Print Complex Structures with GDB -
please consider following structures:
/* 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;
if put break-point on function containing structure, can print parameters of structure in pretty-print format.
my requirement is:
i want use gdb output write code fill these structures.
is there advanced command gives each struct member on seperate line, like:
gdb$ <command> test
required output:
test.sample1=1 test.sample2=2; test.sample3="hello" test.sample4.s1_1=3 test.sample4.s1_2='t'
thanks.
there no built-in command in gdb that.
if gdb python-enabled, isn't hard write yourself.
Comments
Post a Comment