7 c++ templates gdb breakpoints header-files
我使用了两个不同版本的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());
}
}
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
为什么要为一个设置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".
Run Code Online (Sandbox Code Playgroud)
在程序开始时,它甚至不接受断点
如果我在函数ASSERTp中断,它就会中断.然后.如果我进入"UP"并键入break,它会成功插入breakpoint(break MyFile.h:2533).[因此它以某种方式在程序实际运行后找到文件/行].但是,尽管设置了断点,但在重新运行程序时,它不会在第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
Run Code Online (Sandbox Code Playgroud)
我没有使用任何其他 Linux 调试器,但我从未遇到过您所解释的此类问题。
您很好地阐述了您的问题(所以您可能做到了),但是您是否使用调试符号编译了源代码?
编辑
顺便说一句,我还没有尝试过 gdb 7.1 - 只有 6.8 版本。如果你认为它有很多 bug,请尝试使用 6 版本的最后一个版本。
| 归档时间: |
|
| 查看次数: |
4059 次 |
| 最近记录: |