Venkateshu.Cherukupalli at ubs.com
2009-Aug-18 20:27 UTC
[dtrace-discuss] Convert fd into string
Hi, I am trying to convert and print fd from read/write calls into string and it fails with below error. dtrace: error on enabled probe ID 1 (ID 23: syscall::read:entry): invalid address (0x0) in action #1 What am I missing ? syscall::read:entry /pid == $1 / { printf("Reading FD (%s) \n", (string)arg0); } Printing fd as integer (%d) works ok. Cheers, Venkat Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases.
Not sure what you mean by FD as a string. If you are trying to print the name of the file from the FD them you can use the fds[] array. Something like syscall::read:entry /pid == $1 / { printf("Reading (%s) \n", fds[arg0].fi_pathname); } -Angelo On Aug 18, 2009, at 4:27 PM, Venkateshu.Cherukupalli at ubs.com wrote:> > Hi, > > I am trying to convert and print fd from read/write calls into string > and it fails with below error. > > dtrace: error on enabled probe ID 1 (ID 23: syscall::read:entry): > invalid address (0x0) in action #1 > > What am I missing ? > > syscall::read:entry > /pid == $1 / > { > printf("Reading FD (%s) \n", (string)arg0); > > } > > Printing fd as integer (%d) works ok. > > Cheers, > Venkat > Visit our website at http://www.ubs.com > > This message contains confidential information and is intended only > for the individual named. If you are not the named addressee you > should not disseminate, distribute or copy this e-mail. Please > notify the sender immediately by e-mail if you have received this > e-mail by mistake and delete this e-mail from your system. > > E-mails are not encrypted and cannot be guaranteed to be secure or > error-free as information could be intercepted, corrupted, lost, > destroyed, arrive late or incomplete, or contain viruses. The sender > therefore does not accept liability for any errors or omissions in the > contents of this message which arise as a result of e-mail > transmission. > If verification is required please request a hard-copy version. This > message is provided for informational purposes and should not be > construed as a solicitation or offer to buy or sell any securities > or related financial instruments. > > > UBS reserves the right to retain all messages. Messages are protected > and accessed only in legally justified cases. > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
Venkateshu.Cherukupalli at ubs.com
2009-Aug-18 20:51 UTC
[dtrace-discuss] Convert fd into string
I just need to print the file descriptor number as a string. I would like to join fd and file name into one string and then aggregate on reads/writes reason I want to do this is, for sockets fi_pathname just shows up as "unknown" - instead if I can get fd, I can do pfiles and get the socket details .. -----Original Message----- From: Angelo.Rajadurai at Sun.COM [mailto:Angelo.Rajadurai at Sun.COM] Sent: Tuesday, August 18, 2009 4:37 PM To: Cherukupalli, Venkateshu Cc: dtrace-discuss at opensolaris.org Subject: Re: [dtrace-discuss] Convert fd into string Not sure what you mean by FD as a string. If you are trying to print the name of the file from the FD them you can use the fds[] array. Something like syscall::read:entry /pid == $1 / { printf("Reading (%s) \n", fds[arg0].fi_pathname); } -Angelo On Aug 18, 2009, at 4:27 PM, Venkateshu.Cherukupalli at ubs.com wrote:> > Hi, > > I am trying to convert and print fd from read/write calls into string > and it fails with below error. > > dtrace: error on enabled probe ID 1 (ID 23: syscall::read:entry): > invalid address (0x0) in action #1 > > What am I missing ? > > syscall::read:entry > /pid == $1 / > { > printf("Reading FD (%s) \n", (string)arg0); > > } > > Printing fd as integer (%d) works ok. > > Cheers, > Venkat > Visit our website at http://www.ubs.com > > This message contains confidential information and is intended only > for the individual named. If you are not the named addressee you > should not disseminate, distribute or copy this e-mail. Please notify> the sender immediately by e-mail if you have received this e-mail by > mistake and delete this e-mail from your system. > > E-mails are not encrypted and cannot be guaranteed to be secure or > error-free as information could be intercepted, corrupted, lost, > destroyed, arrive late or incomplete, or contain viruses. The sender > therefore does not accept liability for any errors or omissions in the> contents of this message which arise as a result of e-mail > transmission. > If verification is required please request a hard-copy version. This > message is provided for informational purposes and should not be > construed as a solicitation or offer to buy or sell any securities or > related financial instruments. > > > UBS reserves the right to retain all messages. Messages are protected > and accessed only in legally justified cases. > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.orgVisit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases.
Why not just aggregate on the tuple <fd, file name>? Something like this: syscall::read:entry { @c[arg0, fds[arg0].fi_pathname] = count(); } If the output''s unsatisfactory, you could always use a printa() in en END clause to get it into the format you want. Chad On Tue, Aug 18, 2009 at 4:51 PM, <Venkateshu.Cherukupalli at ubs.com> wrote:> > I just need to print the file descriptor number ?as a string. I would > like to join fd and file name into one string and then aggregate on > reads/writes > reason I want to do this is, for sockets fi_pathname just shows up as > "unknown" - instead if I can get fd, I can do pfiles and get the socket > details .. > >
Venkateshu.Cherukupalli at ubs.com
2009-Aug-18 22:16 UTC
[dtrace-discuss] Convert fd into string
Yup, that will do. But, still I wonder why the typecast fails ? -----Original Message----- From: Chad Mynhier [mailto:cmynhier at gmail.com] Sent: Tuesday, August 18, 2009 5:06 PM To: Cherukupalli, Venkateshu Cc: Angelo.Rajadurai at sun.com; dtrace-discuss at opensolaris.org Subject: Re: [dtrace-discuss] Convert fd into string Why not just aggregate on the tuple <fd, file name>? Something like this: syscall::read:entry { @c[arg0, fds[arg0].fi_pathname] = count(); } If the output''s unsatisfactory, you could always use a printa() in en END clause to get it into the format you want. Chad On Tue, Aug 18, 2009 at 4:51 PM, <Venkateshu.Cherukupalli at ubs.com> wrote:> > I just need to print the file descriptor number ?as a string. I would > like to join fd and file name into one string and then aggregate on > reads/writes reason I want to do this is, for sockets fi_pathname just > shows up as "unknown" - instead if I can get fd, I can do pfiles and > get the socket details .. > >Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases.
On Tue, Aug 18, 2009 at 06:16:50PM -0400, Venkateshu.Cherukupalli at ubs.com wrote:> > Yup, that will do. But, still I wonder why the typecast fails ?Because the argument is an integer, not a pointer to a kernel string? Typecasting in D is like typecasting in C: almost no work is done. Certainly no lookup of the file descriptor table is done. Cheers, - jonathan> -----Original Message----- > From: Chad Mynhier [mailto:cmynhier at gmail.com] > Sent: Tuesday, August 18, 2009 5:06 PM > To: Cherukupalli, Venkateshu > Cc: Angelo.Rajadurai at sun.com; dtrace-discuss at opensolaris.org > Subject: Re: [dtrace-discuss] Convert fd into string > > Why not just aggregate on the tuple <fd, file name>? Something like this: > > syscall::read:entry > { > @c[arg0, fds[arg0].fi_pathname] = count(); } > > If the output''s unsatisfactory, you could always use a printa() in en END clause to get it into the format you want. > > Chad > > On Tue, Aug 18, 2009 at 4:51 PM, <Venkateshu.Cherukupalli at ubs.com> wrote: > > > > I just need to print the file descriptor number ?as a string. I would > > like to join fd and file name into one string and then aggregate on > > reads/writes reason I want to do this is, for sockets fi_pathname just > > shows up as "unknown" - instead if I can get fd, I can do pfiles and > > get the socket details .. > > > > > Visit our website at http://www.ubs.com > > This message contains confidential information and is intended only > for the individual named. If you are not the named addressee you > should not disseminate, distribute or copy this e-mail. Please > notify the sender immediately by e-mail if you have received this > e-mail by mistake and delete this e-mail from your system. > > E-mails are not encrypted and cannot be guaranteed to be secure or > error-free as information could be intercepted, corrupted, lost, > destroyed, arrive late or incomplete, or contain viruses. The sender > therefore does not accept liability for any errors or omissions in the > contents of this message which arise as a result of e-mail transmission. > If verification is required please request a hard-copy version. This > message is provided for informational purposes and should not be > construed as a solicitation or offer to buy or sell any securities > or related financial instruments. > > > UBS reserves the right to retain all messages. Messages are protected > and accessed only in legally justified cases. > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
In C this would be done (non-standard) with "itoa", or in a more standard way using sprintf, neither of which exist in "D". Chip> -----Original Message----- > From: dtrace-discuss-bounces at opensolaris.org [mailto:dtrace-discuss- > bounces at opensolaris.org] On Behalf Of Jonathan Adams > Sent: Tuesday, August 18, 2009 5:54 PM > To: Venkateshu.Cherukupalli at ubs.com > Cc: dtrace-discuss at opensolaris.org > Subject: Re: [dtrace-discuss] Convert fd into string > > On Tue, Aug 18, 2009 at 06:16:50PM -0400, > Venkateshu.Cherukupalli at ubs.com wrote: > > > > Yup, that will do. But, still I wonder why the typecast fails ? > > Because the argument is an integer, not a pointer to a kernel string? > > Typecasting in D is like typecasting in C: almost no work is done. > Certainly no lookup of the file descriptor table is done. > > Cheers, > - jonathan > > > -----Original Message----- > > From: Chad Mynhier [mailto:cmynhier at gmail.com] > > Sent: Tuesday, August 18, 2009 5:06 PM > > To: Cherukupalli, Venkateshu > > Cc: Angelo.Rajadurai at sun.com; dtrace-discuss at opensolaris.org > > Subject: Re: [dtrace-discuss] Convert fd into string > > > > Why not just aggregate on the tuple <fd, file name>? Something like > this: > > > > syscall::read:entry > > { > > @c[arg0, fds[arg0].fi_pathname] = count(); } > > > > If the output''s unsatisfactory, you could always use a printa() in en > END clause to get it into the format you want. > > > > Chad > > > > On Tue, Aug 18, 2009 at 4:51 PM, <Venkateshu.Cherukupalli at ubs.com> > wrote: > > > > > > I just need to print the file descriptor number ?as a string. I > > > would like to join fd and file name into one string and then > > > aggregate on reads/writes reason I want to do this is, for sockets > > > fi_pathname just shows up as "unknown" - instead if I can get fd, I > > > can do pfiles and get the socket details .. > > > > > > > > Visit our website at http://www.ubs.com > > > > This message contains confidential information and is intended only > > for the individual named. If you are not the named addressee you > > should not disseminate, distribute or copy this e-mail. Please > notify > > the sender immediately by e-mail if you have received this e-mail by > > mistake and delete this e-mail from your system. > > > > E-mails are not encrypted and cannot be guaranteed to be secure or > > error-free as information could be intercepted, corrupted, lost, > > destroyed, arrive late or incomplete, or contain viruses. The sender > > therefore does not accept liability for any errors or omissions in > the > > contents of this message which arise as a result of e-mail > transmission. > > If verification is required please request a hard-copy version. This > > message is provided for informational purposes and should not be > > construed as a solicitation or offer to buy or sell any securities or > > related financial instruments. > > > > > > UBS reserves the right to retain all messages. Messages are protected > > and accessed only in legally justified cases. > > _______________________________________________ > > dtrace-discuss mailing list > > dtrace-discuss at opensolaris.org
Similar to what Chip mentioned, you can use the built-in DTrace subroutine lltostr(). Adam On Aug 18, 2009, at 4:20 PM, Chip Bennett wrote:> In C this would be done (non-standard) with "itoa", or in a more > standard way using sprintf, neither of which exist in "D". > > Chip > >> -----Original Message----- >> From: dtrace-discuss-bounces at opensolaris.org [mailto:dtrace-discuss- >> bounces at opensolaris.org] On Behalf Of Jonathan Adams >> Sent: Tuesday, August 18, 2009 5:54 PM >> To: Venkateshu.Cherukupalli at ubs.com >> Cc: dtrace-discuss at opensolaris.org >> Subject: Re: [dtrace-discuss] Convert fd into string >> >> On Tue, Aug 18, 2009 at 06:16:50PM -0400, >> Venkateshu.Cherukupalli at ubs.com wrote: >>> >>> Yup, that will do. But, still I wonder why the typecast fails ? >> >> Because the argument is an integer, not a pointer to a kernel string? >> >> Typecasting in D is like typecasting in C: almost no work is done. >> Certainly no lookup of the file descriptor table is done. >> >> Cheers, >> - jonathan >> >>> -----Original Message----- >>> From: Chad Mynhier [mailto:cmynhier at gmail.com] >>> Sent: Tuesday, August 18, 2009 5:06 PM >>> To: Cherukupalli, Venkateshu >>> Cc: Angelo.Rajadurai at sun.com; dtrace-discuss at opensolaris.org >>> Subject: Re: [dtrace-discuss] Convert fd into string >>> >>> Why not just aggregate on the tuple <fd, file name>? Something like >> this: >>> >>> syscall::read:entry >>> { >>> @c[arg0, fds[arg0].fi_pathname] = count(); } >>> >>> If the output''s unsatisfactory, you could always use a printa() in >>> en >> END clause to get it into the format you want. >>> >>> Chad >>> >>> On Tue, Aug 18, 2009 at 4:51 PM, <Venkateshu.Cherukupalli at ubs.com> >> wrote: >>>> >>>> I just need to print the file descriptor number as a string. I >>>> would like to join fd and file name into one string and then >>>> aggregate on reads/writes reason I want to do this is, for sockets >>>> fi_pathname just shows up as "unknown" - instead if I can get fd, I >>>> can do pfiles and get the socket details .. >>>> >>>> >>> Visit our website at http://www.ubs.com >>> >>> This message contains confidential information and is intended only >>> for the individual named. If you are not the named addressee you >>> should not disseminate, distribute or copy this e-mail. Please >> notify >>> the sender immediately by e-mail if you have received this e-mail by >>> mistake and delete this e-mail from your system. >>> >>> E-mails are not encrypted and cannot be guaranteed to be secure or >>> error-free as information could be intercepted, corrupted, lost, >>> destroyed, arrive late or incomplete, or contain viruses. The >>> sender >>> therefore does not accept liability for any errors or omissions in >> the >>> contents of this message which arise as a result of e-mail >> transmission. >>> If verification is required please request a hard-copy version. >>> This >>> message is provided for informational purposes and should not be >>> construed as a solicitation or offer to buy or sell any securities >>> or >>> related financial instruments. >>> >>> >>> UBS reserves the right to retain all messages. Messages are >>> protected >>> and accessed only in legally justified cases. >>> _______________________________________________ >>> dtrace-discuss mailing list >>> dtrace-discuss at opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Fishworks http://blogs.sun.com/ahl
Venkateshu.Cherukupalli at ubs.com
2009-Aug-19 14:15 UTC
[dtrace-discuss] Convert fd into string
Great .. Thanks everyone ! -----Original Message----- From: Adam.Leventhal at Sun.COM [mailto:Adam.Leventhal at Sun.COM] On Behalf Of Adam Leventhal Sent: Tuesday, August 18, 2009 8:24 PM To: Chip Bennett Cc: Jonathan Adams; Cherukupalli, Venkateshu; dtrace-discuss at opensolaris.org Subject: Re: [dtrace-discuss] Convert fd into string Similar to what Chip mentioned, you can use the built-in DTrace subroutine lltostr(). Adam On Aug 18, 2009, at 4:20 PM, Chip Bennett wrote:> In C this would be done (non-standard) with "itoa", or in a more > standard way using sprintf, neither of which exist in "D". > > Chip > >> -----Original Message----- >> From: dtrace-discuss-bounces at opensolaris.org [mailto:dtrace-discuss- >> bounces at opensolaris.org] On Behalf Of Jonathan Adams >> Sent: Tuesday, August 18, 2009 5:54 PM >> To: Venkateshu.Cherukupalli at ubs.com >> Cc: dtrace-discuss at opensolaris.org >> Subject: Re: [dtrace-discuss] Convert fd into string >> >> On Tue, Aug 18, 2009 at 06:16:50PM -0400, >> Venkateshu.Cherukupalli at ubs.com wrote: >>> >>> Yup, that will do. But, still I wonder why the typecast fails ? >> >> Because the argument is an integer, not a pointer to a kernel string? >> >> Typecasting in D is like typecasting in C: almost no work is done. >> Certainly no lookup of the file descriptor table is done. >> >> Cheers, >> - jonathan >> >>> -----Original Message----- >>> From: Chad Mynhier [mailto:cmynhier at gmail.com] >>> Sent: Tuesday, August 18, 2009 5:06 PM >>> To: Cherukupalli, Venkateshu >>> Cc: Angelo.Rajadurai at sun.com; dtrace-discuss at opensolaris.org >>> Subject: Re: [dtrace-discuss] Convert fd into string >>> >>> Why not just aggregate on the tuple <fd, file name>? Something like >> this: >>> >>> syscall::read:entry >>> { >>> @c[arg0, fds[arg0].fi_pathname] = count(); } >>> >>> If the output''s unsatisfactory, you could always use a printa() in >>> en >> END clause to get it into the format you want. >>> >>> Chad >>> >>> On Tue, Aug 18, 2009 at 4:51 PM, <Venkateshu.Cherukupalli at ubs.com> >> wrote: >>>> >>>> I just need to print the file descriptor number as a string. I >>>> would like to join fd and file name into one string and then >>>> aggregate on reads/writes reason I want to do this is, for sockets >>>> fi_pathname just shows up as "unknown" - instead if I can get fd, I>>>> can do pfiles and get the socket details .. >>>> >>>> >>> Visit our website at http://www.ubs.com >>> >>> This message contains confidential information and is intended only >>> for the individual named. If you are not the named addressee you >>> should not disseminate, distribute or copy this e-mail. Please >> notify >>> the sender immediately by e-mail if you have received this e-mail by>>> mistake and delete this e-mail from your system. >>> >>> E-mails are not encrypted and cannot be guaranteed to be secure or >>> error-free as information could be intercepted, corrupted, lost, >>> destroyed, arrive late or incomplete, or contain viruses. The >>> sender therefore does not accept liability for any errors or >>> omissions in >> the >>> contents of this message which arise as a result of e-mail >> transmission. >>> If verification is required please request a hard-copy version. >>> This >>> message is provided for informational purposes and should not be >>> construed as a solicitation or offer to buy or sell any securities >>> or related financial instruments. >>> >>> >>> UBS reserves the right to retain all messages. Messages are >>> protected >>> and accessed only in legally justified cases. >>> _______________________________________________ >>> dtrace-discuss mailing list >>> dtrace-discuss at opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Fishworks http://blogs.sun.com/ahl Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases.