安装insight 时 gdb 出现错误的解决 添加patch文件

 

将以下代码保存为  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!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Source Insight添加工程文件,可以按照以下步骤进行操作: 1. 打开Source Insight软件。 2. 选择菜单栏中的"Project",然后点击"New Project"。 3. 在弹出的对话框中,为工程命名,并设置工程路径。可以参考\[1\]中的步骤,选择一个合适的路径。 4. 点击"OK"按钮,然后在弹出的对话框中选择要添加的源码文件。可以根据需要选择多个文件。 5. 点击"Add"按钮,将选中的源码文件添加到工程中。 6. 点击"Close"按钮关闭对话框。 7. 现在,你可以在Source Insight中打开工程文件,查看和编辑源码文件了。 请注意,以上步骤是基于Source Insight 3.5版本的操作。如果你使用的是其他版本,可能会有些许差异。你可以参考\[1\]和\[2\]中提供的链接,了解更多关于Source Insight安装和使用方法。 #### 引用[.reference_title] - *1* [【cc2541开发环境】如何新建SourceInsight工程文件](https://blog.csdn.net/wangjiawu7/article/details/71403085)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [如何添加项目文件到Source insight 4.0中去的详细介绍(配图超简单)](https://blog.csdn.net/weixin_45309916/article/details/108045612)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值