GDB/MI: Add new "--language LANG" command option.
[deliverable/binutils-gdb.git] / gdb / mi / mi-parse.c
index a3c184910bf1e773cf4ad5c56f7a59021fcb8fd9..9994307d9f07f2188d805fb1d5608e92064d64a9 100644 (file)
@@ -27,6 +27,7 @@
 #include <ctype.h>
 #include "gdb_string.h"
 #include "cli/cli-utils.h"
+#include "language.h"
 
 static const char mi_no_values[] = "--no-values";
 static const char mi_simple_values[] = "--simple-values";
@@ -244,6 +245,7 @@ mi_parse (const char *cmd, char **token)
   parse->thread_group = -1;
   parse->thread = -1;
   parse->frame = -1;
+  parse->language = language_unknown;
 
   cleanup = make_cleanup (mi_parse_cleanup, parse);
 
@@ -292,7 +294,10 @@ mi_parse (const char *cmd, char **token)
      some important commands, like '-break-*' are implemented by
      forwarding to the CLI layer directly.  We want to parse --thread
      and --frame here, so as not to leave those option in the string
-     that will be passed to CLI.  */
+     that will be passed to CLI.
+
+     Same for the --language option.  */
+
   for (;;)
     {
       const char *option;
@@ -300,6 +305,7 @@ mi_parse (const char *cmd, char **token)
       size_t tgs = sizeof ("--thread-group ") - 1;
       size_t ts = sizeof ("--thread ") - 1;
       size_t fs = sizeof ("--frame ") - 1;
+      size_t ls = sizeof ("--language ") - 1;
 
       if (strncmp (chp, "--all ", as) == 0)
        {
@@ -348,6 +354,23 @@ mi_parse (const char *cmd, char **token)
          parse->frame = strtol (chp, &endp, 10);
          chp = endp;
        }
+      else if (strncmp (chp, "--language ", ls) == 0)
+       {
+         char *lang_name;
+         struct cleanup *old_chain;
+
+         option = "--language";
+         chp += ls;
+         lang_name = extract_arg_const (&chp);
+         old_chain = make_cleanup (xfree, lang_name);
+
+         parse->language = language_enum (lang_name);
+         if (parse->language == language_unknown
+             || parse->language == language_auto)
+           error (_("Invalid --language argument: %s"), lang_name);
+
+         do_cleanups (old_chain);
+       }
       else
        break;
 
This page took 0.024748 seconds and 4 git commands to generate.