- 论坛徽章:
- 0
|
附件 http://sourceware.org/ml/gdb/2007-08/msg00094/gdb-6.6-record-0.0.1.patch.bz2 是一个给GDB-6.6的PATCH,其将加入2个新命令(“record”和“reverse”)以及一个新的target “record”到GDB-6.6中。
命令record可以记录程序的运行信息比如PC寄存器值和一些FRAME信息,这些信息记录的默认文件名为“now.rec”。
target “record”可以打开记录文件读出这些记录信息来模拟对运行文件的调试。如果当前GDB target 是 “record”,你还可以使用“reverse”命令来设置GDB为反向执行调试模式,在这个模式下程序将反向执行。并且各种GDB命令比如next,step,breakpoint都可以使用。
而且record功能也许可以帮助对实时程序的调试。比如在调试实时程序的时候可以在不能打断的位置进行记录,然后运行结束后调试运行信息。
现在record功能还很不完善,在以后我将加入寄存器信息记录功能,内存改变记录功能以及设置记录代码段的功能。
希望大家能多提宝贵意见,多谢了。
编译和安装GDB record target 0.0.1 with GDB-6.6:
tar vxjf gdb-6.6.tar.bz2
bunzip2 gdb-6.6-record-0.0.1.patch.bz2
patch -p0 < gdb-6.6-record-0.0.1.patch
mkdir bgdb
cd bgdb
../gdb-6.6/configure
make
make install
使用GDB record功能:
cat 1.c
void
cool ()
{
printf ("123");
}
int
main(int argc,char *argv[],char *envp[])
{
int a = 0;
printf ("1\n");
cool ();
a = 1;
a += 2;
return (0);
}
gcc -g 1.c
./gdb a.out
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/tls/libthread_db.so.1".
Setting up the environment for debugging gdb.
Function "internal_error" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
Function "info_command" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
/home/qwang/rec/bgdb/gdb/.gdbinit:8: Error in sourced command file:
No breakpoint number 0.
(gdb) b main
Breakpoint 1 at 0x804836c: file 1.c, line 9.
(gdb) r
Starting program: /home/qwang/rec/bgdb/gdb/a.out
Breakpoint 1, main (argc=
During symbol reading, incomplete CFI data; unspecified registers (e.g., eax) at 0x804837b.
1, argv=0xbfffdae4, envp=0xbfffdaec) at 1.c:9
9 int a = 0;
(gdb) rec
Record the paogram running message to the file "now.rec".
1
During symbol reading, incomplete CFI data; DW_CFA_restore unspecified
register ebx (#3) at 0x0075df5f.
123
Program exited normally.
(gdb) quit
./gdb a.out
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/tls/libthread_db.so.1".
Setting up the environment for debugging gdb.
Function "internal_error" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
Function "info_command" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
/home/qwang/rec/bgdb/gdb/.gdbinit:8: Error in sourced command file:
No breakpoint number 0.
(gdb) target rec
Record the paogram running message to the file "now.rec".
main (argc=Cannot access memory at address 0x8
) at 1.c:9
9 int a = 0;
(gdb) n
11 printf ("1\n");
(gdb)
13 cool ();
(gdb)
15 a = 1;
(gdb) c
Continuing.
0x00738b09 in ?? ()
(gdb) rev
GDB is set to reverse debug mode.
(gdb) b 16
Breakpoint 1 at 0x804838f: file 1.c, line 16.
(gdb) c
Continuing.
Breakpoint 1, main (argc=Cannot access memory at address 0x8
) at 1.c:16
16 a += 2;
(gdb) n
15 a = 1;
(gdb) n
13 cool ();
(gdb) rev
GDB is set to normal debug mode.
(gdb) s
cool () at 1.c:4
4 printf ("123");
(gdb) n
5 }
(gdb)
main (argc=Cannot access memory at address 0x8
) at 1.c:15
15 a = 1;
(gdb) rev
GDB is set to reverse debug mode.
(gdb) s
cool () at 1.c:4
4 printf ("123");
(gdb) s
0x08048347 3 {
(gdb)
main (argc=Cannot access memory at address 0x8
) at 1.c:13
13 cool ();
(gdb) quit
The program is running. Exit anyway? (y or n) y |
|