mian.c
tom@ubuntu:~/dvp$ cat -n main.c
1 #include <stdio.h>
2
3 typedef struct
4 {
5 int iW;
6 int iH;
7 int iX;
8 int iY;
9 }BOX_ST;
10
11 int main()
12 {
13 BOX_ST stBox;
14
15 stBox.iW = 1;
16 stBox.iH = 2;
17 stBox.iX = 3;
18 stBox.iY = 4;
19
20 return 0;
21 }
tom@ubuntu:~/dvp$
gdb脚本(使用arg0 arg1,.....)
使用arg0 arg1 arg2, ....等可变参数来代表输入的任意名称的数据结构对象
tom@ubuntu:~/dvp$ cat -n gdbcmd_printBOX_ST.txt
1 define print_stBox
2 print $arg0
3 end
tom@ubuntu:~/dvp$
使用gdb脚本
(gdb) file ./a.out
Reading symbols from ./a.out...done.
(gdb) list main
7 int iX;
8 int iY;
9 }BOX_ST;
10
11 int main()
12 {
13 BOX_ST stBox;
14
15 stBox.iW = 1;
16 stBox.iH = 2;
(gdb) l
17 stBox.iX = 3;
18