public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Use errno value of first openp failure
@ 2020-05-27 17:44 Hannes Domani
  0 siblings, 0 replies; only message in thread
From: Hannes Domani @ 2020-05-27 17:44 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=96445f0b66af20343e2ffed08c4da8cfac101a03

commit 96445f0b66af20343e2ffed08c4da8cfac101a03
Author: Hannes Domani <ssbssa@yahoo.de>
Date:   Wed May 13 12:41:51 2020 +0200

    Use errno value of first openp failure
    
    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.

Diff:
---
 gdb/ChangeLog | 4 ++++
 gdb/exec.c    | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 08641e5721b..2f2958c599b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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):
diff --git a/gdb/exec.c b/gdb/exec.c
index 14c77495a38..ee13c5e027e 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -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)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-27 17:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 17:44 [binutils-gdb] Use errno value of first openp failure Hannes Domani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).