From patchwork Mon Dec 15 20:59:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 4261 Received: (qmail 7403 invoked by alias); 15 Dec 2014 21:00:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 7265 invoked by uid 89); 15 Dec 2014 21:00:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 15 Dec 2014 21:00:10 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBFL09kv009362 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 15 Dec 2014 16:00:09 -0500 Received: from psique.yyz.redhat.com (dhcp-10-15-16-169.yyz.redhat.com [10.15.16.169]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBFL05ag028671; Mon, 15 Dec 2014 16:00:07 -0500 From: Sergio Durigan Junior To: GDB Patches Cc: Jan Kratochvil , Sergio Durigan Junior Subject: [PATCH] Make dg-extract-results.sh explicitly treat .{sum, log} files as text Date: Mon, 15 Dec 2014 15:59:56 -0500 Message-Id: <1418677196-20721-1-git-send-email-sergiodj@redhat.com> X-IsSubscribed: yes This weekend I was running GDB's testsuite with many options enabled, and I noticed that, for some specific configurations (specifically when testing gdbserver), I was getting the following error: dg-extract-results.sh: sum files are for multiple tools, specify a tool I remembered seeing this a lot before, so I spent some time investigating the cause... First, I found the line on dg-extract-results.sh that printed this error message. The code does: CNT=`grep '=== .* tests ===' $SUM_FILES --text | $AWK '{ print $3 }' | sort -u | wc -l` if [ $CNT -eq 1 ]; then TOOL=`grep '=== .* tests ===' $FIRST_SUM --text | $AWK '{ print $2 }'` else msg "${PROGNAME}: sum files are for multiple tools, specify a tool" msg "" usage exit 1 fi So, the first thing to do was to identify why $CNT was not 1. When I ran the command that generated the result for CNT, I found: $ grep '=== .* tests ===' `find outputs -name gdb.log -print` \ | awk '{ print $3 }' | sort -u | wc -l 7 Hm, strange. So, removing the wc command, the output was: gdb outputs/gdb.base/gdb-sigterm/gdb.log outputs/gdb.threads/non-ldr-exc-1/gdb.log outputs/gdb.threads/non-ldr-exc-2/gdb.log outputs/gdb.threads/non-ldr-exc-3/gdb.log outputs/gdb.threads/non-ldr-exc-4/gdb.log outputs/gdb.threads/thread-execl/gdb.log And, when I used only the grep command, without the awk and the sort, I saw that the majority of the lines were like this: outputs/gdb.trace/tfind/gdb.log: === gdb tests === Which would generated the first line in the output above, "gdb". But, for the other 6 files above, I saw: Binary file outputs/gdb.base/gdb-sigterm/gdb.log matches Right, the problem is that grep is assuming those 6 files are binary, not text. This happens because of this code, in grep: static enum textbin buffer_textbin (char *buf, size_t size) { if (eolbyte && memchr (buf, '\0', size)) return TEXTBIN_BINARY; ... If one looks at those 6 files, one will find that they contain the NUL byte there. They are all printed by the same message, by gdbserver's code: input_interrupt, count = 0 c = 0 ('^@') (The ^@ above is the NUL byte.) Maybe the right fix would be to improve input_interrupt in gdbserver/remote-utils.c (see PR server/16359), but I decided to go the easier route and adjust the dg-extract-results.sh to be more robust when dealing with the sum and log files. To do that, I am suggest passing the '--text' option to grep, which overrides grep's machinery to identify if the file is binary and forces it to treat every file as text. For me, it makes sense to do that because sum and log files will always be text, no matter what happens. OK to apply? 2014-12-14 Sergio Durigan Junior * dg-extract-results.sh: Pass '--text' option to grep when filtering .{sum,log} files, which may contain binary data. --- gdb/testsuite/dg-extract-results.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/dg-extract-results.sh b/gdb/testsuite/dg-extract-results.sh index 42190ae..5fe935a 100755 --- a/gdb/testsuite/dg-extract-results.sh +++ b/gdb/testsuite/dg-extract-results.sh @@ -120,9 +120,9 @@ if [ -z "$TOOL" ]; then # If no tool was specified, all specified summary files must be for # the same tool. - CNT=`grep '=== .* tests ===' $SUM_FILES | $AWK '{ print $3 }' | sort -u | wc -l` + CNT=`grep '=== .* tests ===' $SUM_FILES --text | $AWK '{ print $3 }' | sort -u | wc -l` if [ $CNT -eq 1 ]; then - TOOL=`grep '=== .* tests ===' $FIRST_SUM | $AWK '{ print $2 }'` + TOOL=`grep '=== .* tests ===' $FIRST_SUM --text | $AWK '{ print $2 }'` else msg "${PROGNAME}: sum files are for multiple tools, specify a tool" msg "" @@ -133,7 +133,7 @@ else # Ignore the specified summary files that are not for this tool. This # should keep the relevant files in the same order. - SUM_FILES=`grep -l "=== $TOOL" $SUM_FILES` + SUM_FILES=`grep -l "=== $TOOL" $SUM_FILES --text` if test -z "$SUM_FILES" ; then msg "${PROGNAME}: none of the specified files are results for $TOOL" exit 1 @@ -222,7 +222,7 @@ else VARIANTS="" for VAR in $VARS do - grep "Running target $VAR" $SUM_FILES > /dev/null && VARIANTS="$VARIANTS $VAR" + grep "Running target $VAR" $SUM_FILES --text > /dev/null && VARIANTS="$VARIANTS $VAR" done fi