From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19891 invoked by alias); 5 Aug 2002 10:27:11 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 19879 invoked from network); 5 Aug 2002 10:27:10 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 5 Aug 2002 10:27:10 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu.redhat.com [172.16.52.200] (may be forged)) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id g75AELl04290 for ; Mon, 5 Aug 2002 06:14:22 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id g75AR8u03186 for ; Mon, 5 Aug 2002 06:27:08 -0400 Received: from cygbert.vinschen.de (vpn50-27.rdu.redhat.com [172.16.50.27]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id g75AR6o11837 for ; Mon, 5 Aug 2002 03:27:06 -0700 Received: (from corinna@localhost) by cygbert.vinschen.de (8.11.6/8.9.3/Linux sendmail 8.9.3) id g75AR0H17339 for gdb-patches@sources.redhat.com; Mon, 5 Aug 2002 12:27:00 +0200 Date: Mon, 05 Aug 2002 03:27:00 -0000 From: Corinna Vinschen To: gdb-patches@sources.redhat.com Subject: [RFA] cli/cli-dump.c: Write dump always in binary mode on Cygwin Message-ID: <20020805122700.Z3921@cygbert.vinschen.de> Reply-To: gdb-patches@sources.redhat.com Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.22.1i X-SW-Source: 2002-08/txt/msg00092.txt.bz2 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 * 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 +#include #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