From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124415 invoked by alias); 8 Mar 2019 11:33:27 -0000 Mailing-List: contact dwz-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: dwz-owner@sourceware.org Received: (qmail 124399 invoked by uid 89); 8 Mar 2019 11:33:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=ll, ap, showing X-Spam-Status: No, score=-26.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: mx1.suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Subject: Re: [PATCH] Don't process low-mem files in multifile mode From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com References: <20190301184820.GA21919@delia> Message-ID: Date: Tue, 01 Jan 2019 00:00:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20190301184820.GA21919@delia> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-SW-Source: 2019-q1/txt/msg00105.txt.bz2 On 01-03-19 19:48, Tom de Vries wrote: > Hi, > > Consider three executables, a.out and b.out with n DIEs, and c.out with > n + m DIEs. > > When running in multifile mode, with a low-mem limit of n + m - 1 DIEs: > ... > $ dwz -m common.out -l$(($n + $m - 1)) a.out b.out c.out > ... > the expectation is that c.out is not used in multifile processing, because it > exceeds the low-mem limit. However, all three files turn out to have the > .gnu_debugaltlink section, showing that in fact c.out was used in multifile > processing. > > Fix this by adding a low_mem_p field to struct file_result, setting it in > function dwz and using it in main. > To put it in terms of the --trace switch I just posted, the effect of the patch is: ... $ dwz -t -l$l -m common.out a.out b.out c.out Compressing a.out Write-multifile a.out Compressing b.out Write-multifile b.out Compressing c.out Hit low-mem die-limit Compressing c.out in low-mem mode Optimize-multifile Read-multifile Compressing a.out in finalize-multifile mode Compressing b.out in finalize-multifile mode -Compressing c.out in finalize-multifile mode ... Thanks, - Tom > OK for trunk? > > Thanks, > - Tom > > Don't process low-mem files in multifile mode > > 2019-03-01 Tom de Vries > > PR dwz/24274 > * Makefile (TEST_EXECS): Add hello2. > * dwz.c (struct file_result): Add low_mem_p field. > (dwz): Set low_mem_p field. Remove non-functional low_mem test. > (main): Don't use low_mem_p files in multifile loop. > * hello.c [HAVE_STRUCT] (struct a): New struct. > [HAVE_STRUCT] (a): New var. > (main) [HAVE_STRUCT]: Use a. > * testsuite/dwz.tests/multifile-low-mem.sh: New test. > > --- > Makefile | 5 ++++- > dwz.c | 8 ++++++-- > hello.c | 14 ++++++++++++++ > testsuite/dwz.tests/multifile-low-mem.sh | 26 ++++++++++++++++++++++++++ > 4 files changed, 50 insertions(+), 3 deletions(-) > > diff --git a/Makefile b/Makefile > index bc51ca2..b8dd9ca 100644 > --- a/Makefile > +++ b/Makefile > @@ -17,11 +17,14 @@ clean: > > PWD:=$(shell pwd -P) > > -TEST_EXECS = hello > +TEST_EXECS = hello hello2 > > hello: > $(CC) hello.c -o $@ -g > > +hello2: > + $(CC) hello.c -o $@ -DWITH_STRUCT -g > + > check: dwz $(TEST_EXECS) > mkdir -p testsuite-bin > cd testsuite-bin; ln -sf $(PWD)/dwz . > diff --git a/dwz.c b/dwz.c > index d348418..ffa8e08 100644 > --- a/dwz.c > +++ b/dwz.c > @@ -10954,6 +10954,7 @@ struct file_result > dev_t dev; > ino_t ino; > nlink_t nlink; > + bool low_mem_p; > }; > > /* Handle compression of a single file FILE. If OUTFILE is > @@ -10970,6 +10971,7 @@ dwz (const char *file, const char *outfile, struct file_result *res, > struct stat st; > > res->res = -1; > + res->low_mem_p = low_mem ? true : false; > fd = open (file, O_RDONLY); > if (fd < 0) > { > @@ -10999,6 +11001,7 @@ dwz (const char *file, const char *outfile, struct file_result *res, > break; > if (&resa[n] != res) > { > + res->low_mem_p = resa[n].low_mem_p; > /* If a hardlink to this has been processed before > and we didn't change it, just assume the same > state. */ > @@ -11224,7 +11227,7 @@ dwz (const char *file, const char *outfile, struct file_result *res, > close (fd); > > free (dso); > - if (ret == 0 && !low_mem) > + if (ret == 0) > res->res = 0; > return ret; > } > @@ -11968,7 +11971,8 @@ main (int argc, char *argv[]) > /* Don't process again files that couldn't > be processed successfully. */ > if (resa[i - optind].res == -1 > - || resa[i - optind].res == 1) > + || resa[i - optind].res == 1 > + || resa[i - optind].low_mem_p) > continue; > for (cu = alt_first_cu; cu; cu = cu->cu_next) > alt_clear_dups (cu->cu_die); > diff --git a/hello.c b/hello.c > index 82d070e..ee65515 100644 > --- a/hello.c > +++ b/hello.c > @@ -1,8 +1,22 @@ > #include > > +#ifdef WITH_STRUCT > +struct a { > + int a; > + char *p; > +}; > + > +struct a a; > +#endif > + > int > main (void) > { > +#ifdef WITH_STRUCT > + a.p = "hello"; > + printf ("%s\n", a.p); > +#else > printf ("hello\n"); > +#endif > return 0; > } > diff --git a/testsuite/dwz.tests/multifile-low-mem.sh b/testsuite/dwz.tests/multifile-low-mem.sh > new file mode 100755 > index 0000000..435dfa3 > --- /dev/null > +++ b/testsuite/dwz.tests/multifile-low-mem.sh > @@ -0,0 +1,26 @@ > +#!/bin/sh > + > +set -e > + > +cp ../hello 1 > +cp ../hello 2 > +cp ../hello2 3 > + > +low_mem_limit=$(readelf -w 3 | grep '(DW_TAG' | wc -l) > +low_mem_limit=$((low_mem_limit - 1)) > + > +dwz -l$low_mem_limit -m 4 1 2 3 > + > +smaller-than.sh 1 ../hello > +smaller-than.sh 2 ../hello > +smaller-than.sh 3 ../hello2 > + > +ls=$(ls) > +ls=$(echo $ls) > +[ "$ls" = "1 2 3 4" ] > + > +[ $(gnu-debugaltlink-name.sh 1) = "4" ] > +[ $(gnu-debugaltlink-name.sh 2) = "4" ] > +[ "$(gnu-debugaltlink-name.sh 3)" = "" ] > + > +rm -f 1 2 3 4 >