public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Mark Wielaard <mark@klomp.org>
Cc: dwz@sourceware.org
Subject: Re: [PATCH] Don't handle blocks as exprlocs for DWARF version 4 or higher.
Date: Thu, 18 Feb 2021 17:59:40 +0100	[thread overview]
Message-ID: <20210218165940.GJ4020736@tucnak> (raw)
In-Reply-To: <bbeec145346023a0895783901bb0b743bf9c1778.camel@klomp.org>

On Thu, Feb 18, 2021 at 05:18:10PM +0100, Mark Wielaard wrote:
> > > >        if (form == DW_FORM_block1)
> > 
> > And likewise here:
> > -      if (form == DW_FORM_block1)
> > +      if (form == DW_FORM_block1 && cu->cu_version < 4)
> 
> But here we do need to handle the DW_FORM_block && cu->cu_version >=4
> version separately. But that can be done by not indention the large
> block and adding an small else if block.

Ah, I got confused by DW_FORM_block{2,4,} cases changing form to
DW_FORM_block1, indeed, for all of DW_FORM_{block{1,2,4,},exprloc} we need
to do ptr += len;
But perhaps we could do instead do:
-      if (form == DW_FORM_block1)
+      if (form == DW_FORM_block1 && cu->cu_version < 4)
...
-	  ptr += len;
...
-	  ptr += len;
 	}
+      ptr += len;
?
len is only set to non-0 for:
        case DW_FORM_block1:
          len = *ptr++;
          break;
        case DW_FORM_block2:
          len = read_16 (ptr);
          form = DW_FORM_block1;
          break;
        case DW_FORM_block4:
          len = read_32 (ptr);
          form = DW_FORM_block1;
          break;
        case DW_FORM_block:
          len = read_uleb128 (ptr);
          form = DW_FORM_block1;
          break;
        case DW_FORM_exprloc:
          len = read_uleb128 (ptr);
          break;
i.e. exactly the cases we want to move.

Anyway, looking around some more,
              if (unlikely (low_mem_phase1)
                  && add_locexpr_dummy_dies (dso, cu, die, ptr, form,
                                             t->attr[i].attr, len))
                  goto fail;
looks incorrect to me, form in that case will be DW_FORM_block{2,4,}
and won't be canonicalized to DW_FORM_block1.  And furthermore
len will be always 0.  It is preceded only by
              size_t len = 0;
and a loop handling DW_FORM_indirect.  So, ptr will always be
the pointer to the block count too.
This has been added for PR dwz/24204 by Tom, Tom, can you please comment on
that?
That function handles the DW_FORM_block1 (it wants canonicalization of
DW_FORM_block{2,4,} to DW_FORM_block1) and DW_FORM_exprloc but wants
ptr to be the start of those blocks and len to be the block length, or
it handles DW_FORM_data{4,8} and DW_FORM_sec_offset for which it wants
ptr to stay before the bump.

So, I bet we need something like:
	      switch (form)
		{
		case DW_FORM_block1:
		  len = *ptr++;
		  break;
		case DW_FORM_block2:
		  len = read_16 (ptr);
		  form = DW_FORM_block1;
		  break;
		case DW_FORM_block4:
		  len = read_32 (ptr);
		  form = DW_FORM_block1;
		  break;
		case DW_FORM_block:
		  len = read_uleb128 (ptr);
		  form = DW_FORM_block1;
		  break;
		case DW_FORM_exprloc:
		  len = read_uleb128 (ptr);
		  break;
		default:
		  break;
		}
added before the
              if (unlikely (low_mem_phase1)
                  && add_locexpr_dummy_dies (dso, cu, die, ptr, form,
                                             t->attr[i].attr, len))
                  goto fail;
and then the DW_FORM_{block*,exprloc} handling later on be changed to:
                case DW_FORM_block1:
		  break;
		case DW_FORM_exprloc:
		  form = DW_FORM_block1;
		  break;
and remove the DW_FORM_block{2,4,} cases.

	Jakub


  reply	other threads:[~2021-02-18 16:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-13 22:46 Mark Wielaard
2021-02-18 13:40 ` Mark Wielaard
2021-02-18 14:09   ` Jakub Jelinek
2021-02-18 16:18     ` Mark Wielaard
2021-02-18 16:59       ` Jakub Jelinek [this message]
2021-02-18 17:32         ` Jakub Jelinek
2021-02-18 20:01         ` Mark Wielaard
2021-02-18 20:06           ` Jakub Jelinek
2021-02-18 21:17             ` Mark Wielaard

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=20210218165940.GJ4020736@tucnak \
    --to=jakub@redhat.com \
    --cc=dwz@sourceware.org \
    --cc=mark@klomp.org \
    /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).