Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Philippe De Muyter" <phdm@macqel.be>
To: gdb-patches@cygnus.com, gdb-testers@cygnus.com
Subject: No Subject
Date: Mon, 06 Apr 1998 04:43:00 -0000	[thread overview]
Message-ID: <199804061141.NAA23820@mail.macqel.be> (raw)

Am I the only one to have (sometimes) the problem of finding a non-executable
with the same name earlier in my path than the program I want to debug ?

Here is a patch.

I also removed the obsolete (now that we have gdb_string.h) strstr
declaration comment.

Mon Apr  6 13:20:21 1998  Philippe De Muyter  <phdm@macqel.be>

	* source.c (openp): Accept only files that match prot.
	* exec.c (exec_file_command): Request openp to find an executable
	file.

--- ./gdb/source.c	Mon Apr  6 11:22:17 1998
+++ ./gdb/source.c	Mon Apr  6 09:49:08 1998
@@ -83,11 +83,6 @@
 
 static void find_source_lines PARAMS ((struct symtab *, int));
 
-/* If we use this declaration, it breaks because of fucking ANSI "const" stuff
-   on some systems.  We just have to not declare it at all, have it default
-   to int, and possibly botch on a few systems.  Thanks, ANSIholes... */
-/* extern char *strstr(); */
-
 /* Path of directories to search for source files.
    Same format as the PATH environment variable's value.  */
 
@@ -521,7 +516,7 @@ openp (path, try_cwd_first, string, mode
     {
       int i;
       filename = string;
-      fd = open (filename, mode, prot);
+      fd = open (filename, mode);
       if (fd >= 0)
 	goto done;
       for (i = 0; string[i]; i++)
@@ -570,8 +565,10 @@ openp (path, try_cwd_first, string, mode
       strcat (filename+len, SLASH_STRING);
       strcat (filename, string);
 
-      fd = open (filename, mode);
-      if (fd >= 0) break;
+      /* Accept only files matching prot. */
+      if ((prot == 0 || access(filename, prot) == 0)
+      	  && (fd = open (filename, mode)) >= 0)
+	break;
     }
 
  done:
--- ./gdb/exec.c	Mon Apr  6 11:22:18 1998
+++ ./gdb/exec.c	Sat Apr  4 09:37:50 1998
@@ -32,6 +32,12 @@
 #endif
 
 #include <fcntl.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifndef X_OK
+#define X_OK	1
+#endif
 #include "gdb_string.h"
 
 #include "gdbcore.h"
@@ -185,8 +191,8 @@ exec_file_command (args, from_tty)
       make_cleanup (free, filename);
       
       scratch_chan = openp (getenv ("PATH"), 1, filename, 
-			    write_files? O_RDWR|O_BINARY: O_RDONLY|O_BINARY, 0,
-			    &scratch_pathname);
+			    write_files? O_RDWR|O_BINARY: O_RDONLY|O_BINARY,
+			    X_OK, &scratch_pathname);
 #if defined(__GO32__) || defined(_WIN32)
       if (scratch_chan < 0)
       {


             reply	other threads:[~1998-04-06  4:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-06  4:43 Philippe De Muyter [this message]
1998-04-06 14:16 ` Stan Shebs
1998-04-06 14:36   ` Michael Snyder
1998-04-06 15:14     ` Re: Michael Meissner
1999-03-08  7:10 No Subject Andris Pavenis
1999-04-01  0:00 ` Andris Pavenis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199804061141.NAA23820@mail.macqel.be \
    --to=phdm@macqel.be \
    --cc=gdb-patches@cygnus.com \
    --cc=gdb-testers@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox