On Tue, Feb 26, 2008 at 03:56:36PM +0100, Vladimir Marek wrote:
> N_conreq:entry {
>         self->x=1;
> 
>         calledaddr=(struct xaddrf *)arg3;
>         callingaddr=(struct xaddrf *)arg4;
> 
>         trace(calledaddr->link_id);
>         tracemem(calledaddr->DTE_MAC.lsap_add, 80);
> 
>         trace(callingaddr->link_id);
>         tracemem(callingaddr->DTE_MAC.lsap_add, 80);
> }
> 
>   0  -> N_conreq                                    255                       
>  <===== first link_id
>              0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  0123456789abcdef 
>  <===== first tracemem
>          0: 12 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00  .0..............
>         10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>         20: 00 ff 00 03 45 60 00 00 00 00 00 00 00 00 00 00  ....E`..........
>         30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>         40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>       255  E`
>       ^    ^-- dtrace being smart here? The memory is 0x45 0x60 0x00 ... 
> which is E` in ascii.
> 2nd link_id
> 
> Is there a way to really trace 80 bytes of memory?

As is usually the case with DTrace, there _is_ a way, but, as is ocassionally
the case, it's not beautiful. There's a bug here in that DTrace -- as you
suspected -- tries to be a little bit too clever when printing bytes by
assuming that you must want something printed as a string if the first few
bytes are printable.

What you can do is create a buffer to hold your real data, prepend it with
a non-printable character, and trace the whole thing (remembering to mentally
discard the first byte). For example:

syscall::write:entry
/execname == "cat"/
{
        this->a = copyin(arg1, 80);
        this->p = (char *)alloca(81);
        *this->p = '\0';
        bcopy(this->a, this->p + 1, 80);
        tracemem(this->p, 81);
}

Despite this glorious work-around, please file a bug; if someone is interested
in getting involved with DTrace development, this would be a good fix to try
out.

Adam

-- 
Adam Leventhal, Fishworks                        http://blogs.sun.com/ahl
_______________________________________________
dtrace-discuss mailing list
[email protected]

Reply via email to