]> www.infradead.org Git - users/jedix/linux-maple.git/commit
ctf: major duplicate detection fixes
authorNick Alcock <nick.alcock@oracle.com>
Mon, 30 Jul 2012 18:21:15 +0000 (19:21 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Mon, 29 Jun 2015 21:40:27 +0000 (22:40 +0100)
commitf0d0ebd0b4c08edfe65d3f6d2a139484bd7d02df
tree6302e7447bbb5326add2c7e51c8288aeb0ae494a
parent6a6d090b7ddbec76a4be9d62a8dbaa2a0ffadd1a
ctf: major duplicate detection fixes

The duplicate detector had numerous faults.  Among the situations it couldn't
handle:

 - a shared structure 'struct foo' visible in both opaque and non-opaque form,
   with an identically-sized array, pointer, or other entity referring to that
   type in both modules where the type was visible only as an opaque type and
   types where it was visible non-opaquely.

 - any situation in which a member of a shared structure points to a structure
   which would not be shared but for that (and so on, for as many repeated
   points-tos as one wishes)

 - situations in which structures had anonymous structures contained within
   themselves that were used as types for members within the outermost
   structure, whether or not either was shared, e.g.

   struct foo {
       struct {
           int womble;
       } *baz;
   };

   In this situation, the innermost struct would not be noted by the duplicate
   detector, which would lead to a failure to assemble the type later on, as CTF
   assembly can't tell what CTF file it belongs in.

A large-scale rewrite was needed for this, transforming the duplicate detector
from a three-pass scheme with one sharer-of-all-obviously-duplicated-types
running first and last and one detector of transparent/opaque struct/union
aliasing running in the middle, into a scheme where the sharer-of-all runs once,
then the alias detector runs repeatedly, sharing opaque types for which the
corresponding transparent types are already shared, and recursively sharing
transparent types for which the opaque ones are already shared: in the latter
case, it triggers another rerun of the alias detector, in case that recursive
sharing run marks more structures as shared (opaque or transparent).

Worse yet, when we mark a type 'struct foo' as shared, this may not be enough --
there may be types which use that type as a base type which should also be
shared. So the alias detector now runs over not just all structures and unions
but all types which have structures and unions as an ultimate base type,
checking at each level of descent towards the structure whether sharing is
required, and recursively sharing everything from that level down if such is
needed.  (This is done with a type_id() callback, like everything that
involves descending DWARF type use/def chains.)

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