* gas/config/tc-avr.c: Change ISA for devices with USB support to
[external/binutils.git] / gdb / mi / mi-main.c
index 28de126..f69cd8d 100644 (file)
 #include "osdata.h"
 #include "splay-tree.h"
 #include "tracepoint.h"
+#include "ctf.h"
 #include "ada-lang.h"
 #include "linespec.h"
+#ifdef HAVE_PYTHON
+#include "python/python-internal.h"
+#endif
 
 #include <ctype.h>
 #include <sys/time.h>
@@ -677,6 +681,7 @@ list_available_thread_groups (VEC (int) *ids, int recurse)
   struct osdata_item *item;
   int ix_items;
   struct ui_out *uiout = current_uiout;
+  struct cleanup *cleanup;
 
   /* This keeps a map from integer (pid) to VEC (struct osdata_item *)*
      The vector contains information about all threads for the given pid.
@@ -686,7 +691,7 @@ list_available_thread_groups (VEC (int) *ids, int recurse)
 
   /* get_osdata will throw if it cannot return data.  */
   data = get_osdata ("processes");
-  make_cleanup_osdata_free (data);
+  cleanup = make_cleanup_osdata_free (data);
 
   if (recurse)
     {
@@ -789,6 +794,8 @@ list_available_thread_groups (VEC (int) *ids, int recurse)
 
       do_cleanups (back_to);
     }
+
+  do_cleanups (cleanup);
 }
 
 void
@@ -1756,7 +1763,8 @@ mi_cmd_list_features (char *command, char **argv, int argc)
       ui_out_field_string (uiout, NULL, "ada-task-info");
       
 #if HAVE_PYTHON
-      ui_out_field_string (uiout, NULL, "python");
+      if (gdb_python_initialized)
+       ui_out_field_string (uiout, NULL, "python");
 #endif
       
       do_cleanups (cleanup);
@@ -1962,7 +1970,7 @@ mi_print_exception (const char *token, struct gdb_exception exception)
 }
 
 void
-mi_execute_command (char *cmd, int from_tty)
+mi_execute_command (const char *cmd, int from_tty)
 {
   char *token;
   struct mi_parse *command = NULL;
@@ -2357,7 +2365,6 @@ void
 mi_cmd_trace_define_variable (char *command, char **argv, int argc)
 {
   struct expression *expr;
-  struct cleanup *back_to;
   LONGEST initval = 0;
   struct trace_state_variable *tsv;
   char *name = 0;
@@ -2365,19 +2372,11 @@ mi_cmd_trace_define_variable (char *command, char **argv, int argc)
   if (argc != 1 && argc != 2)
     error (_("Usage: -trace-define-variable VARIABLE [VALUE]"));
 
-  expr = parse_expression (argv[0]);
-  back_to = make_cleanup (xfree, expr);
-
-  if (expr->nelts == 3 && expr->elts[0].opcode == OP_INTERNALVAR)
-    {
-      struct internalvar *intvar = expr->elts[1].internalvar;
-
-      if (intvar)
-       name = internalvar_name (intvar);
-    }
+  name = argv[0];
+  if (*name++ != '$')
+    error (_("Name of trace variable should start with '$'"));
 
-  if (!name || *name == '\0')
-    error (_("Invalid name of trace variable"));
+  validate_trace_state_variable_name (name);
 
   tsv = find_trace_state_variable (name);
   if (!tsv)
@@ -2387,8 +2386,6 @@ mi_cmd_trace_define_variable (char *command, char **argv, int argc)
     initval = value_as_long (parse_and_eval (argv[1]));
 
   tsv->initial_value = initval;
-
-  do_cleanups (back_to);
 }
 
 void
@@ -2488,25 +2485,45 @@ void
 mi_cmd_trace_save (char *command, char **argv, int argc)
 {
   int target_saves = 0;
+  int generate_ctf = 0;
   char *filename;
+  int oind = 0;
+  char *oarg;
 
-  if (argc != 1 && argc != 2)
-    error (_("Usage: -trace-save [-r] filename"));
-
-  if (argc == 2)
+  enum opt
+  {
+    TARGET_SAVE_OPT, CTF_OPT
+  };
+  static const struct mi_opt opts[] =
     {
-      filename = argv[1];
-      if (strcmp (argv[0], "-r") == 0)
-       target_saves = 1;
-      else
-       error (_("Invalid option: %s"), argv[0]);
-    }
-  else
+      {"r", TARGET_SAVE_OPT, 0},
+      {"ctf", CTF_OPT, 0},
+      { 0, 0, 0 }
+    };
+
+  while (1)
     {
-      filename = argv[0];
+      int opt = mi_getopt ("-trace-save", argc, argv, opts,
+                          &oind, &oarg);
+
+      if (opt < 0)
+       break;
+      switch ((enum opt) opt)
+       {
+       case TARGET_SAVE_OPT:
+         target_saves = 1;
+         break;
+       case CTF_OPT:
+         generate_ctf = 1;
+         break;
+       }
     }
+  filename = argv[oind];
 
-  trace_save (filename, target_saves);
+  if (generate_ctf)
+    trace_save_ctf (filename, target_saves);
+  else
+    trace_save_tfile (filename, target_saves);
 }
 
 void