From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 57867 invoked by alias); 19 Apr 2017 02:42:13 -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 57827 invoked by uid 89); 19 Apr 2017 02:42:12 -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,KAM_STOCKGEN,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=2247, wpt, 2348 X-HELO: gproxy10.mail.unifiedlayer.com Received: from gproxy10-pub.mail.unifiedlayer.com (HELO gproxy10.mail.unifiedlayer.com) (69.89.20.226) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Apr 2017 02:42:10 +0000 Received: from cmgw2 (unknown [10.0.90.83]) by gproxy10.mail.unifiedlayer.com (Postfix) with ESMTP id 2292314082C for ; Tue, 18 Apr 2017 20:41:50 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id A2hm1v00U2f2jeq012hp6k; Tue, 18 Apr 2017 20:41:50 -0600 X-Authority-Analysis: v=2.2 cv=LIwWeNe9 c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=AzvcPWV-tVgA:10 a=20KFwNOVAAAA:8 a=zstS-IiYAAAA:8 a=-9rSqtDjaI_70DpYhdsA:9 a=FaeceMtwnwxsa7mx:21 a=dsYjvvmQRf380bgv:21 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-65-226.hlrn.qwest.net ([75.166.65.226]:47696 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1d0fYw-0003TA-Ik; Tue, 18 Apr 2017 20:41:46 -0600 From: Tom Tromey To: Pedro Alves Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [RFA 2/5] More uses of ui_out_emit_tuple References: <20170414022337.28368-1-tom@tromey.com> <20170414022337.28368-3-tom@tromey.com> <9c78ec4d-1f47-1462-4a1b-125b78a8d3a7@redhat.com> Date: Wed, 19 Apr 2017 02:42:00 -0000 In-Reply-To: <9c78ec4d-1f47-1462-4a1b-125b78a8d3a7@redhat.com> (Pedro Alves's message of "Tue, 18 Apr 2017 19:42:52 +0100") Message-ID: <87inm15day.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BWhitelist: no X-Exim-ID: 1d0fYw-0003TA-Ik X-Source-Sender: 75-166-65-226.hlrn.qwest.net (bapiya) [75.166.65.226]:47696 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-SW-Source: 2017-04/txt/msg00543.txt.bz2 >>>>> "Pedro" == Pedro Alves writes: Pedro> Looks like the reason that this needed a new scope was Pedro> this annotate_arg_end call. Pedro> How about instead adding something like this: [...] That does make the patch clearer. Here's the updated version; I'm not resending the whole series as nothing else has changed. I'm running this through the buildbot; OK if it passes? Tom commit 7ee4a9c7624658a17fd566b2a236260a5b2e258e Author: Tom Tromey Date: Wed Apr 12 16:10:02 2017 -0600 More uses of ui_out_emit_tuple This patch adds a few more uses of ui_out_emit_tuple. In these cases a slightly more complicated change was needed. This also adds annotate_arg_emitter, for use in stack.c, to avoid having to introduce a new scope and reindent the code for a single call. ChangeLog 2017-04-18 Tom Tromey * stack.c (print_frame_arg): Use ui_out_emit_tuple, annotate_arg_emitter. * breakpoint.c (print_mention_watchpoint) (print_mention_masked_watchpoint): Use ui_out_emit_tuple. * annotate.h (struct annotate_arg_emitter): New. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f5fed2f..52560f7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2017-04-18 Tom Tromey + + * stack.c (print_frame_arg): Use ui_out_emit_tuple, + annotate_arg_emitter. + * breakpoint.c (print_mention_watchpoint) + (print_mention_masked_watchpoint): Use ui_out_emit_tuple. + * annotate.h (struct annotate_arg_emitter): New. + 2017-04-13 Tom Tromey * record-btrace.c (record_btrace_insn_history) diff --git a/gdb/annotate.h b/gdb/annotate.h index a1454a1..7161689 100644 --- a/gdb/annotate.h +++ b/gdb/annotate.h @@ -74,6 +74,17 @@ extern void annotate_arg_name_end (void); extern void annotate_arg_value (struct type *); extern void annotate_arg_end (void); +/* Wrap calls to annotate_arg_begin and annotate_arg_end in an RAII + class. */ +struct annotate_arg_emitter +{ + annotate_arg_emitter () { annotate_arg_begin (); } + ~annotate_arg_emitter () { annotate_arg_end (); } + + annotate_arg_emitter (const annotate_arg_emitter &) = delete; + annotate_arg_emitter &operator= (const annotate_arg_emitter &) = delete; +}; + extern void annotate_source (char *, int, int, int, struct gdbarch *, CORE_ADDR); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 2ff4406..269cddd 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -10778,37 +10778,37 @@ print_it_watchpoint (bpstat bs) static void print_mention_watchpoint (struct breakpoint *b) { - struct cleanup *ui_out_chain; struct watchpoint *w = (struct watchpoint *) b; struct ui_out *uiout = current_uiout; + const char *tuple_name; switch (b->type) { case bp_watchpoint: uiout->text ("Watchpoint "); - ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt"); + tuple_name = "wpt"; break; case bp_hardware_watchpoint: uiout->text ("Hardware watchpoint "); - ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt"); + tuple_name = "wpt"; break; case bp_read_watchpoint: uiout->text ("Hardware read watchpoint "); - ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-rwpt"); + tuple_name = "hw-rwpt"; break; case bp_access_watchpoint: uiout->text ("Hardware access (read/write) watchpoint "); - ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-awpt"); + tuple_name = "hw-awpt"; break; default: internal_error (__FILE__, __LINE__, _("Invalid hardware watchpoint type.")); } + ui_out_emit_tuple tuple_emitter (uiout, tuple_name); uiout->field_int ("number", b->number); uiout->text (": "); uiout->field_string ("exp", w->exp_string); - do_cleanups (ui_out_chain); } /* Implement the "print_recreate" breakpoint_ops method for @@ -10977,31 +10977,31 @@ print_mention_masked_watchpoint (struct breakpoint *b) { struct watchpoint *w = (struct watchpoint *) b; struct ui_out *uiout = current_uiout; - struct cleanup *ui_out_chain; + const char *tuple_name; switch (b->type) { case bp_hardware_watchpoint: uiout->text ("Masked hardware watchpoint "); - ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt"); + tuple_name = "wpt"; break; case bp_read_watchpoint: uiout->text ("Masked hardware read watchpoint "); - ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-rwpt"); + tuple_name = "hw-rwpt"; break; case bp_access_watchpoint: uiout->text ("Masked hardware access (read/write) watchpoint "); - ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-awpt"); + tuple_name = "hw-awpt"; break; default: internal_error (__FILE__, __LINE__, _("Invalid hardware watchpoint type.")); } + ui_out_emit_tuple tuple_emitter (uiout, tuple_name); uiout->field_int ("number", b->number); uiout->text (": "); uiout->field_string ("exp", w->exp_string); - do_cleanups (ui_out_chain); } /* Implement the "print_recreate" breakpoint_ops method for diff --git a/gdb/stack.c b/gdb/stack.c index 32acca1..fa47264 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -224,7 +224,6 @@ static void print_frame_arg (const struct frame_arg *arg) { struct ui_out *uiout = current_uiout; - struct cleanup *old_chain; const char *error_message = NULL; string_file stb; @@ -235,9 +234,8 @@ print_frame_arg (const struct frame_arg *arg) || (!uiout->is_mi_like_p () && arg->entry_kind == print_entry_values_compact)); - annotate_arg_begin (); - - old_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + annotate_arg_emitter arg_emitter; + ui_out_emit_tuple tuple_emitter (uiout, NULL); fprintf_symbol_filtered (&stb, SYMBOL_PRINT_NAME (arg->sym), SYMBOL_LANGUAGE (arg->sym), DMGL_PARAMS | DMGL_ANSI); if (arg->entry_kind == print_entry_values_compact) @@ -305,11 +303,6 @@ print_frame_arg (const struct frame_arg *arg) } uiout->field_stream ("value", stb); - - /* Also invoke ui_out_tuple_end. */ - do_cleanups (old_chain); - - annotate_arg_end (); } /* Read in inferior function local SYM at FRAME into ARGP. Caller is