]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/commit
MFC r256571:
authormarkj <markj@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Mon, 4 Aug 2014 15:36:23 +0000 (15:36 +0000)
committermarkj <markj@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Mon, 4 Aug 2014 15:36:23 +0000 (15:36 +0000)
commitc2d828cd0d78967b4e8c3f84c6bdac8ca8e6cc1e
tree0164d570f9c65985b84113516bfc5db64a5884b3
parentc94a562efea33e8e3e0b2de15880032a34774d83
MFC r256571:
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().

git-svn-id: svn://svn.freebsd.org/base/stable/9@269521 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
cddl/lib/libdtrace/psinfo.d
sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h
sys/cddl/dev/dtrace/dtrace_sysctl.c