/usr/share/systemtap/examples/process
NameSizeModeActions
auditbt.meta4290644editdlrm
auditbt.stp6220755editdlrm
auditbt.tcl790644editdlrm
chng_cpu.meta7750644editdlrm
chng_cpu.stp10490755editdlrm
chng_cpu.tcl1400644editdlrm
cycle_thief.meta10820644editdlrm
cycle_thief.stp28930755editdlrm
cycle_thief.txt59740644editdlrm
errsnoop.meta5750644editdlrm
errsnoop.stp10150755editdlrm
forktracker.meta5250644editdlrm
forktracker.stp6010755editdlrm
futexes.meta5200644editdlrm
futexes.stp11180755editdlrm
futexes.txt9440644editdlrm
futexes2.meta5930644editdlrm
futexes2.stp20140644editdlrm
ltrace.meta3140644editdlrm
ltrace.stp30070755editdlrm
ltrace.tcl1220644editdlrm
migrate.meta7460644editdlrm
migrate.stp10370755editdlrm
mutex-contention.meta4790644editdlrm
mutex-contention.stp55590755editdlrm
mutex-contention.tcl790644editdlrm
noptrace.meta5120644editdlrm
noptrace.stp22350755editdlrm
noptrace.txt12120644editdlrm
pfiles.meta4500644editdlrm
pfiles.stp245230755editdlrm
plimit.meta3870644editdlrm
plimit.stp30290755editdlrm
procmod_watcher.meta6570644editdlrm
procmod_watcher.stp24060644editdlrm
proctop.meta6010644editdlrm
proctop.stp42450755editdlrm
proctop.txt86540644editdlrm
proc_snoop.stp11330755editdlrm
proc_snoop_parser.xml8180644editdlrm
proc_snoop_parser_instructions.txt21800644editdlrm
psig.meta3540644editdlrm
psig.stp56160755editdlrm
pstrace_exec.meta5450644editdlrm
pstrace_exec.stp4650755editdlrm
pstree.meta4550644editdlrm
pstree.stp19570755editdlrm
rlimit_nofile.meta3190644editdlrm
rlimit_nofile.stp11510755editdlrm
sched-latency.meta4700644editdlrm
sched-latency.stp5080644editdlrm
sched-latency.txt15660644editdlrm
schedtimes.meta8140644editdlrm
schedtimes.stp39490755editdlrm
schedtimes.txt32780644editdlrm
semop-watch.meta2670644editdlrm
semop-watch.stp8220755editdlrm
sigkill.meta5600644editdlrm
sigkill.stp6560755editdlrm
sigmon.meta6690644editdlrm
sigmon.stp9320755editdlrm
sig_by_pid.meta3570644editdlrm
sig_by_pid.stp10780755editdlrm
sig_by_pid.txt15140644editdlrm
sig_by_proc.meta3640644editdlrm
sig_by_proc.stp8510755editdlrm
sig_by_proc.txt9510644editdlrm
sleepingBeauties.meta5810644editdlrm
sleepingBeauties.stp13640755editdlrm
sleepingBeauties.tcl1400644editdlrm
sleeptime.meta6010644editdlrm
sleeptime.stp14690755editdlrm
spawn_seeker.meta8540644editdlrm
spawn_seeker.stp15260755editdlrm
spawn_seeker.txt13180644editdlrm
strace.meta3850644editdlrm
strace.stp20810755editdlrm
strace.txt36720644editdlrm
syscalls_by_pid.meta5140644editdlrm
syscalls_by_pid.stp6330755editdlrm
syscalls_by_pid.txt5970644editdlrm
syscalls_by_proc.meta5310644editdlrm
syscalls_by_proc.stp6920755editdlrm
syscalls_by_proc.txt11300644editdlrm
syscalltimes62910755editdlrm
syscalltimes.meta4540644editdlrm
syscalltimes.txt114590644editdlrm
thread-business.meta3460644editdlrm
thread-business.stp8660755editdlrm
thread-business.txt28230644editdlrm
threadstacks.meta5850644editdlrm
threadstacks.stp17890755editdlrm
threadstacks.tcl790644editdlrm
wait4time.meta6580644editdlrm
wait4time.stp13470755editdlrm
Edit: /usr/share/systemtap/examples/process/psig.stp (5616B)
#! /bin/sh //bin/true && exec stap -DMAXACTION=10000 -g $0 ${1+"$@"} # psig # Copyright (C) 2008-2012 Red Hat, Inc., Eugene Teo # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # psig reports information about signals by the process id. # # psig is not a port of Solaris' psig tool. It was written based on the example # output at http://developers.sun.com/solaris/articles/solaris_linux_app.html. # This script requires the signal.stp-psig.patch for tapset/signal.stp (not in # the upstream version of SystemTap at the time of writing). # # $ psig $$ | head -10 # 1852: bash # HUP caught 0x0808d040 0 HUP,INT,ILL,TRAP,ABRT,BUS,FPE,USR1,SEGV,USR2,PIPE,ALRM,TERM,XCPU,XFSZ,VTALRM,SYS # INT caught 0x0808d280 0 # QUIT ignored # ILL caught 0x0808d040 0 HUP,INT,ILL,TRAP,ABRT,BUS,FPE,USR1,SEGV,USR2,PIPE,ALRM,TERM,XCPU,XFSZ,VTALRM,SYS # TRAP caught 0x0808d040 0 HUP,INT,ILL,TRAP,ABRT,BUS,FPE,USR1,SEGV,USR2,PIPE,ALRM,TERM,XCPU,XFSZ,VTALRM,SYS # ABRT caught 0x0808d040 0 HUP,INT,ILL,TRAP,ABRT,BUS,FPE,USR1,SEGV,USR2,PIPE,ALRM,TERM,XCPU,XFSZ,VTALRM,SYS # BUS caught 0x0808d040 0 HUP,INT,ILL,TRAP,ABRT,BUS,FPE,USR1,SEGV,USR2,PIPE,ALRM,TERM,XCPU,XFSZ,VTALRM,SYS # FPE caught 0x0808d040 0 HUP,INT,ILL,TRAP,ABRT,BUS,FPE,USR1,SEGV,USR2,PIPE,ALRM,TERM,XCPU,XFSZ,VTALRM,SYS # KILL default # $ stap -V # systemtap-20071229.tar.bz2 # SystemTap translator/driver (version 0.6/0.131 built 2008-01-12) # $ cat /etc/redhat-release # Fedora release 8 (Werewolf) # $ uname -a # Linux kerndev.xxx.redhat.com 2.6.23.9-85.fc8 #1 SMP Fri Dec 7 15:49:59 EST 2007 i686 i686 i386 GNU/Linux # # NOTES: # HUP caught 0x0808d040 0 HUP,INT,ILL,TRAP,ABRT,BUS,... # [.......][.......][..........][.][............................ # |<-- type of signal (1..64) # |<-- signal disposition. it can be SIG_{DFL,IGN,ERR} or a pointer to a function # |<-- address of the signal-catching function # |<-- sa_flags. see the code snippet below # |<-- set of signals to be blocked when executing the handler # # linux-2.6/include/asm-x86/signal.h: # [...] # /* # * SA_FLAGS values: # * # * SA_ONSTACK indicates that a registered stack_t will be used. # * SA_RESTART flag to get restarting signals (which were the default long ago) # * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. # * SA_RESETHAND clears the handler when the signal is delivered. # * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. # * SA_NODEFER prevents the current signal from being masked in the handler. # * # * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single # * Unix names RESETHAND and NODEFER respectively. # */ # #define SA_NOCLDSTOP 0x00000001u # #define SA_NOCLDWAIT 0x00000002u # #define SA_SIGINFO 0x00000004u # #define SA_ONSTACK 0x08000000u # #define SA_RESTART 0x10000000u # #define SA_NODEFER 0x40000000u # #define SA_RESETHAND 0x80000000u # # #define SA_NOMASK SA_NODEFER # #define SA_ONESHOT SA_RESETHAND # # #define SA_RESTORER 0x04000000 # global _NSIG = 64 function get_k_sigaction:long (task:long, sig:long) %{ struct task_struct *p = (struct task_struct *)((long)STAP_ARG_task); STAP_RETVALUE = (long)&p->sighand->action[(int)STAP_ARG_sig]; %} function get_task_info:string (task:long) %{ char pid[10]; /* just to realign the header properly */ struct task_struct *p = (struct task_struct *)((long)STAP_ARG_task); if (!p) strlcpy(STAP_RETVALUE, "NULL", MAXSTRINGLEN); else { sprintf(pid, "%d:", p->pid); snprintf(STAP_RETVALUE, MAXSTRINGLEN, "%-8s %s", pid, p->comm); } %} function translate_mask:string (mask:string) { str = signal_str(strtol(tokenize(mask, ","), 10)) while (1) { sig = signal_str(strtol(tokenize("", ","), 10)) if (strlen(sig) == 0) break; str = str . "," . sig } return str; } /* * if sa_flags is 0, then return 0. If not, return the interpreted sa_flags. */ function sa_flags_str2:string (sa_flags:string) %{ if (strlen(STAP_ARG_sa_flags) == 0) strcpy(STAP_ARG_sa_flags, "0"); strlcpy (STAP_RETVALUE, STAP_ARG_sa_flags, MAXSTRINGLEN); %} probe begin { %( $# < 1 %? pid = target() %: pid = $1 %) # if (pid == 0) error ("Please provide valid target process-id as $1 or -x PID"); task = pid2task(pid) assert(task, "pid2task: process not found. exiting.\n") task_info = get_task_info(task) assert(!isinstr(task_info, "NULL"), "get_task_info: invalid task_struct. exiting.\n") printf("%s\n", task_info) for (i = 0; i < _NSIG; ++i) { handler_status = "" act = get_k_sigaction(task, i) assert(act, "get_k_sigaction: invalid k_sigaction pointer. exiting.\n") sig = signal_str(i+1) handler = sa_handler_str(get_sa_handler(act)) # XXX: convert hex pointer via usymdata() to useful function if (! (isinstr(handler, "default") || isinstr(handler, "ignored"))) { blocked = is_sig_blocked(task, i+1) if (blocked) handler_status = "blocked," handler_status = handler_status . "caught" } else handler_status = handler flags = sa_flags_str2(sa_flags_str(get_sa_flags(act))) mask = sigset_mask_str(get_sigaction_mask(act)) printf("%-8s %-8s ", sig, handler_status); if (isinstr(handler_status, "caught")) printf("%s %s %s\n", handler, flags, translate_mask(mask)) else printf("\n") } exit() }