[dtrace-discuss] Handling userland char ** pointers

Nicolas Williams Nicolas.Williams at sun.com
Tue Aug 8 14:16:18 PDT 2006


On Tue, Aug 08, 2006 at 02:09:48PM -0700, Jonathan Adams wrote:
> On Tue, Aug 08, 2006 at 04:04:02PM -0500, Nicolas Williams wrote:
> > I was going to follow up to say this, but something nags me: the
> > dereference of the return value of copying after casting it to
> > uintptr_t.  This part of the expression is the same whether the userland
> > program is a 32-bit or 64-bit program, and I'm surprised it works...
> 
> Uh, this is likely to work on little-endian machines, but not on big-endian
> machines.  And only on little-endian machines if the space after the buffer
> is all zeros.  uintptr_t on a 64-bit kernel is always 64-bits.

I suspected something was wrong.

> I'd do:
> 
> pid$target::sub2:entry
> /curpsinfo->pr_dmodel == PR_MODEL_ILP32/
> {
> 	trace(copyinstr(*(uint32_t *)copyin(arg0, 4)));
> }
> 
> pid$target::sub2:entry
> /curpsinfo->pr_dmodel == PR_MODEL_LP64/
> {
> 	trace(copyinstr(*(uint64_t *)copyin(arg0, 8)));
> }

Yup.  I meant something like that but typed it in before trying it.

The prototypes for copyin*() in the docs say to use uintptr_t, and I
suspected that was a bit of a magic type.

Nico
-- 


More information about the dtrace-discuss mailing list