Sanjeev Bagewadi
2005-Sep-22 12:26 UTC
[dtrace-discuss] How to print a buffer allocated using alloca ?
Hi, I need to print the contents of the memory which are passed to uiomove(). I decided to allocate a buffer using alloca() and have copied the contents using bcopy(). Now, I need to print the conents of the buffer and haven''t found a way. Any pointers/suggestions would be of great help ! Thanks in advance !! Regards, Sanjeev. -- snip -- #!/usr/sbin/dtrace -s fbt:pxfs:*pxreg*read_cache*:entry { self->flag = 1 } fbt::uiomove:entry /self->flag = 1/ { buf = alloca(1024); bcopy((void *)arg1, buf, 1024); printf("buffer = %s", stringof(buf)); <-- ** This needs to be fixed *** self->flag = 0; }
Adam Leventhal
2005-Sep-22 16:50 UTC
[dtrace-discuss] How to print a buffer allocated using alloca ?
Hi Sanjeev, You can use the tracemem() action to trace an arbitrary memory block. Does that solve your problem? There isn''t (currently) a printf() format character that allows for an arbitrary chunk of memory. Adam On Thu, Sep 22, 2005 at 05:56:48PM +0530, Sanjeev Bagewadi wrote:> Hi, > > I need to print the contents of the memory which are passed to uiomove(). > I decided to allocate a buffer using alloca() and have copied the > contents using bcopy(). > Now, I need to print the conents of the buffer and haven''t found a way. > > Any pointers/suggestions would be of great help ! > Thanks in advance !! > > Regards, > Sanjeev. > > -- snip -- > #!/usr/sbin/dtrace -s > fbt:pxfs:*pxreg*read_cache*:entry > { > self->flag = 1 > } > > fbt::uiomove:entry > /self->flag = 1/ > { > buf = alloca(1024); > bcopy((void *)arg1, buf, 1024); > printf("buffer = %s", stringof(buf)); <-- ** This needs to be > fixed *** > self->flag = 0; > } > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Solaris Kernel Development http://blogs.sun.com/ahl
Sanjeev Bagewadi
2005-Sep-23 01:32 UTC
[dtrace-discuss] How to print a buffer allocated using alloca ?
Thanks Adam ! I shall try that... Regards, Sanjeev Adam Leventhal wrote:>Hi Sanjeev, > >You can use the tracemem() action to trace an arbitrary memory block. Does >that solve your problem? There isn''t (currently) a printf() format character >that allows for an arbitrary chunk of memory. > >Adam > >On Thu, Sep 22, 2005 at 05:56:48PM +0530, Sanjeev Bagewadi wrote: > > >>Hi, >> >>I need to print the contents of the memory which are passed to uiomove(). >>I decided to allocate a buffer using alloca() and have copied the >>contents using bcopy(). >>Now, I need to print the conents of the buffer and haven''t found a way. >> >>Any pointers/suggestions would be of great help ! >>Thanks in advance !! >> >>Regards, >>Sanjeev. >> >>-- snip -- >>#!/usr/sbin/dtrace -s >>fbt:pxfs:*pxreg*read_cache*:entry >>{ >> self->flag = 1 >>} >> >>fbt::uiomove:entry >>/self->flag = 1/ >>{ >> buf = alloca(1024); >> bcopy((void *)arg1, buf, 1024); >> printf("buffer = %s", stringof(buf)); <-- ** This needs to be >>fixed *** >> self->flag = 0; >>} >> >>_______________________________________________ >>dtrace-discuss mailing list >>dtrace-discuss at opensolaris.org >> >> > > >