From d61b194cff21efd0172ad19d346116bd36a8edd4 Mon Sep 17 00:00:00 2001 From: William Cohen Date: Wed, 7 May 2008 16:00:48 -0400 Subject: Clean up output. --- testsuite/systemtap.examples/ChangeLog | 4 ++++ testsuite/systemtap.examples/pf2.stp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/testsuite/systemtap.examples/ChangeLog b/testsuite/systemtap.examples/ChangeLog index ad46276c..46146889 100644 --- a/testsuite/systemtap.examples/ChangeLog +++ b/testsuite/systemtap.examples/ChangeLog @@ -1,3 +1,7 @@ +2008-05-07 William Cohen + + * pf2.stp: Clean up output. + 2008-05-01 William Cohen * helloworld.meta: New file. diff --git a/testsuite/systemtap.examples/pf2.stp b/testsuite/systemtap.examples/pf2.stp index 96fdb7e7..a804c3ff 100755 --- a/testsuite/systemtap.examples/pf2.stp +++ b/testsuite/systemtap.examples/pf2.stp @@ -6,10 +6,10 @@ probe timer.profile { fn = probefunc () if (fn != "") profile[fn] <<< 1 } -probe timer.ms(4000) { +probe timer.ms(5000) { printf ("\n--- %d samples recorded:\n", @count(pcount)) foreach (f in profile- limit 10) { - printf ("%s\t%d\n", f, @count(profile[f])) + printf ("%-30s\t%6d\n", f, @count(profile[f])) } delete profile delete pcount -- cgit From 100ae9d775be39068b7918f7d8c1079d254494eb Mon Sep 17 00:00:00 2001 From: William Cohen Date: Wed, 7 May 2008 17:00:57 -0400 Subject: futexes.meta, nettop.meta, pf2.meta: New. --- testsuite/systemtap.examples/ChangeLog | 4 ++++ testsuite/systemtap.examples/futexes.meta | 13 +++++++++++++ testsuite/systemtap.examples/nettop.meta | 13 +++++++++++++ testsuite/systemtap.examples/pf2.meta | 13 +++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 testsuite/systemtap.examples/futexes.meta create mode 100644 testsuite/systemtap.examples/nettop.meta create mode 100644 testsuite/systemtap.examples/pf2.meta diff --git a/testsuite/systemtap.examples/ChangeLog b/testsuite/systemtap.examples/ChangeLog index 46146889..00206e70 100644 --- a/testsuite/systemtap.examples/ChangeLog +++ b/testsuite/systemtap.examples/ChangeLog @@ -1,3 +1,7 @@ +2008-05-07 William Cohen + + * futexes.meta, nettop.meta, pf2.meta: New. + 2008-05-07 William Cohen * pf2.stp: Clean up output. diff --git a/testsuite/systemtap.examples/futexes.meta b/testsuite/systemtap.examples/futexes.meta new file mode 100644 index 00000000..908e2f43 --- /dev/null +++ b/testsuite/systemtap.examples/futexes.meta @@ -0,0 +1,13 @@ +title: System-Wide Futex Contention +name: futex.stp +version: 1.0 +author: anonymous +keywords: syscall locking futex +subsystem: locking +status: production +exit: user-controlled +output: sorted-list on-exit +scope: system-wide +description: The script watches the futex syscall on the system. On exit the futexes address, the number of contentions, and the average time for each contention on the futex are printed from lowest pid number to highest. +test_check: stap -p4 futex.stp +test_installcheck: stap futex.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/nettop.meta b/testsuite/systemtap.examples/nettop.meta new file mode 100644 index 00000000..61d1c153 --- /dev/null +++ b/testsuite/systemtap.examples/nettop.meta @@ -0,0 +1,13 @@ +title: Periodic Listing of Processes Using Network Interfaces +name: nettop.stp +version: 1.0 +author: anonymous +keywords: network traffic per-process +subsystem: network +status: production +exit: user-controlled +output: timed +scope: system-wide +description: Every five seconds the nettop.stp script prints out a list of processed (PID and command) with the number of packets sent/received and the amount of data sent/received by the process during that interval. +test_check: stap -p4 nettop.stp +test_installcheck: stap nettop.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/pf2.meta b/testsuite/systemtap.examples/pf2.meta new file mode 100644 index 00000000..d0a534bd --- /dev/null +++ b/testsuite/systemtap.examples/pf2.meta @@ -0,0 +1,13 @@ +title: Profile kernel functions +name: pf2.stp +version: 1.0 +author: anonymous +keywords: profiling +subsystem: kernel +status: production +exit: user-controlled +output: sorted-list +scope: system-wide +description: The pf2.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top ten kernel functions with samples. +test_check: stap -p4 pf2.stp +test_installcheck: stap pf2.stp -c "sleep 1" -- cgit From 56d9a530202979fed9544131aa2e53bf2da0c7de Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Wed, 7 May 2008 19:23:18 -0400 Subject: PR5648: Fix memcpy's endianess issue. --- runtime/ChangeLog | 5 +++++ runtime/vsprintf.c | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 8410b918..0a66a28b 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,8 @@ +2008-05-06 Masami Hiramatsu + + PR 5648 + * vsprintf.c (_stp_vsnprintf): Fix memcpy's endianess issue. + 2008-05-05 Frank Ch. Eigler PR 6481. diff --git a/runtime/vsprintf.c b/runtime/vsprintf.c index dcaa1bc3..4ffcf72e 100644 --- a/runtime/vsprintf.c +++ b/runtime/vsprintf.c @@ -248,6 +248,11 @@ int _stp_vsnprintf(char *buf, size_t size, const char *fmt, va_list args) ++str; } } +#ifdef __ia64__ + if ((str + precision - 1) <= end) + memcpy(str, &num, precision); //to prevent unaligned access + str += precision; +#else switch(precision) { case 1: if(str <= end) @@ -256,21 +261,22 @@ int _stp_vsnprintf(char *buf, size_t size, const char *fmt, va_list args) break; case 2: if((str + 1) <= end) - memcpy(str, &num, 2); + *(int16_t *)str = (int16_t)num; str+=2; break; case 4: if((str + 3) <= end) - memcpy(str, &num, 4); + *(int32_t *)str = num; str+=4; break; default: // "%.8b" by default case 8: if((str + 7) <= end) - memcpy(str, &num, 8); + *(int64_t *)str = num; str+=8; break; } +#endif while (len < field_width--) { if (str <= end) *str = '\0'; -- cgit From 3e2a19a9f57fe40b872f5084c5c60ba1a45f087c Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Wed, 7 May 2008 19:23:44 -0400 Subject: PR5648: Fix unaligned access warning in stp_print_flush on ia64 --- runtime/ChangeLog | 7 +++++++ runtime/print_new.c | 12 +++++++----- runtime/print_old.c | 12 +++++++----- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 0a66a28b..f0f65215 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,10 @@ +2008-05-06 Masami Hiramatsu + + PR 5648 + * print_old.c (stp_print_flush): Fix unaligned access warning on + ia64. + * print_new.c (stp_print_flush): Ditto. + 2008-05-06 Masami Hiramatsu PR 5648 diff --git a/runtime/print_new.c b/runtime/print_new.c index 75bbd82b..07af2e33 100644 --- a/runtime/print_new.c +++ b/runtime/print_new.c @@ -40,11 +40,13 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) else atomic_inc (&_stp_transport_failures); #else - struct _stp_trace *t = relay_reserve(_stp_utt->rchan, sizeof(*t) + len); - if (likely(t)) { - t->sequence = _stp_seq_inc(); - t->pdu_len = len; - memcpy((void *) t + sizeof(*t), pb->buf, len); + void *buf = relay_reserve(_stp_utt->rchan, + sizeof(struct _stp_trace) + len); + if (likely(buf)) { + struct _stp_trace t = { .sequence = _stp_seq_inc(), + .pdu_len = len}; + memcpy(buf, &t, sizeof(t)); // prevent unaligned access + memcpy(buf + sizeof(t), pb->buf, len); } else atomic_inc (&_stp_transport_failures); #endif diff --git a/runtime/print_old.c b/runtime/print_old.c index 5ee050b5..5c117e5f 100644 --- a/runtime/print_old.c +++ b/runtime/print_old.c @@ -35,11 +35,13 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb) else atomic_inc (&_stp_transport_failures); #else - struct _stp_trace *t = relay_reserve(_stp_utt->rchan, sizeof(*t) + len); - if (likely(t)) { - t->sequence = _stp_seq_inc(); - t->pdu_len = len; - memcpy((void *) t + sizeof(*t), pb->buf, len); + void *buf = relay_reserve(_stp_utt->rchan, + sizeof(struct _stp_trace) + len); + if (likely(buf)) { + struct _stp_trace t = { .sequence = _stp_seq_inc(), + .pdu_len = len}; + memcpy(buf, &t, sizeof(t)); // prevent unaligned access + memcpy(buf + sizeof(t), pb->buf, len); } else atomic_inc (&_stp_transport_failures); #endif -- cgit From 4bd48e4b30fdf2caa4d4d9cc9a52dad347807535 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Wed, 7 May 2008 19:35:50 -0400 Subject: PR6492: make listing mode warning-free --- ChangeLog | 5 +++++ main.cxx | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 57b1debc..1054e468 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-05-07 Frank Ch. Eigler + + PR 6492. + * main.cxx (main): let -l imply -w. + 2008-05-05 Frank Ch. Eigler PR 444886. From : diff --git a/main.cxx b/main.cxx index 6546db11..53c8b51f 100644 --- a/main.cxx +++ b/main.cxx @@ -510,6 +510,7 @@ main (int argc, char * const argv []) break; case 'l': + s.suppress_warnings = true; s.listing_mode = true; s.last_pass = 2; if (have_script) -- cgit From 5341054cc6cbe0ecc05947b59c12820a34635e1b Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 8 May 2008 13:48:11 +0200 Subject: In ioblock.stp ioblock.end set bytes_done depending on kernel version. --- tapset/ChangeLog | 6 ++++++ tapset/ioblock.stp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tapset/ChangeLog b/tapset/ChangeLog index cf41c9cb..70d75b83 100644 --- a/tapset/ChangeLog +++ b/tapset/ChangeLog @@ -1,3 +1,9 @@ +2008-05-08 Ananth N Mavinakayanahalli + + PR 5231 + * ioblock.stp (ioblock.end): Set bytes_done depending on kernel + version. + 2008-04-29 Frank Ch. Eigler PR 6466 diff --git a/tapset/ioblock.stp b/tapset/ioblock.stp index 94781c04..14ce3f6b 100644 --- a/tapset/ioblock.stp +++ b/tapset/ioblock.stp @@ -167,7 +167,7 @@ probe ioblock.end = kernel.function("bio_endio") devname = __bio_devname($bio) ino = __bio_ino($bio) - bytes_done = $bytes_done + bytes_done = %( kernel_vr < "2.6.24" %? $bytes_done %: $bio->bi_size %) error = $error sector = $bio->bi_sector -- cgit From 8dd6b23de4dd099aa244402192cb3d7be2bda739 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 8 May 2008 14:02:52 +0200 Subject: systemtap.examples futexes.meta change futex.stp to futexes.stp. --- testsuite/systemtap.examples/ChangeLog | 5 +++++ testsuite/systemtap.examples/futexes.meta | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/testsuite/systemtap.examples/ChangeLog b/testsuite/systemtap.examples/ChangeLog index 00206e70..6c5d014d 100644 --- a/testsuite/systemtap.examples/ChangeLog +++ b/testsuite/systemtap.examples/ChangeLog @@ -1,3 +1,8 @@ +2008-05-08 Mark Wielaard + + * futexes.meta (test_check,test_installcheck): Change futex.stp to + futexes.stp. + 2008-05-07 William Cohen * futexes.meta, nettop.meta, pf2.meta: New. diff --git a/testsuite/systemtap.examples/futexes.meta b/testsuite/systemtap.examples/futexes.meta index 908e2f43..0a34b2d8 100644 --- a/testsuite/systemtap.examples/futexes.meta +++ b/testsuite/systemtap.examples/futexes.meta @@ -9,5 +9,5 @@ exit: user-controlled output: sorted-list on-exit scope: system-wide description: The script watches the futex syscall on the system. On exit the futexes address, the number of contentions, and the average time for each contention on the futex are printed from lowest pid number to highest. -test_check: stap -p4 futex.stp -test_installcheck: stap futex.stp -c "sleep 1" +test_check: stap -p4 futexes.stp +test_installcheck: stap futexes.stp -c "sleep 1" -- cgit From 28bfdd29418549cbf12415d22c90023848663776 Mon Sep 17 00:00:00 2001 From: William Cohen Date: Thu, 8 May 2008 17:25:59 -0400 Subject: * sleeptime.meta, wait4time.meta: New. --- testsuite/systemtap.examples/sleeptime.meta | 13 +++++++++++++ testsuite/systemtap.examples/wait4time.meta | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 testsuite/systemtap.examples/sleeptime.meta create mode 100644 testsuite/systemtap.examples/wait4time.meta 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/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" -- cgit From 1cd26cfa5d1a8f12b4aff9aef06c8c5289d7334a Mon Sep 17 00:00:00 2001 From: William Cohen Date: Thu, 8 May 2008 17:27:38 -0400 Subject: Update ChangeLog --- testsuite/systemtap.examples/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testsuite/systemtap.examples/ChangeLog b/testsuite/systemtap.examples/ChangeLog index 6c5d014d..c05123cb 100644 --- a/testsuite/systemtap.examples/ChangeLog +++ b/testsuite/systemtap.examples/ChangeLog @@ -1,3 +1,7 @@ +2008-05-08 William Cohen + + * sleeptime.meta, wait4time.meta: New. + 2008-05-08 Mark Wielaard * futexes.meta (test_check,test_installcheck): Change futex.stp to -- cgit From 22bf9dc8f992e30e325fcad9b5af77db190e977f Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 8 May 2008 16:19:08 -0500 Subject: Fix for PR 6500. 2008-05-08 David Smith 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. --- runtime/ChangeLog | 10 +++++ runtime/task_finder.c | 110 +++++++++++++++++++++++++++++++++++--------------- 2 files changed, 88 insertions(+), 32 deletions(-) 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 + + 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 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; } -- cgit From c01bb1ec6d4d3d747975a9e4d16b1df9a938bc2f Mon Sep 17 00:00:00 2001 From: William Cohen Date: Thu, 8 May 2008 17:48:24 -0400 Subject: * iotime.meta: New. --- testsuite/systemtap.examples/ChangeLog | 4 ++++ testsuite/systemtap.examples/iotime.meta | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 testsuite/systemtap.examples/iotime.meta diff --git a/testsuite/systemtap.examples/ChangeLog b/testsuite/systemtap.examples/ChangeLog index c05123cb..8d8c2ca1 100644 --- a/testsuite/systemtap.examples/ChangeLog +++ b/testsuite/systemtap.examples/ChangeLog @@ -1,3 +1,7 @@ +2008-05-08 William Cohen + + * iotime.meta: New. + 2008-05-08 William Cohen * sleeptime.meta, wait4time.meta: New. diff --git a/testsuite/systemtap.examples/iotime.meta b/testsuite/systemtap.examples/iotime.meta new file mode 100644 index 00000000..4c1971f5 --- /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 number of bytes attempted 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" -- cgit From 0382b42d78fb0d6355b0bec2219fbdc2ef9dca8c Mon Sep 17 00:00:00 2001 From: William Cohen Date: Thu, 8 May 2008 18:15:16 -0400 Subject: Adjust iotime.meta description. --- testsuite/systemtap.examples/iotime.meta | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/systemtap.examples/iotime.meta b/testsuite/systemtap.examples/iotime.meta index 4c1971f5..f656ff85 100644 --- a/testsuite/systemtap.examples/iotime.meta +++ b/testsuite/systemtap.examples/iotime.meta @@ -8,6 +8,6 @@ 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 number of bytes attempted 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. +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" -- cgit From e0d0dcf974e2d0898a7f5a05a2a3fdc93ba51fea Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 9 May 2008 15:51:57 -0400 Subject: PR6487: extend blacklist with relay/timer subsystem --- ChangeLog | 6 ++++++ tapsets.cxx | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1054e468..5ed59476 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-05-09 Frank Ch. Eigler + + 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 PR 6492. diff --git a/tapsets.cxx b/tapsets.cxx index 7cdf3c32..67412396 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -2425,8 +2425,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 @@ -2497,6 +2500,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"; -- cgit From d9b47a1d2744d0c8f2a3f74ea3705b9d10916b5b Mon Sep 17 00:00:00 2001 From: William Cohen Date: Fri, 9 May 2008 16:36:13 -0400 Subject: Add syscalls_by_pid.meta, syscalls_by_proc.meta, sigmon.meta, sig_by_pid.meta, sig_by_proc.meta, and socket-trace.meta. --- testsuite/systemtap.examples/sig_by_pid.meta | 13 +++++++++++++ testsuite/systemtap.examples/sig_by_proc.meta | 13 +++++++++++++ testsuite/systemtap.examples/sigmon.meta | 14 ++++++++++++++ testsuite/systemtap.examples/socket-trace.meta | 13 +++++++++++++ testsuite/systemtap.examples/syscalls_by_pid.meta | 13 +++++++++++++ testsuite/systemtap.examples/syscalls_by_proc.meta | 13 +++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 testsuite/systemtap.examples/sig_by_pid.meta create mode 100644 testsuite/systemtap.examples/sig_by_proc.meta create mode 100644 testsuite/systemtap.examples/sigmon.meta create mode 100644 testsuite/systemtap.examples/socket-trace.meta create mode 100644 testsuite/systemtap.examples/syscalls_by_pid.meta create mode 100644 testsuite/systemtap.examples/syscalls_by_proc.meta 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/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" -- cgit From 49f426d9fd471bbdabb0e7a25525d0884b7e8831 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Mon, 12 May 2008 19:35:17 -0400 Subject: Revert "PR6487: extend blacklist with relay/timer subsystem" This reverts commit e0d0dcf974e2d0898a7f5a05a2a3fdc93ba51fea. It seems that blacklisting kernel/timer.c is overbroad. --- ChangeLog | 6 ------ tapsets.cxx | 12 ++---------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ed59476..1054e468 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,3 @@ -2008-05-09 Frank Ch. Eigler - - 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 PR 6492. diff --git a/tapsets.cxx b/tapsets.cxx index 67412396..7cdf3c32 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -2425,11 +2425,8 @@ 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 @@ -2500,11 +2497,6 @@ 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"; -- cgit From ac158744658d392301e55e42ab53d246de8bc61e Mon Sep 17 00:00:00 2001 From: Jim Keniston Date: Tue, 13 May 2008 15:34:00 -0700 Subject: Converted more aliases to use arg numbers instead of names. In particular, converted the aliases for futex, getrusage, and mq_open -- which presented problems when this tapset is used without dwarf, even if those aliases aren't used. --- tapset/nd_syscalls.stp | 369 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 265 insertions(+), 104 deletions(-) diff --git a/tapset/nd_syscalls.stp b/tapset/nd_syscalls.stp index eb5efda0..5697cd21 100644 --- a/tapset/nd_syscalls.stp +++ b/tapset/nd_syscalls.stp @@ -8,6 +8,15 @@ // Public License (GPL); either version 2, or (at your option) any // later version. +/* + * nd_syscalls.stp is a copy of syscalls.stp, modified to refer to + * function arguments by number rather than name, so that this tapset + * can be used even when the probed kernel lacks debugging information. + * + * So far, the names-to-numbers conversion covers only syscall.a* + * through syscall.c*, plus a few others. + */ + /* Each syscall returns the calls parameters. In addition, the following * variables are set: @@ -88,16 +97,27 @@ probe nd_syscall.acct.return = kernel.function("sys_acct").return ? { # probe nd_syscall.add_key = kernel.function("sys_add_key") ? { name = "add_key" - type_uaddr = $_type - description_auddr = $_description - payload_uaddr = $_payload - plen = $plen - ringid = $ringid + // type_uaddr = $_type + // description_auddr = $_description + // payload_uaddr = $_payload + // plen = $plen + // ringid = $ringid + // argstr = sprintf("%s, %s, %s, %d, %d", + // user_string_quoted($_type), + // user_string_quoted($_description), + // text_strn(user_string($_payload),syscall_string_trunc,1), + // $plen, $ringid) + asmlinkage() + type_uaddr = pointer_arg(1) + description_uaddr = pointer_arg(2) + payload_uaddr = pointer_arg(3) + plen = ulong_arg(4) + ringid = int_arg(5) argstr = sprintf("%s, %s, %s, %d, %d", - user_string_quoted($_type), - user_string_quoted($_description), - text_strn(user_string($_payload),syscall_string_trunc,1), - $plen, $ringid) + user_string_quoted(type_uaddr), + user_string_quoted(description_uaddr), + text_strn(user_string(payload_uaddr),syscall_string_trunc,1), + plen, ringid) } probe nd_syscall.add_key.return = kernel.function("sys_add_key").return ? { name = "add_key" @@ -122,16 +142,21 @@ probe nd_syscall.adjtimex = kernel.function("sys_adjtimex") { * buf_time_tv_usec = __uget_timex_m($txc_p,10) * buf_tick = __uget_timex_m($txc_p,11) */ - argstr = sprintf("%p", $txc_p) + // argstr = sprintf("%p", $txc_p) + asmlinkage() + argstr = sprintf("%p", pointer_arg(1)) } probe nd_syscall.adjtimex.return = kernel.function("sys_adjtimex").return { name = "adjtimex" - retstr = _adjtimex_return_str($return) + // retstr = _adjtimex_return_str($return) + retstr = _adjtimex_return_str(returnval()) } # long compat_sys_adjtimex(struct compat_timex __user *utp) probe nd_syscall.compat_adjtimex = kernel.function("compat_sys_adjtimex") ? { name = "compat_adjtimex" - argstr = sprintf("%p", $utp) + // argstr = sprintf("%p", $utp) + asmlinkage() + argstr = sprintf("%p", pointer_arg(1)) } probe nd_syscall.compat_adjtimex.return = kernel.function("compat_sys_adjtimex").return ? { name = "compat_adjtimex" @@ -147,8 +172,11 @@ probe nd_syscall.alarm = kernel.function("sys32_alarm") ? { name = "alarm" - seconds = $seconds - argstr = sprint($seconds) + // seconds = $seconds + // argstr = sprint($seconds) + asmlinkage() + seconds = uint_arg(1) + argstr = sprint(seconds) } probe nd_syscall.alarm.return = kernel.function("sys_alarm").return ?, @@ -162,12 +190,19 @@ probe nd_syscall.alarm.return = # long sys_bdflush(int func,long data) probe nd_syscall.bdflush = kernel.function("sys_bdflush") ? { name = "bdflush" - func = $func - data = $data - if (($func>=2)&&($func%2==0)) - data_str = sprintf("%p", $data) + // func = $func + // data = $data + // if (($func>=2)&&($func%2==0)) + // data_str = sprintf("%p", $data) + // else + // data_str = sprintf("%d", $data) + asmlinkage() + func = int_arg(1) + data = long_arg(2) + if ((func>=2)&&(func%2==0)) + data_str = sprintf("%p", data) else - data_str = sprintf("%d", $data) + data_str = sprintf("%d", data) argstr = sprintf("%d, %s",func, data_str) } probe nd_syscall.bdflush.return = kernel.function("sys_bdflush").return ? { @@ -179,10 +214,15 @@ probe nd_syscall.bdflush.return = kernel.function("sys_bdflush").return ? { # long sys_bind(int fd, struct sockaddr __user *umyaddr, int addrlen) probe nd_syscall.bind = kernel.function("sys_bind") ? { name = "bind" - sockfd = $fd - my_addr_uaddr = $umyaddr - addrlen = $addrlen - argstr = sprintf("%d, %s, %d", $fd, _struct_sockaddr_u($umyaddr,$addrlen),$addrlen) + // sockfd = $fd + // my_addr_uaddr = $umyaddr + // addrlen = $addrlen + // argstr = sprintf("%d, %s, %d", $fd, _struct_sockaddr_u($umyaddr,$addrlen),$addrlen) + asmlinkage() + sockfd = int_arg(1) + my_addr_uaddr = pointer_arg(2) + addrlen = int_arg(3) + argstr = sprintf("%d, %s, %d", sockfd, _struct_sockaddr_u(my_addr_uaddr,addrlen),addrlen) } probe nd_syscall.bind.return = kernel.function("sys_bind").return ? { name = "bind" @@ -196,7 +236,9 @@ probe nd_syscall.brk = kernel.function("ia64_brk") ? { name = "brk" - brk = $brk + // brk = $brk + asmlinkage() + brk = ulong_arg(1) argstr = sprintf("%p", brk) } probe nd_syscall.brk.return = @@ -222,9 +264,13 @@ probe nd_syscall.brk.return = # long sys_capget(cap_user_header_t header, cap_user_data_t dataptr) probe nd_syscall.capget = kernel.function("sys_capget") { name = "capget" - header_uaddr = $header - data_uaddr = $dataptr - argstr = sprintf("%p, %p", $header, $dataptr) + // header_uaddr = $header + // data_uaddr = $dataptr + // argstr = sprintf("%p, %p", $header, $dataptr) + asmlinkage() + header_uaddr = pointer_arg(1) + data_uaddr = pointer_arg(2) + argstr = sprintf("%p, %p", header_uaddr, data_uaddr) } probe nd_syscall.capget.return = kernel.function("sys_capget").return { name = "capget" @@ -245,9 +291,13 @@ probe nd_syscall.capget.return = kernel.function("sys_capget").return { # long sys_capset(cap_user_header_t header, const cap_user_data_t data) probe nd_syscall.capset = kernel.function("sys_capset") { name = "capset" - header_uaddr = $header - data_uaddr = $data - argstr = sprintf("%p, %p", $header, $data) + // header_uaddr = $header + // data_uaddr = $data + // argstr = sprintf("%p, %p", $header, $data) + asmlinkage() + header_uaddr = pointer_arg(1) + data_uaddr = pointer_arg(2) + argstr = sprintf("%p, %p", header_uaddr, data_uaddr) } probe nd_syscall.capset.return = kernel.function("sys_capset").return { name = "capset" @@ -258,8 +308,11 @@ probe nd_syscall.capset.return = kernel.function("sys_capset").return { # long sys_chdir(const char __user * filename) probe nd_syscall.chdir = kernel.function("sys_chdir") { name = "chdir" - path = user_string($filename) - argstr = user_string_quoted($filename) + // path = user_string($filename) + // argstr = user_string_quoted($filename) + asmlinkage() + path = user_string(pointer_arg(1)) + argstr = user_string_quoted(pointer_arg(1)) } probe nd_syscall.chdir.return = kernel.function("sys_chdir").return { name = "chdir" @@ -270,9 +323,13 @@ probe nd_syscall.chdir.return = kernel.function("sys_chdir").return { # long sys_chmod(const char __user * filename, mode_t mode) probe nd_syscall.chmod = kernel.function("sys_chmod") { name = "chmod" - path = user_string($filename) - mode = $mode - argstr = sprintf("%s, %#o", user_string_quoted($filename), mode) + // path = user_string($filename) + // mode = $mode + // argstr = sprintf("%s, %#o", user_string_quoted($filename), mode) + asmlinkage() + path = user_string(pointer_arg(1)) + mode = uint_arg(2) + argstr = sprintf("%s, %#o", user_string_quoted(pointer_arg(1)), mode) } probe nd_syscall.chmod.return = kernel.function("sys_chmod").return { name = "chmod" @@ -283,10 +340,15 @@ probe nd_syscall.chmod.return = kernel.function("sys_chmod").return { # long sys_chown(const char __user * filename, uid_t user, gid_t group) probe nd_syscall.chown = kernel.function("sys_chown") { name = "chown" - path = user_string($filename) - owner = __int32($user) - group = __int32($group) - argstr = sprintf("%s, %d, %d",user_string_quoted($filename), owner, group) + // path = user_string($filename) + // owner = __int32($user) + // group = __int32($group) + // argstr = sprintf("%s, %d, %d",user_string_quoted($filename), owner, group) + asmlinkage() + path = user_string(pointer_arg(1)) + owner = __int32(uint_arg(2)) + group = __int32(uint_arg(3)) + argstr = sprintf("%s, %d, %d",user_string_quoted(pointer_arg(1)), owner, group) } probe nd_syscall.chown.return = kernel.function("sys_chown").return { name = "chown" @@ -298,10 +360,15 @@ probe nd_syscall.chown.return = kernel.function("sys_chown").return { # probe nd_syscall.chown16 = kernel.function("sys_chown16") ? { name = "chown16" - path = user_string($filename) - owner = __short($user) - group = __short($group) - argstr = sprintf("%s, %d, %d", user_string_quoted($filename), owner, group) + // path = user_string($filename) + // owner = __short($user) + // group = __short($group) + // argstr = sprintf("%s, %d, %d", user_string_quoted($filename), owner, group) + asmlinkage() + path = user_string(pointer_arg(1)) + owner = __short(uint_arg(2)) + group = __short(uint_arg(3)) + argstr = sprintf("%s, %d, %d", user_string_quoted(pointer_arg(1)), owner, group) } probe nd_syscall.chown16.return = kernel.function("sys_chown16").return ? { name = "chown16" @@ -312,8 +379,11 @@ probe nd_syscall.chown16.return = kernel.function("sys_chown16").return ? { # long sys_chroot(const char __user * filename) probe nd_syscall.chroot = kernel.function("sys_chroot") { name = "chroot" - path = user_string($filename) - argstr = user_string_quoted($filename) + // path = user_string($filename) + // argstr = user_string_quoted($filename) + asmlinkage() + path = user_string(pointer_arg(1)) + argstr = user_string_quoted(pointer_arg(1)) } probe nd_syscall.chroot.return = kernel.function("sys_chroot").return { name = "chroot" @@ -329,10 +399,15 @@ probe nd_syscall.clock_getres = kernel.function("compat_clock_getres") ? { name = "clock_getres" - clk_id = $which_clock - clk_id_str = _get_wc_str($which_clock) - res_uaddr = $tp - argstr = sprintf("%s, %p", _get_wc_str($which_clock), $tp) + // clk_id = $which_clock + // clk_id_str = _get_wc_str($which_clock) + // res_uaddr = $tp + // argstr = sprintf("%s, %p", _get_wc_str($which_clock), $tp) + asmlinkage() + clk_id = int_arg(1) + clk_id_str = _get_wc_str(clk_id) + res_uaddr = pointer_arg(2) + argstr = sprintf("%s, %p", clk_id_str, res_uaddr) } probe nd_syscall.clock_getres.return = kernel.function("sys_clock_getres").return, @@ -349,9 +424,13 @@ probe nd_syscall.clock_gettime = kernel.function("sys_clock_gettime") { name = "clock_gettime" - clk_id = $which_clock - clk_id_str = _get_wc_str($which_clock) - argstr = sprintf("%s, %p", _get_wc_str($which_clock), $tp) + // clk_id = $which_clock + // clk_id_str = _get_wc_str($which_clock) + // argstr = sprintf("%s, %p", _get_wc_str($which_clock), $tp) + asmlinkage() + clk_id = int_arg(1) + clk_id_str = _get_wc_str(clk_id) + argstr = sprintf("%s, %p", clk_id_str, pointer_arg(2)) } probe nd_syscall.clock_gettime.return = kernel.function("sys_clock_gettime").return { @@ -367,12 +446,20 @@ probe nd_syscall.clock_gettime.return = kernel.function("sys_clock_gettime").ret # probe nd_syscall.clock_nanosleep = kernel.function("sys_clock_nanosleep") { name = "clock_nanosleep" - if ($flags == 1) + // if ($flags == 1) + // flag_str = "TIMER_ABSTIME" + // else + // flag_str = sprintf("0x%x", $flags) + // argstr = sprintf("%s, %s, %s, %p", _get_wc_str($which_clock), flag_str, + // _struct_timespec_u($rqtp,1), $rmtp) + asmlinkage() + flags = int_arg(2) + if (flags == 1) flag_str = "TIMER_ABSTIME" else - flag_str = sprintf("0x%x", $flags) - argstr = sprintf("%s, %s, %s, %p", _get_wc_str($which_clock), flag_str, - _struct_timespec_u($rqtp,1), $rmtp) + flag_str = sprintf("0x%x", flags) + argstr = sprintf("%s, %s, %s, %p", _get_wc_str(int_arg(1)), flag_str, + _struct_timespec_u(pointer_arg(3),1), pointer_arg(4)) } probe nd_syscall.clock_nanosleep.return = kernel.function("sys_clock_nanosleep").return { name = "clock_nanosleep" @@ -389,12 +476,21 @@ probe nd_syscall.compat_clock_nanosleep = kernel.function("compat_sys_clock_nanosleep") ? { name = "compat_clock_nanosleep" - if ($flags == 1) + // if ($flags == 1) + // flag_str = "TIMER_ABSTIME" + // else + // flag_str = sprintf("0x%x", $flags) + // argstr = sprintf("%s, %s, %s, %p", _get_wc_str($which_clock), flag_str, + // _struct_compat_timespec_u($rqtp,1), $rmtp) + asmlinkage() + flags = int_arg(2) + if (flags == 1) flag_str = "TIMER_ABSTIME" else - flag_str = sprintf("0x%x", $flags) - argstr = sprintf("%s, %s, %s, %p", _get_wc_str($which_clock), flag_str, - _struct_compat_timespec_u($rqtp,1), $rmtp) + flag_str = sprintf("0x%x", flags) + argstr = sprintf("%s, %s, %s, %p", _get_wc_str(int_arg(1)), flag_str, + _struct_compat_timespec_u(pointer_arg(3),1), + pointer_arg(4)) } probe nd_syscall.compat_clock_nanosleep.return = kernel.function("compat_clock_nanosleep").return ?, @@ -410,10 +506,15 @@ probe nd_syscall.compat_clock_nanosleep.return = # probe nd_syscall.clock_settime = kernel.function("sys_clock_settime") { name = "clock_settime" - clk_id = $which_clock - clk_id_str = _get_wc_str($which_clock) - tp_uaddr = $tp - argstr = sprintf("%s, %s", clk_id_str, _struct_timespec_u($tp,1)) + // clk_id = $which_clock + // clk_id_str = _get_wc_str($which_clock) + // tp_uaddr = $tp + // argstr = sprintf("%s, %s", clk_id_str, _struct_timespec_u($tp,1)) + asmlinkage() + clk_id = int_arg(1) + clk_id_str = _get_wc_str(clk_id) + tp_uaddr = pointer_arg(2) + argstr = sprintf("%s, %s", clk_id_str, _struct_timespec_u(tp_uaddr,1)) } probe nd_syscall.clock_settime.return = kernel.function("sys_clock_settime").return { name = "clock_settime" @@ -437,10 +538,15 @@ probe nd_syscall.close.return = kernel.function("sys_close").return { # long sys_connect(int fd, struct sockaddr __user *uservaddr, int addrlen) probe nd_syscall.connect = kernel.function("sys_connect") ? { name = "connect" - sockfd = $fd - serv_addr_uaddr = $uservaddr - addrlen = $addrlen - argstr = sprintf("%d, %s, %d", $fd, _struct_sockaddr_u($uservaddr,$addrlen),$addrlen) + // sockfd = $fd + // serv_addr_uaddr = $uservaddr + // addrlen = $addrlen + // argstr = sprintf("%d, %s, %d", $fd, _struct_sockaddr_u($uservaddr,$addrlen),$addrlen) + asmlinkage() + sockfd = int_arg(1) + serv_addr_uaddr = pointer_arg(2) + addrlen = int_arg(3) + argstr = sprintf("%d, %s, %d", sockfd, _struct_sockaddr_u(serv_addr_uaddr,addrlen),addrlen) } probe nd_syscall.connect.return = kernel.function("sys_connect").return ? { name = "connect" @@ -452,9 +558,12 @@ probe nd_syscall.connect.return = kernel.function("sys_connect").return ? { probe nd_syscall.creat = kernel.function("sys_creat") ? { name = "creat" - mode = $mode - pathname = user_string($pathname) - argstr = sprintf("%s, %#o", user_string_quoted($pathname), $mode) + // mode = $mode + // pathname = user_string($pathname) + // argstr = sprintf("%s, %#o", user_string_quoted($pathname), $mode) + mode = int_arg(2) + pathname = user_string(pointer_arg(1)) + argstr = sprintf("%s, %#o", user_string_quoted(pointer_arg(1)), mode) } probe nd_syscall.creat.return = kernel.function("sys_creat").return ? { @@ -1128,18 +1237,32 @@ probe nd_syscall.ftruncate64.return = kernel.function("sys_ftruncate64").return # probe nd_syscall.futex = kernel.function("sys_futex") ? { name = "futex" - futex_uaddr = $uaddr - op = $op - val = $val - utime_uaddr = $utime - uaddr2_uaddr = $uaddr2 - val3 = $val3 + // futex_uaddr = $uaddr + // op = $op + // val = $val + // utime_uaddr = $utime + // uaddr2_uaddr = $uaddr2 + // val3 = $val3 + // if (op == 0) + // argstr = sprintf("%p, %s, %d, %s", $uaddr, _futex_op_str($op), + // $val, _struct_timespec_u($utime,1)) + // else + // argstr = sprintf("%p, %s, %d", $uaddr, _futex_op_str($op), + // $val) + asmlinkage() + futex_uaddr = pointer_arg(1) + op = int_arg(2) + val = u32_arg(3) + utime_uaddr = pointer_arg(4) + uaddr2_uaddr = pointer_arg(5) + val3 = u32_arg(6) if (op == 0) - argstr = sprintf("%p, %s, %d, %s", $uaddr, _futex_op_str($op), - $val, _struct_timespec_u($utime,1)) + argstr = sprintf("%p, %s, %d, %s", futex_uaddr, + _futex_op_str(op), val, + _struct_timespec_u(utime_uaddr,1)) else - argstr = sprintf("%p, %s, %d", $uaddr, _futex_op_str($op), - $val) + argstr = sprintf("%p, %s, %d", futex_uaddr, + _futex_op_str(op), val) } probe nd_syscall.futex.return = kernel.function("sys_futex").return ? { name = "futex" @@ -1147,18 +1270,32 @@ probe nd_syscall.futex.return = kernel.function("sys_futex").return ? { } probe nd_syscall.compat_futex = kernel.function("compat_sys_futex") ? { name = "futex" - futex_uaddr = $uaddr - op = $op - val = $val - utime_uaddr = $utime - uaddr2_uaddr = $uaddr2 - val3 = $val3 + // futex_uaddr = $uaddr + // op = $op + // val = $val + // utime_uaddr = $utime + // uaddr2_uaddr = $uaddr2 + // val3 = $val3 + // if (op == 0) + // argstr = sprintf("%p, %s, %d, %s", $uaddr, _futex_op_str($op), + // $val, _struct_compat_timespec_u($utime,1)) + // else + // argstr = sprintf("%p, %s, %d", $uaddr, _futex_op_str($op), + // $val) + asmlinkage() + futex_uaddr = pointer_arg(1) + op = int_arg(2) + val = u32_arg(3) + utime_uaddr = pointer_arg(4) + uaddr2_uaddr = pointer_arg(5) + val3 = u32_arg(6) if (op == 0) - argstr = sprintf("%p, %s, %d, %s", $uaddr, _futex_op_str($op), - $val, _struct_compat_timespec_u($utime,1)) + argstr = sprintf("%p, %s, %d, %s", futex_uaddr, + _futex_op_str(op), val, + _struct_compat_timespec_u(utime_uaddr,1)) else - argstr = sprintf("%p, %s, %d", $uaddr, _futex_op_str($op), - $val) + argstr = sprintf("%p, %s, %d", futex_uaddr, + _futex_op_str(op), val) } probe nd_syscall.compat_futex.return = kernel.function("compat_sys_futex").return ? { name = "futex" @@ -1542,17 +1679,29 @@ probe nd_syscall.getrlimit.return = kernel.function("sys_getrlimit").return, # long sys_getrusage(int who, struct rusage __user *ru) probe nd_syscall.getrusage = kernel.function("sys_getrusage") { name = "getrusage" - who = $who - if($who==-2) + // who = $who + // if($who==-2) + // { + // # RUSAGE_BOTH is not valid argument for sys_getrusage + // who_str = sprintf("UNKNOWN VALUE: %d", $who) + // } + // else + // { + // who_str = _rusage_who_str($who) + // } + // usage_uaddr = $ru + asmlinkage() + who = int_arg(1) + if(who==-2) { # RUSAGE_BOTH is not valid argument for sys_getrusage - who_str = sprintf("UNKNOWN VALUE: %d", $who) + who_str = sprintf("UNKNOWN VALUE: %d", who) } else { - who_str = _rusage_who_str($who) + who_str = _rusage_who_str(who) } - usage_uaddr = $ru + usage_uaddr = pointer_arg(2) argstr = sprintf("%s, %p", who_str, usage_uaddr) } probe nd_syscall.getrusage.return = kernel.function("sys_getrusage").return { @@ -2561,16 +2710,28 @@ probe nd_syscall.mq_open = kernel.function("compat_sys_mq_open") ? { name = "mq_open" - name_uaddr = $u_name - filename = user_string($u_name) - mode = $mode - u_attr_uaddr = $u_attr - oflag = $oflag + // name_uaddr = $u_name + // filename = user_string($u_name) + // mode = $mode + // u_attr_uaddr = $u_attr + // oflag = $oflag + // if (oflag & 64) + // argstr = sprintf("%s, %s, %#o, %p", user_string_quoted($u_name), + // _sys_open_flag_str($oflag), $mode, $u_attr) + // else + // argstr = sprintf("%s, %s", user_string_quoted($u_name), _sys_open_flag_str($oflag)) + asmlinkage() + name_uaddr = pointer_arg(1) + filename = user_string(name_uaddr) + mode = uint_arg(3) + u_attr_uaddr = pointer_arg(4) + oflag = int_arg(2) if (oflag & 64) - argstr = sprintf("%s, %s, %#o, %p", user_string_quoted($u_name), - _sys_open_flag_str($oflag), $mode, $u_attr) + argstr = sprintf("%s, %s, %#o, %p", + user_string_quoted(name_uaddr), + _sys_open_flag_str(oflag), mode, u_attr_uaddr) else - argstr = sprintf("%s, %s", user_string_quoted($u_name), _sys_open_flag_str($oflag)) + argstr = sprintf("%s, %s", user_string_quoted(name_uaddr), _sys_open_flag_str(oflag)) } probe nd_syscall.mq_open.return = kernel.function("sys_mq_open").return ?, -- cgit From 838cd09eb9134f49a4f290ae5f615edff781f153 Mon Sep 17 00:00:00 2001 From: Jim Keniston Date: Tue, 13 May 2008 16:33:26 -0700 Subject: Factored returnval() out of returnstr(), for use in dwarfless probing. --- tapset/errno.stp | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/tapset/errno.stp b/tapset/errno.stp index 550e5d4f..2523d846 100644 --- a/tapset/errno.stp +++ b/tapset/errno.stp @@ -351,33 +351,45 @@ function errno_str:string (err:long) %{ /* pure */ strlcpy (THIS->__retvalue, errlist[e], MAXSTRINGLEN); %} -/* for syscall tapset. set returnp = 1 for decimal, 2 for hex */ -function returnstr:string (returnp:long) %{ /* pure */ - long ret; - - /* XXX: unfortunate duplication with return.stp:retval() */ - - if (CONTEXT->regs) { +%{ +static long _stp_returnval(struct pt_regs *regs) { + if (regs) { #if defined (STAPCONF_X86_UNIREGS) && (defined (__x86_64__) || defined (__i386__)) - ret = CONTEXT->regs->ax; + return regs->ax; #elif defined (__i386__) - ret = CONTEXT->regs->eax; + return regs->eax; #elif defined (__x86_64__) - ret = CONTEXT->regs->rax; + // TODO: Handle -m32 apps. + return regs->rax; #elif defined (__powerpc64__) - ret = CONTEXT->regs->gpr[3]; + return regs->gpr[3]; #elif defined (__ia64__) - ret = CONTEXT->regs->r8; + return regs->r8; #elif defined (__sparc64__) - ret = CONTEXT->regs->u_regs[UREG_RETPC]; + return regs->u_regs[UREG_RETPC]; #elif defined (__s390x__) - ret = CONTEXT->regs->gprs[2]; + return regs->gprs[2]; #elif defined (__arm__) - ret = CONTEXT->regs->ARM_r0; + return regs->ARM_r0; #else - goto no_ret; + _stp_error("returnval() not defined for this architecture"); + return 0; #endif + } else { + _stp_error("returnval() not defined in this context"); + return 0; + } +} +%} + +function returnval:long () %{ /* pure */ + THIS->__retvalue = _stp_returnval(CONTEXT->regs); +%} +/* for syscall tapset. set returnp = 1 for decimal, 2 for hex */ +function returnstr:string (returnp:long) %{ /* pure */ + if (CONTEXT->regs) { + long ret = _stp_returnval(CONTEXT->regs); if (ret < 0 && ret > -Maxerrno && errlist[-ret]) snprintf (THIS->__retvalue, MAXSTRINGLEN, "%ld (%s)", ret, errlist[-ret]); else if (THIS->returnp == 2) -- cgit From c3799d720b60bd74a60de4addcd0d77a90f7842a Mon Sep 17 00:00:00 2001 From: Ananth N Mavinakayanahalli Date: Wed, 14 May 2008 10:56:37 +0530 Subject: PR 5955 - Accept ; terminated globals --- ChangeLog | 7 ++++ NEWS | 5 +++ parse.cxx | 3 ++ testsuite/parseko/twentyfive.stp | 3 ++ testsuite/parseko/twentyfour.stp | 3 ++ testsuite/systemtap.base/global_vars.exp | 5 +++ testsuite/systemtap.base/global_vars.stp | 57 ++++++++++++++++++++++++++++++++ 7 files changed, 83 insertions(+) create mode 100644 testsuite/parseko/twentyfive.stp create mode 100644 testsuite/parseko/twentyfour.stp create mode 100644 testsuite/systemtap.base/global_vars.exp create mode 100644 testsuite/systemtap.base/global_vars.stp diff --git a/ChangeLog b/ChangeLog index e913e76b..13f6254e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-05-13 Ananth N Mavinakayanahalli + PR 5955. + * parse.cxx (parser::parse_global): accept ";" terminated globals + * NEWS - update documentation + * testsuite/systemtap.base/global_vars.(stp/exp) - supporting tests + * testsuite/parseko/twenty(four/five).stp - supporting tests + 2008-05-12 Jim Keniston PR 4311 - Function boundary tracing without debuginfo: Phase II diff --git a/NEWS b/NEWS index 03fb7117..5d45b4a8 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,11 @@ probe process(PID).syscall.return { } probe process("PATH").syscall.return { } +- Globals now accept ; terminators + + global odds, evens; + global little[10], big[5]; + * What's new in version 0.6 - A copy of the systemtap tutorial and language reference guide diff --git a/parse.cxx b/parse.cxx index ea22f36d..82116009 100644 --- a/parse.cxx +++ b/parse.cxx @@ -1215,6 +1215,9 @@ parser::parse_global (vector & globals, vector&) t = peek (); } + if (t && t->type == tok_operator && t->content == ";") // termination + next(); + if (t && t->type == tok_operator && t->content == ",") // next global { next (); diff --git a/testsuite/parseko/twentyfive.stp b/testsuite/parseko/twentyfive.stp new file mode 100644 index 00000000..bebc72f8 --- /dev/null +++ b/testsuite/parseko/twentyfive.stp @@ -0,0 +1,3 @@ +#! stap -p1 + +global a,;b diff --git a/testsuite/parseko/twentyfour.stp b/testsuite/parseko/twentyfour.stp new file mode 100644 index 00000000..41ea076d --- /dev/null +++ b/testsuite/parseko/twentyfour.stp @@ -0,0 +1,3 @@ +#! stap -p1 + +global a;,b diff --git a/testsuite/systemtap.base/global_vars.exp b/testsuite/systemtap.base/global_vars.exp new file mode 100644 index 00000000..059ebf8d --- /dev/null +++ b/testsuite/systemtap.base/global_vars.exp @@ -0,0 +1,5 @@ +# Check that global variables terminated with a ; work fine + +set test "global_vars" + +stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string diff --git a/testsuite/systemtap.base/global_vars.stp b/testsuite/systemtap.base/global_vars.stp new file mode 100644 index 00000000..737e2556 --- /dev/null +++ b/testsuite/systemtap.base/global_vars.stp @@ -0,0 +1,57 @@ +/* + * global_vars.stp + * + * Check that global variables with a ; termination work fine + */ + +probe begin { println("systemtap starting probe") } +probe end { println("systemtap ending probe") } + +global a; +global c, d; +global g = 42; +global e[1], f; +global gstr = "foobar"; + +global gstr_saved; +probe begin(-9223372036854775808) { + c = g + d = c + g + a = d + f = c + e[0] = "a"; + gstr_saved = gstr +} + +probe end { + if (c == 42) + println("systemtap test success") + else + printf("systemtap test failure - c:%d != 42\n", c) + + if (d == (c + g)) + println("systemtap test success") + else + printf("systemtap test failure - d:%d != %d\n", d, (c+g)) + + if (a == d) + println("systemtap test success") + else + printf("systemtap test failure - a:%d != %d\n", a, d) + + if (f == c) + println("systemtap test success") + else + printf("systemtap test failure - f:%d != %d\n", f, c) + + if (e[0] == "a") + println("systemtap test success") + else + printf("systemtap test failure - e:%s != a\n", e[0]) + + if (gstr_saved == "foobar") + println("systemtap test success") + else + printf("systemtap test failure - gstr_saved:%s != foobar\n", gstr_saved) +} + -- cgit