我需要从gdb中的代码中进入TCL源代码。我在启用调试符号的情况下构建了TCL,但仍然无法进入它。这是我做的:
构建TCL
./configure --prefix=<path to my tcl build> --enable-symbols=all
make
make install
构建我的代码
gcc -g -O0 -I <path to my tcl build>/include -L<path to my tcl build>/lib -ltcl8.6 m.c
export LD_LIBRARY_PATH=<path to my tcl build>/lib:$LD_LIBRARY_PATH
运行gdb
gdb ./a.out
<inside gdb>dir <path to tcl source>/generic
但是当我尝试像Tcl_Init()和Tcl_ParseCommand()一样进入TCL调用时,gdb只是简单地跳过了。
当我运行&#34; info sharedlib&#34;在gdb中,我明白了:
From To Syms Read Shared Object Library
0x0000003cf6400b00 0x0000003cf64198eb Yes (*) /lib64/ld-linux-x86-64.so.2
0x00007ffff7c91350 0x00007ffff7db0518 Yes <path to my tcl build>/lib/libtcl8.6.so
0x0000003cf681ea60 0x0000003cf694024c Yes (*) /lib64/libc.so.6
0x0000003cf7000de0 0x0000003cf7001998 Yes (*) /lib64/libdl.so.2
0x0000003cf7802120 0x0000003cf780d3a8 Yes (*) /lib64/libz.so.1
0x0000003cf7405760 0x0000003cf74110c8 Yes (*) /lib64/libpthread.so.0
0x0000003cf6c03e70 0x0000003cf6c43fb8 Yes (*) /lib64/libm.so.6
(*): Shared library is missing debugging information.
你看到可能出现什么问题吗?
我正在使用TCL8.6.1。
这是我的代码:
#include <stdio.h>
#include <stdlib.h>
#include <tcl.h>
int main()
{
const char *my_tcl = "set a 100;";
size_t my_tcl_len = strlen(my_tcl);
Tcl_Interp *interp = NULL;
if ((interp = Tcl_CreateInterp()) == NULL) {
perror("Tcl_CreateInterp");
return -1;
}
if (Tcl_Init(interp) == TCL_ERROR) {
perror("Tcl_Init");
return -1;
}
Tcl_Parse parse;
if (Tcl_ParseCommand(interp, my_tcl, my_tcl_len, 0i, &parse) != TCL_OK) {
fprintf(stderr, "Error: %s\n", Tcl_GetStringResult(interp));
return -1;
}
printf("All right.\n");
return 0;
}