Remove unused variables from gdbserver
[deliverable/binutils-gdb.git] / gdb / tracepoint.c
index 189a97d49f0865b78bbdc04ec20647b1c9c3747b..74d1183386cb01686a027737a275080b0e70dfda 100644 (file)
@@ -579,8 +579,10 @@ actions_command (const char *args, int from_tty)
 
       counted_command_line l = read_command_lines (tmpbuf.c_str (),
                                                   from_tty, 1,
-                                                  check_tracepoint_command,
-                                                  t);
+                                                  [=] (const char *line)
+                                                    {
+                                                      validate_actionline (line, t);
+                                                    });
       breakpoint_set_commands (t, std::move (l));
     }
   /* else just return */
@@ -1493,15 +1495,11 @@ collection_list::add_aexpr (agent_expr_up aexpr)
 static void
 process_tracepoint_on_disconnect (void)
 {
-  VEC(breakpoint_p) *tp_vec = NULL;
-  int ix;
-  struct breakpoint *b;
   int has_pending_p = 0;
 
   /* Check whether we still have pending tracepoint.  If we have, warn the
      user that pending tracepoint will no longer work.  */
-  tp_vec = all_tracepoints ();
-  for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++)
+  for (breakpoint *b : all_tracepoints ())
     {
       if (b->loc == NULL)
        {
@@ -1525,7 +1523,6 @@ process_tracepoint_on_disconnect (void)
            break;
        }
     }
-  VEC_free (breakpoint_p, tp_vec);
 
   if (has_pending_p)
     warning (_("Pending tracepoints will not be resolved while"
@@ -1546,23 +1543,16 @@ trace_reset_local_state (void)
 void
 start_tracing (const char *notes)
 {
-  VEC(breakpoint_p) *tp_vec = NULL;
-  int ix;
-  struct breakpoint *b;
-  struct trace_state_variable *tsv;
   int any_enabled = 0, num_to_download = 0;
   int ret;
 
-  tp_vec = all_tracepoints ();
+  std::vector<breakpoint *> tp_vec = all_tracepoints ();
 
   /* No point in tracing without any tracepoints...  */
-  if (VEC_length (breakpoint_p, tp_vec) == 0)
-    {
-      VEC_free (breakpoint_p, tp_vec);
-      error (_("No tracepoints defined, not starting trace"));
-    }
+  if (tp_vec.empty ())
+    error (_("No tracepoints defined, not starting trace"));
 
-  for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++)
+  for (breakpoint *b : tp_vec)
     {
       if (b->enable_state == bp_enabled)
        any_enabled = 1;
@@ -1584,20 +1574,16 @@ start_tracing (const char *notes)
        {
          /* No point in tracing with only disabled tracepoints that
             cannot be re-enabled.  */
-         VEC_free (breakpoint_p, tp_vec);
          error (_("No tracepoints enabled, not starting trace"));
        }
     }
 
   if (num_to_download <= 0)
-    {
-      VEC_free (breakpoint_p, tp_vec);
-      error (_("No tracepoints that may be downloaded, not starting trace"));
-    }
+    error (_("No tracepoints that may be downloaded, not starting trace"));
 
   target_trace_init ();
 
-  for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++)
+  for (breakpoint *b : tp_vec)
     {
       struct tracepoint *t = (struct tracepoint *) b;
       struct bp_location *loc;
@@ -1636,7 +1622,6 @@ start_tracing (const char *notes)
       if (bp_location_downloaded)
        gdb::observers::breakpoint_modified.notify (b);
     }
-  VEC_free (breakpoint_p, tp_vec);
 
   /* Send down all the trace state variables too.  */
   for (const trace_state_variable &tsv : tvariables)
@@ -1703,14 +1688,10 @@ void
 stop_tracing (const char *note)
 {
   int ret;
-  VEC(breakpoint_p) *tp_vec = NULL;
-  int ix;
-  struct breakpoint *t;
 
   target_trace_stop ();
 
-  tp_vec = all_tracepoints ();
-  for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++)
+  for (breakpoint *t : all_tracepoints ())
     {
       struct bp_location *loc;
 
@@ -1731,8 +1712,6 @@ stop_tracing (const char *note)
        }
     }
 
-  VEC_free (breakpoint_p, tp_vec);
-
   if (!note)
     note = trace_stop_notes;
   ret = target_set_trace_notes (NULL, NULL, note);
