diff options
author | Jim Keniston <jkenisto@us.ibm.com> | 2008-05-12 14:09:18 -0700 |
---|---|---|
committer | Jim Keniston <jkenisto@us.ibm.com> | 2008-05-12 14:09:18 -0700 |
commit | d1e750063b97a968cb3ae86afaa25646f32b4b71 (patch) | |
tree | b73f9fbaba8048c1d327c5e00fa2df16b44b8ea6 | |
parent | c7fe0041d2132e801f72e158854d54da50fc651d (diff) | |
parent | 77042bd72b98a29a89ccdb32c6eb69b3705664d4 (diff) | |
download | systemtap-steved-d1e750063b97a968cb3ae86afaa25646f32b4b71.tar.gz systemtap-steved-d1e750063b97a968cb3ae86afaa25646f32b4b71.tar.xz systemtap-steved-d1e750063b97a968cb3ae86afaa25646f32b4b71.zip |
PR 4311 - Function boundary tracing without debuginfo: Phases I and II
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | runtime/ChangeLog | 10 | ||||
-rw-r--r-- | runtime/task_finder.c | 110 | ||||
-rw-r--r-- | tapsets.cxx | 12 | ||||
-rw-r--r-- | testsuite/systemtap.examples/ChangeLog | 8 | ||||
-rw-r--r-- | testsuite/systemtap.examples/iotime.meta | 13 | ||||
-rw-r--r-- | testsuite/systemtap.examples/sig_by_pid.meta | 13 | ||||
-rw-r--r-- | testsuite/systemtap.examples/sig_by_proc.meta | 13 | ||||
-rw-r--r-- | testsuite/systemtap.examples/sigmon.meta | 14 | ||||
-rw-r--r-- | testsuite/systemtap.examples/sleeptime.meta | 13 | ||||
-rw-r--r-- | testsuite/systemtap.examples/socket-trace.meta | 13 | ||||
-rw-r--r-- | testsuite/systemtap.examples/syscalls_by_pid.meta | 13 | ||||
-rw-r--r-- | testsuite/systemtap.examples/syscalls_by_proc.meta | 13 | ||||
-rw-r--r-- | testsuite/systemtap.examples/wait4time.meta | 13 |
14 files changed, 230 insertions, 34 deletions
@@ -43,6 +43,12 @@ --ignore-vmlinux, and --ignore-dwarf. * testsuite/{semok,semko}/nodwf*.stp +2008-05-09 Frank Ch. Eigler <fche@elastic.org> + + PR 6487. + * main.cxx (dwarf_query::build_blacklist): Add kernel/relay.c + and kernel/timer.c to probing blacklist. + 2008-05-07 Frank Ch. Eigler <fche@elastic.org> PR 6492. diff --git a/runtime/ChangeLog b/runtime/ChangeLog index f0f65215..aab6a862 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,13 @@ +2008-05-08 David Smith <dsmith@redhat.com> + + PR 6500. + * task_finder.c (__stp_utrace_task_finder_report_exec): Moved + attach logic to __stp_utrace_attach_match_filename(). + (__stp_utrace_attach_match_filename): New function. + (__stp_utrace_task_finder_report_clone): Calls + __stp_utrace_attach_match_filename() to attach to newly cloned + threads. + 2008-05-06 Masami Hiramatsu <mhiramat@redhat.com> PR 5648 diff --git a/runtime/task_finder.c b/runtime/task_finder.c index 6d79c98a..2c27e4a3 100644 --- a/runtime/task_finder.c +++ b/runtime/task_finder.c @@ -231,43 +231,16 @@ __stp_utrace_attach(struct task_struct *tsk, return rc; } -static u32 -__stp_utrace_task_finder_report_clone(struct utrace_attached_engine *engine, - struct task_struct *parent, - unsigned long clone_flags, - struct task_struct *child) -{ - struct utrace_attached_engine *child_engine; - struct mm_struct *mm; - - if (atomic_read(&__stp_task_finder_state) != __STP_TF_RUNNING) - return UTRACE_ACTION_RESUME; - - // On clone, attach to the child. - (void) __stp_utrace_attach(child, engine->ops, 0, - __STP_UTRACE_TASK_FINDER_EVENTS); - return UTRACE_ACTION_RESUME; -} - -static u32 -__stp_utrace_task_finder_report_exec(struct utrace_attached_engine *engine, - struct task_struct *tsk, - const struct linux_binprm *bprm, - struct pt_regs *regs) +static inline void +__stp_utrace_attach_match_filename(struct task_struct *tsk, + const char * const filename) { size_t filelen; struct list_head *tgt_node; struct stap_task_finder_target *tgt; int found_node = 0; - if (atomic_read(&__stp_task_finder_state) != __STP_TF_RUNNING) - return UTRACE_ACTION_RESUME; - - // On exec, check bprm - if (bprm->filename == NULL) - return UTRACE_ACTION_RESUME; - - filelen = strlen(bprm->filename); + filelen = strlen(filename); list_for_each(tgt_node, &__stp_task_finder_list) { tgt = list_entry(tgt_node, struct stap_task_finder_target, list); @@ -275,7 +248,7 @@ __stp_utrace_task_finder_report_exec(struct utrace_attached_engine *engine, // here, since they are handled at startup. if (tgt != NULL && tgt->pathlen > 0 && tgt->pathlen == filelen - && strcmp(tgt->pathname, bprm->filename) == 0) { + && strcmp(tgt->pathname, filename) == 0) { found_node = 1; break; } @@ -309,6 +282,79 @@ __stp_utrace_task_finder_report_exec(struct utrace_attached_engine *engine, cb_tgt->engine_attached = 1; } } +} + +static u32 +__stp_utrace_task_finder_report_clone(struct utrace_attached_engine *engine, + struct task_struct *parent, + unsigned long clone_flags, + struct task_struct *child) +{ + int rc; + struct mm_struct *mm; + char *mmpath_buf; + char *mmpath; + + if (atomic_read(&__stp_task_finder_state) != __STP_TF_RUNNING) + return UTRACE_ACTION_RESUME; + + // On clone, attach to the child. + rc = __stp_utrace_attach(child, engine->ops, 0, + __STP_UTRACE_TASK_FINDER_EVENTS); + if (rc != 0 && rc != EPERM) + return UTRACE_ACTION_RESUME; + + /* Grab the path associated with this task. */ + mm = get_task_mm(child); + if (! mm) { + /* If the thread doesn't have a mm_struct, it is + * a kernel thread which we need to skip. */ + return UTRACE_ACTION_RESUME; + } + + // Allocate space for a path + mmpath_buf = _stp_kmalloc(PATH_MAX); + if (mmpath_buf == NULL) { + _stp_error("Unable to allocate space for path"); + return UTRACE_ACTION_RESUME; + } + + // Grab the path associated with the new task + mmpath = __stp_get_mm_path(mm, mmpath_buf, PATH_MAX); + mmput(mm); /* We're done with mm */ + if (IS_ERR(mmpath)) { + rc = -PTR_ERR(mmpath); + _stp_error("Unable to get path (error %d) for pid %d", + rc, (int)child->pid); + } + else { + __stp_utrace_attach_match_filename(child, mmpath); + } + + _stp_kfree(mmpath_buf); + return UTRACE_ACTION_RESUME; +} + +static u32 +__stp_utrace_task_finder_report_exec(struct utrace_attached_engine *engine, + struct task_struct *tsk, + const struct linux_binprm *bprm, + struct pt_regs *regs) +{ + size_t filelen; + struct list_head *tgt_node; + struct stap_task_finder_target *tgt; + int found_node = 0; + + if (atomic_read(&__stp_task_finder_state) != __STP_TF_RUNNING) + return UTRACE_ACTION_RESUME; + + // On exec, check bprm + if (bprm->filename == NULL) + return UTRACE_ACTION_RESUME; + + __stp_utrace_attach_match_filename(tsk, bprm->filename); + return UTRACE_ACTION_RESUME; } diff --git a/tapsets.cxx b/tapsets.cxx index 9528066f..ef9cf0c6 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -2704,8 +2704,11 @@ dwarf_query::build_blacklist() // XXX: it would be nice if these blacklisted functions were pulled // in dynamically, instead of being statically defined here. - // Perhaps it could be populated from script files. A "noprobe - // kernel.function("...")" construct might do the trick. + // Perhaps it could be populated from script files. A + // + // noprobe kernel.function("...")" + // + // construct might do the trick. // Most of these are marked __kprobes in newer kernels. We list // them here (anyway) so the translator can block them on older @@ -2776,6 +2779,11 @@ dwarf_query::build_blacklist() blfn += "|.*preempt_count.*"; blfn += "|preempt_schedule"; + // PR 6487, relay/timer interactions + blfile += "|kernel/relay.c"; + blfile += "|kernel/timer.c"; + // blfile += "|kernel/workqueue.c"; + // These functions don't return, so return probes would never be recovered blfn_ret += "do_exit"; // no "|" blfn_ret += "|sys_exit"; diff --git a/testsuite/systemtap.examples/ChangeLog b/testsuite/systemtap.examples/ChangeLog index 6c5d014d..8d8c2ca1 100644 --- a/testsuite/systemtap.examples/ChangeLog +++ b/testsuite/systemtap.examples/ChangeLog @@ -1,3 +1,11 @@ +2008-05-08 William Cohen <wcohen@redhat.com> + + * iotime.meta: New. + +2008-05-08 William Cohen <wcohen@redhat.com> + + * sleeptime.meta, wait4time.meta: New. + 2008-05-08 Mark Wielaard <mwielaard@redhat.com> * futexes.meta (test_check,test_installcheck): Change futex.stp to diff --git a/testsuite/systemtap.examples/iotime.meta b/testsuite/systemtap.examples/iotime.meta new file mode 100644 index 00000000..f656ff85 --- /dev/null +++ b/testsuite/systemtap.examples/iotime.meta @@ -0,0 +1,13 @@ +title: Trace Time Spent in Read and Write for Files +name: iotime.stp +version: 1.0 +author: Daniel Berrange and Will Cohen +keywords: syscall read write time io +subsystem: syscall +status: production +exit: user-controlled +output: trace +scope: system-wide +description: The script watches each open, close, read, and write syscalls on the system. For each file the scripts observes opened it accumulates the amount of wall clock time spend in read and write operations and the number of bytes read and written. When a file is closed the script prints out a pair of lines for the file. Both lines begin with a timestamp in microseconds, the PID number, and the executable name in parenthesese. The first line with the "access" keyword lists the file name, the attempted number of bytes for the read and write operations. The second line with the "iotime" keyword list the file name and the number of microseconds accumulated in the read and write syscalls. +test_check: stap -p4 iotime.stp +test_installcheck: stap iotime.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/sig_by_pid.meta b/testsuite/systemtap.examples/sig_by_pid.meta new file mode 100644 index 00000000..03b02fba --- /dev/null +++ b/testsuite/systemtap.examples/sig_by_pid.meta @@ -0,0 +1,13 @@ +title: Signal Counts by Process ID +name: sig_by_pid.stp +version: 1.0 +author: IBM +keywords: signals +subsystem: signals +status: experimental +exit: user-controlled +output: sorted-list on-exit +scope: system-wide +description: Print signal counts by process ID in descending order. +test_check: stap -p4 sig_by_pid.stp +test_installcheck: stap sig_by_pid.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/sig_by_proc.meta b/testsuite/systemtap.examples/sig_by_proc.meta new file mode 100644 index 00000000..eea42be4 --- /dev/null +++ b/testsuite/systemtap.examples/sig_by_proc.meta @@ -0,0 +1,13 @@ +title: Signal Counts by Process Name +name: sig_by_proc.stp +version: 1.0 +author: IBM +keywords: signals +subsystem: signals +status: experimental +exit: user-controlled +output: sorted-list on-exit +scope: system-wide +description: Print signal counts by process name in descending order. +test_check: stap -p4 sig_by_proc.stp +test_installcheck: stap sig_by_proc.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/sigmon.meta b/testsuite/systemtap.examples/sigmon.meta new file mode 100644 index 00000000..18834997 --- /dev/null +++ b/testsuite/systemtap.examples/sigmon.meta @@ -0,0 +1,14 @@ +title: System-Wide Count of Syscalls by PID +name: syscalls_by_pid.stp +version: 1.0 +author: IBM +keywords: signals +subsystem: signals +status: experimental +exit: user-controlled +output: trace +scope: pid +description: The script watches for a particular signal sent to a specific process. When that signal is sent to the specified process, the script prints out the PID and executable of the process sending the signal, the PID and executable name of the process receiving the signal, and the signal number and name. +arg_1: The name of the signal to look for on selected process. +test_check: stap -p4 sigmon.stp SIGKILL +test_installcheck: stap sigmon.stp -c "sleep 1" SIGKILL diff --git a/testsuite/systemtap.examples/sleeptime.meta b/testsuite/systemtap.examples/sleeptime.meta new file mode 100644 index 00000000..d6c59345 --- /dev/null +++ b/testsuite/systemtap.examples/sleeptime.meta @@ -0,0 +1,13 @@ +title: Trace Time Spent in nanosleep Syscalls +name: sleeptime.stp +version: 1.0 +author: Daniel Berrange and Will Cohen +keywords: syscall sleep +subsystem: syscall +status: production +exit: user-controlled +output: trace +scope: system-wide +description: The script watches each nanosleep syscall on the system. At the end of each nanosleep syscall the script prints out a line with a timestamp in microseconds, the pid, the executable name in paretheses, the "nanosleep:" key, and the duration of the sleep in microseconds. +test_check: stap -p4 sleeptime.stp +test_installcheck: stap sleeptime.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/socket-trace.meta b/testsuite/systemtap.examples/socket-trace.meta new file mode 100644 index 00000000..0b26f2fe --- /dev/null +++ b/testsuite/systemtap.examples/socket-trace.meta @@ -0,0 +1,13 @@ +title: Trace Functions called in Network Socket Code +name: socket-trace.stp +version: 1.0 +author: anonymous +keywords: network socket +subsystem: network +status: production +exit: user-controlled +output: trace +scope: system-wide +description: The script instrument each of the functions inn the Linux kernel's net/socket.c file. The script prints out trace. The first element of a line is time delta in microseconds from the previous entry. This is followed by the command name and the PID. The "->" and "<-" indicates function entry and function exit, respectively. The last element of the line is the function name. +test_check: stap -p4 socket-trace.stp +test_installcheck: stap socket-trace.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/syscalls_by_pid.meta b/testsuite/systemtap.examples/syscalls_by_pid.meta new file mode 100644 index 00000000..590652b3 --- /dev/null +++ b/testsuite/systemtap.examples/syscalls_by_pid.meta @@ -0,0 +1,13 @@ +title: System-Wide Count of Syscalls by PID +name: syscalls_by_pid.stp +version: 1.0 +author: anonymous +keywords: syscall +subsystem: syscall +status: production +exit: user-controlled +output: sorted-list on-exit +scope: system-wide +description: The script watches all syscall on the system. On exit the script prints a list showing the number of systemcalls executed by each PID ordered from greatest to least number of syscalls. +test_check: stap -p4 syscalls_by_pid.stp +test_installcheck: stap syscalls_by_pid.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/syscalls_by_proc.meta b/testsuite/systemtap.examples/syscalls_by_proc.meta new file mode 100644 index 00000000..79aa3e87 --- /dev/null +++ b/testsuite/systemtap.examples/syscalls_by_proc.meta @@ -0,0 +1,13 @@ +title: System-Wide Count of Syscalls by Executable +name: syscalls_by_proc.stp +version: 1.0 +author: anonymous +keywords: syscall +subsystem: syscall +status: production +exit: user-controlled +output: sorted-list on-exit +scope: system-wide +description: The script watches all syscall on the system. On exit the script prints a list showing the number of systemcalls executed by each executable ordered from greates to least number of syscalls. +test_check: stap -p4 syscalls_by_proc.stp +test_installcheck: stap syscalls_by_proc.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/wait4time.meta b/testsuite/systemtap.examples/wait4time.meta new file mode 100644 index 00000000..a939d466 --- /dev/null +++ b/testsuite/systemtap.examples/wait4time.meta @@ -0,0 +1,13 @@ +title: Trace Time Spent in wait4 Syscalls +name: wait4time.stp +version: 1.0 +author: Daniel Berrange and Will Cohen +keywords: syscall wait4 +subsystem: syscall +status: production +exit: user-controlled +output: trace +scope: system-wide +description: The script watches each wait4 syscall on the system. At the end of each wait4 syscall the script prints out a line with a timestamp in microseconds, the pid, the executable name in paretheses, the "wait4:" key, the duration of the wait and the PID that the wait4 was waiting for. If the waited for PID is not specified , it is "-1". +test_check: stap -p4 wait4time.stp +test_installcheck: stap wait4time.stp -c "sleep 1" |