Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Charles Wilson <cygwin@cwilson.fastmail.fm>
To: gdb-patches@sourceware.org
Subject: Re: RFA: ensure binary objects opened in binary mode
Date: Fri, 24 Feb 2006 10:37:00 -0000	[thread overview]
Message-ID: <43FEC572.3090403@cwilson.fastmail.fm> (raw)
In-Reply-To: <20060222185032.GA29383@nevyn.them.org>

[-- Attachment #1: Type: text/plain, Size: 1896 bytes --]

Daniel Jacobowitz wrote:
> On Wed, Feb 22, 2006 at 08:34:54PM +0200, Eli Zaretskii wrote:
>>> (1) for every file that #includes both defs.h AND <fcntl.h>, remove the 
>>> <fcntl.h> inclusion.
[snip]
>> So I'd prefer if you committed the 1st and the 3rd patch. but not the
>> second.  However, before you actually do that, let's wait and hear
>> what others think.
> 
> Fine by me.
> 
>>> +/* In case this is not defined in fcntl.h */
>>> +
>>> +#ifndef O_BINARY
>>> +#define O_BINARY 0
>>> +#endif
>> I'd change the comment to explain that O_BINARY has a meaning on
>> non-Posix platforms, while on Posix platforms it should be a no-op.
>> That is the _real_ reason we define O_BINARY.
> 
> Ditto.
> 

Alrighty then -- here's the next iteration.  Both parts have changed a 
bit: the first patch no longer removes #include <fcntl.h> from solib.c, 
while the second patch ONLY addresses the #ifndef O_BINARY clutter and 
no longer removes <fcntl.h> from the 48 files.

Patch 1:
  defs.h  |   12 ++++++++++++
  solib.c |   12 ++++++------
  2 files changed, 18 insertions(+), 6 deletions(-)

2006-02-24  Charles Wilson  <cygwin@...>

	* gdb/defs.h: unconditionally include <fcntl.h>, and
	ensure that O_BINARY is defined.
	* gdb/solib.c(solib_open): ensure solib files are opened in
	binary mode.

Patch 2:
  corelow.c    |    3 ---
  exec.c       |    3 ---
  remote-rdp.c |    3 ---
  source.c     |    3 ---
  symfile.c    |    3 ---
  5 files changed, 15 deletions(-)

2006-02-24  Charles Wilson  <cygwin@...>

	* gdb/corelow.c: Remove O_BINARY macro definition.
	* gdb/exec.c: Remove O_BINARY macro definition
	* gdb/remote-rdp.c: Remove O_BINARY macro definition
	* gdb/source.c: Remove O_BINARY macro definition
	* gdb/symfile.c: Remove O_BINARY macro definition

Per cgf's earlier message, I can go ahead and check this in myself 
assuming everybody's happy with it at this point?

--
Chuck

[-- Attachment #2: gdb-6.4.50.20060131-cvs.solib.patch-attempt3-part1 --]
[-- Type: text/plain, Size: 3351 bytes --]

Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.190
diff -u -r1.190 defs.h
--- defs.h	17 Dec 2005 22:33:59 -0000	1.190
+++ defs.h	22 Feb 2006 20:37:34 -0000
@@ -39,6 +39,8 @@
 #include <unistd.h>
 #endif
 
+#include <fcntl.h>
+
 /* First include ansidecl.h so we can use the various macro definitions
    here and in all subsequent file inclusions.  */
 
@@ -58,6 +60,16 @@
 #define SEEK_CUR 1
 #endif
 
+/* The O_BINARY flag is defined in fcntl.h on some non-Posix platforms.
+   It is used as an access modifier in calls to open(), where it acts
+   similarly to the "b" character in fopen()'s MODE argument. On Posix
+   platforms it should be a no-op, so it is defined as 0 here. This 
+   ensures that the symbol may be used freely elsewhere in gdb. */
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
 #include <stdarg.h>		/* For va_list.  */
 
 #include "libiberty.h"
Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.83
diff -u -r1.83 solib.c
--- solib.c	21 Jan 2006 22:23:27 -0000	1.83
+++ solib.c	22 Feb 2006 20:37:34 -0000
@@ -171,7 +171,7 @@
 	}
 
       /* Now see if we can open it.  */
-      found_file = open (temp_pathname, O_RDONLY, 0);
+      found_file = open (temp_pathname, O_RDONLY | O_BINARY, 0);
     }
 
   /* If the search in solib_absolute_prefix failed, and the path name is
@@ -192,32 +192,32 @@
   /* If not found, search the solib_search_path (if any).  */
   if (found_file < 0 && solib_search_path != NULL)
     found_file = openp (solib_search_path, OPF_TRY_CWD_FIRST,
-			in_pathname, O_RDONLY, 0, &temp_pathname);
+			in_pathname, O_RDONLY | O_BINARY, 0, &temp_pathname);
   
   /* If not found, next search the solib_search_path (if any) for the basename
      only (ignoring the path).  This is to allow reading solibs from a path
      that differs from the opened path.  */
   if (found_file < 0 && solib_search_path != NULL)
     found_file = openp (solib_search_path, OPF_TRY_CWD_FIRST,
-                        lbasename (in_pathname), O_RDONLY, 0,
+                        lbasename (in_pathname), O_RDONLY | O_BINARY, 0,
                         &temp_pathname);
 
   /* If not found, try to use target supplied solib search method */
   if (found_file < 0 && ops->find_and_open_solib)
