oracle / oracle/dtrace

Update prototype of copyinstr()

Open
#113 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
189
Forks
23
PR merge metrics
No merged PRs in 30d

Description

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 *.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the copyinstr() declaration and the scripts or callers that pass uintptr_t casts, then review how USDT probe argument type information is used. Done means the prototype change and its impact on existing scripts are understood and documented well enough to choose a compatible implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.