"complete" command and completion word break characters
[deliverable/binutils-gdb.git] / gdb / break-catch-syscall.c
index 602aba4e935ff9f832f1ac2fb1c5ca2443585c43..eb51a6118f1da337a865cadc394c86c063d8a2f2 100644 (file)
@@ -1,6 +1,6 @@
 /* Everything about syscall catchpoints, for GDB.
 
-   Copyright (C) 2009-2016 Free Software Foundation, Inc.
+   Copyright (C) 2009-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "xml-syscall.h"
 
 /* An instance of this type is used to represent a syscall catchpoint.
-   It includes a "struct breakpoint" as a kind of base class; users
-   downcast to "struct breakpoint *" when needed.  A breakpoint is
-   really of this type iff its ops pointer points to
+   A breakpoint is really of this type iff its ops pointer points to
    CATCH_SYSCALL_BREAKPOINT_OPS.  */
 
-struct syscall_catchpoint
+struct syscall_catchpoint : public breakpoint
 {
-  /* The base class.  */
-  struct breakpoint base;
+  ~syscall_catchpoint () override;
 
   /* Syscall numbers used for the 'catch syscall' feature.  If no
      syscall has been specified for filtering, its value is NULL.
@@ -48,17 +45,11 @@ struct syscall_catchpoint
   VEC(int) *syscalls_to_be_caught;
 };
 
-/* Implement the "dtor" breakpoint_ops method for syscall
-   catchpoints.  */
+/* catch_syscall destructor.  */
 
-static void
-dtor_catch_syscall (struct breakpoint *b)
+syscall_catchpoint::~syscall_catchpoint ()
 {
-  struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
-
-  VEC_free (int, c->syscalls_to_be_caught);
-
-  base_breakpoint_ops.dtor (b);
+  VEC_free (int, this->syscalls_to_be_caught);
 }
 
 static const struct inferior_data *catch_syscall_inferior_data = NULL;
@@ -158,7 +149,7 @@ insert_catch_syscall (struct bp_location *bl)
    catchpoints.  */
 
 static int
-remove_catch_syscall (struct bp_location *bl)
+remove_catch_syscall (struct bp_location *bl, enum remove_bp_reason reason)
 {
   struct syscall_catchpoint *c = (struct syscall_catchpoint *) bl->owner;
   struct inferior *inf = current_inferior ();
@@ -257,30 +248,30 @@ print_it_catch_syscall (bpstat bs)
   maybe_print_thread_hit_breakpoint (uiout);
 
   if (b->disposition == disp_del)
-    ui_out_text (uiout, "Temporary catchpoint ");
+    uiout->text ("Temporary catchpoint ");
   else
-    ui_out_text (uiout, "Catchpoint ");
-  if (ui_out_is_mi_like_p (uiout))
+    uiout->text ("Catchpoint ");
+  if (uiout->is_mi_like_p ())
     {
-      ui_out_field_string (uiout, "reason",
+      uiout->field_string ("reason",
                           async_reason_lookup (last.kind == TARGET_WAITKIND_SYSCALL_ENTRY
                                                ? EXEC_ASYNC_SYSCALL_ENTRY
                                                : EXEC_ASYNC_SYSCALL_RETURN));
-      ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition));
+      uiout->field_string ("disp", bpdisp_text (b->disposition));
     }
-  ui_out_field_int (uiout, "bkptno", b->number);
+  uiout->field_int ("bkptno", b->number);
 
   if (last.kind == TARGET_WAITKIND_SYSCALL_ENTRY)
-    ui_out_text (uiout, " (call to syscall ");
+    uiout->text (" (call to syscall ");
   else
-    ui_out_text (uiout, " (returned from syscall ");
+    uiout->text (" (returned from syscall ");
 
-  if (s.name == NULL || ui_out_is_mi_like_p (uiout))
-    ui_out_field_int (uiout, "syscall-number", last.value.syscall_number);
+  if (s.name == NULL || uiout->is_mi_like_p ())
+    uiout->field_int ("syscall-number", last.value.syscall_number);
   if (s.name != NULL)
-    ui_out_field_string (uiout, "syscall-name", s.name);
+    uiout->field_string ("syscall-name", s.name);
 
-  ui_out_text (uiout, "), ");
+  uiout->text ("), ");
 
   return PRINT_SRC_AND_LOC;
 }
@@ -302,14 +293,14 @@ print_one_catch_syscall (struct breakpoint *b,
      line up too nicely with the headers, but the effect is relatively
      readable).  */
   if (opts.addressprint)
