From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27047 invoked by alias); 9 Sep 2017 18:32:03 -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 26869 invoked by uid 89); 9 Sep 2017 18:32:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1628 X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Sep 2017 18:32:01 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id v89IVtgg011976 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 9 Sep 2017 14:31:59 -0400 Received: by simark.ca (Postfix, from userid 112) id F037D1EAAB; Sat, 9 Sep 2017 14:31:54 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 78F301E984; Sat, 9 Sep 2017 14:31:54 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 09 Sep 2017 18:32:00 -0000 From: Simon Marchi To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [RFA 3/7] Use ui_out_emit_tuple in more places In-Reply-To: <20170909153540.15008-4-tom@tromey.com> References: <20170909153540.15008-1-tom@tromey.com> <20170909153540.15008-4-tom@tromey.com> Message-ID: <87ca116d1d533e670303699afa0240d4@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sat, 9 Sep 2017 18:31:55 +0000 X-IsSubscribed: yes X-SW-Source: 2017-09/txt/msg00246.txt.bz2 On 2017-09-09 17:35, Tom Tromey wrote: > 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 ()); Can this conversion to hex be replaced with a call to bin2hex (the version that returns an std::string) ? Otherwise, LGTM. Simon