From patchwork Thu Mar 22 13:39:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 26429 Received: (qmail 122354 invoked by alias); 22 Mar 2018 13:40:00 -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 122334 invoked by uid 89); 22 Mar 2018 13:40:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.144.218) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 13:39:58 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 76FE8E77E for ; Thu, 22 Mar 2018 08:39:57 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id z0Rhe19ssntAoz0RhefXE7; Thu, 22 Mar 2018 08:39:57 -0500 Received: from 174-29-60-18.hlrn.qwest.net ([174.29.60.18]:55404 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1ez0Rh-000oFt-6H; Thu, 22 Mar 2018 08:39:57 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Remove some cleanups from record-full.c Date: Thu, 22 Mar 2018 07:39:54 -0600 Message-Id: <20180322133954.15452-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1ez0Rh-000oFt-6H X-Source-Sender: 174-29-60-18.hlrn.qwest.net (bapiya.Home) [174.29.60.18]:55404 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This removes some cleanups from record-full.c in a straightforward way. Tested by the buildbot. gdb/ChangeLog 2018-03-22 Tom Tromey * record-full.c (record_full_exec_insn): Use gdb::byte_vector. (record_full_goto_bookmark): Use std::string. --- gdb/ChangeLog | 5 +++++ gdb/record-full.c | 22 +++++++--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/gdb/record-full.c b/gdb/record-full.c index abaf99bab9..4d8dd61bca 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -702,8 +702,7 @@ record_full_exec_insn (struct regcache *regcache, /* Nothing to do if the entry is flagged not_accessible. */ if (!entry->u.mem.mem_entry_not_accessible) { - gdb_byte *mem = (gdb_byte *) xmalloc (entry->u.mem.len); - struct cleanup *cleanup = make_cleanup (xfree, mem); + gdb::byte_vector mem (entry->u.mem.len); if (record_debug > 1) fprintf_unfiltered (gdb_stdlog, @@ -714,7 +713,8 @@ record_full_exec_insn (struct regcache *regcache, entry->u.mem.len); if (record_read_memory (gdbarch, - entry->u.mem.addr, mem, entry->u.mem.len)) + entry->u.mem.addr, mem.data (), + entry->u.mem.len)) entry->u.mem.mem_entry_not_accessible = 1; else { @@ -731,7 +731,7 @@ record_full_exec_insn (struct regcache *regcache, } else { - memcpy (record_full_get_loc (entry), mem, + memcpy (record_full_get_loc (entry), mem.data (), entry->u.mem.len); /* We've changed memory --- check if a hardware @@ -748,8 +748,6 @@ record_full_exec_insn (struct regcache *regcache, record_full_stop_reason = TARGET_STOPPED_BY_WATCHPOINT; } } - - do_cleanups (cleanup); } } break; @@ -1750,28 +1748,22 @@ record_full_goto_bookmark (struct target_ops *self, const gdb_byte *raw_bookmark, int from_tty) { const char *bookmark = (const char *) raw_bookmark; - struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); if (record_debug) fprintf_unfiltered (gdb_stdlog, "record_full_goto_bookmark receives %s\n", bookmark); + std::string name_holder; if (bookmark[0] == '\'' || bookmark[0] == '\"') { - char *copy; - if (bookmark[strlen (bookmark) - 1] != bookmark[0]) error (_("Unbalanced quotes: %s"), bookmark); - - copy = savestring (bookmark + 1, strlen (bookmark) - 2); - make_cleanup (xfree, copy); - bookmark = copy; + name_holder = std::string (bookmark + 1, strlen (bookmark) - 2); + bookmark = name_holder.c_str (); } record_goto (bookmark); - - do_cleanups (cleanup); } static enum exec_direction_kind