-    ui_out_field_skip (uiout, "addr");
+    uiout->field_skip ("addr");
   annotate_field (5);
 
   if (c->syscalls_to_be_caught
       && VEC_length (int, c->syscalls_to_be_caught) > 1)
-    ui_out_text (uiout, "syscalls \"");
+    uiout->text ("syscalls \"");
   else
-    ui_out_text (uiout, "syscall \"");
+    uiout->text ("syscall \"");
 
   if (c->syscalls_to_be_caught)
     {
@@ -336,14 +327,14 @@ print_one_catch_syscall (struct breakpoint *b,
         }
       /* Remove the last comma.  */
       text[strlen (text) - 2] = '\0';
-      ui_out_field_string (uiout, "what", text);
+      uiout->field_string ("what", text);
     }
   else
-    ui_out_field_string (uiout, "what", "<any syscall>");
-  ui_out_text (uiout, "\" ");
+    uiout->field_string ("what", "<any syscall>");
+  uiout->text ("\" ");
 
-  if (ui_out_is_mi_like_p (uiout))
-    ui_out_field_string (uiout, "catch-type", "syscall");
+  if (uiout->is_mi_like_p ())
+    uiout->field_string ("catch-type", "syscall");
 }
 
 /* Implement the "print_mention" breakpoint_ops method for syscall
@@ -433,11 +424,11 @@ create_syscall_event_catchpoint (int tempflag, VEC(int) *filter,
   struct syscall_catchpoint *c;
   struct gdbarch *gdbarch = get_current_arch ();
 
-  c = XNEW (struct syscall_catchpoint);
-  init_catchpoint (&c->base, gdbarch, tempflag, NULL, ops);
+  c = new syscall_catchpoint ();
+  init_catchpoint (c, gdbarch, tempflag, NULL, ops);
   c->syscalls_to_be_caught = filter;
 
-  install_breakpoint (0, &c->base, 1);
+  install_breakpoint (0, c, 1);
 }
 
 /* Splits the argument using space as delimiter.  Returns an xmalloc'd
@@ -621,15 +612,14 @@ catching_syscall_number (int syscall_number)
 }
 
 /* Complete syscall names.  Used by "catch syscall".  */
-static VEC (char_ptr) *
+
+static void
 catch_syscall_completer (struct cmd_list_element *cmd,
+                        completion_tracker &tracker,
                          const char *text, const char *word)
 {
   struct gdbarch *gdbarch = get_current_arch ();
   struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
-  VEC (char_ptr) *group_retlist = NULL;
-  VEC (char_ptr) *syscall_retlist = NULL;
-  VEC (char_ptr) *retlist = NULL;
   const char **group_list = NULL;
   const char **syscall_list = NULL;
   const char *prefix;
@@ -645,8 +635,8 @@ catch_syscall_completer (struct cmd_list_element *cmd,
     {
       /* Perform completion inside 'group:' namespace only.  */
       group_list = get_syscall_group_names (gdbarch);
-      retlist = (group_list == NULL
-                ? NULL : complete_on_enum (group_list, word, word));
+      if (group_list != NULL)
+       complete_on_enum (tracker, group_list, word, word);
     }
   else
     {
@@ -663,21 +653,15 @@ catch_syscall_completer (struct cmd_list_element *cmd,
          make_cleanup (xfree, prefixed_group);
        }
 
-      syscall_retlist = ((syscall_list == NULL)
-                        ? NULL : complete_on_enum (syscall_list, word, word));
-      group_retlist = ((group_list == NULL)
-                      ? NULL : complete_on_enum (group_list, word, word));
-
-      retlist = VEC_merge (char_ptr, syscall_retlist, group_retlist);
+      if (syscall_list != NULL)
+       complete_on_enum (tracker, syscall_list, word, word);
+      if (group_list != NULL)
+       complete_on_enum (tracker, group_list, word, word);
     }
 
-  VEC_free (char_ptr, syscall_retlist);
-  VEC_free (char_ptr, group_retlist);
   xfree (syscall_list);
   xfree (group_list);
   do_cleanups (cleanups);
-
-  return retlist;
 }
 
 static void
@@ -701,7 +685,6 @@ initialize_syscall_catchpoint_ops (void)
   /* Syscall catchpoints.  */
   ops = &catch_syscall_breakpoint_ops;
   *ops = base_breakpoint_ops;
-  ops->dtor = dtor_catch_syscall;
   ops->insert_location = insert_catch_syscall;
   ops->remove_location = remove_catch_syscall;
   ops->breakpoint_hit = breakpoint_hit_catch_syscall;
This page took 0.027876 seconds and 4 git commands to generate.