Priya Krishnan
2009-Apr-23 02:04 UTC
[dtrace-discuss] using global variables with translators
Is it possible to use global variables with translators? Let me explain with an example Lets say we have a D struct conninfo_t translated from a C struct conn_t. Now is it possible to save a value e.g. transport_type (i.e. socket, iser, iwarp etc.) from conn_t (not present in conninfo_t) in a global variable such that it can be used in the translator of the second argument (for the same probe)? #pragma D binding "1.5" translator translator conninfo_t < conn_t *P > { ci_local = P->laddr; ci_remote = P->raddr; ci_protocol = P->protocol; save P->transport_type }; translator scsiinfo_t <scsi_info_t *P > { <snip> ... retrieve transport_type }; I am not sure if this is supported, any feedback is appreciated I see procfs.d use inline translator and use variable to save the cwd. But it is able to use curthread to get the current thread context.. inline string cwd = curthread->t_procp->p_user.u_cdir->v_path == NULL ? "<unknown>" : stringof(curthread->t_procp->p_user.u_cdir->v_path); thanks Priya
Adam Leventhal
2009-Apr-24 20:39 UTC
[dtrace-discuss] using global variables with translators
That should work just fine. Are you hitting an issue? Adam On Apr 22, 2009, at 7:04 PM, Priya Krishnan wrote:> Is it possible to use global variables with translators? Let me > explain with an example > > Lets say we have a D struct conninfo_t translated from a C struct > conn_t. Now is it possible to save a value e.g. transport_type (i.e. > socket, iser, iwarp etc.) from conn_t (not present in conninfo_t) in > a global variable such that it can be used in the translator of the > second argument (for the same probe)? > > #pragma D binding "1.5" translator > translator conninfo_t < conn_t *P > { > ci_local = P->laddr; > ci_remote = P->raddr; > ci_protocol = P->protocol; > > save P->transport_type > > }; > > translator scsiinfo_t <scsi_info_t *P > { > <snip> > ... > retrieve transport_type > }; > I am not sure if this is supported, any feedback is appreciated > > I see procfs.d use inline translator and use variable to save the > cwd. But it is able to use curthread to get the current thread > context.. > inline string cwd = curthread->t_procp->p_user.u_cdir->v_path == > NULL ? > "<unknown>" : stringof(curthread->t_procp->p_user.u_cdir->v_path); > > thanks > Priya > > > > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Fishworks http://blogs.sun.com/ahl