]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use ui_out_emit_tuple
authorTom Tromey <tom@tromey.com>
Wed, 12 Apr 2017 14:23:08 +0000 (08:23 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 22 Apr 2017 15:46:58 +0000 (09:46 -0600)
This patch changes various places to use ui_out_emit_tuple,
eliminating a number of cleanups.  This patch only tackles "easy"
cases, which are ones where the cleanups in question were
block-structured and did not involve any changes other than the
obvious replacement.

ChangeLog
2017-04-22  Tom Tromey  <tom@tromey.com>

* record-btrace.c (record_btrace_insn_history)
(record_btrace_insn_history_range, record_btrace_call_history)
(record_btrace_call_history_range): Use ui_out_emit_tuple.
* thread.c (do_captured_list_thread_ids, print_thread_info_1): Use
ui_out_emit_tuple.
* stack.c (print_frame_info): Use ui_out_emit_tuple.
* solib.c (info_sharedlibrary_command): Use ui_out_emit_tuple.
* skip.c (skip_info): Use ui_out_emit_tuple.
* remote.c (show_remote_cmd): Use ui_out_emit_tuple.
* progspace.c (print_program_space): Use ui_out_emit_tuple.
* probe.c (info_probes_for_ops): Use ui_out_emit_tuple.
* osdata.c (info_osdata): Use ui_out_emit_tuple.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Use
ui_out_emit_tuple.
* mi/mi-main.c (print_one_inferior, list_available_thread_groups)
(output_register, mi_cmd_data_read_memory)
(mi_cmd_data_read_memory_bytes, mi_load_progress)
(mi_cmd_trace_frame_collected): Use ui_out_emit_tuple.
* mi/mi-cmd-var.c (mi_cmd_var_list_children, varobj_update_one):
Use ui_out_emit_tuple.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_args): Use
ui_out_emit_tuple.
* mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions)
(mi_cmd_info_gdb_mi_command): Use ui_out_emit_tuple.
* linux-thread-db.c (info_auto_load_libthread_db): Use
ui_out_emit_tuple.
* inferior.c (print_inferior): Use ui_out_emit_tuple.
* gdb_bfd.c (print_one_bfd): Use ui_out_emit_tuple.
* disasm.c (do_mixed_source_and_assembly_deprecated)
(do_mixed_source_and_assembly): Use ui_out_emit_tuple.
* cp-abi.c (list_cp_abis): Use ui_out_emit_tuple.
* cli/cli-setshow.c (cmd_show_list): Use ui_out_emit_tuple.
* breakpoint.c (print_one_breakpoint_location)
(print_one_breakpoint): Use ui_out_emit_tuple.
* auto-load.c (print_script, info_auto_load_cmd): Use
ui_out_emit_tuple.
* ada-tasks.c (print_ada_task_info): Use ui_out_emit_tuple.

24 files changed:
gdb/ChangeLog
gdb/ada-tasks.c
gdb/auto-load.c
gdb/breakpoint.c
gdb/cli/cli-setshow.c
gdb/cp-abi.c
gdb/disasm.c
gdb/gdb_bfd.c
gdb/inferior.c
gdb/linux-thread-db.c
gdb/mi/mi-cmd-info.c
gdb/mi/mi-cmd-stack.c
gdb/mi/mi-cmd-var.c
gdb/mi/mi-main.c
gdb/mi/mi-symbol-cmds.c
gdb/osdata.c
gdb/probe.c
gdb/progspace.c
gdb/record-btrace.c
gdb/remote.c
gdb/skip.c
gdb/solib.c
gdb/stack.c
gdb/thread.c

index 2aa0b5945ffe5ac1e7b5826e66e9cae5efbadbc4..2e0ea7a85b4cf63f75eef16ea3789eddaf533578 100644 (file)
@@ -1,3 +1,43 @@
+2017-04-22  Tom Tromey  <tom@tromey.com>
+
+       * record-btrace.c (record_btrace_insn_history)
+       (record_btrace_insn_history_range, record_btrace_call_history)
+       (record_btrace_call_history_range): Use ui_out_emit_tuple.
+       * thread.c (do_captured_list_thread_ids, print_thread_info_1): Use
+       ui_out_emit_tuple.
+       * stack.c (print_frame_info): Use ui_out_emit_tuple.
+       * solib.c (info_sharedlibrary_command): Use ui_out_emit_tuple.
+       * skip.c (skip_info): Use ui_out_emit_tuple.
+       * remote.c (show_remote_cmd): Use ui_out_emit_tuple.
+       * progspace.c (print_program_space): Use ui_out_emit_tuple.
+       * probe.c (info_probes_for_ops): Use ui_out_emit_tuple.
+       * osdata.c (info_osdata): Use ui_out_emit_tuple.
+       * mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Use
+       ui_out_emit_tuple.
+       * mi/mi-main.c (print_one_inferior, list_available_thread_groups)
+       (output_register, mi_cmd_data_read_memory)
+       (mi_cmd_data_read_memory_bytes, mi_load_progress)
+       (mi_cmd_trace_frame_collected): Use ui_out_emit_tuple.
+       * mi/mi-cmd-var.c (mi_cmd_var_list_children, varobj_update_one):
+       Use ui_out_emit_tuple.
+       * mi/mi-cmd-stack.c (mi_cmd_stack_list_args): Use
+       ui_out_emit_tuple.
+       * mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions)
+       (mi_cmd_info_gdb_mi_command): Use ui_out_emit_tuple.
+       * linux-thread-db.c (info_auto_load_libthread_db): Use
+       ui_out_emit_tuple.
+       * inferior.c (print_inferior): Use ui_out_emit_tuple.
+       * gdb_bfd.c (print_one_bfd): Use ui_out_emit_tuple.
+       * disasm.c (do_mixed_source_and_assembly_deprecated)
+       (do_mixed_source_and_assembly): Use ui_out_emit_tuple.
+       * cp-abi.c (list_cp_abis): Use ui_out_emit_tuple.
+       * cli/cli-setshow.c (cmd_show_list): Use ui_out_emit_tuple.
+       * breakpoint.c (print_one_breakpoint_location)
+       (print_one_breakpoint): Use ui_out_emit_tuple.
+       * auto-load.c (print_script, info_auto_load_cmd): Use
+       ui_out_emit_tuple.
+       * ada-tasks.c (print_ada_task_info): Use ui_out_emit_tuple.
+
 2017-04-21  Simon Marchi  <simon.marchi@ericsson.com>
 
        * thread.c (print_thread_info_1): Remove dead code.
