1

次の構造を考慮してください。

/* 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'

ありがとう。

4

1 に答える 1

2

これを行うための組み込みコマンドは gdb にありません。

gdb が Python 対応であれば、自分で作成するのはそれほど難しくありません。

于 2013-07-31T13:16:15.023 に答える