Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 3/5] Use ui_out_emit_tuple in tracepoint.c
Date: Fri, 14 Apr 2017 02:23:00 -0000	[thread overview]
Message-ID: <20170414022337.28368-4-tom@tromey.com> (raw)
In-Reply-To: <20170414022337.28368-1-tom@tromey.com>

This changes some code in tracepoint.c to use ui_out_emit_tuple.  One
of these involved removing an otherwise unrelated cleanup (changing
type to std::string) and the other involved introducing a new block.

gdb/ChangeLog
2017-04-13  Tom Tromey  <tom@tromey.com>

	* tracepoint.c (tvariables_info_1)
	(print_one_static_tracepoint_marker): Use ui_out_emit_tuple.
---
 gdb/ChangeLog    |  5 +++++
 gdb/tracepoint.c | 42 ++++++++++++++++--------------------------
 2 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1ec48a3..ba91cdc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2017-04-13  Tom Tromey  <tom@tromey.com>
 
+	* tracepoint.c (tvariables_info_1)
+	(print_one_static_tracepoint_marker): Use ui_out_emit_tuple.
+
+2017-04-13  Tom Tromey  <tom@tromey.com>
+
 	* stack.c (print_frame_arg): Use ui_out_emit_tuple.
 	* breakpoint.c (print_mention_watchpoint)
 	(print_mention_masked_watchpoint): Use ui_out_emit_tuple.
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index c947c95..808afde 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -506,15 +506,12 @@ tvariables_info_1 (void)
 
   for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix)
     {
-      struct cleanup *back_to2;
       const char *c;
-      char *name;
 
-      back_to2 = make_cleanup_ui_out_tuple_begin_end (uiout, "variable");
+      ui_out_emit_tuple tuple_emitter (uiout, "variable");
 
-      name = concat ("$", tsv->name, (char *) NULL);
-      make_cleanup (xfree, name);
-      uiout->field_string ("name", name);
+      std::string name = std::string ("$") + tsv->name;
+      uiout->field_string ("name", name.c_str ());
       uiout->field_string ("initial", plongest (tsv->initial_value));
 
       if (tsv->value_known)
@@ -533,8 +530,6 @@ tvariables_info_1 (void)
       if (c)
         uiout->field_string ("current", c);
       uiout->text ("\n");
-
-      do_cleanups (back_to2);
     }
 
   do_cleanups (back_to);
@@ -3841,7 +3836,6 @@ print_one_static_tracepoint_marker (int count,
   char wrap_indent[80];
   char extra_field_indent[80];
   struct ui_out *uiout = current_uiout;
-  struct cleanup *bkpt_chain;
   VEC(breakpoint_p) *tracepoints;
 
   struct symtab_and_line sal;
@@ -3852,7 +3846,7 @@ print_one_static_tracepoint_marker (int count,
 
   tracepoints = static_tracepoints_here (marker->address);
 
-  bkpt_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "marker");
+  ui_out_emit_tuple tuple_emitter (uiout, "marker");
 
   /* A counter field to help readability.  This is not a stable
      identifier!  */
@@ -3919,24 +3913,22 @@ print_one_static_tracepoint_marker (int count,
 
   if (!VEC_empty (breakpoint_p, tracepoints))
     {
-      struct cleanup *cleanup_chain;
       int ix;
       struct breakpoint *b;
 
-      cleanup_chain = make_cleanup_ui_out_tuple_begin_end (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++)
-	{
-	  if (ix > 0)
-	    uiout->text (", ");
-	  uiout->text ("#");
-	  uiout->field_int ("tracepoint-id", b->number);
-	}
+      {
+	ui_out_emit_tuple tuple_emitter (uiout, "tracepoints-at");
 
-      do_cleanups (cleanup_chain);
+	uiout->text (extra_field_indent);
+	uiout->text (_("Probed by static tracepoints: "));
+	for (ix = 0; VEC_iterate(breakpoint_p, tracepoints, ix, b); ix++)
+	  {
+	    if (ix > 0)
+	      uiout->text (", ");
+	    uiout->text ("#");
+	    uiout->field_int ("tracepoint-id", b->number);
+	  }
+      }
 
       if (uiout->is_mi_like_p ())
 	uiout->field_int ("number-of-tracepoints",
@@ -3945,8 +3937,6 @@ print_one_static_tracepoint_marker (int count,
 	uiout->text ("\n");
     }
   VEC_free (breakpoint_p, tracepoints);
-
-  do_cleanups (bkpt_chain);
 }
 
 static void
-- 
2.9.3


  parent reply	other threads:[~2017-04-14  2:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-14  2:23 [RFA 0/5] some cleanup removal for ui_out Tom Tromey
2017-04-14  2:23 ` [RFA 5/5] Use ui_out_emit_list Tom Tromey
2017-04-18 18:44   ` Pedro Alves
2017-04-14  2:23 ` Tom Tromey [this message]
2017-04-18 18:43   ` [RFA 3/5] Use ui_out_emit_tuple in tracepoint.c Pedro Alves
2017-04-14  2:23 ` [RFA 2/5] More uses of ui_out_emit_tuple Tom Tromey
2017-04-18 18:42   ` Pedro Alves
2017-04-19  2:42     ` Tom Tromey
2017-04-19  9:39       ` Pedro Alves
2017-04-14  2:24 ` [RFA 1/5] Use ui_out_emit_tuple Tom Tromey
2017-04-18 18:42   ` Pedro Alves
2017-04-14  2:42 ` [RFA 4/5] Use ui_out_emit_tuple in more places in MI Tom Tromey
2017-04-18 18:44   ` Pedro Alves
2017-04-22 15:44 ` [RFA 0/5] some cleanup removal for ui_out Tom Tromey
2017-04-27 14:51   ` Simon Marchi
2017-04-27 21:23     ` 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=20170414022337.28368-4-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