Use errno value of first openp failure
authorHannes Domani <ssbssa@yahoo.de>
Wed, 13 May 2020 10:41:51 +0000 (12:41 +0200)
committerHannes Domani <ssbssa@yahoo.de>
Wed, 27 May 2020 17:41:07 +0000 (19:41 +0200)
Fixes this testsuite fail on Windows:
FAIL: gdb.base/bad-file.exp: directory

If both tries to open the file fail (without and with ".exe"), use the
errno value of the first try.

gdb/ChangeLog:

2020-05-27  Hannes Domani  <ssbssa@yahoo.de>

* exec.c (exec_file_attach): Use errno value of first openp failure.

gdb/ChangeLog
gdb/exec.c

index 08641e5721bb7ed75b96c6d45d5e4cd669d4d0e3..2f2958c599bca904dc47e6e10e5982bdfa1c23b9 100644 (file)
@@ -1,3 +1,7 @@
+2020-05-27  Hannes Domani  <ssbssa@yahoo.de>
+
+       * exec.c (exec_file_attach): Use errno value of first openp failure.
+
 2020-05-27  Hannes Domani  <ssbssa@yahoo.de>
 
        * nat/windows-nat.c (windows_thread_info::~windows_thread_info):
index 14c77495a38f14629d9f67a2a41901d6c74a47ce..ee13c5e027efc29eb07843b8c5474e60fd6a043d 100644 (file)
@@ -435,6 +435,7 @@ exec_file_attach (const char *filename, int from_tty)
 #if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)
          if (scratch_chan < 0)
            {
+             int first_errno = errno;
              char *exename = (char *) alloca (strlen (filename) + 5);
 
              strcat (strcpy (exename, filename), ".exe");
@@ -443,6 +444,8 @@ exec_file_attach (const char *filename, int from_tty)
                                    O_RDWR | O_BINARY
                                    : O_RDONLY | O_BINARY,
                                    &scratch_storage);
+             if (scratch_chan < 0)
+               errno = first_errno;
            }
 #endif
          if (scratch_chan < 0)
This page took 0.028962 seconds and 4 git commands to generate.