From patchwork Thu Nov 14 16:40:58 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: 35887 Received: (qmail 82962 invoked by alias); 14 Nov 2019 16:41:02 -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 82952 invoked by uid 89); 14 Nov 2019 16:41:02 -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=windows-nat.c, UD:windows-nat.c, windowsnatc 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; Thu, 14 Nov 2019 16:41:01 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 9A45520413; Thu, 14 Nov 2019 11:40:59 -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 95E0F201E8 for ; Thu, 14 Nov 2019 11:40:58 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 7BD8520AF6 for ; Thu, 14 Nov 2019 11:40:58 -0500 (EST) X-Gerrit-PatchSet: 1 Date: Thu, 14 Nov 2019 11:40:58 -0500 From: "Tom Tromey (Code Review)" To: gdb-patches@sourceware.org Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Report GetLastError value when DebugActiveProcess fails X-Gerrit-Change-Id: Ie1bf502a0d96bb7c09bd5b1c5e0c924ba58cd68c X-Gerrit-Change-Number: 629 X-Gerrit-ChangeURL: X-Gerrit-Commit: d7a803277bc1204931a18213e70ba057ef7d3aa2 References: Reply-To: tromey@sourceware.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-76-gf8b6da0ab5 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-14 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 719574f..f709df7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-11-14 Tom Tromey + + * windows-nat.c (windows_nat_target::attach): Include GetLastError + result in error when DebugActiveProcess fails. + 2019-11-14 Simon Marchi * unittests/vec-utils-selftests.c (unordered_remove_tests::obj): 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);