Remove the ui_out_style_kind enum
[deliverable/binutils-gdb.git] / gdb / tracepoint.c
index 8cd53374f91c34cf82c6075e08a139081012cec4..2f91e49efd3f21450495542145bfe11fe3bdc020 100644 (file)
@@ -1,6 +1,6 @@
 /* Tracing functionality for remote targets in custom GDB protocol
 
-   Copyright (C) 1997-2018 Free Software Foundation, Inc.
+   Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "cli/cli-utils.h"
 #include "probe.h"
 #include "ctf.h"
-#include "filestuff.h"
-#include "rsp-low.h"
+#include "gdbsupport/filestuff.h"
+#include "gdbsupport/rsp-low.h"
 #include "tracefile.h"
 #include "location.h"
 #include <algorithm>
-
-/* readline include files */
-#include "readline/readline.h"
-#include "readline/history.h"
-
-/* readline defines this.  */
-#undef savestring
+#include "cli/cli-style.h"
 
 #include <unistd.h>
 
@@ -138,12 +132,12 @@ static struct cmd_list_element *tfindlist;
 /* List of expressions to collect by default at each tracepoint hit.  */
 char *default_collect;
 
-static int disconnected_tracing;
+static bool disconnected_tracing;
 
 /* This variable controls whether we ask the target for a linear or
    circular trace buffer.  */
 
-static int circular_trace_buffer;
+static bool circular_trace_buffer;
 
 /* This variable is the requested trace buffer size, or -1 to indicate
    that we don't care and leave it up to the target to set a size.  */
@@ -2000,8 +1994,8 @@ trace_status_mi (int on_stop)
            {
              uiout->field_string ("stop-reason", stop_reason);
              if (stopping_tracepoint != -1)
-               uiout->field_int ("stopping-tracepoint",
-                                 stopping_tracepoint);
+               uiout->field_signed ("stopping-tracepoint",
+                                    stopping_tracepoint);
              if (ts->stop_reason == tracepoint_error)
                uiout->field_string ("error-description",
                                     ts->stop_desc);
@@ -2010,16 +2004,16 @@ trace_status_mi (int on_stop)
     }
 
   if (ts->traceframe_count != -1)
-    uiout->field_int ("frames", ts->traceframe_count);
+    uiout->field_signed ("frames", ts->traceframe_count);
   if (ts->traceframes_created != -1)
-    uiout->field_int ("frames-created", ts->traceframes_created);
+    uiout->field_signed ("frames-created", ts->traceframes_created);
   if (ts->buffer_size != -1)
-    uiout->field_int ("buffer-size", ts->buffer_size);
+    uiout->field_signed ("buffer-size", ts->buffer_size);
   if (ts->buffer_free != -1)
-    uiout->field_int ("buffer-free", ts->buffer_free);
+    uiout->field_signed ("buffer-free", ts->buffer_free);
 
-  uiout->field_int ("disconnected",  ts->disconnected_tracing);
-  uiout->field_int ("circular",  ts->circular_buffer);
+  uiout->field_signed ("disconnected",  ts->disconnected_tracing);
+  uiout->field_signed ("circular",  ts->circular_buffer);
 
   uiout->field_string ("user-name", ts->user_name);
   uiout->field_string ("notes", ts->notes);
@@ -2183,8 +2177,8 @@ tfind_1 (enum trace_find_type type, int num,
       if (uiout->is_mi_like_p ())
        {
          uiout->field_string ("found", "1");
-         uiout->field_int ("tracepoint", tracepoint_number);
-         uiout->field_int ("traceframe", traceframe_number);
+         uiout->field_signed ("tracepoint", tracepoint_number);
+         uiout->field_signed ("traceframe", traceframe_number);
        }
       else
        {
@@ -2636,8 +2630,11 @@ info_scope_command (const char *args_in, int from_tty)
                }
            }
          if (SYMBOL_TYPE (sym))
-           printf_filtered (", length %d.\n",
-                            TYPE_LENGTH (check_typedef (SYMBOL_TYPE (sym))));
+           {
+             struct type *t = check_typedef (SYMBOL_TYPE (sym));
+
+             printf_filtered (", length %s.\n", pulongest (TYPE_LENGTH (t)));
+           }
        }
       if (BLOCK_FUNCTION (block))
        break;
