Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCHv3 5/7] gdb: create address map after parsing all DIE
Date: Mon, 05 Jan 2026 21:37:24 +0000	[thread overview]
Message-ID: <87v7hfwxkb.fsf@redhat.com> (raw)
In-Reply-To: <878qebvnce.fsf@tromey.com>

Tom Tromey <tom@tromey.com> writes:

>>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
>
> Andrew> The addrmap requires that we add the most inner blocks first.  I
> Andrew> achieve this by walking the blockvector backward, as we always add
> Andrew> parent blocks before their more inner child blocks.
>
>>> I wonder if this is guaranteed to be correct.  Like, does gdb cope
>>> properly if a compiler happens to emit multiple lexical scopes that each
>>> have non-contiguous ranges, and then where the ranges happen to overlap.
>
> [...]
> Andrew> Now the two lexical blocks are siblings, but if we make the second block
> Andrew> overlap the first then this patch does cause problems.
> [...]
> Andrew> This DOES change GDB's behaviour.
>
> Andrew> Is this sibling case the type of case you were thinking of?  Or have I
> Andrew> got the wrong end of the stick here?
>
> I think your analysis is in line with what I was thinking.
>
> My main concern is whether incorrect input can make gdb crash by
> violating some addrmap invariant; and then also if sufficiently weird
> but nominally valid input can make gdb do the wrong thing.

I'm not too worried about addrmap crashing; I'm just adding things in a
slightly different order so if there is some weird overlap, addrmap will
just build a different address to block mapping, but this shouldn't
cause crashes from addrmap.  And ideally shouldn't be crashing the rest
of GDB either, we'll just end up with a different block (possibly, and
again, this is only in the case of some weird overlap).

At least, my experience while working on this was less, oops I've built
the wrong addrmap and now GDB crashed, and more, I've built the wrong
addrmap, and now GDB doesn't know where it is stopped, or the local
variables are no longer visible.

Which brings us to your second worry.  This patch, for sure changes the
order in which blocks are added into the addrmap.  More nested blocks
are added before their parents, so if we don't have overlapping
siblings, then this should result in the same mapping.  But I cannot
guarantee that there's not some weird compiler out there that does emit
such cases.  But we don't have tests for such cases yet, and I saw no
comments discussing such things, so I'm hoping that's not a thing.

If we do have overlapping siblings then I don't think current GDB will
work; at least, locals from one of the siblings will not be visible in
the overlap region.  This patch might change which sibling though.

When I originally wrote this patch I did try to retain the original
order in which blocks are added to the addrmap, and I looked at this
again today.  The problem is the particular ordering we use when
building the pending block list (see record_pending_block), as well as
pending block sorting (see end_compunit_symtab_get_static_block).  The
conclusion I've come to is that if the original block order is critical,
or if we just don't want to move away from this ordering, then we'd need
to add another data structure to track the desired order.  I didn't do
this for two reasons (1) saving space and time, and (2) so long as the
bottom up invariant remained, I figured the other changes should be
harmless.

You did give an approve for the original patch; I still need to update
the comments as you suggested, but is there anything else you'd like me
to investigate to help address your concerns?  Otherwise my hope would
be to merge this and address any issues if/when they arise down the
line.

Thanks,
Andrew


  reply	other threads:[~2026-01-05 21:37 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-20 10:20 [PATCH 0/7] Inline Function Optimised Code Debug Improvements Andrew Burgess
2025-07-20 10:20 ` [PATCH 1/7] gdb: improve line number lookup around inline functions Andrew Burgess
2025-07-20 10:20 ` [PATCH 2/7] gdb: handle empty ranges for inline subroutines Andrew Burgess
2025-07-20 10:20 ` [PATCH 3/7] gdb: split dwarf line table parsing in two Andrew Burgess
2025-07-20 10:20 ` [PATCH 4/7] gdb: move block range recording into its own function Andrew Burgess
2025-07-20 10:20 ` [PATCH 5/7] gdb: create address map after parsing all DIE Andrew Burgess
2025-07-20 10:20 ` [PATCH 6/7] gdb: record block end addresses while parsing DIEs Andrew Burgess
2025-07-20 10:20 ` [PATCH 7/7] gdb: fix-up truncated inline function block ranges Andrew Burgess
2025-08-01  8:58 ` [PATCHv2 0/7] Inline Function Optimised Code Debug Improvements Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 1/7] gdb: improve line number lookup around inline functions Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 2/7] gdb: handle empty ranges for inline subroutines Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 3/7] gdb: split dwarf line table parsing in two Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 4/7] gdb: move block range recording into its own function Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 5/7] gdb: create address map after parsing all DIE Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 6/7] gdb: record block end addresses while parsing DIEs Andrew Burgess
2025-08-01  8:58   ` [PATCHv2 7/7] gdb: fix-up truncated inline function block ranges Andrew Burgess
2025-10-16 17:49   ` [PATCHv3 0/7] Inline Function Optimised Code Debug Improvements Andrew Burgess
2025-10-16 17:49     ` [PATCHv3 1/7] gdb: improve line number lookup around inline functions Andrew Burgess
2025-10-27 22:22       ` Tom Tromey
2025-12-17 14:32         ` Andrew Burgess
2025-12-17 14:48           ` Tom de Vries
2025-12-18 14:46             ` Andrew Burgess
2025-10-16 17:49     ` [PATCHv3 2/7] gdb: handle empty ranges for inline subroutines Andrew Burgess
2025-10-16 17:49     ` [PATCHv3 3/7] gdb: split dwarf line table parsing in two Andrew Burgess
2025-10-16 17:49     ` [PATCHv3 4/7] gdb: move block range recording into its own function Andrew Burgess
2025-10-27 22:45       ` Tom Tromey
2025-10-16 17:49     ` [PATCHv3 5/7] gdb: create address map after parsing all DIE Andrew Burgess
2025-10-27 22:56       ` Tom Tromey
2026-01-02 16:36         ` Andrew Burgess
2026-01-05 20:03           ` Tom Tromey
2026-01-05 21:37             ` Andrew Burgess [this message]
2026-01-06  0:53               ` Tom Tromey
2025-10-16 17:49     ` [PATCHv3 6/7] gdb: record block end addresses while parsing DIEs Andrew Burgess
2025-10-27 23:00       ` Tom Tromey
2025-10-16 17:49     ` [PATCHv3 7/7] gdb: fix-up truncated inline function block ranges Andrew Burgess
2026-02-04 10:43     ` [PATCHv3 0/7] Inline Function Optimised Code Debug Improvements Andrew Burgess
2025-08-01 15:41 ` [PATCH " Sam James

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=87v7hfwxkb.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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