From patchwork Tue Oct 29 17:57:54 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: 35417 Received: (qmail 47187 invoked by alias); 29 Oct 2019 17:58:04 -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 47048 invoked by uid 89); 29 Oct 2019 17:58:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.9 required=5.0 tests=AWL, 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, 29 Oct 2019 17:58:02 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 40AF82163E; Tue, 29 Oct 2019 13:57:59 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 89A9F212F4 for ; Tue, 29 Oct 2019 13:57:54 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 6329A2A7DB for ; Tue, 29 Oct 2019 13:57:54 -0400 (EDT) X-Gerrit-PatchSet: 1 Date: Tue, 29 Oct 2019 13:57:54 -0400 From: "Tom Tromey (Code Review)" To: gdb-patches@sourceware.org Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] 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: 9d51627f7ac0a6b8551f5ec82f3ad484f05ea191 References: Reply-To: tromey@sourceware.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-74-g460fb0f7e9 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-10-29 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 c83fb0e..92f77fc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2019-10-29 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-10-29 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 0cfc071..06c6486 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. */ @@ -68,7 +63,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 75d61cf..12a69bb 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; @@ -3000,7 +2999,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 (); }