index 624bbddbd56ad74b3d66f4c43d2957be9e3510d2..ae43da55535b3c5a148f73e34c8d75a098f9b280 100644 (file)
@@ -1073,7 +1073,6 @@ print_ada_task_info (struct ui_out *uiout,
       const struct ada_task_info *const task_info =
        VEC_index (ada_task_info_s, data->task_list, taskno - 1);
       int parent_id;
-      struct cleanup *chain2;
 
       gdb_assert (task_info != NULL);
 
@@ -1083,7 +1082,7 @@ print_ada_task_info (struct ui_out *uiout,
       if (taskno_arg && taskno != taskno_arg)
         continue;
 
-      chain2 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+      ui_out_emit_tuple tuple_emitter (uiout, NULL);
 
       /* Print a star if this task is the current task (or the task
          currently selected).  */
@@ -1143,7 +1142,6 @@ print_ada_task_info (struct ui_out *uiout,
                                                   : _("<no name>"));
 
       uiout->text ("\n");
-      do_cleanups (chain2);
     }
 
   do_cleanups (old_chain);
index edaf264548e35761fdfc4fa73f0003166437e879..37bf94286d3b3d6f4fef66c0241a60ef0ee83503 100644 (file)
@@ -1268,9 +1268,8 @@ static void
 print_script (struct loaded_script *script)
 {
   struct ui_out *uiout = current_uiout;
-  struct cleanup *chain;
 
-  chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+  ui_out_emit_tuple tuple_emitter (uiout, NULL);
 
   uiout->field_string ("loaded", script->loaded ? "Yes" : "No");
   uiout->field_string ("script", script->name);
@@ -1284,8 +1283,6 @@ print_script (struct loaded_script *script)
       uiout->field_string ("full_path", script->full_path);
       uiout->text ("\n");
     }
-
-  do_cleanups (chain);
 }
 
 /* Helper for info_auto_load_scripts to sort the scripts by name.  */
@@ -1561,12 +1558,11 @@ info_auto_load_cmd (char *args, int from_tty)
   struct cleanup *infolist_chain;
   struct ui_out *uiout = current_uiout;
 
-  infolist_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "infolist");
+  ui_out_emit_tuple tuple_emitter (uiout, "infolist");
 
   for (list = *auto_load_info_cmdlist_get (); list != NULL; list = list->next)
     {
-      struct cleanup *option_chain
-       = make_cleanup_ui_out_tuple_begin_end (uiout, "option");
+      ui_out_emit_tuple option_emitter (uiout, "option");
 
       gdb_assert (!list->prefixlist);
       gdb_assert (list->type == not_set_cmd);
@@ -1574,13 +1570,7 @@ info_auto_load_cmd (char *args, int from_tty)
       uiout->field_string ("name", list->name);
       uiout->text (":  ");
       cmd_func (list, auto_load_info_scripts_pattern_nl, from_tty);
-
-      /* Close the tuple.  */
-      do_cleanups (option_chain);
     }
-
-  /* Close the tuple.  */
-  do_cleanups (infolist_chain);
 }
 
 /* Initialize "info auto-load " commands prefix and return it.  */
index 4940ec271b7529a1b36aa3f5db6a8c99df933482..2ff4406275678b4353a5ecf2fe318d5ef5421e42 100644 (file)
@@ -6619,12 +6619,9 @@ print_one_breakpoint_location (struct breakpoint *b,
   l = b->commands ? b->commands->commands : NULL;
   if (!part_of_multiple && l)
     {
-      struct cleanup *script_chain;
-
       annotate_field (9);
-      script_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "script");
+      ui_out_emit_tuple tuple_emitter (uiout, "script");
       print_command_lines (uiout, l, 4);
-      do_cleanups (script_chain);
     }
 
   if (is_tracepoint (b))
