public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 4/6] Remove a use of is_mi_like_p from tracepoint.c
Date: Mon, 30 Apr 2018 14:07:00 -0000	[thread overview]
Message-ID: <20180430140732.21601-5-tom@tromey.com> (raw)
In-Reply-To: <20180430140732.21601-1-tom@tromey.com>

This removes a use of is_mi_like_p and changes a printf_filtered into
a call to ui_out::text.

2018-04-29  Tom Tromey  <tom@tromey.com>

	* tracepoint.c (tvariables_info_1): Remove use of is_mi_like_p.
---
 gdb/ChangeLog    |  4 +++
 gdb/tracepoint.c | 75 ++++++++++++++++++++++++++++----------------------------
 2 files changed, 41 insertions(+), 38 deletions(-)

diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 7e173ce75d..f40fb048d8 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -420,51 +420,50 @@ tvariables_info_1 (void)
 {
   struct ui_out *uiout = current_uiout;
 
-  if (tvariables.empty () && !uiout->is_mi_like_p ())
-    {
-      printf_filtered (_("No trace state variables.\n"));
-      return;
-    }
-
   /* Try to acquire values from the target.  */
   for (trace_state_variable &tsv : tvariables)
     tsv.value_known
       = target_get_trace_state_variable_value (tsv.number, &tsv.value);
 
-  ui_out_emit_table table_emitter (uiout, 3, tvariables.size (),
-				   "trace-variables");
-  uiout->table_header (15, ui_left, "name", "Name");
-  uiout->table_header (11, ui_left, "initial", "Initial");
-  uiout->table_header (11, ui_left, "current", "Current");
+  {
+    ui_out_emit_table table_emitter (uiout, 3, tvariables.size (),
+				     "trace-variables");
+    uiout->table_header (15, ui_left, "name", "Name");
+    uiout->table_header (11, ui_left, "initial", "Initial");
+    uiout->table_header (11, ui_left, "current", "Current");
 
-  uiout->table_body ();
+    uiout->table_body ();
 
-  for (const trace_state_variable &tsv : tvariables)
-    {
-      const char *c;
-
-      ui_out_emit_tuple tuple_emitter (uiout, "variable");
-
-      uiout->field_string ("name", std::string ("$") + tsv.name);
-      uiout->field_string ("initial", plongest (tsv.initial_value));
-
-      if (tsv.value_known)
-        c = plongest (tsv.value);
-      else if (uiout->is_mi_like_p ())
-        /* For MI, we prefer not to use magic string constants, but rather
-           omit the field completely.  The difference between unknown and
-           undefined does not seem important enough to represent.  */
-        c = NULL;
-      else if (current_trace_status ()->running || traceframe_number >= 0)
-	/* The value is/was defined, but we don't have it.  */
-        c = "<unknown>";
-      else
-	/* It is not meaningful to ask about the value.  */
-        c = "<undefined>";
-      if (c)
-        uiout->field_string ("current", c);
-      uiout->text ("\n");
-    }
+    for (const trace_state_variable &tsv : tvariables)
+      {
+	const char *c;
+
+	ui_out_emit_tuple tuple_emitter (uiout, "variable");
+
+	uiout->field_string ("name", std::string ("$") + tsv.name);
+	uiout->field_string ("initial", plongest (tsv.initial_value));
+
+	if (tsv.value_known)
+	  c = plongest (tsv.value);
+	else if (uiout->is_mi_like_p ())
+	  /* For MI, we prefer not to use magic string constants, but rather
+	     omit the field completely.  The difference between unknown and
+	     undefined does not seem important enough to represent.  */
+	  c = NULL;
+	else if (current_trace_status ()->running || traceframe_number >= 0)
+	  /* The value is/was defined, but we don't have it.  */
+	  c = "<unknown>";
+	else
+	  /* It is not meaningful to ask about the value.  */
+	  c = "<undefined>";
+	if (c)
+	  uiout->field_string ("current", c);
+	uiout->text ("\n");
+      }
+  }
+
+  if (tvariables.empty ())
+    uiout->text (_("No trace state variables.\n"));
 }
 
 /* List all the trace state variables.  */
-- 
2.13.6

  parent reply	other threads:[~2018-04-30 14:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-30 14:07 [RFA 0/6] Remove some uses of is_mi_like_p Tom Tromey
2018-04-30 14:07 ` [RFA 6/6] Remove a use of is_mi_like_p from darwin-nat-info.c Tom Tromey
2018-04-30 14:07 ` [RFA 5/6] Remove some is_mi_like_p from breakpoint code Tom Tromey
2018-04-30 14:07 ` Tom Tromey [this message]
2018-04-30 14:07 ` [RFA 1/6] Make do_is_mi_like_p const Tom Tromey
2018-04-30 14:07 ` [RFA 2/6] Remove some uses of is_mi_like_p from py-framefilter.c Tom Tromey
2018-04-30 14:07 ` [RFA 3/6] Remove some uses of is_mi_like_p from spu-tdep.c Tom Tromey
2018-04-30 18:36 ` [RFA 0/6] Remove some uses of is_mi_like_p Pedro Alves
2018-04-30 18:52   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180430140732.21601-5-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).