From patchwork Tue Nov 19 15:38:06 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: 36037 Received: (qmail 93105 invoked by alias); 19 Nov 2019 15:38:12 -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 93069 invoked by uid 89); 19 Nov 2019 15:38:11 -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, 19 Nov 2019 15:38:10 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id F204D20300; Tue, 19 Nov 2019 10:38:08 -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 9AA89202D0; Tue, 19 Nov 2019 10:38:07 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 6E8D72816F; Tue, 19 Nov 2019 10:38:07 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Tue, 19 Nov 2019 10:38:06 -0500 From: "Sourceware to Gerrit sync (Code Review)" To: Tom Tromey , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [pushed] Report GetLastError value when DebugActiveProcess fails X-Gerrit-Change-Id: Ie1bf502a0d96bb7c09bd5b1c5e0c924ba58cd68c X-Gerrit-Change-Number: 629 X-Gerrit-ChangeURL: X-Gerrit-Commit: c9739b6a06730b65df135766dec4c4d14d78bd38 In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, tromey@sourceware.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191119153807.6E8D72816F@gnutoolchain-gerrit.osci.io> The original change was created by Tom Tromey. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/629 ...................................................................... Report GetLastError value when DebugActiveProcess fails When DebugActiveProcess fails, the error message is fairly generic: error (_("Can't attach to process.")); It would be more useful for diagnosing problems if the Windows error code was included in the message. This patch implements this. gdb/ChangeLog 2019-11-19 Tom Tromey * windows-nat.c (windows_nat_target::attach): Include GetLastError result in error when DebugActiveProcess fails. Change-Id: Ie1bf502a0d96bb7c09bd5b1c5e0c924ba58cd68c --- M gdb/ChangeLog M gdb/windows-nat.c 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 80ec8f3..0305d67 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-11-19 Tom Tromey + + * windows-nat.c (windows_nat_target::attach): Include GetLastError + result in error when DebugActiveProcess fails. + 2019-11-18 Sergio Durigan Junior Pedro Alves diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 5901f63..fdc21f3 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1983,7 +1983,8 @@ #endif if (!ok) - error (_("Can't attach to process.")); + error (_("Can't attach to process %u (error %u)"), + (unsigned) pid, (unsigned) GetLastError ()); DebugSetProcessKillOnExit (FALSE);