@@ -1749,9 +1728,7 @@ static void
 tstatus_command (const char *args, int from_tty)
 {
   struct trace_status *ts = current_trace_status ();
-  int status, ix;
-  VEC(breakpoint_p) *tp_vec = NULL;
-  struct breakpoint *t;
+  int status;
   
   status = target_get_trace_status (ts);
 
@@ -1894,12 +1871,8 @@ tstatus_command (const char *args, int from_tty)
                     (long int) (ts->stop_time % 1000000));
 
   /* Now report any per-tracepoint status available.  */
-  tp_vec = all_tracepoints ();
-
-  for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++)
+  for (breakpoint *t : all_tracepoints ())
     target_get_tracepoint_status (t, NULL);
-
-  VEC_free (breakpoint_p, tp_vec);
 }
 
 /* Report the trace status to uiout, in a way suitable for MI, and not
@@ -2677,9 +2650,6 @@ trace_dump_actions (struct command_line *action,
             STEPPING_ACTIONS should be equal.  */
          if (stepping_frame == stepping_actions)
            {
-             char *cmd = NULL;
-             struct cleanup *old_chain
-               = make_cleanup (free_current_contents, &cmd);
              int trace_string = 0;
 
              if (*action_exp == '/')
@@ -2704,31 +2674,22 @@ trace_dump_actions (struct command_line *action,
                    info_args_command (NULL, from_tty);
                  else
                    {           /* variable */
+                     std::string contents;
+                     const char *exp = action_exp;
                      if (next_comma != NULL)
                        {
                          size_t len = next_comma - action_exp;
-
-                         cmd = (char *) xrealloc (cmd, len + 1);
-                         memcpy (cmd, action_exp, len);
-                         cmd[len] = 0;
+                         contents = std::string (action_exp, len);
+                         exp = contents.c_str ();
                        }
-                     else
-                       {
-                         size_t len = strlen (action_exp);
 
-                         cmd = (char *) xrealloc (cmd, len + 1);
-                         memcpy (cmd, action_exp, len + 1);
-                       }
-
-                     printf_filtered ("%s = ", cmd);
-                     output_command_const (cmd, from_tty);
+                     printf_filtered ("%s = ", exp);
+                     output_command (exp, from_tty);
                      printf_filtered ("\n");
                    }
                  action_exp = next_comma;
                }
              while (action_exp && *action_exp == ',');
-
-             do_cleanups (old_chain);
            }
        }
     }