-    found_file = ops->find_and_open_solib (in_pathname, O_RDONLY,
+    found_file = ops->find_and_open_solib (in_pathname, O_RDONLY | O_BINARY,
 					   &temp_pathname);
 
   /* If not found, next search the inferior's $PATH environment variable. */
   if (found_file < 0 && solib_absolute_prefix == NULL)
     found_file = openp (get_in_environ (inferior_environ, "PATH"),
-			OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY, 0,
+			OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY | O_BINARY, 0,
 			&temp_pathname);
 
   /* If not found, next search the inferior's $LD_LIBRARY_PATH 
      environment variable. */
   if (found_file < 0 && solib_absolute_prefix == NULL)
     found_file = openp (get_in_environ (inferior_environ, "LD_LIBRARY_PATH"),
-			OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY, 0,
+			OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY | O_BINARY, 0,
 			&temp_pathname);
 
   /* Done.  If not found, tough luck.  Return found_file and 

[-- Attachment #3: gdb-6.4.50.20060131-cvs.solib.patch-attempt3-part2 --]
[-- Type: text/plain, Size: 2201 bytes --]

Index: corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.54
diff -u -r1.54 corelow.c
--- corelow.c	24 Jan 2006 22:34:34 -0000	1.54
+++ corelow.c	22 Feb 2006 20:29:45 -0000
@@ -47,9 +47,6 @@
 #include "exceptions.h"
 #include "solib.h"
 
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
 
 #ifndef O_LARGEFILE
 #define O_LARGEFILE 0
Index: exec.c
===================================================================
RCS file: /cvs/src/src/gdb/exec.c,v
retrieving revision 1.59
diff -u -r1.59 exec.c
--- exec.c	17 Dec 2005 22:33:59 -0000	1.59
+++ exec.c	22 Feb 2006 20:29:45 -0000
@@ -42,9 +42,6 @@
 
 #include <ctype.h>
 #include "gdb_stat.h"
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
 
 #include "xcoffsolib.h"
 
Index: remote-rdp.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-rdp.c,v
retrieving revision 1.47
diff -u -r1.47 remote-rdp.c
--- remote-rdp.c	24 Jan 2006 22:09:28 -0000	1.47
+++ remote-rdp.c	22 Feb 2006 20:29:45 -0000
@@ -791,9 +791,6 @@
 #define SWI_GenerateError               0x71
 
 
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
 
 static int translate_open_mode[] =
 {
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.72
diff -u -r1.72 source.c
--- source.c	15 Jan 2006 19:09:30 -0000	1.72
+++ source.c	22 Feb 2006 20:29:45 -0000
@@ -46,9 +46,6 @@
 #include "ui-out.h"
 #include "readline/readline.h"
 
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
 
 #define OPEN_MODE (O_RDONLY | O_BINARY)
 #define FDOPEN_MODE FOPEN_RB
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.165
diff -u -r1.165 symfile.c
--- symfile.c	15 Jan 2006 19:50:03 -0000	1.165
+++ symfile.c	22 Feb 2006 20:29:45 -0000
@@ -60,9 +60,6 @@
 #include <time.h>
 #include <sys/time.h>
 
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
 
 int (*deprecated_ui_load_progress_hook) (const char *section, unsigned long num);
 void (*deprecated_show_load_progress) (const char *section,

  reply	other threads:[~2006-02-24  8:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-17 22:02 Charles Wilson
2006-02-17 23:41 ` Christopher Faylor
2006-02-18 10:45   ` Eli Zaretskii
2006-02-18 11:19     ` Mark Kettenis
2006-02-18 11:47       ` Eli Zaretskii
2006-02-18 11:55         ` Mark Kettenis
2006-02-22  5:52         ` Charles Wilson
2006-02-22 17:06           ` Christopher Faylor
2006-02-22 18:50           ` Eli Zaretskii
2006-02-22 21:55             ` Daniel Jacobowitz
2006-02-24 10:37               ` Charles Wilson [this message]
2006-02-24 11:44                 ` Eli Zaretskii
2006-02-25  7:29                   ` Charles Wilson
2006-03-01 22:11             ` Michael Snyder
2006-02-18 10:50 ` Eli Zaretskii

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=43FEC572.3090403@cwilson.fastmail.fm \
    --to=cygwin@cwilson.fastmail.fm \
    --cc=gdb-patches@sourceware.org \
    /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