Hi, How can I print the structure contents using DTrace ... For example, here is the truss output while execution of my program, /90: ioctl(12, 0x04C9, 0xFE97B83C) = 0 /90: ioctl(12, 0x04C9, 0xFE97B924) Err#5 EIO The third field above is ''struct uscsi_cmd''. I am not sure why the second ioctl is failing, I want to confirm that scsi cdb is formed correctly in this case. How can I print this structure in parallel while running the program? Thanks for the inputs. Cheers, Vivek -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20070729/9269d954/attachment.html>
mdb DTrace is used when you know the internal structure, while MDB can show the internal structure to you in the case of only knowing the structure name. Another way, download a copy of the ON source code and use cscope or ggrep. Regards, TJ 2007/7/29, Vivek Joshi <techvbj at gmail.com>:> > > Hi, > > How can I print the structure contents using DTrace ... > > For example, here is the truss output while execution of my program, > /90: ioctl(12, 0x04C9, 0xFE97B83C) = 0 > /90: ioctl(12, 0x04C9, 0xFE97B924) Err#5 EIO > > The third field above is ''struct uscsi_cmd''. I am not sure why the > second ioctl is failing, I want to confirm that scsi cdb is formed > correctly in this case. How can I print this structure in parallel > while running the program? > > Thanks for the inputs. > > Cheers, > Vivek > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20070730/a4453059/attachment.html>
Hi, Vivek: These 2 addresses are inside the process of your program, and they are determined by the OS (unix and rtld) and are valid on the fly. I don''t think you need to mdb step-by-step. Suppose your program looks like: ... function (...) { ...... ioctl(12, 0x04C9, 0xFE97B83C) ...... } After compiling this program, dump the elf program. You could find a useful addresses: the address of calling ioctl You can stop at this address directly and print the structure that you are interested. Regards, TJ 2007/7/30, Vivek Joshi <techvbj at gmail.com>:> > Thanks TJ! I tried to print the structure using addr::print struct > uscsi_cmd but the address is null .. > > > 0xFE97B83C/J > mdb: failed to read data from target: no mapping for address > 0xfe97b83c: > > 0xFE97B924/J > mdb: failed to read data from target: no mapping for address > 0xfe97b924: > > > > I want to print this structure during the execution of the program sothat > I get a valid address. I don''t want to set break points and do a > step-by-step. It''ll be too time consuming :-) > > Or did I miss something? > > Thanks again! > > Cheers, > Vivek > > > On 7/30/07, ?? Tao Jie <eulertao at gmail.com > wrote: > > > mdb > > DTrace is used when you know the internal structure, while MDB can show > > the internal structure to you in the case of only knowing the structure > > name. > > > > Another way, download a copy of the ON source code and use cscope or > > ggrep. > > > > > > Regards, > > TJ > > > > 2007/7/29, Vivek Joshi <techvbj at gmail.com>: > > > > > > > > > Hi, > > > > > > How can I print the structure contents using DTrace ... > > > > > > For example, here is the truss output while execution of my program, > > > /90: ioctl(12, 0x04C9, 0xFE97B83C) = 0 > > > /90: ioctl(12, 0x04C9, 0xFE97B924) Err#5 EIO > > > > > > The third field above is ''struct uscsi_cmd''. I am not sure why the > > > second ioctl is failing, I want to confirm that scsi cdb is formed > > > correctly in this case. How can I print this structure in parallel > > > while running the program? > > > > > > Thanks for the inputs. > > > > > > Cheers, > > > Vivek > > > _______________________________________________ > > > dtrace-discuss mailing list > > > dtrace-discuss at opensolaris.org > > > > > > > > > _______________________________________________ > > dtrace-discuss mailing list > > dtrace-discuss at opensolaris.org > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20070730/6a719691/attachment.html>
Hi Vivek, ?? Tao Jie wrote:> Hi, Vivek: > These 2 addresses are inside the process of your program, and they are > determined by the OS (unix and rtld) and are valid on the fly. > I don''t think you need to mdb step-by-step. > Suppose your program looks like: > ... function (...) > { > ...... > ioctl(12, 0x04C9, 0xFE97B83C) > ...... > } > After compiling this program, dump the elf program. You could find a > useful addresses: the address of calling ioctl > You can stop at this address directly and print the structure that you > are interested. > Regards, > TJ > 2007/7/30, Vivek Joshi <techvbj at gmail.com <mailto:techvbj at gmail.com>>: > > Thanks TJ! I tried to print the structure using addr::print struct > uscsi_cmd but the address is null .. > > > 0xFE97B83C/J > mdb: failed to read data from target: no mapping for address > 0xfe97b83c: > > 0xFE97B924/J > mdb: failed to read data from target: no mapping for address > 0xfe97b924: > > > > I want to print this structure during the execution of the program > sothat I get a valid address. I don''t want to set break points and > do a step-by-step. It''ll be too time consuming :-) >How are you setting the breakpoint with mdb? I assume you are setting the breakpoint in your application at the place where the ioctl is being called? If you are trying to set the breakpoint in the kernel, you won''t be able to dump the uscsi_cmd with the address truss shows you. That address is a user address. Also, you have no NULL pointer in your truss output. The message "mdb: failed to read data from target: no mapping for address" means that the virtual address you specified (0xfe97b924) has no mapping in the target in which you are running mdb. It is possible that a member of the uscsi_cmd struct is not valid. How are you running mdb? max
Hi Vivek, One other thing. This probably belongs in the mdb-discuss list. It would be really nice if dtrace had a way to allow "::print ..." from within the D language. I have asked for this, but I don''t have a good way to do it. max Vivek Joshi wrote:> > Hello Max, > > I attached the process while running the mdb (mdb -p <pid>). I didn''t > set the breakpoint earlier ... But I checked it now like this, > > > :b 0xFE97B924 > > > > Once the program is stopped and I can now print this structure, > > 0xFE97B924::print struct uscsi_cmd > { > uscsi_flags = 0 > uscsi_status = 0 > uscsi_timeout = 0 > uscsi_cdb = 0 > uscsi_bufaddr = 0x46a83f18 > uscsi_buflen = 0 > uscsi_resid = 0x46a83f18 > uscsi_cdblen = 0 > uscsi_rqlen = 0 > uscsi_rqstatus = 0 > uscsi_rqresid = 0 > uscsi_rqbuf = 0x46a83f18 > uscsi_reserved_5 = 0 > } > > which too doesn''t look valid ... or there might be an issue with the > application while forming the cdb. > > Cheers, > Vivek > > > > > How are you setting the breakpoint with mdb? I assume you are setting > the breakpoint in your application > at the place where the ioctl is being called? If you are trying to set > the breakpoint in the kernel, you won''t be able > to dump the uscsi_cmd with the address truss shows you. That > address is > a user address. Also, you have no > NULL pointer in your truss output. The message "mdb: failed to > read data > from target: no mapping for address" > means that the virtual address you specified (0xfe97b924) has no > mapping > in the target in which you are running > mdb. It is possible that a member of the uscsi_cmd struct is not > valid. > How are you running mdb? > > max > >