@@ -6679,13 +6676,13 @@ print_one_breakpoint (struct breakpoint *b,
                      struct bp_location **last_loc, 
                      int allflag)
 {
-  struct cleanup *bkpt_chain;
   struct ui_out *uiout = current_uiout;
 
-  bkpt_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "bkpt");
+  {
+    ui_out_emit_tuple tuple_emitter (uiout, "bkpt");
 
-  print_one_breakpoint_location (b, NULL, 0, last_loc, allflag);
-  do_cleanups (bkpt_chain);
+    print_one_breakpoint_location (b, NULL, 0, last_loc, allflag);
+  }
 
   /* If this breakpoint has custom print function,
      it's already printed.  Otherwise, print individual
@@ -6708,10 +6705,8 @@ print_one_breakpoint (struct breakpoint *b,
 
          for (loc = b->loc; loc; loc = loc->next, ++n)
            {
-             struct cleanup *inner2 =
-               make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+             ui_out_emit_tuple tuple_emitter (uiout, NULL);
              print_one_breakpoint_location (b, loc, n, last_loc, allflag);
-             do_cleanups (inner2);
            }
        }
     }
index 218e1f36d8fc4db11d304203f06acf4e17abc8f1..fb0bd490f50ae9d8855b780d7467f3925089c579 100644 (file)
@@ -664,32 +664,27 @@ do_show_command (const char *arg, int from_tty, struct cmd_list_element *c)
 void
 cmd_show_list (struct cmd_list_element *list, int from_tty, const char *prefix)
 {
-  struct cleanup *showlist_chain;
   struct ui_out *uiout = current_uiout;
 
-  showlist_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "showlist");
+  ui_out_emit_tuple tuple_emitter (uiout, "showlist");
   for (; list != NULL; list = list->next)
     {
       /* If we find a prefix, run its list, prefixing our output by its
          prefix (with "show " skipped).  */
       if (list->prefixlist && !list->abbrev_flag)
        {
-         struct cleanup *optionlist_chain
-           = make_cleanup_ui_out_tuple_begin_end (uiout, "optionlist");
+         ui_out_emit_tuple optionlist_emitter (uiout, "optionlist");
          const char *new_prefix = strstr (list->prefixname, "show ") + 5;
 
          if (uiout->is_mi_like_p ())
            uiout->field_string ("prefix", new_prefix);
          cmd_show_list (*list->prefixlist, from_tty, new_prefix);
-         /* Close the tuple.  */
-         do_cleanups (optionlist_chain);
        }
       else
        {
          if (list->theclass != no_set_class)
            {
-             struct cleanup *option_chain
-               = make_cleanup_ui_out_tuple_begin_end (uiout, "option");
+             ui_out_emit_tuple option_emitter (uiout, "option");
 
              uiout->text (prefix);
              uiout->field_string ("name", list->name);
@@ -698,12 +693,8 @@ cmd_show_list (struct cmd_list_element *list, int from_tty, const char *prefix)
                do_show_command ((char *) NULL, from_tty, list);
              else
                cmd_func (list, NULL, from_tty);
-             /* Close the tuple.  */
-             do_cleanups (option_chain);
            }
        }
     }
-  /* Close the tuple.  */
-  do_cleanups (showlist_chain);
 }
 
index 510dfd0f484d968db9fe9bbdc36409858025e019..b72f2272a2fd4b13b711c18b77d1ecef6900aa71 100644 (file)
@@ -314,12 +314,10 @@ static void
 list_cp_abis (int from_tty)
 {
   struct ui_out *uiout = current_uiout;
-  struct cleanup *cleanup_chain;
   int i;
 
   uiout->text ("The available C++ ABIs are:\n");
-  cleanup_chain = make_cleanup_ui_out_tuple_begin_end (uiout,
-                                                      "cp-abi-list");
+  ui_out_emit_tuple tuple_emitter (uiout, "cp-abi-list");
   for (i = 0; i < num_cp_abis; i++)
     {
       char pad[14];
@@ -337,7 +335,6 @@ list_cp_abis (int from_tty)
       uiout->field_string ("doc", cp_abis[i]->doc);
       uiout->text ("\n");
     }
-  do_cleanups (cleanup_chain);
 }
 
 /* Set the current C++ ABI, or display the list of options if no
index 734db2b1c8296b284b56c7f9a46a92c3ea10bf05..fde52c392b26f7fdb1264c21a4c310d12812f6bd 100644 (file)
@@ -437,18 +437,15 @@ do_mixed_source_and_assembly_deprecated
                  for (; next_line < mle[i].line; next_line++)
                    {
                      struct cleanup *ui_out_list_chain_line;
-                     struct cleanup *ui_out_tuple_chain_line;
                      
-                     ui_out_tuple_chain_line
-                       = make_cleanup_ui_out_tuple_begin_end (uiout,
-                                                              "src_and_asm_line");
+                     ui_out_emit_tuple tuple_emitter (uiout,
+                                                      "src_and_asm_line");
                      print_source_lines (symtab, next_line, next_line + 1,
                                          psl_flags);
                      ui_out_list_chain_line
                        = make_cleanup_ui_out_list_begin_end (uiout,
                                                              "line_asm_insn");
                      do_cleanups (ui_out_list_chain_line);
-                     do_cleanups (ui_out_tuple_chain_line);
                    }
                  /* Print the last line and leave list open for
                     asm instructions to be added.  */
@@ -680,22 +677,18 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch,
                 a bunch of line tuples with no asm entries.  */
              int l;
              struct cleanup *ui_out_list_chain_line;
-             struct cleanup *ui_out_tuple_chain_line;
 
              gdb_assert (sal.symtab != NULL);
              for (l = start_preceding_line_to_display;
                   l < end_preceding_line_to_display;
                   ++l)
                {
-                 ui_out_tuple_chain_line
-                   = make_cleanup_ui_out_tuple_begin_end (uiout,
-                                                          "src_and_asm_line");
+                 ui_out_emit_tuple tuple_emitter (uiout, "src_and_asm_line");
                  print_source_lines (sal.symtab, l, l + 1, psl_flags);
                  ui_out_list_chain_line
                    = make_cleanup_ui_out_list_begin_end (uiout,
                                                          "line_asm_insn");
                  do_cleanups (ui_out_list_chain_line);
-                 do_cleanups (ui_out_tuple_chain_line);
                }
            }
          ui_out_tuple_chain
index 37cf6e2754c317995caeecec5b63bf7ba4d1247f..2230127761c86d03b8de8929cd9bc0a58ff47115 100644 (file)
@@ -961,14 +961,12 @@ print_one_bfd (void **slot, void *data)
   bfd *abfd = (struct bfd *) *slot;
   struct gdb_bfd_data *gdata = (struct gdb_bfd_data *) bfd_usrdata (abfd);
   struct ui_out *uiout = (struct ui_out *) data;
