Message ID | 20190508160012.32596-1-simon.marchi@efficios.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 29359 invoked by alias); 8 May 2019 16:00:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 29214 invoked by uid 89); 8 May 2019 16:00:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HDKIM-Filter:v2.10.3, rc X-HELO: mail.efficios.com Received: from mail.efficios.com (HELO mail.efficios.com) (167.114.142.138) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 May 2019 16:00:24 +0000 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 552351E1D66; Wed, 8 May 2019 12:00:22 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id veEbVRjVwaQB; Wed, 8 May 2019 12:00:21 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id CD3B61E1D61; Wed, 8 May 2019 12:00:21 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com CD3B61E1D61 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1557331221; bh=HHyLKZSP63p2lfXdBRxBKs65zEsZmvEOk49RwP9f/Qs=; h=From:To:Date:Message-Id:MIME-Version; b=YWhhaWitrZGJYX+5aaa51Z8/ekrAMVCywFfolq/j/iZ4yzgej+66UrPKS4chb+uan Qblk6C9qPdwSWOO0RAlLB0Rfwgduor7wLHvgXMP0obAj1VzHCXiTWeBWHlJ+GVdFMj hrTBcNCxJSMUHgiJe/q+CNxRf+I6rszx12GhdwvN+rit8OkrjpZZKgFP/qnEzPU8Lq kF+vDfekZ4QqTNUirKwAfYqVotZGqSMoPlWPNKIsdoYOe5BS4SocgyLAoayJL7EG2B as6CGq+CqkQwu0/jbOHWBTNGY+gd7TOEbP3viS835CK5lfV7sf4QBCwetzIcoJItBJ oeQqIkD7YfHxw== Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id oWw7AGKWUFVk; Wed, 8 May 2019 12:00:21 -0400 (EDT) Received: from smarchi-efficios.internal.efficios.com (192-222-157-41.qc.cable.ebox.net [192.222.157.41]) by mail.efficios.com (Postfix) with ESMTPSA id 978541E1D5C; Wed, 8 May 2019 12:00:21 -0400 (EDT) From: Simon Marchi <simon.marchi@efficios.com> To: gdb-patches@sourceware.org Cc: Tom de Vries <tdevries@suse.de>, Simon Marchi <simon.marchi@efficios.com> Subject: [PATCH] cc-with-tweaks: show dwz stderr and check exit code Date: Wed, 8 May 2019 12:00:12 -0400 Message-Id: <20190508160012.32596-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable |
Commit Message
Simon Marchi
May 8, 2019, 4 p.m. UTC
When running the gdb.base/index-cache.exp test case with the cc-with-dwz-m board, I noticed that the final executable didn't actually contain a .gnu_debugaltlink section with the name of the external dwz file: $ readelf --debug-dump=links testsuite/outputs/gdb.base/index-cache/index-cache * empty * Running dwz by hand, I realized it's because dwz complains that the output .debug_info section is empty and fails: $ gcc ~/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.c -g3 -O0 -o a && cp a b $ dwz -m foo a b dwz: foo: .debug_info section not present $ echo $? 1 This is because index-cache.c is trivial (just an empty main) and dwz doesn't find anything to factor out to the dwz file. [1] I think that cc-with-tweaks should fail in this scenario: if the user asks for an external dwz file to be generated (the -m flag), then it should be an error if cc-with-tweaks doesn't manage to produce an executable with the proper link to this external dwz file. Otherwise, the test runs with a regular non-dwzified executable, which gives a false sense of security about whether the feature under test works with dwzified executables. So this patch adds checks for that after invoking dwz. It also removes the 2>&1 to allow the error message to be printed like so: Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.exp ... gdb compile failed, dwz: /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/index-cache/index-cache.dwz: .debug_info section not present With this patch, fewer tests will pass than before with the cc-with-dwz and cc-with-dwz-m boards, but those were false positives anyway. [1] Note that dwz has been patched by Tom de Vries to work correctly in this case, so we can use dwz master to run the test: https://sourceware.org/git/?p=dwz.git;a=commit;h=08becc8b33453b6d013a65e7eeae57fc1881e801 gdb/ChangeLog: * contrib/cc-with-tweaks.sh: Check for return value of dwz. --- gdb/contrib/cc-with-tweaks.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Comments
On 08-05-19 18:00, Simon Marchi wrote: > When running the gdb.base/index-cache.exp test case with the > cc-with-dwz-m board, I noticed that the final executable didn't actually > contain a .gnu_debugaltlink section with the name of the external dwz > file: > > $ readelf --debug-dump=links testsuite/outputs/gdb.base/index-cache/index-cache > * empty * > > Running dwz by hand, I realized it's because dwz complains that the > output .debug_info section is empty and fails: > > $ gcc ~/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.c -g3 -O0 -o a && cp a b > $ dwz -m foo a b > dwz: foo: .debug_info section not present > $ echo $? > 1 > > This is because index-cache.c is trivial (just an empty main) and dwz > doesn't find anything to factor out to the dwz file. [1] > > I think that cc-with-tweaks should fail in this scenario: > if the user > asks for an external dwz file to be generated (the -m flag), This dwz semantics is open for debate, I think. In the case of dwz a, the user asks for a to be compressed, and if that doesn't happen due to size heuristics, then execution is still considered a success. In the case of dwz a -o b, the user asks for b to be generated, and failure to generate b (f.i. due to size heuristics) is considered an error. [ Which I guess is similar to the -o option of many other Linux commands. ] ISTM that the -m option could be interpreted either way. And I prefer the interpretation of -m as: generate an external dwz file, if beneficial. > then it > should be an error if cc-with-tweaks doesn't manage to produce an > executable with the proper link to this external dwz file. Otherwise, > the test runs with a regular non-dwzified executable, which gives a > false sense of security about whether the feature under test works with > dwzified executables. > Agreed. Failing in cc-with-tweaks.sh in this case will list the test-case as UNTESTED, which is a fair representation. [ And at some point we can add support in cc-with-tweaks.sh for dwz --devel-ignore-size (a switch only supported if dwz is compiled with -DDEVEL) which makes it more likely to transform the input file and generate an -m file, even if it's not beneficial, which will mean fewer UNTESTED test-cases. ] [ nitpick: And coming back to the false sense of security: there's no guarantee that the DWARF that is intended to be tested by a particular test-case is in fact transformed by dwz, even if the executable as a whole is indeed transformed. So running the test-suite with dwz does not guarantee that the feature under test works with dwzified executables. ] > So this patch adds checks for that after invoking dwz. It also removes > the 2>&1 to allow the error message to be printed like so: > > Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/index-cache.exp ... > gdb compile failed, dwz: /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/index-cache/index-cache.dwz: .debug_info section not present > Nice. I've used your patch to test, and because of this more verbose behaviour I already noticed a new error message ("Error mmapping multi-file temporary files"), and fixed it in dwz. > With this patch, fewer tests will pass than before with the > cc-with-dwz and cc-with-dwz-m boards, but those were false positives > anyway. > Ack. > [1] Note that dwz has been patched by Tom de Vries to work correctly in > this case, so we can use dwz master to run the test: > > https://sourceware.org/git/?p=dwz.git;a=commit;h=08becc8b33453b6d013a65e7eeae57fc1881e801 > > gdb/ChangeLog: > > * contrib/cc-with-tweaks.sh: Check for return value of dwz. > --- > gdb/contrib/cc-with-tweaks.sh | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/gdb/contrib/cc-with-tweaks.sh b/gdb/contrib/cc-with-tweaks.sh > index 47379cc15875..366b90918c18 100755 > --- a/gdb/contrib/cc-with-tweaks.sh > +++ b/gdb/contrib/cc-with-tweaks.sh > @@ -180,10 +180,14 @@ if [ "$want_index" = true ]; then > fi > > if [ "$want_dwz" = true ]; then > - $DWZ "$output_file" > /dev/null 2>&1 > + $DWZ "$output_file" > /dev/null > + rc=$? > + [ $rc != 0 ] && exit $rc > elif [ "$want_multi" = true ]; then > cp $output_file ${output_file}.alt > - $DWZ -m ${output_file}.dwz "$output_file" ${output_file}.alt > /dev/null 2>&1 > + $DWZ -m ${output_file}.dwz "$output_file" ${output_file}.alt > /dev/null > + rc=$? > + [ $rc != 0 ] && exit $rc > rm -f ${output_file}.alt > fi I wonder if it's more reliable to test for presence of -m file rather than exit status (and likewise, we could copy and compare for the want_dwz case). Also, I propose to run dwz with -q, to inhibit the countless "not beneficial" messages. It's good to list these cases as untested, but in the log we'd rather skip the uninteresting messages, to increase the likelyhood that interesting messages get spotted. Thanks, - Tom
diff --git a/gdb/contrib/cc-with-tweaks.sh b/gdb/contrib/cc-with-tweaks.sh index 47379cc15875..366b90918c18 100755 --- a/gdb/contrib/cc-with-tweaks.sh +++ b/gdb/contrib/cc-with-tweaks.sh @@ -180,10 +180,14 @@ if [ "$want_index" = true ]; then fi if [ "$want_dwz" = true ]; then - $DWZ "$output_file" > /dev/null 2>&1 + $DWZ "$output_file" > /dev/null + rc=$? + [ $rc != 0 ] && exit $rc elif [ "$want_multi" = true ]; then cp $output_file ${output_file}.alt - $DWZ -m ${output_file}.dwz "$output_file" ${output_file}.alt > /dev/null 2>&1 + $DWZ -m ${output_file}.dwz "$output_file" ${output_file}.alt > /dev/null + rc=$? + [ $rc != 0 ] && exit $rc rm -f ${output_file}.alt fi