Date: Sun, 6 Jun 2010 00:18:09 -0700 From: Artem Belevich <fbsdlist@src.cx> To: Shrikanth Kamath <shrikanth07@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: ctfconvert : failed to resolve types Message-ID: <AANLkTimpeuUV5Yg5ENuGrKPK6HY3o1xOwCK1Wip5S4Dc@mail.gmail.com> In-Reply-To: <AANLkTil86P4To3IvAkTqePaB_BUMztdIK5R8srMQF_At@mail.gmail.com> References: <AANLkTil86P4To3IvAkTqePaB_BUMztdIK5R8srMQF_At@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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@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@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimpeuUV5Yg5ENuGrKPK6HY3o1xOwCK1Wip5S4Dc>
