From patchwork Tue Nov 26 17:11:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 36215 Received: (qmail 93641 invoked by alias); 26 Nov 2019 17:11:53 -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 93571 invoked by uid 89); 26 Nov 2019 17:11:53 -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 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Nov 2019 17:11:51 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id EA4F52053D; Tue, 26 Nov 2019 12:11:47 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 498E82064A; Tue, 26 Nov 2019 12:11:31 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 3284128174; Tue, 26 Nov 2019 12:11:31 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Tue, 26 Nov 2019 12:11:28 -0500 From: "Tom Tromey (Code Review)" To: Simon Marchi , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [review v2] Make windows_thread_info::name a unique_xmalloc_ptr X-Gerrit-Change-Id: Ieb950249ddaf58ecc8faf98cc2b464d86c53fde3 X-Gerrit-Change-Number: 410 X-Gerrit-ChangeURL: X-Gerrit-Commit: 4722adb7cc9f9a88027bc1b68168d7722ab79dfe In-Reply-To: References: Reply-To: tromey@sourceware.org, simon.marchi@polymtl.ca, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191126171131.3284128174@gnutoolchain-gerrit.osci.io> Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/410 ...................................................................... Make windows_thread_info::name a unique_xmalloc_ptr This changes windows_thread_info::name to be a unique_xmalloc_ptr, removing some manual memory management. gdb/ChangeLog 2019-11-26 Tom Tromey * windows-nat.c (handle_exception) (windows_nat_target::thread_name): Update. * nat/windows-nat.h (windows_thread_info): Remove destructor. : Now unique_xmalloc_ptr. Change-Id: Ieb950249ddaf58ecc8faf98cc2b464d86c53fde3 --- M gdb/ChangeLog M gdb/nat/windows-nat.h M gdb/windows-nat.c 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e48f650..621f890 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2019-11-26 Tom Tromey + * windows-nat.c (handle_exception) + (windows_nat_target::thread_name): Update. + * nat/windows-nat.h (windows_thread_info): Remove destructor. + : Now unique_xmalloc_ptr. + +2019-11-26 Tom Tromey + * windows-nat.c (thread_rec) (windows_nat_target::fetch_registers): Update. * nat/windows-nat.h (struct windows_thread_info) : diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h index e5d7e63..db21ca7 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -30,11 +30,6 @@ { } - ~windows_thread_info () - { - xfree (name); - } - DISABLE_COPY_AND_ASSIGN (windows_thread_info); /* The Win32 thread identifier. */ @@ -69,7 +64,7 @@ bool reload_context = false; /* The name of the thread, allocated by xmalloc. */ - char *name = nullptr; + gdb::unique_xmalloc_ptr name; }; #endif diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 4898fba..f283495 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1261,8 +1261,7 @@ if (thread_name_len > 0) { thread_name.get ()[thread_name_len - 1] = '\0'; - xfree (named_thread->name); - named_thread->name = thread_name.release (); + named_thread->name = std::move (thread_name); } } ourstatus->value.sig = GDB_SIGNAL_TRAP; @@ -3001,7 +3000,7 @@ const char * windows_nat_target::thread_name (struct thread_info *thr) { - return thread_rec (thr->ptid.tid (), 0)->name; + return thread_rec (thr->ptid.tid (), 0)->name.get (); }