]> www.infradead.org Git - users/jedix/linux-maple.git/commit
ctf: correctly propagate IDs for array types
authorNick Alcock <nick.alcock@oracle.com>
Thu, 9 Aug 2012 23:54:55 +0000 (00:54 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Mon, 29 Jun 2015 21:40:30 +0000 (22:40 +0100)
commitd7ea997059ccf6c75248d62b5df440efcabc5c80
tree618266727884ea1f5294efa0662ca32c082b327d
parentfa9f3942a92d05f2a7e9387c7a8b68c29aef8de9
ctf: correctly propagate IDs for array types

We were constructing things of array type wrongly, for a rather interesting
reason.

DWARF describes an array by putting its base type in the parent DIE, then
describing its bounds in the child DIE.  Unfortunately, this puts us in an
unfortunate position: we always visit the parent before its children (so we can
build things like structures before filling their members in) -- but you can't
build a CTF array without knowing what its bounds are ('flexible' is not the
same as 'we don't know yet') -- and we *do* need the base type to be constructed
anyway.  So we constructed the base type when working over the parent DIE, then
wrapped an array around it when we visited the children where the dimensions
were described (possibly more than one for a multidimensional array: though GCC
happens not to emit those for C, it is permitted to, and handling it is easy, so
we do).  Unfortunately, recurse_ctf() throws away the type ID returned from
child DIEs, so the CTF ID that gets stashed for assignment to things of that
array type (when they are looked up via lookup_ctf_type()) turns out not to be
an array type at all, but the base type!

So we add an optional override parameter to recurse_ctf() and to all the
construction functions: it is passed only by recursive recurse_ctf() calls (when
processing child DIEs): it is set nonzero by construction functions that wrap
and replace the ID from their parent DIE, and when it is set, the type ID
returned by the construction function replaces the type ID that recurse_ctf()
passes back to its parent.  Now assemble_ctf_array_dimension() just needs to
set this override parameter, and all is well.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
scripts/dwarf2ctf/dwarf2ctf.c