Jim Nissen
2009-Apr-28 19:28 UTC
[dtrace-discuss] Best way to deal with casting of undefined kernel structures
I''m trying to probe the ssfcp_transport function, to dig out the following... 9481 fcp_transport(opaque_t port_handle, fc_packet_t *fpkt, int internal) ... 9554 } else { 9555 struct fcp_pkt *cmd; 9556 struct fcp_port *pptr; 9557 * 9558 cmd = (struct fcp_pkt *)fpkt->pkt_ulp_private;* 9559 cmd->cmd_state = FCP_PKT_IDLE; * 9560 pptr = ADDR2FCP(&cmd->cmd_pkt->pkt_address); * fbt::ssfcp_transport:entry { this->pkt=(fc_packet_t *)arg1; this->frame=(fc_frame_hdr_t )this->pkt->pkt_cmd_fhdr; * this->cmd=(fcp_pkt *)this->pkt->pkg_cmd_fhdr;* this->port=(fcp_port *)this->cmd->cmd_pkt->pkt_address->a_hba_tran->tran_hba_private; } # ./fcp.d dtrace: failed to compile script ./fcp.d: line 55: syntax error near ")" This suggests that dtrace doesn''t know what fcp_pkt type is. I followed this up with... BEGIN { printf("%d %d",sizeof(fcp_pkt),offsetof(fcp_pkt,cmd_pkt)); } ...and confirmed that dtrace doesn''t have fcp_pkt or fcp_port defined as types. I''ve tried including all of the "*.h" files... #include <sys/mutex.h> #include "/var/tmp/fc_types.h" #include "/var/tmp/fc_appif.h" #include "/var/tmp/fcpvar.h" ...but then get this error... dtrace: failed to compile script ./fcp.d: "/var/tmp/fcpvar.h", line 343: incomplete struct/union/enum struct modlinkage: port_fp_modlinkage Is there a better way to do this? Jim -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20090428/139e4f55/attachment.html>
Adam Leventhal
2009-Apr-28 22:05 UTC
[dtrace-discuss] Best way to deal with casting of undefined kernel structures
On Tue, Apr 28, 2009 at 02:28:45PM -0500, Jim Nissen wrote:> I''m trying to probe the ssfcp_transport function, to dig out the > following... > > 9555 struct fcp_pkt *cmd; > > * this->cmd=(fcp_pkt *)this->pkt->pkg_cmd_fhdr;* > > # ./fcp.d > dtrace: failed to compile script ./fcp.d: line 55: syntax error near ")" > > This suggests that dtrace doesn''t know what fcp_pkt type is. I followed > this up with...I think you want to do ''(struct fcp_pkt *)'' rather than ''(fcp_pkt *)'' just as you would in C. Adam -- Adam Leventhal, Fishworks http://blogs.sun.com/ahl
Jim Nissen
2009-Apr-29 15:29 UTC
[dtrace-discuss] Best way to deal with casting of undefined kernel structures
Adam, Thanks for responding. I forgot to mention that I went the (struct...) route, to begin with. I recreated that script w/meat of... fbt::ssfcp_transport:entry { this->pkt=(fc_packet_t *)arg1; this->frame=(fc_frame_hdr_t )this->pkt->pkt_cmd_fhdr; this->cmd=(struct fcp_pkt *)this->pkt->pkt_ulp_private; * this->scsipkt=(struct scsi_pkt *)this->cmd->cmd_pkt; * this->scsiaddr=(struct scsi_address) this->scsipkt.pkt_address; this->hbatran=(struct scsi_hba_tran *)this->scsiaddr->a_hba_tran; this->port=(struct fcp_port *) this->hbatran->tran_hba_private; /* All the above is long for this... this->port=(struct fcp_port *)this->cmd->cmd_pkt->pkt_address->a_hba_tran->tran_hba_private; */ } # ./fcp.d dtrace: failed to compile script ./fcp.d: line 56: operator -> cannot be applied to a forward declaration: no struct fcp_pkt definition is available. This is without the #includes. fcp_pkt is defined as a structure in fcpvar.h However, when I start the process of #includes ... #include <sys/mutex.h> #include <sys/modctl.h> #include <sys/dditypes.h> #include <sys/ddidmareq.h> #include "/var/tmp/fc_types.h" #include "/var/tmp/fc_appif.h" #include "/var/tmp/fcpvar.h" ... I still end up getting ... # ./fcp.d dtrace: failed to compile script ./fcp.d: "/var/tmp/fcpvar.h", line 350: syntax error near "ddi_device_acc_attr_t" The only definition of ddi_device_acc_attr_t, in fcpvar.h, is here... struct fcp_port { ... ddi_dma_attr_t port_data_dma_attr; ddi_dma_attr_t port_cmd_dma_attr; ddi_dma_attr_t port_resp_dma_attr; * ddi_device_acc_attr_t port_dma_acc_attr;* /* * Field containing the hba_tran structure registered with SCSA. */ struct scsi_hba_tran *port_tran; ... } So, again, I''m left with what the best way to handle this. Any clues? I''m trying to get this script working for a case I am working on. Thanks, Jim Adam Leventhal wrote:> On Tue, Apr 28, 2009 at 02:28:45PM -0500, Jim Nissen wrote: > >> I''m trying to probe the ssfcp_transport function, to dig out the >> following... >> >> 9555 struct fcp_pkt *cmd; >> >> * this->cmd=(fcp_pkt *)this->pkt->pkg_cmd_fhdr;* >> >> # ./fcp.d >> dtrace: failed to compile script ./fcp.d: line 55: syntax error near ")" >> >> This suggests that dtrace doesn''t know what fcp_pkt type is. I followed >> this up with... >> > > I think you want to do ''(struct fcp_pkt *)'' rather than ''(fcp_pkt *)'' just > as you would in C. > > Adam > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20090429/944e70c4/attachment.html>
Jonathan Adams
2009-Apr-29 16:16 UTC
[dtrace-discuss] Best way to deal with casting of undefined kernel structures
On Wed, Apr 29, 2009 at 10:29:41AM -0500, Jim Nissen wrote:> Adam, > Thanks for responding. I forgot to mention that I went the (struct...) > route, to begin with. I recreated that script w/meat of... > > fbt::ssfcp_transport:entry > { > this->pkt=(fc_packet_t *)arg1; > this->frame=(fc_frame_hdr_t )this->pkt->pkt_cmd_fhdr; > > this->cmd=(struct fcp_pkt *)this->pkt->pkt_ulp_private; > * this->scsipkt=(struct scsi_pkt *)this->cmd->cmd_pkt; * > this->scsiaddr=(struct scsi_address) this->scsipkt.pkt_address; > this->hbatran=(struct scsi_hba_tran *)this->scsiaddr->a_hba_tran; > this->port=(struct fcp_port *) this->hbatran->tran_hba_private; > /* All the above is long for this... > this->port=(struct fcp_port > *)this->cmd->cmd_pkt->pkt_address->a_hba_tran->tran_hba_private; > */ > } > > # ./fcp.d > dtrace: failed to compile script ./fcp.d: line 56: operator -> cannot be > applied to a forward declaration: no struct fcp_pkt definition is available.Try "struct fcp`fcp_pkt". I assume the fcp module is loaded? Cheers, - jonathan
Jim Nissen
2009-Apr-29 18:34 UTC
[dtrace-discuss] Best way to deal with casting of undefined kernel structures
Jonathan Adams wrote:> On Wed, Apr 29, 2009 at 10:29:41AM -0500, Jim Nissen wrote: > >> Adam, >> Thanks for responding. I forgot to mention that I went the (struct...) >> route, to begin with. I recreated that script w/meat of... >> >> fbt::ssfcp_transport:entry >> { >> this->pkt=(fc_packet_t *)arg1; >> this->frame=(fc_frame_hdr_t )this->pkt->pkt_cmd_fhdr; >> >> this->cmd=(struct fcp_pkt *)this->pkt->pkt_ulp_private; >> * this->scsipkt=(struct scsi_pkt *)this->cmd->cmd_pkt; * >> this->scsiaddr=(struct scsi_address) this->scsipkt.pkt_address; >> this->hbatran=(struct scsi_hba_tran *)this->scsiaddr->a_hba_tran; >> this->port=(struct fcp_port *) this->hbatran->tran_hba_private; >> /* All the above is long for this... >> this->port=(struct fcp_port >> *)this->cmd->cmd_pkt->pkt_address->a_hba_tran->tran_hba_private; >> */ >> } >> >> # ./fcp.d >> dtrace: failed to compile script ./fcp.d: line 56: operator -> cannot be >> applied to a forward declaration: no struct fcp_pkt definition is available. >> > > Try "struct fcp`fcp_pkt". I assume the fcp module is loaded? >Yes, fcp is loaded... # modinfo | grep fcp 35 133e4e0 3300 - 1 fcpci (FCode pci bus functions 1.9) 116 7bb26000 19350 294 1 fcp (SunFC FCP v20090122-1.132) With fcp`fcp_pkt, I get the same error... # ./fcp.d dtrace: failed to compile script ./fcp.d: line 59: operator -> cannot be applied to a forward declaration: no struct fcp`fcp_pkt definition is available Any other ideas? Jim> Cheers, > - jonathan > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20090429/38d3b7b8/attachment.html>