GDB pretty-print
set print pretty on
GDB 打印数组索引
set print array-indexes on
例子
#include <stdio.h>
#include <stdlib.h>
typedef struct{
int a;
char*str;
int b;
}t1_t;
typedef struct{
int a;
int b;
char*str1;
int c;
int arr1[10];
int d;
char str2[10];
t1_t t;
int arr2[10];
}type_t;
int main(int argc,char *argv[])
{
type_t var = {1,2,"string1",3,
{2,3,4,5,6,7,8,9,0,1},9,
"string2",
{4,"string3",6},
{1,3,4,5,6,9,2,6,8,9}};
return 0;
}
GDB启动脚本.gdbinit
把上述2条命名 vi ~/.gdbinit写入,则gdb启动时自动生效