@@ -2790,7 +2751,6 @@ all_tracepoint_actions (struct breakpoint *t)
      the fly, and don't cache it.  */
   if (*default_collect)
     {
-      struct command_line *default_collect_action;
       gdb::unique_xmalloc_ptr<char> default_collect_line
        (xstrprintf ("collect %s", default_collect));
 
@@ -3068,12 +3028,9 @@ cond_string_is_same (char *str1, char *str2)
 static struct bp_location *
 find_matching_tracepoint_location (struct uploaded_tp *utp)
 {
-  VEC(breakpoint_p) *tp_vec = all_tracepoints ();
-  int ix;
-  struct breakpoint *b;
   struct bp_location *loc;
 
-  for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++)
+  for (breakpoint *b : all_tracepoints ())
     {
       struct tracepoint *t = (struct tracepoint *) b;
 
@@ -3104,9 +3061,7 @@ merge_uploaded_tracepoints (struct uploaded_tp **uploaded_tps)
 {
   struct uploaded_tp *utp;
   /* A set of tracepoints which are modified.  */
-  VEC(breakpoint_p) *modified_tp = NULL;
-  int ix;
-  struct breakpoint *b;
+  std::vector<breakpoint *> modified_tp;
 
   /* Look for GDB tracepoints that match up with our uploaded versions.  */
   for (utp = *uploaded_tps; utp; utp = utp->next)
@@ -3132,16 +3087,14 @@ merge_uploaded_tracepoints (struct uploaded_tp **uploaded_tps)
             MODIFIED_TP if not there yet.  The 'breakpoint-modified'
             observers will be notified later once for each tracepoint
             saved in MODIFIED_TP.  */
-         for (ix = 0;
-              VEC_iterate (breakpoint_p, modified_tp, ix, b);
-              ix++)
+         for (breakpoint *b : modified_tp)
            if (b == loc->owner)
              {
                found = 1;
                break;
              }
          if (!found)
-           VEC_safe_push (breakpoint_p, modified_tp, loc->owner);
+           modified_tp.push_back (loc->owner);
        }
       else
        {
@@ -3166,10 +3119,9 @@ merge_uploaded_tracepoints (struct uploaded_tp **uploaded_tps)
 
   /* Notify 'breakpoint-modified' observer that at least one of B's
      locations was changed.  */
-  for (ix = 0; VEC_iterate (breakpoint_p, modified_tp, ix, b); ix++)
+  for (breakpoint *b : modified_tp)
     gdb::observers::breakpoint_modified.notify (b);
 
-  VEC_free (breakpoint_p, modified_tp);
   free_uploaded_tps (uploaded_tps);
 }
 
@@ -3225,7 +3177,6 @@ create_tsv_from_upload (struct uploaded_tsv *utsv)
 void
 merge_uploaded_trace_state_variables (struct uploaded_tsv **uploaded_tsvs)
 {
-  int ix;
   struct uploaded_tsv *utsv;
   struct trace_state_variable *tsv;
   int highest;
@@ -3653,12 +3604,12 @@ print_one_static_tracepoint_marker (int count,
   char wrap_indent[80];
   char extra_field_indent[80];
   struct ui_out *uiout = current_uiout;
-  VEC(breakpoint_p) *tracepoints;
 
   symtab_and_line sal;
   sal.pc = marker.address;
 
-  tracepoints = static_tracepoints_here (marker.address);
+  std::vector<breakpoint *> tracepoints
+    = static_tracepoints_here (marker.address);
 
   ui_out_emit_tuple tuple_emitter (uiout, "marker");
 
@@ -3669,7 +3620,7 @@ print_one_static_tracepoint_marker (int count,
   uiout->field_string ("marker-id", marker.str_id.c_str ());
 
   uiout->field_fmt ("enabled", "%c",
-                   !VEC_empty (breakpoint_p, tracepoints) ? 'y' : 'n');
+                   !tracepoints.empty () ? 'y' : 'n');
   uiout->spaces (2);
 
   strcpy (wrap_indent, "                                   ");
@@ -3725,32 +3676,29 @@ print_one_static_tracepoint_marker (int count,
   uiout->field_string ("extra-data", marker.extra.c_str ());
   uiout->text ("\"\n");
 
-  if (!VEC_empty (breakpoint_p, tracepoints))
+  if (!tracepoints.empty ())
     {
       int ix;
-      struct breakpoint *b;
 
       {
        ui_out_emit_tuple tuple_emitter (uiout, "tracepoints-at");
 
        uiout->text (extra_field_indent);
        uiout->text (_("Probed by static tracepoints: "));
-       for (ix = 0; VEC_iterate(breakpoint_p, tracepoints, ix, b); ix++)
+       for (ix = 0; ix < tracepoints.size (); ix++)
          {
            if (ix > 0)
              uiout->text (", ");
            uiout->text ("#");
-           uiout->field_int ("tracepoint-id", b->number);
+           uiout->field_int ("tracepoint-id", tracepoints[ix]->number);
          }
       }
 
       if (uiout->is_mi_like_p ())
-       uiout->field_int ("number-of-tracepoints",
-                         VEC_length(breakpoint_p, tracepoints));
+       uiout->field_int ("number-of-tracepoints", tracepoints.size ());
       else
        uiout->text ("\n");
     }
-  VEC_free (breakpoint_p, tracepoints);
 }
 
 static void
@@ -3802,7 +3750,7 @@ sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var,
 {
   /* We need to read the whole object before we know its size.  */
   gdb::optional<gdb::byte_vector> buf
-    = target_read_alloc (target_stack, TARGET_OBJECT_STATIC_TRACE_DATA,
+    = target_read_alloc (current_top_target (), TARGET_OBJECT_STATIC_TRACE_DATA,
                         NULL);
   if (buf)
     {
@@ -4077,13 +4025,13 @@ De-select any trace frame and resume 'live' debugging."),
 
   add_com ("tstop", class_trace, tstop_command, _("\
 Stop trace data collection.\n\
-Usage: tstop [ <notes> ... ]\n\
+Usage: tstop [NOTES]...\n\
 Any arguments supplied are recorded with the trace as a stop reason and\n\
 reported by tstatus (if the target supports trace notes)."));
 
   add_com ("tstart", class_trace, tstart_command, _("\
 Start trace data collection.\n\
-Usage: tstart [ <notes> ... ]\n\
+Usage: tstart [NOTES]...\n\
 Any arguments supplied are recorded with the trace as a note and\n\
 reported by tstatus (if the target supports trace notes)."));
 
This page took 0.031548 seconds and 4 git commands to generate.