我使用了两个不同版本的 GDB,都在以下代码中出现问题:
删减代码MyFile.h
:
template<class T>
struct ABC: PQR<T> {
void flow(PP pp) {
const QX qx = XYZ<Z>::foo(pp); // Trying to set a breakpoint here, line no. 2533
ASSERTp(qx >= last_qx());
}
}
GDB 7.1:
Reading symbols from /path_to_exec/exec...done.
(gdb) break MyFile.h:2533
Note: breakpoint 1 also set at pc 0x121.
Note: breakpoint 1 also set at pc 0x121.
Note: breakpoint 1 also set at pc 0x121.
Note: breakpoint 1 also set at pc 0x156.
Note: breakpoint 1 also set at pc 0x156.
Note: breakpoint 1 also set at pc 0x121.
Note: breakpoint 1 also set at pc 0x121.
Note: breakpoint 1 also set at pc 0x121.
Note: breakpoint 1 also set at pc 0x121.
Note: breakpoint 1 also set at pc 0x121.
Note: breakpoint 1 also set at pc 0x121.
Note: breakpoint 1 also set at pc 0x156.
Note: breakpoint 1 also set at pc 0x156.
Note: breakpoint 1 also set at pc 0x121.
Breakpoint 1 at 0x44e5c4: file PacketEngine.h, line 2533. (23 locations)
(gdb) run
Starting program: /path_to_exec/exec -options
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x121: Input/output error.
Cannot insert breakpoint 1.
Error accessing memory address 0x156: Input/output error.
为什么要为一个设置23个断点?再往下,它给出了错误run
GDB 6.3:
This GDB was configured as "x86_64-redhat-linux-gnu"...Using host libthread_db library "/lib64/tls/libthread_db.so.1".
(gdb) break MyFile.h:2533
No line 2533 in file "MyFile.h".
在程序开始时,它甚至不接受断点如果我中断函数 ASSERTp,它就会中断。然后。如果我转到“UP”并输入break,它会成功插入断点(break MyFile.h:2533
)。 [因此它在程序实际运行后以某种方式找到文件/行]。However,尽管设置了断点,但重新运行程序时,它不会在第 2533 行停止,而仅在第 2534 行停止(函数 ASSERTp 中的断点)。
我的问题:
1)有人可以帮我解决这个问题吗?
2) 我经常遇到模板代码和GDB 的问题。有没有好的、免费的 C++ 模板调试器?
3) 并不是很重要,但如果重要的话还有一个附带问题:哪个版本更好? 7.1 似乎有更多错误,但我记得在某些运行中,它出现的问题较少。
系统信息:
uname -a
Linux ... 2.6.9-67.ELsmp #1 SMP Fri Nov 16 12:49:06 EST 2007 x86_64 x86_64 x86_64 GNU/Linux
file /usr/bin/gdb #### GDB 6.3
/usr/bin/gdb: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), stripped
file ~/local/bin/gdb #### GDB 7.1
/home/user/local/bin/gdb: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), not stripped
file /path_to_exec/exec
/path_to_exec/exec: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), not stripped