-  struct cleanup *inner;
 
-  inner = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+  ui_out_emit_tuple tuple_emitter (uiout, NULL);
   uiout->field_int ("refcount", gdata->refc);
   uiout->field_string ("addr", host_address_to_string (abfd));
   uiout->field_string ("filename", bfd_get_filename (abfd));
   uiout->text ("\n");
-  do_cleanups (inner);
 
   return 1;
 }
index e85859f6d3e9af5d3e1afbe8e485574fed9c9550..db23df96fa35812575ebf4f097525641e4d3f0ae 100644 (file)
@@ -587,12 +587,10 @@ print_inferior (struct ui_out *uiout, char *requested_inferiors)
   uiout->table_body ();
   for (inf = inferior_list; inf; inf = inf->next)
     {
-      struct cleanup *chain2;
-
       if (!number_is_in_list (requested_inferiors, inf->num))
        continue;
 
-      chain2 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+      ui_out_emit_tuple tuple_emitter (uiout, NULL);
 
       if (inf == current_inferior ())
        uiout->field_string ("current", "*");
@@ -623,7 +621,6 @@ print_inferior (struct ui_out *uiout, char *requested_inferiors)
        }
 
       uiout->text ("\n");
-      do_cleanups (chain2);
     }
 
   do_cleanups (old_chain);
index eda3d7bff16903e8162023736ec2faca88f6a820..86254f87242cab1757298ab1d994f185903e2284 100644 (file)
@@ -1636,7 +1636,7 @@ info_auto_load_libthread_db (char *args, int from_tty)
   /* Note I is incremented inside the cycle, not at its end.  */
   for (i = 0; i < info_count;)
     {
-      struct cleanup *chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+      ui_out_emit_tuple tuple_emitter (uiout, NULL);
       char *pids_end;
 
       info = array[i];
@@ -1661,7 +1661,6 @@ info_auto_load_libthread_db (char *args, int from_tty)
       uiout->field_string ("pids", pids);
 
       uiout->text ("\n");
-      do_cleanups (chain);
     }
 
   do_cleanups (back_to);
index 1a96d6feed2be5ff3f3e26cdc90446ec253402e1..7da4f9095cd583dc4d9f860dbf310df57cc18b79 100644 (file)
@@ -59,13 +59,9 @@ mi_cmd_info_ada_exceptions (const char *command, char **argv, int argc)
 
   for (ix = 0; VEC_iterate(ada_exc_info, exceptions, ix, info); ix++)
     {
-      struct cleanup *sub_chain;
-
-      sub_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+      ui_out_emit_tuple tuple_emitter (uiout, NULL);
       uiout->field_string ("name", info->name);
       uiout->field_core_addr ("address", gdbarch, info->addr);
-
-      do_cleanups (sub_chain);
     }
 
   do_cleanups (old_chain);
@@ -79,7 +75,6 @@ mi_cmd_info_gdb_mi_command (const char *command, char **argv, int argc)
   const char *cmd_name;
   struct mi_cmd *cmd;
   struct ui_out *uiout = current_uiout;
-  struct cleanup *old_chain;
 
   /* This command takes exactly one argument.  */
   if (argc != 1)
@@ -95,9 +90,8 @@ mi_cmd_info_gdb_mi_command (const char *command, char **argv, int argc)
 
   cmd = mi_lookup (cmd_name);
 
-  old_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "command");
+  ui_out_emit_tuple tuple_emitter (uiout, "command");
   uiout->field_string ("exists", cmd != NULL ? "true" : "false");
-  do_cleanups (old_chain);
 }
 
 void
index bd910337486bab27c97474963794b01dd0d399bf..f288817b5c7ba8c77659d31d82a9da776e7486ac 100644 (file)
@@ -387,13 +387,10 @@ mi_cmd_stack_list_args (const char *command, char **argv, int argc)
           fi && (i <= frame_high || frame_high == -1);
           i++, fi = get_prev_frame (fi))
        {
-         struct cleanup *cleanup_frame;
-
          QUIT;
-         cleanup_frame = make_cleanup_ui_out_tuple_begin_end (uiout, "frame");
+         ui_out_emit_tuple tuple_emitter (uiout, "frame");
          uiout->field_int ("level", i);
          list_args_or_locals (arguments, print_values, fi, skip_unavailable);
-         do_cleanups (cleanup_frame);
        }
     }
   do_cleanups (cleanup_stack_args);
index 78ef8e00a74c6c49990827de110ec267e247dd73..0a4ed62f89de50ef8bc4bfe27d5ede6db666d93f 100644 (file)
@@ -421,11 +421,9 @@ mi_cmd_var_list_children (const char *command, char **argv, int argc)
           ix < to && VEC_iterate (varobj_p, children, ix, child);
           ++ix)
        {
-         struct cleanup *cleanup_child;
+         ui_out_emit_tuple child_emitter (uiout, "child");
 
-         cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
          print_varobj (child, print_values, 1 /* print expression */);
-         do_cleanups (cleanup_child);
        }
       do_cleanups (cleanup_children);
     }
