ctfconvert : failed to resolve types

Artem Belevich fbsdlist at src.cx
Sun Jun 6 07:18:11 UTC 2010


Interesting. Looking at dwarf parsing sources in DTrace, and there are
comments that suggest that ctfconvert should've been able to deal with
zero-sized arrays.

Look at die_sou_resolve() in cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c

One observation, if you add a real member to the union that otherwise
contains only zero-sized arrays, then ctfconvert is happy.
This suggests that it can deal with zero-sized arrays as such, but got
surprised that we've managed to define zero-sized data type that is
not an array.

It sounds like a corner case to me. After all, who could have thought
that someone may need zero-sized struct or union one day?

One possible way to deal with that would be to move zero-sized arrays
out of the union. ctfconvert is happy and the size of your data
structure should not change -- you still should be able to use
zero-sized array members to append real data, only now they are
members of the structure itself, not of the member union.

This seems to work:

struct abc {
   int length;
   int bit;
  char key[0];
  char *key_ptr[0];
};

--Artem



On Sat, Jun 5, 2010 at 10:23 PM, Shrikanth Kamath <shrikanth07 at gmail.com> wrote:
> I have a small snippet trying to study ctfconvert...
>
> struct abc {
>    int length;
>    int bit;
>    union {
>        char key[0];
>        char *key_ptr[0];
>    } keys;
> };
>
> int main()
> {
>    int a =1;
>    struct abc member = { 16, 5 };
>    printf("Sizeof abc structure [%d] \n", sizeof(struct abc));
> }
>
> % gcc -g ctfconvert_prob.c
> % ctfconvert a.out
>
> I get the following error on running "ctfconvert"...
> ctfconvert_prob.c: failed to resolve the following types:
> struct 362 <16a>: failed to size member "keys" of type __anon__ (297 <129>)
> ERROR: ctfconvert_prob.c: failed to resolve types
>
> How can ctfconvert be equipped to resolve this data type?
>
> --
> Shrikanth R K
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>


More information about the freebsd-hackers mailing list