@@ -3083,7 +3080,8 @@ find_matching_tracepoint_location (struct uploaded_tp *utp)
       if (b->type == utp->type
          && t->step_count == utp->step
          && t->pass_count == utp->pass
-         && cond_string_is_same (t->cond_string, utp->cond_string)
+         && cond_string_is_same (t->cond_string,
+                                 utp->cond_string.get ())
          /* FIXME also test actions.  */
          )
        {
@@ -3462,7 +3460,7 @@ parse_tracepoint_definition (const char *line, struct uploaded_tp **utpp)
   int enabled, end;
   enum bptype type;
   const char *srctype;
-  char *cond, *buf;
+  char *buf;
   struct uploaded_tp *utp = NULL;
 
   p = line;
@@ -3475,13 +3473,14 @@ parse_tracepoint_definition (const char *line, struct uploaded_tp **utpp)
   p++;  /* skip a colon */
   if (piece == 'T')
     {
+      gdb::unique_xmalloc_ptr<char[]> cond;
+
       enabled = (*p++ == 'E');
       p++;  /* skip a colon */
       p = unpack_varlen_hex (p, &step);
       p++;  /* skip a colon */
       p = unpack_varlen_hex (p, &pass);
       type = bp_tracepoint;
-      cond = NULL;
       /* Thumb through optional fields.  */
       while (*p == ':')
        {
@@ -3502,8 +3501,8 @@ parse_tracepoint_definition (const char *line, struct uploaded_tp **utpp)
              p++;
              p = unpack_varlen_hex (p, &xlen);
              p++;  /* skip a comma */
-             cond = (char *) xmalloc (2 * xlen + 1);
-             strncpy (cond, p, 2 * xlen);
+             cond.reset ((char *) xmalloc (2 * xlen + 1));
+             strncpy (&cond[0], p, 2 * xlen);
              cond[2 * xlen] = '\0';
              p += 2 * xlen;
            }
@@ -3516,17 +3515,17 @@ parse_tracepoint_definition (const char *line, struct uploaded_tp **utpp)
       utp->enabled = enabled;
       utp->step = step;
       utp->pass = pass;
-      utp->cond = cond;
+      utp->cond = std::move (cond);
     }
   else if (piece == 'A')
     {
       utp = get_uploaded_tp (num, addr, utpp);
-      utp->actions.push_back (xstrdup (p));
+      utp->actions.emplace_back (xstrdup (p));
     }
   else if (piece == 'S')
     {
       utp = get_uploaded_tp (num, addr, utpp);
-      utp->step_actions.push_back (xstrdup (p));
+      utp->step_actions.emplace_back (xstrdup (p));
     }
   else if (piece == 'Z')
     {
@@ -3546,11 +3545,11 @@ parse_tracepoint_definition (const char *line, struct uploaded_tp **utpp)
       buf[end] = '\0';
 
       if (startswith (srctype, "at:"))
-       utp->at_string = xstrdup (buf);
+       utp->at_string.reset (xstrdup (buf));
       else if (startswith (srctype, "cond:"))
-       utp->cond_string = xstrdup (buf);
+       utp->cond_string.reset (xstrdup (buf));
       else if (startswith (srctype, "cmd:"))
-       utp->cmd_strings.push_back (xstrdup (buf));
+       utp->cmd_strings.emplace_back (xstrdup (buf));
     }
   else if (piece == 'V')
     {
@@ -3660,7 +3659,7 @@ print_one_static_tracepoint_marker (int count,
 
   /* A counter field to help readability.  This is not a stable
      identifier!  */
-  uiout->field_int ("count", count);
+  uiout->field_signed ("count", count);
 
   uiout->field_string ("marker-id", marker.str_id.c_str ());
 
@@ -3684,8 +3683,8 @@ print_one_static_tracepoint_marker (int count,
   if (sym)
     {
       uiout->text ("in ");
-      uiout->field_string ("func",
-                          SYMBOL_PRINT_NAME (sym));
+      uiout->field_string ("func", SYMBOL_PRINT_NAME (sym),
+                          function_name_style.style ());
       uiout->wrap_hint (wrap_indent);
       uiout->text (" at ");
     }
@@ -3695,7 +3694,8 @@ print_one_static_tracepoint_marker (int count,
   if (sal.symtab != NULL)
     {
       uiout->field_string ("file",
-                          symtab_to_filename_for_display (sal.symtab));
+                          symtab_to_filename_for_display (sal.symtab),
+                          file_name_style.style ());
       uiout->text (":");
 
       if (uiout->is_mi_like_p ())
@@ -3707,7 +3707,7 @@ print_one_static_tracepoint_marker (int count,
       else
        uiout->field_skip ("fullname");
 
-      uiout->field_int ("line", sal.line);
+      uiout->field_signed ("line", sal.line);
     }
   else
     {
@@ -3735,12 +3735,12 @@ print_one_static_tracepoint_marker (int count,
            if (ix > 0)
              uiout->text (", ");
            uiout->text ("#");
-           uiout->field_int ("tracepoint-id", tracepoints[ix]->number);
+           uiout->field_signed ("tracepoint-id", tracepoints[ix]->number);
          }
       }
 
       if (uiout->is_mi_like_p ())
-       uiout->field_int ("number-of-tracepoints", tracepoints.size ());
+       uiout->field_signed ("number-of-tracepoints", tracepoints.size ());
       else
        uiout->text ("\n");
     }
@@ -3995,7 +3995,7 @@ _initialize_tracepoint (void)
   tracepoint_number = -1;
 
   add_info ("scope", info_scope_command,
-           _("List the variables local to a scope"));
+           _("List the variables local to a scope."));
 
   add_cmd ("tracepoints", class_trace,
           _("Tracing of program execution without stopping the program."),
@@ -4018,16 +4018,14 @@ If no arguments are supplied, delete all variables."), &deletelist);
   /* FIXME add a trace variable completer.  */
 
   add_info ("tvariables", info_tvariables_command, _("\
-Status of trace state variables and their values.\n\
-"));
+Status of trace state variables and their values."));
 
   add_info ("static-tracepoint-markers",
            info_static_tracepoint_markers_command, _("\
-List target static tracepoints markers.\n\
-"));
+List target static tracepoints markers."));
 
   add_prefix_cmd ("tfind", class_trace, tfind_command, _("\
-Select a trace frame;\n\
+Select a trace frame.\n\
 No argument means forward by one frame; '-' means backward by one frame."),
                  &tfindlist, "tfind ", 1, &cmdlist);
 
@@ -4128,8 +4126,8 @@ depending on target's capabilities."));
   default_collect = xstrdup ("");
   add_setshow_string_cmd ("default-collect", class_trace,
                          &default_collect, _("\
-Set the list of expressions to collect by default"), _("\
-Show the list of expressions to collect by default"), NULL,
+Set the list of expressions to collect by default."), _("\
+Show the list of expressions to collect by default."), NULL,
                          NULL, NULL,
                          &setlist, &showlist);
 
@@ -4169,22 +4167,22 @@ disables any attempt to set the buffer size and lets the target choose."),
 
   add_setshow_string_cmd ("trace-user", class_trace,
                          &trace_user, _("\
-Set the user name to use for current and future trace runs"), _("\
-Show the user name to use for current and future trace runs"), NULL,
+Set the user name to use for current and future trace runs."), _("\
+Show the user name to use for current and future trace runs."), NULL,
                          set_trace_user, NULL,
                          &setlist, &showlist);
 
   add_setshow_string_cmd ("trace-notes", class_trace,
                          &trace_notes, _("\
-Set notes string to use for current and future trace runs"), _("\
-Show the notes string to use for current and future trace runs"), NULL,
+Set notes string to use for current and future trace runs."), _("\
+Show the notes string to use for current and future trace runs."), NULL,
                          set_trace_notes, NULL,
                          &setlist, &showlist);
 
   add_setshow_string_cmd ("trace-stop-notes", class_trace,
                          &trace_stop_notes, _("\
-Set notes string to use for future tstop commands"), _("\
-Show the notes string to use for future tstop commands"), NULL,
+Set notes string to use for future tstop commands."), _("\
+Show the notes string to use for future tstop commands."), NULL,
                          set_trace_stop_notes, NULL,
                          &setlist, &showlist);
 }
This page took 0.032898 seconds and 4 git commands to generate.