@@ -778,12 +776,8 @@ varobj_update_one (struct varobj *var, enum print_values print_values,
          cleanup = make_cleanup_ui_out_list_begin_end (uiout, "new_children");
          for (j = 0; VEC_iterate (varobj_p, r->newobj, j, child); ++j)
            {
-             struct cleanup *cleanup_child;
-
-             cleanup_child
-               = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+             ui_out_emit_tuple tuple_emitter (uiout, NULL);
              print_varobj (child, print_values, 1 /* print_expression */);
-             do_cleanups (cleanup_child);
            }
 
          do_cleanups (cleanup);
index c3e7bf77a5b8747fbecd47b191d976faebdf76c5..d309ba3fbfd6f64a896fd1893c4ed111ba8affae 100644 (file)
@@ -660,8 +660,7 @@ print_one_inferior (struct inferior *inferior, void *xdata)
                  compare_positive_ints))
     {
       struct collect_cores_data data;
-      struct cleanup *back_to
-       = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+      ui_out_emit_tuple tuple_emitter (uiout, NULL);
 
       uiout->field_fmt ("id", "i%d", inferior->num);
       uiout->field_string ("type", "process");
@@ -706,8 +705,6 @@ print_one_inferior (struct inferior *inferior, void *xdata)
 
       if (top_data->recurse)
        print_thread_info (uiout, NULL, inferior->pid);
-
-      do_cleanups (back_to);
     }
 
   return 0;
@@ -831,8 +828,6 @@ list_available_thread_groups (VEC (int) *ids, int recurse)
                    ix_items, item);
        ix_items++)
     {
-      struct cleanup *back_to;
-
       const char *pid = get_osdata_column (item, "pid");
       const char *cmd = get_osdata_column (item, "command");
       const char *user = get_osdata_column (item, "user");
@@ -849,7 +844,7 @@ list_available_thread_groups (VEC (int) *ids, int recurse)
        continue;
 
 
-      back_to = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+      ui_out_emit_tuple tuple_emitter (uiout, NULL);
 
       uiout->field_fmt ("id", "%s", pid);
       uiout->field_string ("type", "process");
@@ -875,21 +870,16 @@ list_available_thread_groups (VEC (int) *ids, int recurse)
                   VEC_iterate (osdata_item_s, children, ix_child, child);
                   ++ix_child)
                {
-                 struct cleanup *back_to_2 =
-                   make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+                 ui_out_emit_tuple tuple_emitter (uiout, NULL);
                  const char *tid = get_osdata_column (child, "tid");
                  const char *tcore = get_osdata_column (child, "core");
 
                  uiout->field_string ("id", tid);
                  if (tcore)
                    uiout->field_string ("core", tcore);
-
-                 do_cleanups (back_to_2);
                }
            }
        }
-
-      do_cleanups (back_to);
     }
 
   do_cleanups (cleanup);
@@ -1257,13 +1247,12 @@ output_register (struct frame_info *frame, int regnum, int format,
 {
   struct ui_out *uiout = current_uiout;
   struct value *val = value_of_register (regnum, frame);
-  struct cleanup *tuple_cleanup;
   struct value_print_options opts;
 
   if (skip_unavailable && !value_entirely_available (val))
     return;
 
-  tuple_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+  ui_out_emit_tuple tuple_emitter (uiout, NULL);
   uiout->field_int ("number", regnum);
 
   if (format == 'N')
@@ -1280,8 +1269,6 @@ output_register (struct frame_info *frame, int regnum, int format,
             value_embedded_offset (val), 0,
             &stb, 0, val, &opts, current_language);
   uiout->field_stream ("value", stb);
-
-  do_cleanups (tuple_cleanup);
 }
 
 /* Write given values into registers. The registers and values are
@@ -1520,11 +1507,10 @@ mi_cmd_data_read_memory (const char *command, char **argv, int argc)
       {
        int col;
        int col_byte;
-       struct cleanup *cleanup_tuple;
        struct cleanup *cleanup_list_data;
        struct value_print_options opts;
 
-       cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+       ui_out_emit_tuple tuple_emitter (uiout, NULL);
        uiout->field_core_addr ("addr", gdbarch, addr + row_byte);
        /* ui_out_field_core_addr_symbolic (uiout, "saddr", addr +
           row_byte); */
@@ -1564,7 +1550,6 @@ mi_cmd_data_read_memory (const char *command, char **argv, int argc)
              }
            uiout->field_stream ("ascii", stream);
          }
-       do_cleanups (cleanup_tuple);
       }
     do_cleanups (cleanup_list);
   }
@@ -1629,7 +1614,7 @@ mi_cmd_data_read_memory_bytes (const char *command, char **argv, int argc)
        VEC_iterate (memory_read_result_s, result, ix, read_result);
        ++ix)
     {
-      struct cleanup *t = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+      ui_out_emit_tuple tuple_emitter (uiout, NULL);
       char *data, *p;
       int i;
       int alloc_len;
@@ -1649,7 +1634,6 @@ mi_cmd_data_read_memory_bytes (const char *command, char **argv, int argc)
        }
       uiout->field_string ("contents", data);
       xfree (data);
-      do_cleanups (t);
     }
   do_cleanups (cleanups);
 }
@@ -2385,19 +2369,18 @@ mi_load_progress (const char *section_name,
                 strcmp (previous_sect_name, section_name) : 1);
   if (new_section)
     {
-      struct cleanup *cleanup_tuple;
-
       xfree (previous_sect_name);
       previous_sect_name = xstrdup (section_name);
 
       if (current_token)
        fputs_unfiltered (current_token, mi->raw_stdout);
       fputs_unfiltered ("+download", mi->raw_stdout);
-      cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
-      uiout->field_string ("section", section_name);
-      uiout->field_int ("section-size", total_section);
-      uiout->field_int ("total-size", grand_total);
-      do_cleanups (cleanup_tuple);
+      {
+       ui_out_emit_tuple tuple_emitter (uiout, NULL);
+       uiout->field_string ("section", section_name);
+       uiout->field_int ("section-size", total_section);
+       uiout->field_int ("total-size", grand_total);
+      }
       mi_out_put (uiout, mi->raw_stdout);
       fputs_unfiltered ("\n", mi->raw_stdout);
       gdb_flush (mi->raw_stdout);
@@ -2406,19 +2389,18 @@ mi_load_progress (const char *section_name,
   steady_clock::time_point time_now = steady_clock::now ();
   if (time_now - last_update > milliseconds (500))
     {
-      struct cleanup *cleanup_tuple;
-
       last_update = time_now;
       if (current_token)
        fputs_unfiltered (current_token, mi->raw_stdout);
       fputs_unfiltered ("+download", mi->raw_stdout);
-      cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
-      uiout->field_string ("section", section_name);
-      uiout->field_int ("section-sent", sent_so_far);
-      uiout->field_int ("section-size", total_section);
-      uiout->field_int ("total-sent", total_sent);
-      uiout->field_int ("total-size", grand_total);
-      do_cleanups (cleanup_tuple);
+      {
+       ui_out_emit_tuple tuple_emitter (uiout, NULL);
+       uiout->field_string ("section", section_name);
+       uiout->field_int ("section-sent", sent_so_far);
+       uiout->field_int ("section-size", total_section);
+       uiout->field_int ("total-sent", total_sent);
+       uiout->field_int ("total-size", grand_total);
+      }
       mi_out_put (uiout, mi->raw_stdout);
       fputs_unfiltered ("\n", mi->raw_stdout);
       gdb_flush (mi->raw_stdout);
@@ -2888,12 +2870,11 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc)
 
     for (i = 0; VEC_iterate (int, tinfo->tvars, i, tvar); i++)
       {
-       struct cleanup *cleanup_child;
        struct trace_state_variable *tsv;
 
        tsv = find_trace_state_variable_by_number (tvar);
 
-       cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+       ui_out_emit_tuple tuple_emitter (uiout, NULL);
 
        if (tsv != NULL)
          {
@@ -2911,8 +2892,6 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc)
            uiout->field_skip ("name");
            uiout->field_skip ("current");
          }
-
-       do_cleanups (cleanup_child);
       }
 
     do_cleanups (list_cleanup);
index 6614447cb9449283cea491a4104a274bd996d67c..f9e464dfcb6718e49c6e4fdbeda7d7167e3ae6ea 100644 (file)
@@ -33,7 +33,7 @@ mi_cmd_symbol_list_lines (const char *command, char **argv, int argc)
   char *filename;
   struct symtab *s;
   int i;
-  struct cleanup *cleanup_stack, *cleanup_tuple;
+  struct cleanup *cleanup_stack;
   struct ui_out *uiout = current_uiout;
 
   if (argc != 1)
@@ -55,10 +55,9 @@ mi_cmd_symbol_list_lines (const char *command, char **argv, int argc)
   if (SYMTAB_LINETABLE (s) != NULL && SYMTAB_LINETABLE (s)->nitems > 0)
     for (i = 0; i < SYMTAB_LINETABLE (s)->nitems; i++)
     {
-      cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+      ui_out_emit_tuple tuple_emitter (uiout, NULL);
       uiout->field_core_addr ("pc", gdbarch, SYMTAB_LINETABLE (s)->item[i].pc);
       uiout->field_int ("line", SYMTAB_LINETABLE (s)->item[i].line);
-      do_cleanups (cleanup_tuple);
     }
 
   do_cleanups (cleanup_stack);
index 84c4ed7282c0f175595dde2ef03fa993a6287699..b9014dddf278a0d5e61b35bf098278ecb1757124 100644 (file)
@@ -381,27 +381,26 @@ info_osdata (const char *type)
                        ix_items, item);
           ix_items++)
        {
-         struct cleanup *old_chain;
          int ix_cols;
          struct osdata_column *col;
 
-         old_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "item");
+        {
+          ui_out_emit_tuple tuple_emitter (uiout, "item");
 
-         for (ix_cols = 0;
-              VEC_iterate (osdata_column_s, item->columns,
-                           ix_cols, col);
-              ix_cols++)
-          {
-            char col_name[32];
+          for (ix_cols = 0;
+               VEC_iterate (osdata_column_s, item->columns,
+                            ix_cols, col);
+               ix_cols++)
+            {
+              char col_name[32];
 
-            if (ix_cols == col_to_skip)
-              continue;
+              if (ix_cols == col_to_skip)
+                continue;
 
-            snprintf (col_name, 32, "col%d", ix_cols);
-            uiout->field_string (col_name, col->value);
-          }
-        
-         do_cleanups (old_chain);
+              snprintf (col_name, 32, "col%d", ix_cols);
+              uiout->field_string (col_name, col->value);
+            }
+        }
 
          uiout->text ("\n");
        }
