|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /proc/21573/root/usr/share/systemtap/tapset/ |
Upload File : |
global _target_set # map: target-set-pid -> ancestor-pid
/**
* sfunction target_set_pid - Does pid descend from target process?
*
* @pid: The pid of the process to query
*
* Description: This function returns whether the given process-id is
* within the "target set", that is whether it is a descendant of the
* top-level target() process.
*/
function target_set_pid (pid)
{
return ([pid] in _target_set)
}
probe begin
{
if (target())
_target_set[target()] = stp_pid()
}
%( arch != "ia64" && kernel_v >= "2.6.18" %?
probe nd_syscall.fork.return
{
pid = returnval()
if (pid in _target_set)
next
ppid = pid()
if (ppid in _target_set)
_target_set[pid] = ppid
}
probe nd_syscall.exit
{
delete _target_set[pid()]
}
%:
# ia64 systems and pre-2.6.18 systems don't support dwarfless probes,
# so we'll use 'syscall' probes instead of 'nd_syscall' probes.
probe syscall.fork.return
{
pid = $return
if (pid in _target_set)
next
ppid = pid()
if (ppid in _target_set)
_target_set[pid] = ppid
}
probe syscall.exit
{
delete _target_set[pid()]
}
%)
/**
* sfunction target_set_report - Print a report about the target set
*
* Description: This function prints a report about the processes in the
* target set, and their ancestry.
*/
function target_set_report ()
{
printf("target set:\n")
foreach (pid in _target_set+)
printf("%d begat %d\n", _target_set[pid], pid)
}