User Space DTrace and dumping function arguments for user space

Shrikanth Kamath shrikanth07 at gmail.com
Fri Aug 16 22:10:14 UTC 2013


Can we dump function arguments for user space functions just like for functions
in kernel space? Can FBT provider dump arguments for user space functions if we
do dtrace -l -f <function name> -v?

I was DTrace'ing "top" utility, (the "top" utility has both
the CTF and the Dwarf debug sections built in the object file)

I am trying to inspect get_system_info function called by "top", I
confirm it is present to be probed

    root% dtrace -l | grep get_system_info
    55154  pid8488      top        get_system_info entry

But I cannot dump the arguments to the function...
root% dtrace -l -f get_system_info -v
   ID   PROVIDER            MODULE                          FUNCTION NAME
55154    pid8488               top                   get_system_info entry

        Probe Description Attributes
                Identifier Names: Private
                Data Semantics:   Private
                Dependency Class: Unknown

        Argument Attributes
                Identifier Names: Private
                Data Semantics:   Private
                Dependency Class: Unknown

        Argument Types
                None

Testing with a simple script,
    pid8488::get_system_info:entry
    {
        this->info = (struct system_info *)copyin(args[0],
sizeof(struct system_info));
        ...
    }

...if I use the args[0] notation it says the following,
 dtrace: failed to compile script top_d.d: line 17: index 0 is out of
range for pid8488::get_system_info:entry args[ ]

Instead if I replace with arg0, it compiles but the values are not
neccesarily sane.
Example the ncpus member of struct system_info shows a garbage value.

The complete script is
pid8488::get_system_info:entry
{
    this->info = (struct system_info *)copyin(arg0, sizeof(struct system_info));
    printf("last pid [%d] \n", this->info->last_pid);
}
pid8488::get_process_info:entry
{
    this->info = (struct system_info *)copyin(arg0, sizeof(struct system_info));
    printf("ncpus [%d] \n", this->info->ncpus);
}

Running this
55154         get_system_info:entry last pid [8513]
55155         get_process_info:entry ncpus [134558720]

Supposed to be showing number of cpus? Anything wrong with the scripting?


More information about the freebsd-hackers mailing list