python - GDB command for indexing the members of a structure -
i have structure several members , see them indexed in order.
struct ant { int type; char name[100]; long long int food; }
now, when execute command in gdb
(gdb) ptype struct ant $1 = struct { int type; char name[100]; long long int food; }
i see output like
{ 0, int type; 1, char name[100]; 2, long long int food; }
is there way index of each structure field in order in gdb ?
there no built-in way this. if need can write in couple of ways.
one way use gdb cli: use set logging
, friends dump ptype
output file, use shell
run other command on file format way like.
another way use gdb's python scripting capability inspect type , display how like. if search pahole
command (maybe on system, try locate pahole.py
-- linux distros ship this) can see example of how done.
Comments
Post a Comment