This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

[commit] Fix MI error output for nonexistant CLI commands


Dirk reported on gdb@ last month that the ^error message for typing "aaa"
at a GDB/MI prompt had disappeared between GDB 6.3 and GDB 6.4.  Whatever
the eventual fate of this "cli hack" support, it's worth fixing the bug.
I've tested and committed this patch.

-- 
Daniel Jacobowitz
CodeSourcery

2006-05-05  Daniel Jacobowitz  <dan@codesourcery.com>

	* mi/mi-main.c (captured_mi_execute_command): Check the return
	value of -interpreter-exec.

Index: mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.83
diff -u -p -r1.83 mi-main.c
--- mi/mi-main.c	10 Jan 2006 22:42:03 -0000	1.83
+++ mi/mi-main.c	5 May 2006 15:49:27 -0000
@@ -1107,23 +1107,37 @@ captured_mi_execute_command (struct ui_o
 	/* Call the "console" interpreter.  */
 	argv[0] = "console";
 	argv[1] = context->command;
-	mi_cmd_interpreter_exec ("-interpreter-exec", argv, 2);
+	args->rc = mi_cmd_interpreter_exec ("-interpreter-exec", argv, 2);
 
-	/* If we changed interpreters, DON'T print out anything. */
+	/* If we changed interpreters, DON'T print out anything.  */
 	if (current_interp_named_p (INTERP_MI)
 	    || current_interp_named_p (INTERP_MI1)
 	    || current_interp_named_p (INTERP_MI2)
 	    || current_interp_named_p (INTERP_MI3))
 	  {
-	    /* print the result */
-	    /* FIXME: Check for errors here. */
-	    fputs_unfiltered (context->token, raw_stdout);
-	    fputs_unfiltered ("^done", raw_stdout);
-	    mi_out_put (uiout, raw_stdout);
-	    mi_out_rewind (uiout);
-	    fputs_unfiltered ("\n", raw_stdout);
-	    args->action = EXECUTE_COMMAND_DISPLAY_PROMPT;
-	    args->rc = MI_CMD_DONE;
+	    if (args->rc == MI_CMD_DONE)
+	      {
+		fputs_unfiltered (context->token, raw_stdout);
+		fputs_unfiltered ("^done", raw_stdout);
+		mi_out_put (uiout, raw_stdout);
+		mi_out_rewind (uiout);
+		fputs_unfiltered ("\n", raw_stdout);
+		args->action = EXECUTE_COMMAND_DISPLAY_PROMPT;
+	      }
+	    else if (args->rc == MI_CMD_ERROR)
+	      {
+		if (mi_error_message)
+		  {
+		    fputs_unfiltered (context->token, raw_stdout);
+		    fputs_unfiltered ("^error,msg=\"", raw_stdout);
+		    fputstr_unfiltered (mi_error_message, '"', raw_stdout);
+		    xfree (mi_error_message);
+		    fputs_unfiltered ("\"\n", raw_stdout);
+		  }
+		mi_out_rewind (uiout);
+	      }
+	    else
+	      mi_out_rewind (uiout);
 	  }
 	break;
       }


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