用codeblocks调试时出现warning: GDB: Failed to set controlling terminal: Operation not permitted不过还是可以继续调试。好像是GDB7.0有bug的缘故,网上都说安装6.8的就可以了。可是安装后虽然调试没有出现上面的问题,可是还是没办法调试。现说说gdb-6.8的安装。从http://ftp.gnu.org/gnu/gdb/下载gdb-6.8.tar.gz。解压在工作目录(随便什么地方都可以,我放在~/下)。进入gdb-6.8,开始调试安装。用./configure --target=arm-linux --enable-sim --prefix=/usr/bin/gdb-6.8/(--prefix后的是安装路径,也是什么都可以,我在/usr/bin下创建目录sudo mkdir /usr/bin/gdb-6.8,没什么特殊含义),接着sudo make。其中遇到了一些问题:
.././gdb/cli/cli-cmds.c: In function ‘pwd_command’:
.././gdb/cli/cli-cmds.c:323: error: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result
make[2]: *** [cli-cmds.o] Error 1
make[2]: Leaving directory `/home/yeziqiang/gdb-6.8/gdb'
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory `/home/yeziqiang/gdb-6.8'
make: *** [all] Error 2
打开相应的cli-cmds.c(在main.c、top.c、mi-cmd-env.c等文件也会有相应的错误,改法一样)(得用sudo gedit),找到相应的行,
把getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));注释掉,在前加//活直接删掉。再在下面补充:
if (! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)))
error (_("Error finding name of working directory: %s"),
safe_strerror (errno));
utils.c: In function ‘internal_vproblem’:
utils.c:707: error: ignoring return value of ‘write’, declared with attribute warn_unused_result
make[2]: *** [utils.o] Error 1
make[2]: Leaving directory `/home/yeziqiang/gdb-6.8/gdb'
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory `/home/yeziqiang/gdb-6.8'
make: *** [all] Error 2
打开相应的utils.c,在
void
new_tty (void)
前加
static void
check_syscall (const char *msg, int result)
{
if (result < 0)
{
print_sys_errmsg (msg, errno);
_exit (1);
}
}
之后把大概550行左右类似的地反改成(//是注释掉)
/* Now open the specified new terminal. */
tty = open (inferior_thisrun_terminal, O_RDWR | O_NOCTTY);
// if (tty == -1)
// {
// print_sys_errmsg (inferior_thisrun_terminal, errno);
// _exit (1);
// }
check_syscall (inferior_thisrun_terminal, tty);
/* Avoid use of dup2; doesn't exist on all systems. */
if (tty != 0)
{
close (0);
// dup (tty);
check_syscall ("dup'ing tty into fd 0", dup (tty));
}
if (tty != 1)
{
close (1);
// dup (tty);
check_syscall ("dup'ing tty into fd 1", dup (tty));
}
if (tty != 2)
{
close (2);
// dup (tty);
check_syscall ("dup'ing tty into fd 2", dup (tty));
}
就好了!
把inflow.c出错的地方改成
/* Don't allow infinite error/warning recursion. */
{
static char msg[] = "Recursive internal problem./n";
switch (dejavu)
{
case 0:
dejavu = 1;
break;
case 1:
dejavu = 2;
fputs_unfiltered (msg, gdb_stderr);
abort (); /* NOTE: GDB has only three calls to abort(). */
default:
dejavu = 3;
// write (STDERR_FILENO, msg, sizeof (msg));把此行注释掉
/* Newer GLIBC versions put the warn_unused_result attribute
on write, but this is one of those rare cases where
ignoring the return value is correct. Casting to (void)
does not fix this problem. This is the solution suggested
at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509. */
if (write (STDERR_FILENO, msg, sizeof (msg)) != sizeof (msg))
abort ();//添加了这两行
exit (1);
}
}
在eval.c中如果出现subscript_array为定义,则在相应位置添加
if (nargs != ndimensions)
error (_("Wrong number of subscripts"));
memset(&subscript_array, 0, sizeof(subscript_array));//添加的
就遇到上面这些问题。结果就顺利安装了。之后把/usr/bin/gdb-6.8(安装的目录)/bin下的arm-linux-gdb复制到/usr/bin下就可以了。这样gdb-6.8就安装成功了。
不过可能是我不会设置还是其它原因,在codeblocks下调试随让没有出现一开始的问题,可还是不能调试。再接着尝试。
安装好gdb后一帮把gdbserver也安装了。在原来的目录/gdb/gdbserver下运行./configure在(sudo make && sudo make install),再把gdbserver目录下的gdbserver复制到/usr/bin下就可以了。
安装gdb-6.8
最新推荐文章于 2024-01-15 15:14:46 发布