Mailing-List: contact cygwin-apps-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-apps-owner AT sourceware DOT cygnus DOT com List-Subscribe: List-Archive: List-Post: List-Help: , Delivered-To: mailing list cygwin-apps AT sources DOT redhat DOT com Message-ID: <20011105205727.41535.qmail@web14507.mail.yahoo.com> Date: Tue, 6 Nov 2001 07:57:27 +1100 (EST) From: =?iso-8859-1?q?Danny=20Smith?= Subject: Patch for gcc profiling code (2.95.3) To: cygwin-apps MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sorry about my fat fingers on the last empty message. Just in case your thinking of another maintenance of 2.95.3 for cygwin, the following patch (which has been in gcc trunk for ages) fixes problems with CRLF in source files when profiling. This is motivated by recent bug report to GCC http://gcc.gnu.org/ml/gcc-bugs/2001-11/msg00145.html ChangeLog Fri Oct 29 15:25:07 1999 Arnaud Charlet * gcov.c (DIR_SEPARATOR): Provide default. (output_data): Add test for MS-DOS format absolute filename. (fancy_abort): Correct program name. (open_files): Open all files in binary mode. * libgcc2.c (__bb_exit_func): Likewise. * profile.c (init_branch_prob): Specify binary when opening files 2001-11-05 Danny Smith * gcov.c (IS_DIR_SEPARATOR): Provide default definition. (output_data): Use it to test for absolute pathname. diff -urp gcc-2.95.3-20010828\gcc\gcov.c gcc-2.95.3\gcc\gcov.c --- gcc-2.95.3-20010828\gcc\gcov.c Wed May 16 18:38:18 2001 +++ gcc-2.95.3\gcc\gcov.c Mon Nov 05 21:51:34 2001 @@ -266,6 +266,17 @@ fnotice VPROTO ((FILE *file, const char va_end (ap); } +#ifndef DIR_SEPARATOR +#define DIR_SEPARATOR '/' +#endif + +/* Define IS_DIR_SEPARATOR. */ +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ PTR xmalloc (size) @@ -286,7 +297,7 @@ xmalloc (size) void fancy_abort () { - fnotice (stderr, "Internal gcc abort.\n"); + fnotice (stderr, "Internal gcov abort.\n"); exit (FATAL_EXIT_CODE); } @@ -410,7 +421,7 @@ open_files () else strcat (bbg_file_name, ".bbg"); - bb_file = fopen (bb_file_name, "r"); + bb_file = fopen (bb_file_name, "rb"); if (bb_file == NULL) { fnotice (stderr, "Could not open basic block file %s.\n", bb_file_name); @@ -419,14 +430,14 @@ open_files () /* If none of the functions in the file were executed, then there won't be a .da file. Just assume that all counts are zero in this case. */ - da_file = fopen (da_file_name, "r"); + da_file = fopen (da_file_name, "rb"); if (da_file == NULL) { fnotice (stderr, "Could not open data file %s.\n", da_file_name); fnotice (stderr, "Assuming that all execution counts are zero.\n"); } - bbg_file = fopen (bbg_file_name, "r"); + bbg_file = fopen (bbg_file_name, "rb"); if (bbg_file == NULL) { fnotice (stderr, "Could not open program flow graph file %s.\n", @@ -1006,7 +1017,15 @@ output_data () { /* If this is a relative file name, and an object directory has been specified, then make it relative to the object directory name. */ - if (*s_ptr->name != '/' && object_directory != 0 + if (! (IS_DIR_SEPARATOR (s_ptr->name[0]) + /* Check for disk name on MS-DOS-based systems. */ +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + || (s_ptr->name[0] != '\0' + && s_ptr->name[1] == ':' + && IS_DIR_SEPARATOR (s_ptr->name[2])) +#endif + ) + && object_directory != 0 && *object_directory != '\0') { int objdir_count = strlen (object_directory); diff -urp gcc-2.95.3-20010828\gcc\libgcc2.c gcc-2.95.3\gcc\libgcc2.c --- gcc-2.95.3-20010828\gcc\libgcc2.c Wed May 16 22:08:30 2001 +++ gcc-2.95.3\gcc\libgcc2.c Mon Nov 05 16:19:46 2001 @@ -1523,7 +1523,7 @@ __bb_exit_func (void) /* If the file exists, and the number of counts in it is the same, then merge them in. */ - if ((da_file = fopen (ptr->filename, "r")) != 0) + if ((da_file = fopen (ptr->filename, "rb")) != 0) { long n_counts = 0; @@ -1559,7 +1559,7 @@ __bb_exit_func (void) feprintf ("arc profiling: Error closing output file %s.\n", ptr->filename); } - if ((da_file = fopen (ptr->filename, "w")) == 0) + if ((da_file = fopen (ptr->filename, "wb")) == 0) { feprintf ("arc profiling: Can't open output file %s.\n", ptr->filename); diff -urp gcc-2.95.3-20010828\gcc\profile.c gcc-2.95.3\gcc\profile.c --- gcc-2.95.3-20010828\gcc\profile.c Wed May 16 18:38:18 2001 +++ gcc-2.95.3\gcc\profile.c Mon Nov 05 16:21:37 2001 @@ -1420,7 +1420,7 @@ init_branch_prob (filename) strcpy (data_file, filename); strip_off_ending (data_file, len); strcat (data_file, ".bb"); - if ((bb_file = fopen (data_file, "w")) == 0) + if ((bb_file = fopen (data_file, "wb")) == 0) pfatal_with_name (data_file); /* Open an output file for the program flow graph. */ @@ -1429,7 +1429,7 @@ init_branch_prob (filename) strcpy (bbg_file_name, filename); strip_off_ending (bbg_file_name, len); strcat (bbg_file_name, ".bbg"); - if ((bbg_file = fopen (bbg_file_name, "w")) == 0) + if ((bbg_file = fopen (bbg_file_name, "wb")) == 0) pfatal_with_name (bbg_file_name); /* Initialize to zero, to ensure that the first file name will be @@ -1444,7 +1444,7 @@ init_branch_prob (filename) strcpy (da_file_name, filename); strip_off_ending (da_file_name, len); strcat (da_file_name, ".da"); - if ((da_file = fopen (da_file_name, "r")) == 0) + if ((da_file = fopen (da_file_name, "rb")) == 0) warning ("file %s not found, execution counts assumed to be zero.", da_file_name); http://briefcase.yahoo.com.au - Yahoo! Briefcase - Manage your files online.