oracle / dtrace-utils

DTrace-utils contains the DTrace port to Linux
Other
153 stars 20 forks source link

Update prototype of copyinstr() #113

Open kvanhees opened 4 days ago

kvanhees commented 4 days ago

The copyinstr() subroutine is declared as:

stirng copyinstr(uintptr_t addr [, size_t maxlen])

which in some aspects makes sense because it is to read bytes from a given userspace address (up to a terminating 0-byte or a given maximum length if specified). However, this results in the odd circumstance that if a variable is of datatype char , a (uintptr_t) cast is necessary because char and uintptr_t are not compatible. But this subroutine is to be used explicitly for reading in strings from userspace and that is often done to get the value of USDT probe arguments and we have type information for those (by using the args[] elements). Also, even if we do not have type information, the very fact that we are trying to read a string seems to imply that requiring a char ) cast would be a lot more understandable than needing to cast char to uintptr_t.

Changing the prototype of copyinstr() seems a sensible change. However, we should consider the impact that any scripts that people may already have written will likely include these crazy (uintptr_t) casts that would (with this change) result in a compilation failure, again, uintptr_t vs char *.