This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC:mi] Remove CLI_COMMAND
- From: nickrob at snap dot net dot nz (Nick Roberts)
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 23 Sep 2009 19:01:11 +1200
- Subject: [RFC:mi] Remove CLI_COMMAND
This patch removes the CLI_COMMAND case from captured_mi_execute_command in
mi-main.c. It simplifies the code and unifies the two ways of entering a CLI
command, CMD, namely directly and using "-interpreter-exec console CMD". I
think the presence of CLI_COMMAND is historical, as -interpreter-exec was
added later by Jim Ingham, Andrew Cagney et al.
A few tests, e.g mi2-hack-cli.exp will have to change as CLI commands are no
longer echoed in the console internals stream which I think is a good thing,
e.g,
(gdb)
pwd
~"Working directory /home/nickrob.\n"
^done
(gdb)
instead of:
pwd
&"pwd\n"
~"Working directory /home/nickrob.\n"
^done
(gdb)
The node "GDB/MI Compatibility with CLI" should also be removed as there will
no longer be any anomalies between the two ways of entering CLI commands.
--
Nick http://users.snap.net.nz/~nickrob
2009-09-23 Nick Roberts <nickrob@snap.net.nz>
* mi/mi-parse.h (mi_command_type): Delete enum.
(mi_parse): Remove op field.
* mi/mi-parse.c (mi_parse): Execute CLI command as an MI command.
* mi/mi-main.c (captured_mi_execute_command): Romove unused
CLI_COMMAND case.
--- mi-parse.h.~1.12.~ 2009-01-03 18:57:57.000000000 +1300
+++ mi-parse.h 2009-09-23 17:38:04.000000000 +1200
@@ -31,14 +31,8 @@ struct mi_timestamp {
struct timeval stime;
};
-enum mi_command_type
- {
- MI_COMMAND, CLI_COMMAND
- };
-
struct mi_parse
{
- enum mi_command_type op;
char *command;
char *token;
const struct mi_cmd *cmd;
--- mi-parse.c.~1.17.~ 2009-01-03 18:57:57.000000000 +1300
+++ mi-parse.c 2009-09-23 17:40:16.000000000 +1200
@@ -165,13 +165,20 @@ mi_parse (char *cmd)
memcpy (parse->token, cmd, (chp - cmd));
parse->token[chp - cmd] = '\0';
- /* This wasn't a real MI command. Return it as a CLI_COMMAND. */
+ /* This wasn't a real MI command use "-interpreter-exec console". */
if (*chp != '-')
{
- while (isspace (*chp))
- chp++;
- parse->command = xstrdup (chp);
- parse->op = CLI_COMMAND;
+ int len;
+ char* argv;
+ parse->command = xstrdup ("interpreter-exec");
+ parse->cmd = mi_lookup (parse->command);
+ len = strlen (chp);
+ argv = (char*) malloc ((len + 20) * sizeof (char));
+ strcpy (argv, "console ");
+ strcat (argv, "\"");
+ strcat (argv, chp);
+ strcat (argv, "\"");
+ mi_parse_argv (argv, parse);
return parse;
}
@@ -259,7 +266,5 @@ mi_parse (char *cmd)
if (parse->cmd->cli.cmd != NULL)
parse->args = xstrdup (chp);
- /* Fully parsed. */
- parse->op = MI_COMMAND;
return parse;
}
--- mi-main.c.~1.157.~ 2009-09-01 12:43:55.000000000 +1200
+++ mi-main.c 2009-09-23 17:39:08.000000000 +1200
@@ -1181,78 +1181,38 @@ captured_mi_execute_command (struct ui_o
running_result_record_printed = 0;
mi_proceeded = 0;
- switch (context->op)
- {
- case MI_COMMAND:
- /* A MI command was read from the input stream. */
- if (mi_debug_p)
- /* FIXME: gdb_???? */
- fprintf_unfiltered (raw_stdout, " token=`%s' command=`%s' args=`%s'\n",
- context->token, context->command, context->args);
-
-
- mi_cmd_execute (context);
-
- /* Print the result if there were no errors.
-
- Remember that on the way out of executing a command, you have
- to directly use the mi_interp's uiout, since the command could
- have reset the interpreter, in which case the current uiout
- will most likely crash in the mi_out_* routines. */
- if (!running_result_record_printed)
- {
- fputs_unfiltered (context->token, raw_stdout);
- /* There's no particularly good reason why target-connect results
- in not ^done. Should kill ^connected for MI3. */
- fputs_unfiltered (strcmp (context->command, "target-select") == 0
- ? "^connected" : "^done", raw_stdout);
- mi_out_put (uiout, raw_stdout);
- mi_out_rewind (uiout);
- mi_print_timing_maybe ();
- fputs_unfiltered ("\n", raw_stdout);
- }
- else
- /* The command does not want anything to be printed. In that
- case, the command probably should not have written anything
- to uiout, but in case it has written something, discard it. */
- mi_out_rewind (uiout);
- break;
-
- case CLI_COMMAND:
- {
- char *argv[2];
- /* A CLI command was read from the input stream. */
- /* This "feature" will be removed as soon as we have a
- complete set of mi commands. */
- /* Echo the command on the console. */
- fprintf_unfiltered (gdb_stdlog, "%s\n", context->command);
- /* Call the "console" interpreter. */
- argv[0] = "console";
- argv[1] = context->command;
- mi_cmd_interpreter_exec ("-interpreter-exec", argv, 2);
-
- /* 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))
- {
- if (!running_result_record_printed)
- {
- fputs_unfiltered (context->token, raw_stdout);
- fputs_unfiltered ("^done", raw_stdout);
- mi_out_put (uiout, raw_stdout);
- mi_out_rewind (uiout);
- mi_print_timing_maybe ();
- fputs_unfiltered ("\n", raw_stdout);
- }
- else
- mi_out_rewind (uiout);
- }
- break;
- }
+ if (mi_debug_p)
+ /* FIXME: gdb_???? */
+ fprintf_unfiltered (raw_stdout, " token=`%s' command=`%s' args=`%s'\n",
+ context->token, context->command, context->args);
+
+
+ mi_cmd_execute (context);
+
+ /* Print the result if there were no errors.
+
+ Remember that on the way out of executing a command, you have
+ to directly use the mi_interp's uiout, since the command could
+ have reset the interpreter, in which case the current uiout
+ will most likely crash in the mi_out_* routines. */
+ if (!running_result_record_printed)
+ {
+ fputs_unfiltered (context->token, raw_stdout);
+ /* There's no particularly good reason why target-connect results
+ in not ^done. Should kill ^connected for MI3. */
+ fputs_unfiltered (strcmp (context->command, "target-select") == 0
+ ? "^connected" : "^done", raw_stdout);
+ mi_out_put (uiout, raw_stdout);
+ mi_out_rewind (uiout);
+ mi_print_timing_maybe ();
+ fputs_unfiltered ("\n", raw_stdout);
}
+ else
+ /* The command does not want anything to be printed. In that
+ case, the command probably should not have written anything
+ to uiout, but in case it has written something, discard it. */
+ mi_out_rewind (uiout);
do_cleanups (cleanup);