将以下代码保存为 fix_insight-6.8-1.patch
diff -Naur ./gdb/cli/cli-cmds.c ./gdb_new/cli/cli-cmds.c
--- ./gdb/cli/cli-cmds.c 2008-01-02 06:53:14.000000000 +0800
+++ ./gdb_new/cli/cli-cmds.c 2014-07-02 08:59:58.259957990 +0800
@@ -320,8 +320,9 @@
{
if (args)
error (_("The \"pwd\" command does not take an argument: %s"), args);
- getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
-
+// getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); //by sylar
+ if (! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf))) //by sylar
+ error (_("Error finding name of working directory: %s"),safe_strerror (errno)); //by sylar
if (strcmp (gdb_dirbuf, current_directory) != 0)
printf_unfiltered (_("Working directory %s\n (canonically %s).\n"),
current_directory, gdb_dirbuf);
diff -Naur ./gdb/eval.c ./gdb_new/eval.c
--- ./gdb/eval.c 2008-02-04 08:23:04.000000000 +0800
+++ ./gdb_new/eval.c 2014-07-02 09:18:50.204107160 +0800
@@ -1701,7 +1701,7 @@
}
/* Now let us calculate the offset for this item */
-
+ memset(&subscript_array, 0, sizeof(subscript_array)); //by sylar
offset_item = subscript_array[ndimensions - 1];
for (i = ndimensions - 1; i > 0; --i)
diff -Naur ./gdb/inflow.c ./gdb_new/inflow.c
--- ./gdb/inflow.c 2008-01-02 06:53:11.000000000 +0800
+++ ./gdb_new/inflow.c 2014-07-02 09:30:17.112094510 +0800
@@ -513,7 +513,7 @@
new_tty (void)
{
int tty;
-
+ int temp; //by sylar
if (inferior_thisrun_terminal == 0)
return;
#if !defined(__GO32__) && !defined(_WIN32)
@@ -545,17 +545,17 @@
if (tty != 0)
{
close (0);
- dup (tty);
+ temp = dup (tty); //by sylar
}
if (tty != 1)
{
close (1);
- dup (tty);
+ temp = dup (tty); //by sylar
}
if (tty != 2)
{
close (2);
- dup (tty);
+ temp = dup (tty); //by sylar
}
if (tty > 2)
close (tty);
diff -Naur ./gdb/main.c ./gdb_new/main.c
--- ./gdb/main.c 2008-01-06 00:49:53.000000000 +0800
+++ ./gdb_new/main.c 2014-07-02 09:21:00.751512656 +0800
@@ -188,7 +188,9 @@
line[0] = '\0'; /* Terminate saved (now empty) cmd line */
instream = stdin;
- getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
+// getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); //by sylar
+ if (! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf))) //by sylar
+ error (_("Error finding name of working directory: %s"),safe_strerror (errno)); //by sylar
current_directory = gdb_dirbuf;
gdb_stdout = stdio_fileopen (stdout);
diff -Naur ./gdb/mi/mi-cmd-env.c ./gdb_new/mi/mi-cmd-env.c
--- ./gdb/mi/mi-cmd-env.c 2008-01-02 06:53:14.000000000 +0800
+++ ./gdb_new/mi/mi-cmd-env.c 2014-07-02 09:08:31.647396310 +0800
@@ -78,7 +78,9 @@
/* Otherwise the mi level is 2 or higher. */
- getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
+// getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); //by sylar
+ if (! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf))) //by sylar
+ error (_("Error finding name of working directory: %s"),safe_strerror (errno)); //by sylar
ui_out_field_string (uiout, "cwd", gdb_dirbuf);
return MI_CMD_DONE;
diff -Naur ./gdb/top.c ./gdb_new/top.c
--- ./gdb/top.c 2008-01-02 06:53:13.000000000 +0800
+++ ./gdb_new/top.c 2014-07-02 09:25:52.607213607 +0800
@@ -1628,7 +1628,9 @@
/* Run the init function of each source file */
- getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
+// getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); //by sylar
+ if (! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf))) //by sylar
+ error (_("Error finding name of working directory: %s"),safe_strerror (errno)); //by sylar
current_directory = gdb_dirbuf;
#ifdef __MSDOS__
diff -Naur ./gdb/utils.c ./gdb_new/utils.c
--- ./gdb/utils.c 2008-01-02 06:53:13.000000000 +0800
+++ ./gdb_new/utils.c 2014-07-02 09:28:36.507306384 +0800
@@ -693,6 +693,7 @@
/* Don't allow infinite error/warning recursion. */
{
static char msg[] = "Recursive internal problem.\n";
+ int temp; //by sylar
switch (dejavu)
{
case 0:
@@ -704,7 +705,8 @@
abort (); /* NOTE: GDB has only three calls to abort(). */
default:
dejavu = 3;
- write (STDERR_FILENO, msg, sizeof (msg));
+
+ temp = write (STDERR_FILENO, msg, sizeof (msg)); //by sylar
exit (1);
}
}
文件使用方法
1. tar jxvf insight-6.8.tar.bz2
2.将 fix_insight-6.8-1.patch 放入 insight-6.8 文件夹
3. 执行 patch -Np0 < fix_insight-6.8-1.patch
参考 这里
http://blog.csdn.net/qishi_blog/article/details/7317681?reload#cpp
按照上一篇文章安装gdb6.8时出现了好多错误
make之后出现
【1】.././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));
再次make出现这样的错误:
【2】eval.c: In function ‘evaluate_subexp_standard’:
eval.c:1705: error: ‘subscript_array’ may be used uninitialized in this function
在这条语句之后添加:
memset(&subscript_array, 0, sizeof(subscript_array));
【3】utils.c: In function ‘internal_vproblem’:
utils.c:707: error: ignoring return value of ‘write’, declared with attribute warn_unused_result
int temp; //添加
temp = write (STDERR_FILENO, msg, sizeof (msg)); // 修改后
【4】inflow.c: In function ‘new_tty’:
inflow.c:548: error: ignoring return value of ‘dup’, declared with attribute warn_unused_result
inflow.c:553: error: ignoring return value of ‘dup’, declared with attribute warn_unused_result
inflow.c:558: error: ignoring return value of ‘dup’, declared with attribute warn_unused_result
int temp; //添加
temp = dup (tty); //将相应的行修改为
在$make
$make install
OK!