Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] cli/cli-dump.c: Write dump always in binary mode on Cygwin
@ 2002-08-05  3:27 Corinna Vinschen
  2002-08-05  5:30 ` Andreas Schwab
  2002-08-05 16:10 ` Michael Snyder
  0 siblings, 2 replies; 15+ messages in thread
From: Corinna Vinschen @ 2002-08-05  3:27 UTC (permalink / raw)
  To: gdb-patches

Hi,

the following patch solves a problem in the dump code in cli/cli-dump.c.
On systems which support binary and textmode file IO, the dump code
doesn't explicitly write in binary mode, resulting in files written
in textmode if that's the current default on the system.  This leads
to a corrupted dump file since each LF is converted to CR/LF in the
file.  The patch uses the "b" flag in the fopen(3) call to write
explicitly binary.  Even if that flag is POSIX standard, I decided
to use it only on systems supporting binmode/textmode so that also
older systems have a chance.

Corinna

2002-08-05  Corinna Vinschen  <vinschen@redhat.com>

	* cli/cli-dump.c: Include fcntl.h to get open(2) flags.
	(add_dump_command): Utilize "b" fopen(3) flag on systems
	defining O_BINARY.

Index: gdb/cli/cli-dump.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-dump.c,v
retrieving revision 1.4
diff -u -p -r1.4 cli-dump.c
--- gdb/cli/cli-dump.c	24 May 2002 01:25:52 -0000	1.4
+++ gdb/cli/cli-dump.c	5 Aug 2002 10:15:17 -0000
@@ -30,6 +30,7 @@
 #include "cli/cli-dump.h"
 #include "gdb_assert.h"
 #include <ctype.h>
+#include <fcntl.h>
 #include "target.h"
 
 #define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
@@ -442,7 +443,11 @@ add_dump_command (char *name, void (*fun
   c->completer =  filename_completer;
   d = XMALLOC (struct dump_context);
   d->func = func;
+#ifdef O_BINARY
+  d->mode = "wb";
+#else
   d->mode = "w";
+#endif
   set_cmd_context (c, d);
   c->func = call_dump_func;
 
@@ -450,7 +455,11 @@ add_dump_command (char *name, void (*fun
   c->completer =  filename_completer;
   d = XMALLOC (struct dump_context);
   d->func = func;
+#ifdef O_BINARY
+  d->mode = "ab";
+#else
   d->mode = "a";
+#endif
   set_cmd_context (c, d);
   c->func = call_dump_func;
 


-- 
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
mailto:vinschen@redhat.com


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2002-08-09 16:36 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-05  3:27 [RFA] cli/cli-dump.c: Write dump always in binary mode on Cygwin Corinna Vinschen
2002-08-05  5:30 ` Andreas Schwab
2002-08-05 16:10 ` Michael Snyder
2002-08-05 21:45   ` Eli Zaretskii
2002-08-06  1:10     ` Corinna Vinschen
2002-08-06  9:12       ` Eli Zaretskii
2002-08-07  1:52         ` Corinna Vinschen
2002-08-06  7:02     ` Andrew Cagney
2002-08-07  8:45     ` Richard Earnshaw
2002-08-07 10:55       ` Andrew Cagney
2002-08-07 22:09       ` Eli Zaretskii
2002-08-08  9:57         ` Andrew Cagney
2002-08-09  2:19           ` [RFA]: Change all fopen modes to binary in cli-dump.c [was Re: [RFA] cli/cli-dump.c: Write dump always in binary mode on Cygwin] Corinna Vinschen
2002-08-09  7:46             ` Andrew Cagney
2002-08-09  9:36               ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox