Skip to content

Instantly share code, notes, and snippets.

@jclulow
Created June 4, 2013 00:05
Show Gist options
  • Select an option

  • Save jclulow/5702550 to your computer and use it in GitHub Desktop.

Select an option

Save jclulow/5702550 to your computer and use it in GitHub Desktop.
#!/usr/sbin/dtrace -qCs
#pragma D option strsize=4k
syscall::exece:entry
{
this->index = -1;
this->argstr = "";
this->done = 0;
}
syscall::exece:return
/this->index == -1 && curpsinfo->pr_argc < 32/
{
this->index++;
}
syscall::exece:return
/this->index == -1 && curpsinfo->pr_argc >= 32/
{
printf("[%s] pid %d argc %d :: OVERFLOW\n", probefunc, pid, curpsinfo->pr_argc);
}
#define UNROLL_ARGV(cnt) \
syscall::exece:return \
/!this->done && this->index == cnt/ \
{ \
argp = (uintptr_t)(curpsinfo->pr_dmodel == PR_MODEL_ILP32 ? \
*(uint32_t *)copyin(curpsinfo->pr_argv + cnt * 4, 4) : \
*(uint64_t *)copyin(curpsinfo->pr_argv + cnt * 8, 8)); \
this->argstr = strjoin(this->argstr, copyinstr(argp)); \
this->argstr = strjoin(this->argstr, " "); \
this->index += (cnt + 1 < curpsinfo->pr_argc ? 1 : 0); \
this->done = (cnt + 1 == curpsinfo->pr_argc ? 1 : 0); \
}
UNROLL_ARGV(0)
UNROLL_ARGV(1)
UNROLL_ARGV(2)
UNROLL_ARGV(3)
UNROLL_ARGV(4)
UNROLL_ARGV(5)
UNROLL_ARGV(6)
UNROLL_ARGV(7)
UNROLL_ARGV(8)
UNROLL_ARGV(9)
UNROLL_ARGV(10)
UNROLL_ARGV(11)
UNROLL_ARGV(12)
UNROLL_ARGV(13)
UNROLL_ARGV(14)
UNROLL_ARGV(15)
UNROLL_ARGV(16)
UNROLL_ARGV(17)
UNROLL_ARGV(18)
UNROLL_ARGV(19)
UNROLL_ARGV(20)
UNROLL_ARGV(21)
UNROLL_ARGV(22)
UNROLL_ARGV(23)
UNROLL_ARGV(24)
UNROLL_ARGV(25)
UNROLL_ARGV(26)
UNROLL_ARGV(27)
UNROLL_ARGV(28)
UNROLL_ARGV(29)
UNROLL_ARGV(30)
UNROLL_ARGV(31)
syscall::exece:return
/this->done/
{
printf("[%s] pid %d argc %d :: %s\n", probefunc, pid, curpsinfo->pr_argc, this->argstr);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment