From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92716 invoked by alias); 9 Sep 2017 15:35:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 92481 invoked by uid 89); 9 Sep 2017 15:35:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=inbound, sal, 105387, 20917 X-HELO: gproxy8-pub.mail.unifiedlayer.com Received: from gproxy8-pub.mail.unifiedlayer.com (HELO gproxy8-pub.mail.unifiedlayer.com) (67.222.33.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Sep 2017 15:35:55 +0000 Received: from cmgw4 (unknown [10.0.90.85]) by gproxy8.mail.unifiedlayer.com (Postfix) with ESMTP id 82B681AB141 for ; Sat, 9 Sep 2017 09:35:53 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id 7Tbq1w00X2f2jeq01Tbt7g; Sat, 09 Sep 2017 09:35:53 -0600 X-Authority-Analysis: v=2.2 cv=OZLoNlbY c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=2JCJgTwv5E4A:10 a=zstS-IiYAAAA:8 a=KTLctk_1uTXn4bGLT8UA:9 a=_52RmmPx3xLYkx97:21 a=wKtUsZYNOlgLFetU:21 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-76-94.hlrn.qwest.net ([75.166.76.94]:59756 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dqhnR-00381I-Il; Sat, 09 Sep 2017 09:35:50 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 3/7] Use ui_out_emit_tuple in more places Date: Sat, 09 Sep 2017 15:35:00 -0000 Message-Id: <20170909153540.15008-4-tom@tromey.com> In-Reply-To: <20170909153540.15008-1-tom@tromey.com> References: <20170909153540.15008-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dqhnR-00381I-Il X-Source-Sender: 75-166-76-94.hlrn.qwest.net (bapiya.Home) [75.166.76.94]:59756 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes X-SW-Source: 2017-09/txt/msg00231.txt.bz2 This changes more places to use ui_out_emit_tuple, removing cleanups. ChangeLog 2017-09-09 Tom Tromey * target.c (flash_erase_command): Use ui_out_emit_tuple. * stack.c (print_frame): Use ui_out_emit_tuple. * spu-tdep.c (info_spu_event_command): Use ui_out_emit_tuple. (info_spu_mailbox_command, info_spu_dma_command) (info_spu_proxydma_command): Likewise. * mi/mi-main.c (mi_cmd_trace_frame_collected): Use ui_out_emit_tuple, gdb::byte_vector, gdb;:unique_xmalloc_ptr. * mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Use ui_out_emit_tuple. * breakpoint.c (print_it_watchpoint): Use ui_out_emit_tuple. --- gdb/ChangeLog | 13 ++++ gdb/breakpoint.c | 14 ++--- gdb/mi/mi-cmd-file.c | 5 +- gdb/mi/mi-main.c | 20 +++--- gdb/spu-tdep.c | 24 ++----- gdb/stack.c | 174 +++++++++++++++++++++++++-------------------------- gdb/target.c | 5 +- 7 files changed, 121 insertions(+), 134 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4c9c419..a52b1fb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,18 @@ 2017-09-09 Tom Tromey + * target.c (flash_erase_command): Use ui_out_emit_tuple. + * stack.c (print_frame): Use ui_out_emit_tuple. + * spu-tdep.c (info_spu_event_command): Use ui_out_emit_tuple. + (info_spu_mailbox_command, info_spu_dma_command) + (info_spu_proxydma_command): Likewise. + * mi/mi-main.c (mi_cmd_trace_frame_collected): Use + ui_out_emit_tuple, gdb::byte_vector, gdb;:unique_xmalloc_ptr. + * mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Use + ui_out_emit_tuple. + * breakpoint.c (print_it_watchpoint): Use ui_out_emit_tuple. + +2017-09-09 Tom Tromey + * ui-out.h (make_cleanup_ui_out_table_begin_end): Remove. (class ui_out_emit_table): Update comment. * ui-out.c (do_cleanup_table_end) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 778a011..2916470 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -82,6 +82,7 @@ #include #include "progspace-and-thread.h" #include "common/array-view.h" +#include "common/gdb_optional.h" /* Enums for exception-handling support. */ enum exception_event_kind @@ -10538,7 +10539,6 @@ works_in_software_mode_watchpoint (const struct breakpoint *b) static enum print_stop_action print_it_watchpoint (bpstat bs) { - struct cleanup *old_chain; struct breakpoint *b; enum print_stop_action result; struct watchpoint *w; @@ -10549,13 +10549,12 @@ print_it_watchpoint (bpstat bs) b = bs->breakpoint_at; w = (struct watchpoint *) b; - old_chain = make_cleanup (null_cleanup, NULL); - annotate_watchpoint (b->number); maybe_print_thread_hit_breakpoint (uiout); string_file stb; + gdb::optional tuple_emitter; switch (b->type) { case bp_watchpoint: @@ -10564,7 +10563,7 @@ print_it_watchpoint (bpstat bs) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER)); mention (b); - make_cleanup_ui_out_tuple_begin_end (uiout, "value"); + tuple_emitter.emplace (uiout, "value"); uiout->text ("\nOld value = "); watchpoint_value_print (bs->old_val, &stb); uiout->field_stream ("old", stb); @@ -10581,7 +10580,7 @@ print_it_watchpoint (bpstat bs) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_READ_WATCHPOINT_TRIGGER)); mention (b); - make_cleanup_ui_out_tuple_begin_end (uiout, "value"); + tuple_emitter.emplace (uiout, "value"); uiout->text ("\nValue = "); watchpoint_value_print (w->val, &stb); uiout->field_stream ("value", stb); @@ -10597,7 +10596,7 @@ print_it_watchpoint (bpstat bs) ("reason", async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER)); mention (b); - make_cleanup_ui_out_tuple_begin_end (uiout, "value"); + tuple_emitter.emplace (uiout, "value"); uiout->text ("\nOld value = "); watchpoint_value_print (bs->old_val, &stb); uiout->field_stream ("old", stb); @@ -10610,7 +10609,7 @@ print_it_watchpoint (bpstat bs) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER)); - make_cleanup_ui_out_tuple_begin_end (uiout, "value"); + tuple_emitter.emplace (uiout, "value"); uiout->text ("\nValue = "); } watchpoint_value_print (w->val, &stb); @@ -10622,7 +10621,6 @@ print_it_watchpoint (bpstat bs) result = PRINT_UNKNOWN; } - do_cleanups (old_chain); return result; } diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c index 2b3522b..a39ef3b 100644 --- a/gdb/mi/mi-cmd-file.c +++ b/gdb/mi/mi-cmd-file.c @@ -153,10 +153,7 @@ mi_cmd_file_list_shared_libraries (const char *command, char **argv, int argc) if (pattern != NULL && !re_exec (so->so_name)) continue; - struct cleanup *tuple_clean_up - = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_emit_tuple tuple_emitter (uiout, NULL); mi_output_solib_attribs (uiout, so); - - do_cleanups (tuple_clean_up); } } diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index c485544..ca66a77 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2873,36 +2873,32 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc) for (i = 0; VEC_iterate (mem_range_s, available_memory, i, r); i++) { - struct cleanup *cleanup_child; - gdb_byte *data; struct gdbarch *gdbarch = target_gdbarch (); - cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_emit_tuple tuple_emitter (uiout, NULL); uiout->field_core_addr ("address", gdbarch, r->start); uiout->field_int ("length", r->length); - data = (gdb_byte *) xmalloc (r->length); - make_cleanup (xfree, data); + gdb::byte_vector data (r->length); if (memory_contents) { - if (target_read_memory (r->start, data, r->length) == 0) + if (target_read_memory (r->start, data.data (), r->length) == 0) { int m; - char *data_str, *p; + char *p; - data_str = (char *) xmalloc (r->length * 2 + 1); - make_cleanup (xfree, data_str); + gdb::unique_xmalloc_ptr data_str + ((char *) xmalloc (r->length * 2 + 1)); - for (m = 0, p = data_str; m < r->length; ++m, p += 2) + for (m = 0, p = data_str.get (); m < r->length; ++m, p += 2) sprintf (p, "%02x", data[m]); - uiout->field_string ("contents", data_str); + uiout->field_string ("contents", data_str.get ()); } else uiout->field_skip ("contents"); } - do_cleanups (cleanup_child); } do_cleanups (list_cleanup); diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c index 221f6de..6231790 100644 --- a/gdb/spu-tdep.c +++ b/gdb/spu-tdep.c @@ -2064,7 +2064,6 @@ info_spu_event_command (char *args, int from_tty) struct frame_info *frame = get_selected_frame (NULL); ULONGEST event_status = 0; ULONGEST event_mask = 0; - struct cleanup *chain; gdb_byte buf[100]; char annex[32]; LONGEST len; @@ -2091,7 +2090,7 @@ info_spu_event_command (char *args, int from_tty) buf[len] = '\0'; event_mask = strtoulst ((char *) buf, NULL, 16); - chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "SPUInfoEvent"); + ui_out_emit_tuple tuple_emitter (current_uiout, "SPUInfoEvent"); if (current_uiout->is_mi_like_p ()) { @@ -2105,8 +2104,6 @@ info_spu_event_command (char *args, int from_tty) printf_filtered (_("Event Status 0x%s\n"), phex (event_status, 4)); printf_filtered (_("Event Mask 0x%s\n"), phex (event_mask, 4)); } - - do_cleanups (chain); } static void @@ -2121,7 +2118,6 @@ info_spu_signal_command (char *args, int from_tty) ULONGEST signal2 = 0; ULONGEST signal2_type = 0; int signal2_pending = 0; - struct cleanup *chain; char annex[32]; gdb_byte buf[100]; LONGEST len; @@ -2168,7 +2164,7 @@ info_spu_signal_command (char *args, int from_tty) buf[len] = '\0'; signal2_type = strtoulst ((char *) buf, NULL, 16); - chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "SPUInfoSignal"); + ui_out_emit_tuple tuple_emitter (current_uiout, "SPUInfoSignal"); if (current_uiout->is_mi_like_p ()) { @@ -2201,8 +2197,6 @@ info_spu_signal_command (char *args, int from_tty) else printf_filtered (_("(Type Overwrite)\n")); } - - do_cleanups (chain); } static void @@ -2239,7 +2233,6 @@ info_spu_mailbox_command (char *args, int from_tty) struct frame_info *frame = get_selected_frame (NULL); struct gdbarch *gdbarch = get_frame_arch (frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - struct cleanup *chain; char annex[32]; gdb_byte buf[1024]; LONGEST len; @@ -2250,7 +2243,7 @@ info_spu_mailbox_command (char *args, int from_tty) id = get_frame_register_unsigned (frame, SPU_ID_REGNUM); - chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "SPUInfoMailbox"); + ui_out_emit_tuple tuple_emitter (current_uiout, "SPUInfoMailbox"); xsnprintf (annex, sizeof annex, "%d/mbox_info", id); len = target_read (¤t_target, TARGET_OBJECT_SPU, annex, @@ -2278,8 +2271,6 @@ info_spu_mailbox_command (char *args, int from_tty) info_spu_mailbox_list (buf, len / 4, byte_order, "wbox", "SPU Inbound Mailbox"); - - do_cleanups (chain); } static ULONGEST @@ -2475,7 +2466,6 @@ info_spu_dma_command (char *args, int from_tty) ULONGEST dma_info_status; ULONGEST dma_info_stall_and_notify; ULONGEST dma_info_atomic_command_status; - struct cleanup *chain; char annex[32]; gdb_byte buf[1024]; LONGEST len; @@ -2503,7 +2493,7 @@ info_spu_dma_command (char *args, int from_tty) dma_info_atomic_command_status = extract_unsigned_integer (buf + 32, 8, byte_order); - chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "SPUInfoDMA"); + ui_out_emit_tuple tuple_emitter (current_uiout, "SPUInfoDMA"); if (current_uiout->is_mi_like_p ()) { @@ -2542,7 +2532,6 @@ info_spu_dma_command (char *args, int from_tty) } info_spu_dma_cmdlist (buf + 40, 16, byte_order); - do_cleanups (chain); } static void @@ -2554,7 +2543,6 @@ info_spu_proxydma_command (char *args, int from_tty) ULONGEST dma_info_type; ULONGEST dma_info_mask; ULONGEST dma_info_status; - struct cleanup *chain; char annex[32]; gdb_byte buf[1024]; LONGEST len; @@ -2575,8 +2563,7 @@ info_spu_proxydma_command (char *args, int from_tty) dma_info_mask = extract_unsigned_integer (buf + 8, 8, byte_order); dma_info_status = extract_unsigned_integer (buf + 16, 8, byte_order); - chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, - "SPUInfoProxyDMA"); + ui_out_emit_tuple tuple_emitter (current_uiout, "SPUInfoProxyDMA"); if (current_uiout->is_mi_like_p ()) { @@ -2607,7 +2594,6 @@ info_spu_proxydma_command (char *args, int from_tty) } info_spu_dma_cmdlist (buf + 24, 8, byte_order); - do_cleanups (chain); } static void diff --git a/gdb/stack.c b/gdb/stack.c index 8a066b2..c88ded6 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1139,7 +1139,7 @@ print_frame (struct frame_info *frame, int print_level, struct ui_out *uiout = current_uiout; char *funname = NULL; enum language funlang = language_unknown; - struct cleanup *old_chain, *list_chain; + struct cleanup *old_chain; struct value_print_options opts; struct symbol *func; CORE_ADDR pc = 0; @@ -1154,107 +1154,107 @@ print_frame (struct frame_info *frame, int print_level, annotate_frame_begin (print_level ? frame_relative_level (frame) : 0, gdbarch, pc); - list_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "frame"); + { + ui_out_emit_tuple tuple_emitter (uiout, "frame"); - if (print_level) - { - uiout->text ("#"); - uiout->field_fmt_int (2, ui_left, "level", - frame_relative_level (frame)); - } - get_user_print_options (&opts); - if (opts.addressprint) - if (!sal.symtab - || frame_show_address (frame, sal) - || print_what == LOC_AND_ADDRESS) + if (print_level) { - annotate_frame_address (); - if (pc_p) - uiout->field_core_addr ("addr", gdbarch, pc); - else - uiout->field_string ("addr", ""); - annotate_frame_address_end (); - uiout->text (" in "); + uiout->text ("#"); + uiout->field_fmt_int (2, ui_left, "level", + frame_relative_level (frame)); } - annotate_frame_function_name (); - - string_file stb; - fprintf_symbol_filtered (&stb, funname ? funname : "??", - funlang, DMGL_ANSI); - uiout->field_stream ("func", stb); - uiout->wrap_hint (" "); - annotate_frame_args (); - - uiout->text (" ("); - if (print_args) - { - struct gdbarch *gdbarch = get_frame_arch (frame); - int numargs; - - if (gdbarch_frame_num_args_p (gdbarch)) + get_user_print_options (&opts); + if (opts.addressprint) + if (!sal.symtab + || frame_show_address (frame, sal) + || print_what == LOC_AND_ADDRESS) { - numargs = gdbarch_frame_num_args (gdbarch, frame); - gdb_assert (numargs >= 0); + annotate_frame_address (); + if (pc_p) + uiout->field_core_addr ("addr", gdbarch, pc); + else + uiout->field_string ("addr", ""); + annotate_frame_address_end (); + uiout->text (" in "); } - else - numargs = -1; - + annotate_frame_function_name (); + + string_file stb; + fprintf_symbol_filtered (&stb, funname ? funname : "??", + funlang, DMGL_ANSI); + uiout->field_stream ("func", stb); + uiout->wrap_hint (" "); + annotate_frame_args (); + + uiout->text (" ("); + if (print_args) { - ui_out_emit_list list_emitter (uiout, "args"); - TRY - { - print_frame_args (func, frame, numargs, gdb_stdout); - } - CATCH (e, RETURN_MASK_ERROR) + struct gdbarch *gdbarch = get_frame_arch (frame); + int numargs; + + if (gdbarch_frame_num_args_p (gdbarch)) { + numargs = gdbarch_frame_num_args (gdbarch, frame); + gdb_assert (numargs >= 0); } - END_CATCH + else + numargs = -1; + + { + ui_out_emit_list list_emitter (uiout, "args"); + TRY + { + print_frame_args (func, frame, numargs, gdb_stdout); + } + CATCH (e, RETURN_MASK_ERROR) + { + } + END_CATCH - /* FIXME: ARGS must be a list. If one argument is a string it - will have " that will not be properly escaped. */ + /* FIXME: ARGS must be a list. If one argument is a string it + will have " that will not be properly escaped. */ + } + QUIT; } - QUIT; - } - uiout->text (")"); - if (sal.symtab) - { - const char *filename_display; + uiout->text (")"); + if (sal.symtab) + { + const char *filename_display; - filename_display = symtab_to_filename_for_display (sal.symtab); - annotate_frame_source_begin (); - uiout->wrap_hint (" "); - uiout->text (" at "); - annotate_frame_source_file (); - uiout->field_string ("file", filename_display); - if (uiout->is_mi_like_p ()) - { - const char *fullname = symtab_to_fullname (sal.symtab); + filename_display = symtab_to_filename_for_display (sal.symtab); + annotate_frame_source_begin (); + uiout->wrap_hint (" "); + uiout->text (" at "); + annotate_frame_source_file (); + uiout->field_string ("file", filename_display); + if (uiout->is_mi_like_p ()) + { + const char *fullname = symtab_to_fullname (sal.symtab); - uiout->field_string ("fullname", fullname); - } - annotate_frame_source_file_end (); - uiout->text (":"); - annotate_frame_source_line (); - uiout->field_int ("line", sal.line); - annotate_frame_source_end (); - } + uiout->field_string ("fullname", fullname); + } + annotate_frame_source_file_end (); + uiout->text (":"); + annotate_frame_source_line (); + uiout->field_int ("line", sal.line); + annotate_frame_source_end (); + } - if (pc_p && (funname == NULL || sal.symtab == NULL)) - { - char *lib = solib_name_from_address (get_frame_program_space (frame), - get_frame_pc (frame)); + if (pc_p && (funname == NULL || sal.symtab == NULL)) + { + char *lib = solib_name_from_address (get_frame_program_space (frame), + get_frame_pc (frame)); - if (lib) - { - annotate_frame_where (); - uiout->wrap_hint (" "); - uiout->text (" from "); - uiout->field_string ("from", lib); - } - } + if (lib) + { + annotate_frame_where (); + uiout->wrap_hint (" "); + uiout->text (" from "); + uiout->field_string ("from", lib); + } + } + } - /* do_cleanups will call ui_out_tuple_end() for us. */ - do_cleanups (list_chain); uiout->text ("\n"); do_cleanups (old_chain); } diff --git a/gdb/target.c b/gdb/target.c index 3312b89..2f7f317 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3926,9 +3926,7 @@ flash_erase_command (char *cmd, int from_tty) found_flash_region = true; target_flash_erase (m->lo, m->hi - m->lo); - struct cleanup *cleanup_tuple - = make_cleanup_ui_out_tuple_begin_end (current_uiout, - "erased-regions"); + ui_out_emit_tuple tuple_emitter (current_uiout, "erased-regions"); current_uiout->message (_("Erasing flash memory region at address ")); current_uiout->field_fmt ("address", "%s", paddress (gdbarch, @@ -3936,7 +3934,6 @@ flash_erase_command (char *cmd, int from_tty) current_uiout->message (", size = "); current_uiout->field_fmt ("size", "%s", hex_string (m->hi - m->lo)); current_uiout->message ("\n"); - do_cleanups (cleanup_tuple); } } -- 2.9.4