freebsd-skq/sys/cddl/dev/dtrace
Mark Johnston e572bc11ec Add a function, memstr, which can be used to convert a buffer of
null-separated strings to a single string. This can be used to print the
full arguments of a process using execsnoop (from the DTrace toolkit) or
with the following one-liner:

dtrace -n 'syscall::execve:return {trace(curpsinfo->pr_psargs);}'

Note that this relies on the process arguments being cached via the struct
proc, which means that it will not work for argvs longer than
kern.ps_arg_cache_limit. However, the following rather non-portable
script can be used to extract any argv at exec time:

fbt::kern_execve:entry
{
    printf("%s", memstr(args[1]->begin_argv, ' ',
        args[1]->begin_envv - args[1]->begin_argv));
}

The debug.dtrace.memstr_max sysctl limits the maximum argument size to
memstr(). Thanks to Brendan Gregg for helpful comments on freebsd-dtrace.

Tested by:	Fabian Keil (earlier version)
MFC after:	2 weeks
2013-10-16 01:39:26 +00:00
..
amd64 dtrace disassembler: take the latest/last CDDL code from OpenSolaris 2013-07-29 16:56:38 +00:00
i386 dtrace disassembler: take the latest/last CDDL code from OpenSolaris 2013-07-29 16:56:38 +00:00
mips
powerpc Whitespace cleanup. 2013-09-02 23:22:05 +00:00
dtrace_anon.c
dtrace_cddl.h
dtrace_clone.c - Use make_dev_credf(MAKEDEV_REF) instead of the race-prone make_dev()+ 2013-09-07 13:45:44 +00:00
dtrace_debug.c
dtrace_hacks.c
dtrace_ioctl.c
dtrace_load.c Initialize and free the DTrace taskqueue in the dtrace module load/unload 2013-10-08 12:56:46 +00:00
dtrace_modevent.c
dtrace_sysctl.c Add a function, memstr, which can be used to convert a buffer of 2013-10-16 01:39:26 +00:00
dtrace_test.c
dtrace_unload.c Initialize and free the DTrace taskqueue in the dtrace module load/unload 2013-10-08 12:56:46 +00:00
dtrace_vtime.c