This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[review] Report GetLastError value when DebugActiveProcess fails


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  <tromey@adacore.com>

	* 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  <tromey@adacore.com>
+
+	* windows-nat.c (windows_nat_target::attach): Include GetLastError
+	result in error when DebugActiveProcess fails.
+
 2019-11-14  Simon Marchi  <simon.marchi@polymtl.ca>
 
 	* 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);
 

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ie1bf502a0d96bb7c09bd5b1c5e0c924ba58cd68c
Gerrit-Change-Number: 629
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]