From patchwork Thu Jan 22 08:25:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: max X-Patchwork-Id: 431740 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 446C4140284 for ; Thu, 22 Jan 2015 20:25:44 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=LKi7UwCd6Mel9nWkrn241yXYZBVMwRKAa4XlycPO5ir UOnNIdntQP0uuRai0mO8bRgL4U2/Nr9B/by6g1Ylb0yIqYr0TQPXZjOn7VuEZeYX N4TcSyCTfyC5UN1Vw4KO25CFwec4hXuTADYOOTBAB4OI3NXfSrfiKvTSNtAvUGSg = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=Fhd4m2S1ghK0A7O9asNJvwG9IBI=; b=g+q8Lwag8ub+uAlT3 5TfIJigVNgVaryDqQBvGtVJfjeFb5qAchzVZFC1VEdbjMPFEiCf09GFU/Fs42z50 QhFO+uXR7HKQJZJkAsKnZ5AwH5XtMpEIIOjF1TNj8hD4vNvII7JfkByNMoheOaNd +WJ5QZCgyCvqMl8DBo+nfVaC1k= Received: (qmail 25068 invoked by alias); 22 Jan 2015 09:25:36 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 25045 invoked by uid 89); 22 Jan 2015 09:25:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_HDRS_LCASE, T_MANY_HDRS_LCASE, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailout4.w1.samsung.com Received: from mailout4.w1.samsung.com (HELO mailout4.w1.samsung.com) (210.118.77.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (DES-CBC3-SHA encrypted) ESMTPS; Thu, 22 Jan 2015 09:25:30 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NIK005CUNP3OH80@mailout4.w1.samsung.com> for gcc-patches@gcc.gnu.org; Thu, 22 Jan 2015 09:29:27 +0000 (GMT) Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 42.CA.26295.571C0C45; Thu, 22 Jan 2015 09:23:01 +0000 (GMT) Received: from [106.109.130.26] by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NIK00LK3NIDNZ70@eusync3.samsung.com>; Thu, 22 Jan 2015 09:25:26 +0000 (GMT) Message-id: <54C0B3F0.7080508@partner.samsung.com> Date: Thu, 22 Jan 2015 12:25:20 +0400 From: Maxim Ostapenko User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-version: 1.0 To: GCC Patches Cc: Jakub Jelinek , Yury Gribov , Slava Garbuzov Subject: [PATCH, driver/64690] Fix -freport-bug issue with comments. Content-type: multipart/mixed; boundary=------------010502020503010909090205 X-IsSubscribed: yes Hi, As -freport-bug dumps also the error output into the file as /* ... */ comment, there is a problem if that text includes /* or */ character sequences. This patch fixes this by not wrapping error output with /* ... */, but comment out each line with C++ style comments instead. Tested on PR64688 testcase with added /* */ before last line, bootstrap in progress. Ok to commit if bootstrap succeed? -Maxim gcc/ChangeLog: 2015-01-22 Max Ostapenko PR driver/64690 * gcc.c (insert_comments): New function. (try_generate_repro): Call it. (append_text): Removed. diff --git a/gcc/gcc.c b/gcc/gcc.c index 52d0521..6d3939c 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -6487,6 +6487,28 @@ 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]; + fputs ("// ", out); + while (fgets (line, sizeof (line), in)) + { + fputs (line, out); + if (strchr (line, '\n')) + { + fputs ("// ", out); + } + } + 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 +6545,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 +6607,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 +6622,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++)