[PATCH] Update for interpreter API

Keith Seitz <[email protected]>
Newsgroups gmane.comp.debugging.insight
Message-ID <[email protected]>
Hi,

Some recent churn in GDB's interpreter API has left the insight build 
broken with:

../../src/gdb/gdbtk/generic/gdbtk-interp.c: In function 
‘_initialize_gdbtk_interp’:
../../src/gdb/gdbtk/generic/gdbtk-interp.c:168:5: error: initialization 
from incompatible pointer type
../../src/gdb/gdbtk/generic/gdbtk-interp.c:185:9: error: passing 
argument 2 of ‘interp_new’ from incompatible pointer type
../../src/gdb/interps.h:65:23: note: expected ‘const struct interp_procs 
*’ but argument is of type ‘struct gdbtk_interp_data *’
../../src/gdb/gdbtk/generic/gdbtk-interp.c:185:9: error: too many 
arguments to function ‘interp_new’
../../src/gdb/interps.h:65:23: note: declared here

The attached patch should fix that.

Keith

ChangeLog
2011-11-02  Keith Seitz  <[email protected]>

	* generic/gdbtk-interp.c (struct gdbtk_interp_data)
	<uiout>: New member.
	(gdbtk_data): Remove global.
	(gdbtk_interpreter_init): Update with GDB API changes.
	Allocate private intepreter data.
	(gdbtk_interpreter_ui_out): New function.
	(_initialize_gdbtk_interp): Add gdbtk_interpreter_ui_out to
	PROCS.
	Remove gdbtk_data and related allocation/initialization.
insight-interp.patch (text/x-patch, 3.1 KB)
Index: generic/gdbtk-interp.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-interp.c,v
retrieving revision 1.10
diff -u -p -r1.10 gdbtk-interp.c
--- generic/gdbtk-interp.c	18 Mar 2008 18:43:13 -0000	1.10
+++ generic/gdbtk-interp.c	2 Nov 2011 19:37:07 -0000
@@ -1,7 +1,7 @@
 /* Insight Definitions for GDB, the GNU debugger.
    Written by Keith Seitz <[email protected]>
 
-   Copyright (C) 2003, 2004, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2008, 2011 Free Software Foundation, Inc.
 
    This file is part of Insight.
 
@@ -50,10 +50,9 @@ struct gdbtk_interp_data
   struct ui_file *_stdlog;
   struct ui_file *_stdtarg;
   struct ui_file *_stdtargin;
+  struct ui_out *uiout;
 };
 
-static struct gdbtk_interp_data *gdbtk_data;
-
 /* See note in gdbtk_interpreter_init */
 static void
 hack_disable_interpreter_exec (char *args, int from_tty)
@@ -62,12 +61,21 @@ hack_disable_interpreter_exec (char *arg
 }
 
 static void *
-gdbtk_interpreter_init (int top_level)
+gdbtk_interpreter_init (struct interp *interp, int top_level)
 {
   /* Disable interpreter-exec. It causes us big trouble right now. */
   struct cmd_list_element *cmd = NULL;
   struct cmd_list_element *alias = NULL;
   struct cmd_list_element *prefix = NULL;
+  struct gdbtk_interp_data *data;
+
+  data = XZALLOC (struct gdbtk_interp_data);
+  data->_stdout = gdbtk_fileopen ();
+  data->_stderr = gdbtk_fileopen ();
+  data->_stdlog = gdbtk_fileopen ();
+  data->_stdtarg = gdbtk_fileopen ();
+  data->_stdtargin = gdbtk_fileopenin ();
+  data->uiout = cli_out_new (data->_stdout),
 
   gdbtk_init ();
 
@@ -76,7 +84,7 @@ gdbtk_interpreter_init (int top_level)
       set_cmd_cfunc (cmd, hack_disable_interpreter_exec);
     }
 
-  return gdbtk_data;
+  return data;
 }
 
 static int
@@ -161,6 +169,14 @@ gdbtk_command_loop (void)
   Tk_MainLoop ();
 }
 
+static struct ui_out *
+gdbtk_interpreter_ui_out (struct interp *interp)
+{
+  struct gdbtk_interp_data *data = interp_data (interp);
+
+  return data->uiout;
+}
+
 void
 _initialize_gdbtk_interp (void)
 {
@@ -169,19 +185,8 @@ _initialize_gdbtk_interp (void)
     gdbtk_interpreter_resume,           /* resume_proc */
     gdbtk_interpreter_suspend,	        /* suspend_proc */
     gdbtk_interpreter_exec,             /* exec_proc */
-    gdbtk_interpreter_display_prompt_p  /* prompt_proc_p */
+    gdbtk_interpreter_display_prompt_p, /* prompt_proc_p */
+    gdbtk_interpreter_ui_out		/* ui_out_proc */
   };
-  struct interp *gdbtk_interp;
-
-  gdbtk_data = 
-    (struct gdbtk_interp_data *) xmalloc (sizeof (struct gdbtk_interp_data));
-  memset (gdbtk_data, 0, sizeof (struct gdbtk_interp_data));
-  gdbtk_data->_stdout = gdbtk_fileopen ();
-  gdbtk_data->_stderr = gdbtk_fileopen ();
-  gdbtk_data->_stdlog = gdbtk_fileopen ();
-  gdbtk_data->_stdtarg = gdbtk_fileopen ();
-  gdbtk_data->_stdtargin = gdbtk_fileopenin ();
-  gdbtk_interp = interp_new ("insight", gdbtk_data, cli_out_new (gdbtk_data->_stdout),
-			     &procs);
-  interp_add (gdbtk_interp);
+  interp_add (interp_new ("insight", &procs));
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.