index c147810354ede3f384462478d41ef71a4fbb6f52..e65e0313fe64993cc3872f40c5888e8845ff8624 100644 (file)
@@ -678,10 +678,9 @@ info_probes_for_ops (const char *arg, int from_tty,
 
   for (i = 0; VEC_iterate (bound_probe_s, probes, i, probe); ++i)
     {
-      struct cleanup *inner;
       const char *probe_type = probe->probe->pops->type_name (probe->probe);
 
-      inner = make_cleanup_ui_out_tuple_begin_end (current_uiout, "probe");
+      ui_out_emit_tuple tuple_emitter (current_uiout, "probe");
 
       current_uiout->field_string ("type",probe_type);
       current_uiout->field_string ("provider", probe->probe->provider);
@@ -708,8 +707,6 @@ info_probes_for_ops (const char *arg, int from_tty,
       current_uiout->field_string ("object",
                           objfile_name (probe->objfile));
       current_uiout->text ("\n");
-
-      do_cleanups (inner);
     }
 
   any_found = !VEC_empty (bound_probe_s, probes);
index 4efbafec2a6ea400464986912dcda02a67ea40b1..b37701eb442a8d41fb46f770194c8efa8461f466 100644 (file)
@@ -310,14 +310,13 @@ print_program_space (struct ui_out *uiout, int requested)
 
   ALL_PSPACES (pspace)
     {
-      struct cleanup *chain2;
       struct inferior *inf;
       int printed_header;
 
       if (requested != -1 && requested != pspace->num)
        continue;
 
-      chain2 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+      ui_out_emit_tuple tuple_emitter (uiout, NULL);
 
       if (pspace == current_program_space)
        uiout->field_string ("current", "*");
@@ -354,7 +353,6 @@ print_program_space (struct ui_out *uiout, int requested)
          }
 
       uiout->text ("\n");
-      do_cleanups (chain2);
     }
 
   do_cleanups (old_chain);
index 61fba1e46f3272228908e0b3b10f96601076337b..d4f1bcfe8f09b5a748b18e045dd651c0b3ec1d49 100644 (file)
@@ -725,13 +725,11 @@ record_btrace_insn_history (struct target_ops *self, int size, int flags)
   struct btrace_thread_info *btinfo;
   struct btrace_insn_history *history;
   struct btrace_insn_iterator begin, end;
-  struct cleanup *uiout_cleanup;
   struct ui_out *uiout;
   unsigned int context, covered;
 
   uiout = current_uiout;
-  uiout_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout,
-                                                      "insn history");
+  ui_out_emit_tuple tuple_emitter (uiout, "insn history");
   context = abs (size);
   if (context == 0)
     error (_("Bad record instruction-history-size."));
@@ -800,7 +798,6 @@ record_btrace_insn_history (struct target_ops *self, int size, int flags)
     }
 
   btrace_set_insn_history (btinfo, &begin, &end);
-  do_cleanups (uiout_cleanup);
 }
 
 /* The to_insn_history_range method of target record-btrace.  */
@@ -812,14 +809,12 @@ record_btrace_insn_history_range (struct target_ops *self,
   struct btrace_thread_info *btinfo;
   struct btrace_insn_history *history;
   struct btrace_insn_iterator begin, end;
-  struct cleanup *uiout_cleanup;
   struct ui_out *uiout;
   unsigned int low, high;
   int found;
 
   uiout = current_uiout;
-  uiout_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout,
-                                                      "insn history");
+  ui_out_emit_tuple tuple_emitter (uiout, "insn history");
   low = from;
   high = to;
 
@@ -852,8 +847,6 @@ record_btrace_insn_history_range (struct target_ops *self,
 
   btrace_insn_history (uiout, btinfo, &begin, &end, flags);
   btrace_set_insn_history (btinfo, &begin, &end);
-
-  do_cleanups (uiout_cleanup);
 }
 
 /* The to_insn_history_from method of target record-btrace.  */
@@ -1085,14 +1078,12 @@ record_btrace_call_history (struct target_ops *self, int size, int int_flags)
   struct btrace_thread_info *btinfo;
   struct btrace_call_history *history;
   struct btrace_call_iterator begin, end;
-  struct cleanup *uiout_cleanup;
   struct ui_out *uiout;
   unsigned int context, covered;
   record_print_flags flags = (enum record_print_flag) int_flags;
 
   uiout = current_uiout;
-  uiout_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout,
-                                                      "insn history");
+  ui_out_emit_tuple tuple_emitter (uiout, "insn history");
   context = abs (size);
   if (context == 0)
     error (_("Bad record function-call-history-size."));
@@ -1164,7 +1155,6 @@ record_btrace_call_history (struct target_ops *self, int size, int int_flags)
     }
 
   btrace_set_call_history (btinfo, &begin, &end);
-  do_cleanups (uiout_cleanup);
 }
 
 /* The to_call_history_range method of target record-btrace.  */
@@ -1177,15 +1167,13 @@ record_btrace_call_history_range (struct target_ops *self,
   struct btrace_thread_info *btinfo;
   struct btrace_call_history *history;
   struct btrace_call_iterator begin, end;
-  struct cleanup *uiout_cleanup;
   struct ui_out *uiout;
   unsigned int low, high;
   int found;
   record_print_flags flags = (enum record_print_flag) int_flags;
 
   uiout = current_uiout;
-  uiout_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout,
-                                                      "func history");
+  ui_out_emit_tuple tuple_emitter (uiout, "func history");
   low = from;
   high = to;
 
@@ -1218,8 +1206,6 @@ record_btrace_call_history_range (struct target_ops *self,
 
   btrace_call_history (uiout, btinfo, &begin, &end, flags);
   btrace_set_call_history (btinfo, &begin, &end);
-
-  do_cleanups (uiout_cleanup);
 }
 
 /* The to_call_history_from method of target record-btrace.  */
index 694897df1d6c39e3fb061d14cf0555bd71554dad..2cd98502f76502087348478e67d9001048a69f29 100644 (file)
@@ -13799,11 +13799,10 @@ show_remote_cmd (char *args, int from_tty)
 {
   /* We can't just use cmd_show_list here, because we want to skip
      the redundant "show remote Z-packet" and the legacy aliases.  */
-  struct cleanup *showlist_chain;
   struct cmd_list_element *list = remote_show_cmdlist;
   struct ui_out *uiout = current_uiout;
 
-  showlist_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "showlist");
+  ui_out_emit_tuple tuple_emitter (uiout, "showlist");
   for (; list != NULL; list = list->next)
     if (strcmp (list->name, "Z-packet") == 0)
       continue;
