From patchwork Tue Jan 1 22:45:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 30928 Received: (qmail 122788 invoked by alias); 1 Jan 2019 22:45:26 -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 122592 invoked by uid 89); 1 Jan 2019 22:45:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=invite X-HELO: mail-wr1-f67.google.com Received: from mail-wr1-f67.google.com (HELO mail-wr1-f67.google.com) (209.85.221.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Jan 2019 22:45:19 +0000 Received: by mail-wr1-f67.google.com with SMTP id u4so28921585wrp.3 for ; Tue, 01 Jan 2019 14:45:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=vExNAA11eoK7pizeIXVQDeDW5VQG81BczqH2djG8NCY=; b=gjGNuBtSs8UbsIDBi4TwL3HQY3VtCH2sJ/A8ZxfAzCuuXGZVBIKdXWbM3q+SVVrjSb b7wY0h4KZ5ns39BQ8KpQ1sEdbm56VDvjbnyb49BKWGC1+A6Y9gf8L2lCq14mKSn5hmX0 /lRorJ4k1G64gmjTheKSgktFn8dpvXbSCM76ubWNqe8rK7sZldKaYXF9ic0rcuFQUKab Gh3vkY1jgfjAH9wWbL8lkAyHIqdPeS82gI1cscHRo0yXbxsF5aREL621rDZG8isYq8Wz 44POy4MlgNPajK664eJ1Z/E26UwHmiX12If0jfil4LgRUfr8CsEFo9sBaRdtUcRwDDh8 rjcw== Return-Path: Received: from localhost (host86-172-198-47.range86-172.btcentralplus.com. [86.172.198.47]) by smtp.gmail.com with ESMTPSA id m15sm36046175wrr.95.2019.01.01.14.45.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Jan 2019 14:45:16 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/6] gdb/remote: Remove a cleanup in remote_check_symbols Date: Tue, 1 Jan 2019 22:45:02 +0000 Message-Id: <173d5906308c76db0cb28597c6ba2962ba4f0fa4.1546382416.git.andrew.burgess@embecosm.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes Convert one of the variables that requires a cleanup from a 'char *' to a 'gdb::char_vector' in remote_target::remote_check_symbols. Tested on x86-64/Linux with target_board native-gdbserver and native-extended-gdbserver. gdb/ChangeLog: * remote.c (remote_target::remote_check_symbols): Convert `msg` to gdb::char_vector, remove cleanup, and update uses of `msg`. --- gdb/ChangeLog | 5 +++++ gdb/remote.c | 21 +++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index efed99855d4..324ed46809e 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -4883,7 +4883,7 @@ init_all_packet_configs (void) void remote_target::remote_check_symbols () { - char *msg, *reply, *tmp; + char *reply, *tmp; int end; long reply_size; struct cleanup *old_chain; @@ -4905,10 +4905,9 @@ remote_target::remote_check_symbols () /* Allocate a message buffer. We can't reuse the input buffer in RS, because we need both at the same time. */ - msg = (char *) xmalloc (get_remote_packet_size ()); - old_chain = make_cleanup (xfree, msg); + gdb::char_vector msg (get_remote_packet_size ()); reply = (char *) xmalloc (get_remote_packet_size ()); - make_cleanup (free_current_contents, &reply); + old_chain = make_cleanup (free_current_contents, &reply); reply_size = get_remote_packet_size (); /* Invite target to request symbol lookups. */ @@ -4922,11 +4921,13 @@ remote_target::remote_check_symbols () struct bound_minimal_symbol sym; tmp = &reply[8]; - end = hex2bin (tmp, (gdb_byte *) msg, strlen (tmp) / 2); + end = hex2bin (tmp, reinterpret_cast (msg.data ()), + strlen (tmp) / 2); msg[end] = '\0'; - sym = lookup_minimal_symbol (msg, NULL, NULL); + sym = lookup_minimal_symbol (msg.data (), NULL, NULL); if (sym.minsym == NULL) - xsnprintf (msg, get_remote_packet_size (), "qSymbol::%s", &reply[8]); + xsnprintf (msg.data (), get_remote_packet_size (), "qSymbol::%s", + &reply[8]); else { int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8; @@ -4938,11 +4939,11 @@ remote_target::remote_check_symbols () sym_addr, current_top_target ()); - xsnprintf (msg, get_remote_packet_size (), "qSymbol:%s:%s", + xsnprintf (msg.data (), get_remote_packet_size (), "qSymbol:%s:%s", phex_nz (sym_addr, addr_size), &reply[8]); } - - putpkt (msg); + + putpkt (msg.data ()); getpkt (&reply, &reply_size, 0); }