wynne wang
2009-May-06 10:28 UTC
[dtrace-discuss] How to trace the parameters of C++ class ?
Hi If we''d trace an input parameter, which is infact an C++ class , such as TextItem, anyway we could trace the contents inside the TextItem ? Example, it has a member named string, we''d get the contents of TextItem.string. Any advice? Wynne
Ryan Johnson
2009-May-06 14:10 UTC
[dtrace-discuss] How to trace the parameters of C++ class ?
When the compiler passes an aggregate (class, struct, union, array, etc.) to a function it will always pass a pointer (the difference between passing by value, ref, or pointer is just language semantics). Given that, you should be able to typedef the struct in dtrace and then reference ((TextItem*) argN)->string (remember arg0 is the this pointer if it''s a member function). I don''t know whether dtrace can handle member function declarations (it certainly can''t call them!), so you may need to declare a struct type which shadows all the data members of TextItem. Ryan wynne wang wrote:> Hi > > If we''d trace an input parameter, which is infact an C++ class , such as > TextItem, anyway we could trace the contents inside the TextItem ? > > Example, it has a member named string, we''d get the contents of > TextItem.string. > Any advice? > > Wynne > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >
Ryan Johnson
2009-May-06 14:14 UTC
[dtrace-discuss] How to trace the parameters of C++ class ?
Oh, yeah -- make sure to copyin() first so you can actually access the memory... Ryan Ryan Johnson wrote:> When the compiler passes an aggregate (class, struct, union, array, > etc.) to a function it will always pass a pointer (the difference > between passing by value, ref, or pointer is just language semantics). > Given that, you should be able to typedef the struct in dtrace and > then reference ((TextItem*) argN)->string (remember arg0 is the this > pointer if it''s a member function). > > I don''t know whether dtrace can handle member function declarations > (it certainly can''t call them!), so you may need to declare a struct > type which shadows all the data members of TextItem. > > Ryan > > wynne wang wrote: >> Hi >> >> If we''d trace an input parameter, which is infact an C++ class , such as >> TextItem, anyway we could trace the contents inside the TextItem ? >> >> Example, it has a member named string, we''d get the contents of >> TextItem.string. >> Any advice? >> >> Wynne >> >> _______________________________________________ >> dtrace-discuss mailing list >> dtrace-discuss at opensolaris.org >> > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org