On Sat, Oct 28, 2017 at 04:05:23PM +0200, Martin Pieuchot wrote:
> Diff below makes ctfconv(1) aware of forward declarations and merge them
> with the corresponding type as soon as they are known.
> 
> This reduces the number of type entries in a kernel CTF section by ~4K.
> 
> After applying this diff, grepping for "(0 bytes)" in the ctfdump(1)
> output points to code that generally needs a cleanup.
> 
> ok?
> 
> [...]
> @@ -299,12 +324,6 @@ it_cmp(struct itype *a, struct itype *b)
>       if ((diff = (a->it_type - b->it_type)) != 0)
>               return diff;
>  
> -     if ((diff = (a->it_size - b->it_size)) != 0)
> -             return diff;
> -
> -     if ((diff = (a->it_nelems - b->it_nelems)) != 0)
> -             return diff;
> -
>       /* Match by name */
>       if (!(a->it_flags & ITF_ANON) && !(b->it_flags & ITF_ANON))
>               return strcmp(it_name(a), it_name(b));

I don't understand the motivation for this part of the change.
it_merge() copies the it_size and it_nelems fields, so we ought to be
able to merge the two types regardless. Moreover, what if two CUs
define identically named structs? With this patch, we will merge
them even when they have different sizes or member counts.

Note though that the existing checks in it_cmp() are not sufficient.
For instance, ctfconv(1) currently will merge the following structs:

struct a { int foo; };
struct a { u_int bar; };

Fixing this in general is non-trivial.

Reply via email to