DTrace experts :), How do you go about printing out a complex data structure (let''s say in kernel for now) using DTrace? I have a structure which has fields that are dynamic arrays of other data structures that are quite complex themselves. I guess what I''m looking for is some kind of function/macro and loop infrastructure. Any tips or pointer to examples is appreciated. Thanks, Afshin
Afshin Salek wrote:> DTrace experts :), > > How do you go about printing out a complex data structure > (let''s say in kernel for now) using DTrace? I have a structure > which has fields that are dynamic arrays of other data structures > that are quite complex themselves. I guess what I''m looking for > is some kind of function/macro and loop infrastructure.loops don''t exist in DTrace for safety reasons - you cannot tell at compile time how often a loop will be executed, therefore the impact on the running system cannot be known. you can "hand graft" several interations of a "loop" with something like this (this is an example for a linked list, I guess a dyn. array won''t be that much harder to do) myfunc:entry /arg0 != NULL/ { self->d = (cast) arg0; /* print data struct once */ self->d = self->d->next; } myfunc:entry /self->d != NULL/ { /* print data struct once */ self->d = self->d->next; } and repeat the last clause several as many times as you anticipate it may be necessary. HTH Michael -- Michael Schuster http://blogs.sun.com/recursion Recursion, n.: see ''Recursion''
> DTrace experts :), > > How do you go about printing out a complex data structure > (let''s say in kernel for now) using DTrace? I have a structure > which has fields that are dynamic arrays of other data structures > that are quite complex themselves. I guess what I''m looking for > is some kind of function/macro and loop infrastructure.Nothing like that exists and it pain in the a$$ to print just mblk_t structure ... -- Vlad -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 193 bytes Desc: not available URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20080619/9c7c11a1/attachment.bin>