]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2015-01-22 Max Ostapenko <m.ostapenko@partner.samsung.com>
authorchefmax <chefmax@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Jan 2015 10:55:32 +0000 (10:55 +0000)
committerchefmax <chefmax@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Jan 2015 10:55:32 +0000 (10:55 +0000)
PR driver/64690
* gcc.c (insert_comments): New function.
(try_generate_repro): Call it.
(append_text): Removed.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219990 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/gcc.c

index 520b03de580d96f53d7a3534688dd43f1cf11051..7a1c6e567f1320be9e898d4cd07fc6634e2f4a10 100644 (file)
@@ -1,3 +1,10 @@
+2015-01-22  Max Ostapenko  <m.ostapenko@partner.samsung.com>
+
+       PR driver/64690
+       * gcc.c (insert_comments): New function.
+       (try_generate_repro): Call it.
+       (append_text): Removed.
+
 2015-01-22  Richard Biener  <rguenther@suse.de>
 
        * ipa-inline.c (can_inline_edge_p): Disable inlining of edges
index 52d0521f764d637861a0b92d61176e882e5f9570..c1e5ca5037657ea133d5f7952d73b44911bf9bb8 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -6487,6 +6487,29 @@ out:
   return status;
 }
 
+/* This routine reads lines from IN file, adds C++ style comments
+   at the begining of each line and writes result into OUT.  */
+
+static void
+insert_comments (const char *file_in, const char *file_out)
+{
+  FILE *in = fopen (file_in, "rb");
+  FILE *out = fopen (file_out, "wb");
+  char line[256];
+
+  bool add_comment = true;
+  while (fgets (line, sizeof (line), in))
+    {
+      if (add_comment)
+       fputs ("// ", out);
+      fputs (line, out);
+      add_comment = strchr (line, '\n') != NULL;
+    }
+
+  fclose (in);
+  fclose (out);
+}
+
 /* This routine adds preprocessed source code into the given ERR_FILE.
    To do this, it adds "-E" to NEW_ARGV and execute RUN_ATTEMPT routine to
    add information in report file.  RUN_ATTEMPT should return
@@ -6523,19 +6546,6 @@ do_report_bug (const char **new_argv, const int nargs,
     }
 }
 
-/* Append string STR to file FILE.  */
-
-static void
-append_text (char *file, const char *str)
-{
-  int fd = open (file, O_RDWR | O_APPEND);
-  if (fd < 0)
-    return;
-
-  write (fd, str, strlen (str));
-  close (fd);
-}
-
 /* Try to reproduce ICE.  If bug is reproducible, generate report .err file
    containing GCC configuration, backtrace, compiler's command line options
    and preprocessed source code.  */
@@ -6598,16 +6608,10 @@ try_generate_repro (const char **argv)
          emit_system_info = 1;
        }
 
-      if (emit_system_info)
-       append_text (temp_stderr_files[attempt], "/*\n");
-
       status = run_attempt (new_argv, temp_stdout_files[attempt],
                            temp_stderr_files[attempt], emit_system_info,
                            append);
 
-      if (emit_system_info)
-       append_text (temp_stderr_files[attempt], "*/\n");
-
       if (status != ATTEMPT_STATUS_ICE)
        {
          fnotice (stderr, "The bug is not reproducible, so it is"
@@ -6619,11 +6623,17 @@ try_generate_repro (const char **argv)
   if (!check_repro (temp_stdout_files, temp_stderr_files))
     goto out;
 
-  /* In final attempt we append compiler options and preprocesssed code to last
-     generated .err file with configuration and backtrace.  */
-  do_report_bug (new_argv, nargs,
-                &temp_stderr_files[RETRY_ICE_ATTEMPTS - 1],
-                &temp_stdout_files[RETRY_ICE_ATTEMPTS - 1]);
+  {
+    /* Insert commented out backtrace into report file.  */
+    char **stderr_commented = &temp_stdout_files[RETRY_ICE_ATTEMPTS - 1];
+    insert_comments (temp_stderr_files[RETRY_ICE_ATTEMPTS - 1],
+                    *stderr_commented);
+
+    /* In final attempt we append compiler options and preprocesssed code to last
+       generated .out file with configuration and backtrace.  */
+    char **output = &temp_stdout_files[RETRY_ICE_ATTEMPTS - 1];
+    do_report_bug (new_argv, nargs, stderr_commented, output);
+  }
 
 out:
   for (i = 0; i < RETRY_ICE_ATTEMPTS * 2; i++)