This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] MI - add -i=<interpreter> when UI_OUT


Hello,

The attatched patch adds support for the ``-i'' option vis:

	-i=mi
or
	--interpreter=mi

(turns out that the --interpreter option was was already in the code
base).

Roughtly what happens is:

	o	captured_main parses -i=mi and
		saves the interpreter name away

	o	mi's initialization routines
		detect that ``mi'' is the interpreter
		and claim the main event loop

	o	as a sanity check, the code checks
		that when -i=... something claimed
		the event loop.

In the future this can be made a lot more fancy :-)

	enjoy,
		Andrew
Mon Feb 21 13:57:27 2000  Andrew Cagney  <cagney@b1.cygnus.com>

	* defs.h (interpreter_p): Declare when UI_OUT.
	* top.c (gdb_init): When interpreter_p, check that the interpreter
 	was recognized by one of the linked in interpreters.
	* main.c (interpreter_p): Define.
	(captured_main): When UI_OUT, check for ``-i <interpreter>'' option.
	* event-top.c (display_gdb_prompt): When interpreter_p, assume
 	interpreter displays prompt.

Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.2
diff -p -r1.2 defs.h
*** defs.h	2000/02/10 20:06:32	1.2
--- defs.h	2000/02/21 07:09:02
*************** extern int watchdog;
*** 1122,1127 ****
--- 1122,1137 ----
  
  /* Hooks for alternate command interfaces.  */
  
+ #ifdef UI_OUT
+ /* The name of the interpreter if specified on the command line. */
+ extern char *interpreter_p;
+ #endif
+ 
+ /* If a given interpreter matches INTERPRETER_P then it should update
+    command_loop_hook and init_ui_hook with the per-interpreter
+    implementation. */
+ /* FIXME: command_loop_hook and init_ui_hook should be moved here. */
+ 
  struct target_waitstatus;
  struct cmd_list_element;
  
Index: event-top.c
===================================================================
RCS file: /cvs/src/src/gdb/event-top.c,v
retrieving revision 1.1.1.18
diff -p -r1.1.1.18 event-top.c
*** event-top.c	2000/02/03 04:14:27	1.1.1.18
--- event-top.c	2000/02/21 07:09:04
*************** display_gdb_prompt (char *new_prompt)
*** 246,251 ****
--- 246,258 ----
    int prompt_length = 0;
    char *gdb_prompt = get_prompt ();
  
+ #ifdef UI_OUT
+   /* When an alternative interpreter has been installed, do not
+      display the comand prompt. */
+   if (interpreter_p)
+     return;
+ #endif
+ 
    if (target_executing && sync_execution)
      {
        /* This is to trick readline into not trying to display the
Index: top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.2
diff -p -r1.2 top.c
*** top.c	2000/02/09 03:28:18	1.2
--- top.c	2000/02/21 07:09:29
*************** gdb_init (argv0)
*** 801,806 ****
--- 801,817 ----
    uiout = cli_out_new (gdb_stdout);
  #endif
  
+ #ifdef UI_OUT
+   /* All the interpreters should have had a look at things by now.
+      Initialize the selected interpreter. */
+   if (interpreter_p && !init_ui_hook)
+     {
+       fprintf_unfiltered (gdb_stderr, "Interpreter `%s' unrecognized.\n",
+ 			  interpreter_p);
+       exit (1);
+     }
+ #endif
+ 
    if (init_ui_hook)
      init_ui_hook (argv0);
  }
Index: main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.1.1.23
diff -p -r1.1.1.23 main.c
*** main.c	2000/02/07 00:19:34	1.1.1.23
--- main.c	2000/02/21 07:28:56
*************** int display_space;
*** 53,58 ****
--- 53,63 ----
     processes UI events asynchronously. */
  int event_loop_p = 1;
  
+ #ifdef UI_OUT
+ /* Has an interpreter been specified and if so, which. */
+ char *interpreter_p;
+ #endif
+ 
  /* Whether this is the command line version or not */
  int tui_version = 0;
  
*************** captured_main (void *data)
*** 260,268 ****
--- 265,275 ----
        {"enable-external-editor", no_argument, 0, 'y'},
        {"editor-command", required_argument, 0, 'w'},
  #endif
+ #ifdef UI_OUT
        {"ui", required_argument, 0, 'i'},
        {"interpreter", required_argument, 0, 'i'},
        {"i", required_argument, 0, 'i'},
+ #endif
        {"directory", required_argument, 0, 'd'},
        {"d", required_argument, 0, 'd'},
        {"cd", required_argument, 0, 11},
*************** captured_main (void *data)
*** 373,378 ****
--- 380,390 ----
  	      break;
  	    }
  #endif /* GDBTK */
+ #ifdef UI_OUT
+ 	  case 'i':
+ 	    interpreter_p = optarg;
+ 	    break;
+ #endif
  	  case 'd':
  	    dirarg[ndir++] = optarg;
  	    if (ndir >= dirsize)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]