我一直在尝试使用命令
gdb tclsh
运行 GDP 来调试 Tcl C 扩展 - 但 GDB 的 MSYS2 版本表示 Support for debuginfod is not compiled into GDB.
并输出 Reading symbols from tclsh.exe... (No debugging symbols found in tclsh.exe)
所以它不起作用。
我正在尝试复制 this GitHub 评论中的详细信息 - 但我是在 Windows 而不是 Linux 上进行的,我在 MSYS2 或 Windows 的 debuginfod 上找不到任何内容,网上看不到任何内容.
有什么方法可以为我的 GDB 版本获取它,以便它可以像我链接的评论中那样工作吗?
如果您想查看的话,这是控制台输出:
GNU gdb (GDB) 15.1
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from tclsh.exe...
(No debugging symbols found in tclsh.exe)
[New Thread 23524.0x78e4]
[New Thread 23524.0x5a50]
[New Thread 23524.0x3394]
[New Thread 23524.0x4cd4]
[Thread 23524.0x4cd4 exited with code 0]
[Thread 23524.0x3394 exited with code 0]
[Thread 23524.0x5a50 exited with code 0]
[Thread 23524.0x78e4 exited with code 0]
[Inferior 1 (process 23524) exited normally]
(gdb) set debuginfod enabled on
Support for debuginfod is not compiled into GDB.
(gdb)
我只使用 Linux,所以我不熟悉任何 Windows 特定的调试问题,但从您发布的 gdb 输出中我可以看到您正在使用的 tclsh.exe 没有调试符号。 如果您使用 unix 风格的工具(
configure
、make
等)构建 tclsh.exe,我似乎记得在遥远的过去使用 MinGW 做过,然后将 --enable-symbols
添加到 configure
将打开该调试信息。
但是只有当您想逐步了解 Tcl 本身的源代码时才需要这样做。 如果您只想单步调试自己的扩展的代码,那么在编译扩展时打开调试信息就足够了。 如果您使用 MinGW 工具链中的 gcc 来构建扩展,请添加
-g
开关以打开调试符号(如果您的编译器支持,则添加 -ggdb3
)以获得更广泛的 gdb 支持,例如宏的值和枚举)。
一旦您的扩展程序具有调试符号,请像您所做的那样使用
gdb tclsh
启动 gdb,在您感兴趣的扩展程序中的函数处添加一个断点(当 gdb 警告您该符号尚不存在时,请说 y
) ),运行 tcl (r
),在 tclsh REPL 中加载你的包并调用你正在调试的函数应该可以工作(这里通过中断来演示capply_cmd
扩展中的 jitc
符号,在没有调试符号的 tclsh 中):
[cyan@p1 ~]% gdb tclsh
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from tclsh...
(No debugging symbols found in tclsh)
(gdb) b capply_cmd
Function "capply_cmd" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (capply_cmd) pending.
(gdb) r
Starting program: /usr/bin/tclsh
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
% package require jitc
0.5.5
% jitc::capply {code {OBJCMD(foo) {return TCL_OK;}}} foo
Breakpoint 1, capply_cmd (cdata=0x5555556314d0, interp=0x55555556a9d0, objc=3, objv=0x555555578090) at ./generic/jitc.c:1132
1132 {
(gdb) l
1127
1128 //}}}
1129 // Stubs API }}}
1130 // Script API {{{
1131 static int capply_cmd(ClientData cdata, Tcl_Interp* interp, int objc, Tcl_Obj *const objv[]) //{{{
1132 {
1133 int code = TCL_OK;
1134 Tcl_ObjCmdProc* proc = NULL;
1135
1136 if (objc < 3) {
(gdb)