From patchwork Thu Oct 13 21:10:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 16491 Received: (qmail 3135 invoked by alias); 13 Oct 2016 21:11:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 2125 invoked by uid 89); 13 Oct 2016 21:11:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=dispatch, Dispatch, *command, topmost X-HELO: gproxy10-pub.mail.unifiedlayer.com Received: from gproxy10-pub.mail.unifiedlayer.com (HELO gproxy10-pub.mail.unifiedlayer.com) (69.89.20.226) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Thu, 13 Oct 2016 21:11:04 +0000 Received: (qmail 11176 invoked by uid 0); 13 Oct 2016 21:11:03 -0000 Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy10.mail.unifiedlayer.com with SMTP; 13 Oct 2016 21:11:03 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id v9AL1t00h2f2jeq019APiw; Thu, 13 Oct 2016 15:10:23 -0600 X-Authority-Analysis: v=2.1 cv=PIacp5aC c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=CH0kA5CcgfcA:10 a=zstS-IiYAAAA:8 a=VOmTXfRHLFVtO4cwLO0A:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 174-16-143-211.hlrn.qwest.net ([174.16.143.211]:42448 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1bunGf-00011Z-QH; Thu, 13 Oct 2016 15:10:21 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v2 08/17] Remove some cleanups in MI Date: Thu, 13 Oct 2016 15:10:03 -0600 Message-Id: <1476393012-29987-9-git-send-email-tom@tromey.com> In-Reply-To: <1476393012-29987-1-git-send-email-tom@tromey.com> References: <1476393012-29987-1-git-send-email-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1bunGf-00011Z-QH X-Source-Sender: 174-16-143-211.hlrn.qwest.net (bapiya.Home) [174.16.143.211]:42448 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== This patch removes a couple of cleanups from MI by using gdb::unique_ptr. 2016-09-26 Tom Tromey * mi/mi-main.c (mi_cmd_data_read_memory): Use gdb::unique_ptr. Remove some cleanups. --- gdb/ChangeLog | 5 +++++ gdb/mi/mi-main.c | 11 ++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 04e550a..7c072b5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2016-09-26 Tom Tromey + + * mi/mi-main.c (mi_cmd_data_read_memory): Use gdb::unique_ptr. + Remove some cleanups. + 2016-10-10 Tom Tromey * tui/tui-interp.c (tui_on_normal_stop, tui_on_signal_received) diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index b80b4f2..067c9e3 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1413,7 +1413,6 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc) { struct gdbarch *gdbarch = get_current_arch (); struct ui_out *uiout = current_uiout; - struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); CORE_ADDR addr; long total_bytes, nr_cols, nr_rows; char word_format; @@ -1421,7 +1420,6 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc) long word_size; char word_asize; char aschar; - gdb_byte *mbuf; int nr_bytes; long offset = 0; int oind = 0; @@ -1506,13 +1504,13 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc) /* Create a buffer and read it in. */ total_bytes = word_size * nr_rows * nr_cols; - mbuf = XCNEWVEC (gdb_byte, total_bytes); - make_cleanup (xfree, mbuf); + + gdb::unique_ptr mbuf (new gdb_byte[total_bytes]); /* Dispatch memory reads to the topmost target, not the flattened current_target. */ nr_bytes = target_read (current_target.beneath, - TARGET_OBJECT_MEMORY, NULL, mbuf, + TARGET_OBJECT_MEMORY, NULL, mbuf.get (), addr, total_bytes); if (nr_bytes <= 0) error (_("Unable to read memory.")); @@ -1566,7 +1564,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc) else { ui_file_rewind (stream); - print_scalar_formatted (mbuf + col_byte, word_type, &opts, + print_scalar_formatted (&mbuf[col_byte], word_type, &opts, word_asize, stream); ui_out_field_stream (uiout, NULL, stream); } @@ -1593,7 +1591,6 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc) } do_cleanups (cleanup_stream); } - do_cleanups (cleanups); } void