Report GetLastError value when DebugActiveProcess fails
authorTom Tromey <tromey@adacore.com>
Wed, 6 Nov 2019 16:43:52 +0000 (09:43 -0700)
committerTom Tromey <tromey@adacore.com>
Tue, 19 Nov 2019 15:33:53 +0000 (08:33 -0700)
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  <tromey@adacore.com>

* windows-nat.c (windows_nat_target::attach): Include GetLastError
result in error when DebugActiveProcess fails.

Change-Id: Ie1bf502a0d96bb7c09bd5b1c5e0c924ba58cd68c

gdb/ChangeLog
gdb/windows-nat.c

index 80ec8f352283ff2bc8698e36b97124ce509aec67..0305d67bd65975851f42d7e185a693549da37451 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-19  Tom Tromey  <tromey@adacore.com>
+
+       * windows-nat.c (windows_nat_target::attach): Include GetLastError
+       result in error when DebugActiveProcess fails.
+
 2019-11-18  Sergio Durigan Junior  <sergiodj@redhat.com>
            Pedro Alves  <palves@redhat.com>
 
index 5901f63b28a29341569054abee88db6fee4aa016..fdc21f38bfadd41b069eec60da283763bf7ca7f7 100644 (file)
@@ -1983,7 +1983,8 @@ windows_nat_target::attach (const char *args, int from_tty)
 #endif
 
   if (!ok)
-    error (_("Can't attach to process."));
+    error (_("Can't attach to process %u (error %u)"),
+          (unsigned) pid, (unsigned) GetLastError ());
 
   DebugSetProcessKillOnExit (FALSE);
 
This page took 0.032772 seconds and 4 git commands to generate.