public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com
Subject: Re: [PATCH] Don't process low-mem files in multifile mode
Date: Tue, 01 Jan 2019 00:00:00 -0000	[thread overview]
Message-ID: <f1f2983e-1531-bcda-49de-e16733b1882b@suse.de> (raw)
In-Reply-To: <20190301184820.GA21919@delia>

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  <tdevries@suse.de>
> 
> 	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 <stdio.h>
>  
> +#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
> 

      reply	other threads:[~2019-03-08 11:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-01  0:00 Tom de Vries
2019-01-01  0:00 ` Tom de Vries [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f1f2983e-1531-bcda-49de-e16733b1882b@suse.de \
    --to=tdevries@suse.de \
    --cc=dwz@sourceware.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).