Allow integer immediate for VFP vmov instructions.
[deliverable/binutils-gdb.git] / gdb / interps.c
index af86390b3decab6bb95d7f5f1217f85fef4787ca..61db7f4bdf1724fff5b560482fa7fd0ca6596021 100644 (file)
@@ -1,6 +1,6 @@
 /* Manages interpreters for GDB, the GNU debugger.
 
-   Copyright (C) 2000-2017 Free Software Foundation, Inc.
+   Copyright (C) 2000-2018 Free Software Foundation, Inc.
 
    Written by Jim Ingham <jingham@apple.com> of Apple Computer, Inc.
 
@@ -74,8 +74,6 @@ get_current_interp_info (void)
 
 /* The magic initialization routine for this module.  */
 
-void _initialize_interpreter (void);
-
 static struct interp *interp_lookup_existing (struct ui *ui,
                                              const char *name);
 
@@ -93,6 +91,10 @@ interp::~interp ()
 
 struct interp_factory
 {
+  interp_factory (const char *name_, interp_factory_func func_)
+  : name (name_), func (func_)
+  {}
+
   /* This is the name in "-i=INTERP" and "interpreter-exec INTERP".  */
   const char *name;
 
@@ -100,35 +102,24 @@ struct interp_factory
   interp_factory_func func;
 };
 
-typedef struct interp_factory *interp_factory_p;
-DEF_VEC_P(interp_factory_p);
-
 /* The registered interpreter factories.  */
-static VEC(interp_factory_p) *interpreter_factories = NULL;
+static std::vector<interp_factory> interpreter_factories;
 
 /* See interps.h.  */
 
 void
 interp_factory_register (const char *name, interp_factory_func func)
 {
-  struct interp_factory *f;
-  int ix;
-
   /* Assert that no factory for NAME is already registered.  */
-  for (ix = 0;
-       VEC_iterate (interp_factory_p, interpreter_factories, ix, f);
-       ++ix)
-    if (strcmp (f->name, name) == 0)
+  for (const interp_factory &f : interpreter_factories)
+    if (strcmp (f.name, name) == 0)
       {
        internal_error (__FILE__, __LINE__,
                        _("interpreter factory already registered: \"%s\"\n"),
                        name);
       }
 
-  f = XNEW (struct interp_factory);
-  f->name = name;
-  f->func = func;
-  VEC_safe_push (interp_factory_p, interpreter_factories, f);
+  interpreter_factories.emplace_back (name, func);
 }
 
 /* Add interpreter INTERP to the gdb interpreter list.  The
@@ -227,24 +218,18 @@ interp_lookup_existing (struct ui *ui, const char *name)
 struct interp *
 interp_lookup (struct ui *ui, const char *name)
 {
-  struct interp_factory *factory;
-  struct interp *interp;
-  int ix;
-
   if (name == NULL || strlen (name) == 0)
     return NULL;
 
   /* Only create each interpreter once per top level.  */
-  interp = interp_lookup_existing (ui, name);
+  struct interp *interp = interp_lookup_existing (ui, name);
   if (interp != NULL)
     return interp;
 
-  for (ix = 0;
-       VEC_iterate (interp_factory_p, interpreter_factories, ix, factory);
-       ++ix)
-    if (strcmp (factory->name, name) == 0)
+  for (const interp_factory &factory : interpreter_factories)
+    if (strcmp (factory.name, name) == 0)
       {
-       interp = factory->func (name);
+       interp = factory.func (name);
        interp_add (ui, interp);
        return interp;
       }
@@ -290,7 +275,7 @@ current_interp_set_logging (ui_file_up logfile,
 
 /* Temporarily overrides the current interpreter.  */
 struct interp *
-interp_set_temp (const char *name)
+scoped_restore_interp::set_interp (const char *name)
 {
   struct ui_interp_info *ui_interp = get_current_interp_info ();
   struct interp *interp = interp_lookup (current_ui, name);
@@ -403,25 +388,18 @@ clear_interpreter_hooks (void)
 }
 
 static void
-interpreter_exec_cmd (char *args, int from_tty)
+interpreter_exec_cmd (const char *args, int from_tty)
 {
   struct ui_interp_info *ui_interp = get_current_interp_info ();
   struct interp *old_interp, *interp_to_use;
-  char **prules = NULL;
-  char **trule = NULL;
   unsigned int nrules;
   unsigned int i;
-  struct cleanup *cleanup;
 
   if (args == NULL)
     error_no_arg (_("interpreter-exec command"));
 
-  prules = gdb_buildargv (args);
-  cleanup = make_cleanup_freeargv (prules);
-
-  nrules = 0;
-  for (trule = prules; *trule != NULL; trule++)
-    nrules++;
+  gdb_argv prules (args);
+  nrules = prules.count ();
 
   if (nrules < 2)
     error (_("usage: interpreter-exec <interpreter> [ <command> ... ]"));
@@ -446,50 +424,25 @@ interpreter_exec_cmd (char *args, int from_tty)
     }
 
   interp_set (old_interp, 0);
-
-  do_cleanups (cleanup);
 }
 
 /* See interps.h.  */
 
-VEC (char_ptr) *
+void
 interpreter_completer (struct cmd_list_element *ignore,
+                      completion_tracker &tracker,
                       const char *text, const char *word)
 {
-  struct interp_factory *interp;
-  int textlen;
-  VEC (char_ptr) *matches = NULL;
-  int ix;
-
-  textlen = strlen (text);
-  for (ix = 0;
-       VEC_iterate (interp_factory_p, interpreter_factories, ix, interp);
-       ++ix)
+  int textlen = strlen (text);
+
+  for (const interp_factory &interp : interpreter_factories)
     {
-      if (strncmp (interp->name, text, textlen) == 0)
+      if (strncmp (interp.name, text, textlen) == 0)
        {
-         char *match;
-
-         match = (char *) xmalloc (strlen (word) + strlen (interp->name) + 1);
-         if (word == text)
-           strcpy (match, interp->name);
-         else if (word > text)
-           {
-             /* Return some portion of interp->name.  */
-             strcpy (match, interp->name + (word - text));
-           }
-         else
-           {
-             /* Return some of text plus interp->name.  */
-             strncpy (match, word, text - word);
-             match[text - word] = '\0';
-             strcat (match, interp->name);
-           }
-         VEC_safe_push (char_ptr, matches, match);
+         tracker.add_completion
+           (make_completion_match_str (interp.name, text, word));
        }
     }
-
-  return matches;
 }
 
 struct interp *
This page took 0.027167 seconds and 4 git commands to generate.