@@ -13813,8 +13812,7 @@ show_remote_cmd (char *args, int from_tty)
       continue;
     else
       {
-       struct cleanup *option_chain
-         = make_cleanup_ui_out_tuple_begin_end (uiout, "option");
+       ui_out_emit_tuple option_emitter (uiout, "option");
 
        uiout->field_string ("name", list->name);
        uiout->text (":  ");
@@ -13822,12 +13820,7 @@ show_remote_cmd (char *args, int from_tty)
          do_show_command (NULL, from_tty, list);
        else
          cmd_func (list, NULL, from_tty);
-       /* Close the tuple.  */
-       do_cleanups (option_chain);
       }
-
-  /* Close the tuple.  */
-  do_cleanups (showlist_chain);
 }
 
 
index 26ff0006a0344e15544426bad6921e7023b08479..4bd8a9e1c280cef6c9476e6b6880692d7d9ad059 100644 (file)
@@ -395,14 +395,12 @@ skip_info (char *arg, int from_tty)
 
   ALL_SKIPLIST_ENTRIES (e)
     {
-      struct cleanup *entry_chain;
 
       QUIT;
       if (arg != NULL && !number_is_in_list (arg, e->number))
        continue;
 
-      entry_chain = make_cleanup_ui_out_tuple_begin_end (current_uiout,
-                                                        "blklst-entry");
+      ui_out_emit_tuple tuple_emitter (current_uiout, "blklst-entry");
       current_uiout->field_int ("number", e->number); /* 1 */
 
       if (e->enabled)
@@ -426,7 +424,6 @@ skip_info (char *arg, int from_tty)
        "function", e->function ? e->function : "<none>"); /* 6 */
 
       current_uiout->text ("\n");
-      do_cleanups (entry_chain);
     }
 
   do_cleanups (tbl_chain);
index af94383de47e4eab4613ea40a80da0f102e76828..491c18a685b0c3531a55cd9685e9ca2c3a8b8b6e 100644 (file)
@@ -1090,14 +1090,12 @@ info_sharedlibrary_command (char *pattern, int from_tty)
 
   ALL_SO_LIBS (so)
     {
-      struct cleanup *lib_cleanup;
-
       if (! so->so_name[0])
        continue;
       if (pattern && ! re_exec (so->so_name))
        continue;
 
-      lib_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "lib");
+      ui_out_emit_tuple tuple_emitter (uiout, "lib");
 
       if (so->addr_high != 0)
        {
@@ -1123,8 +1121,6 @@ info_sharedlibrary_command (char *pattern, int from_tty)
       uiout->field_string ("name", so->so_name);
 
       uiout->text ("\n");
-
-      do_cleanups (lib_cleanup);
     }
 
   do_cleanups (table_cleanup);
index 1bad88e324745e43e947672a4c3be36c2fbd5675..32acca1741b99cd96494ccbbc13edda02db1ec7a 100644 (file)
@@ -805,8 +805,7 @@ print_frame_info (struct frame_info *frame, int print_level,
       || get_frame_type (frame) == SIGTRAMP_FRAME
       || get_frame_type (frame) == ARCH_FRAME)
     {
-      struct cleanup *uiout_cleanup
-       = make_cleanup_ui_out_tuple_begin_end (uiout, "frame");
+      ui_out_emit_tuple tuple_emitter (uiout, "frame");
 
       annotate_frame_begin (print_level ? frame_relative_level (frame) : 0,
                            gdbarch, get_frame_pc (frame));
@@ -851,7 +850,6 @@ print_frame_info (struct frame_info *frame, int print_level,
        do_gdb_disassembly (get_frame_arch (frame), 1,
                            get_frame_pc (frame), get_frame_pc (frame) + 1);
 
-      do_cleanups (uiout_cleanup);
       return;
     }
 
index 7ce65ff4453c936fddc0b229373f8adff9e2947c..d08f414327330c7fd6243943bed3020d17d9ac6e 100644 (file)
@@ -718,26 +718,25 @@ do_captured_list_thread_ids (struct ui_out *uiout, void *arg)
 {
   struct thread_info *tp;
   int num = 0;
-  struct cleanup *cleanup_chain;
   int current_thread = -1;
 
   update_thread_list ();
 
-  cleanup_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "thread-ids");
-
-  for (tp = thread_list; tp; tp = tp->next)
-    {
-      if (tp->state == THREAD_EXITED)
-       continue;
+  {
+    ui_out_emit_tuple tuple_emitter (uiout, "thread-ids");
 
-      if (tp->ptid == inferior_ptid)
-       current_thread = tp->global_num;
+    for (tp = thread_list; tp; tp = tp->next)
+      {
+       if (tp->state == THREAD_EXITED)
+         continue;
 
-      num++;
-      uiout->field_int ("thread-id", tp->global_num);
-    }
+       if (tp->ptid == inferior_ptid)
+         current_thread = tp->global_num;
 
-  do_cleanups (cleanup_chain);
+       num++;
+       uiout->field_int ("thread-id", tp->global_num);
+      }
+  }
 
   if (current_thread != -1)
     uiout->field_int ("current-thread-id", current_thread);
@@ -1299,14 +1298,13 @@ print_thread_info_1 (struct ui_out *uiout, char *requested_threads,
 
   ALL_THREADS_BY_INFERIOR (inf, tp)
     {
-      struct cleanup *chain2;
       int core;
 
       if (!should_print_thread (requested_threads, default_inf_num,
                                global_ids, pid, tp))
        continue;
 
-      chain2 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+      ui_out_emit_tuple tuple_emitter (uiout, NULL);
 
       if (!uiout->is_mi_like_p ())
        {
@@ -1386,8 +1384,6 @@ print_thread_info_1 (struct ui_out *uiout, char *requested_threads,
       core = target_core_of_thread (tp->ptid);
       if (uiout->is_mi_like_p () && core != -1)
        uiout->field_int ("core", core);
-
-      do_cleanups (chain2);
     }
 
   /* Restores the current thread and the frame selected before