diff options
author | ddomingo <ddomingo@redhat.com> | 2009-03-17 15:31:54 +1000 |
---|---|---|
committer | ddomingo <ddomingo@redhat.com> | 2009-03-17 15:31:54 +1000 |
commit | b9315d945fa0700f9a1d8cf9185c66388d29023c (patch) | |
tree | 8965c368ed7ef5ff8bc835a76fa61b241133f933 | |
parent | 4e7c048f5184ffcb06bc64d8be6e859156c8af97 (diff) | |
parent | bdca08879745471fdb86991a8e7276900aaaf066 (diff) | |
download | systemtap-steved-b9315d945fa0700f9a1d8cf9185c66388d29023c.tar.gz systemtap-steved-b9315d945fa0700f9a1d8cf9185c66388d29023c.tar.xz systemtap-steved-b9315d945fa0700f9a1d8cf9185c66388d29023c.zip |
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap
-rw-r--r-- | runtime/loc2c-runtime.h | 11 | ||||
-rw-r--r-- | tapset/task.stp | 24 | ||||
-rw-r--r-- | tapsets.cxx | 11 | ||||
-rwxr-xr-x | testsuite/buildok/task-embedded.stp | 4 | ||||
-rwxr-xr-x | testsuite/buildok/task_test.stp | 2 |
5 files changed, 42 insertions, 10 deletions
diff --git a/runtime/loc2c-runtime.h b/runtime/loc2c-runtime.h index 92c017d3..16ddb950 100644 --- a/runtime/loc2c-runtime.h +++ b/runtime/loc2c-runtime.h @@ -186,7 +186,7 @@ */ #define kread(ptr) ({ \ - typeof(*(ptr)) _v; \ + typeof(*(ptr)) _v = 0; \ if (lookup_bad_addr((unsigned long)(ptr)) || \ probe_kernel_read((void *)&_v, (void *)(ptr), sizeof(*(ptr)))) \ DEREF_FAULT(ptr); \ @@ -202,14 +202,13 @@ }) #define deref(size, addr) ({ \ - intptr_t _i; \ + intptr_t _i = 0; \ switch (size) { \ case 1: _i = kread((u8 *)(addr)); break; \ case 2: _i = kread((u16 *)(addr)); break; \ case 4: _i = kread((u32 *)(addr)); break; \ case 8: _i = kread((u64 *)(addr)); break; \ default: __deref_bad(); \ - /* uninitialized _i should also be caught by -Werror */ \ } \ _i; \ }) @@ -235,7 +234,7 @@ extern void __store_deref_bad(void); ({ \ int _bad = 0; \ u8 _b; u16 _w; u32 _l; \ - intptr_t _v; \ + intptr_t _v = 0; \ if (lookup_bad_addr((unsigned long)addr)) \ _bad = 1; \ else \ @@ -275,7 +274,7 @@ extern void __store_deref_bad(void); ({ \ int _bad = 0; \ u8 _b; u16 _w; u32 _l; u64 _q; \ - intptr_t _v; \ + intptr_t _v = 0; \ if (lookup_bad_addr((unsigned long)addr)) \ _bad = 1; \ else \ @@ -392,7 +391,7 @@ extern void __store_deref_bad(void); #define deref(size, addr) \ ({ \ int _bad = 0; \ - intptr_t _v; \ + intptr_t _v = 0; \ if (lookup_bad_addr((unsigned long)addr)) \ _bad = 1; \ else \ diff --git a/tapset/task.stp b/tapset/task.stp index 07337156..f1a10b0a 100644 --- a/tapset/task.stp +++ b/tapset/task.stp @@ -63,6 +63,30 @@ function task_pid:long (task:long) } +// Return the task of the given process id +function pid2task:long (pid:long) %{ /* pure */ + struct task_struct *t = NULL; + pid_t t_pid = (pid_t)(long)THIS->pid; + rcu_read_lock(); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) + t = find_task_by_vpid (t_pid); +#else + t = find_task_by_pid (t_pid); +#endif + rcu_read_unlock(); + THIS->__retvalue = (long)t; + CATCH_DEREF_FAULT(); +%} + +// Return the name of the given process id +function pid2execname:string (pid:long) { + tsk = pid2task(pid) + if (tsk) + return task_execname(tsk) + return "" +} + + // Return the thread id of the given task function task_tid:long (task:long) { diff --git a/tapsets.cxx b/tapsets.cxx index 6efcb3af..2f940b29 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -9770,8 +9770,13 @@ tracepoint_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline(1) << "return register_trace_" << p->tracepoint_name << "(enter_tracepoint_probe_" << i << ");"; s.op->newline(-1) << "}"; - s.op->newline() << "static int unregister_tracepoint_probe_" << i << "(void) {"; - s.op->newline(1) << "return unregister_trace_" << p->tracepoint_name + + // NB: we're not prepared to deal with unreg failures. However, failures + // can only occur if the tracepoint doesn't exist (yet?), or if we + // weren't even registered. The former should be OKed by the initial + // registration call, and the latter is safe to ignore. + s.op->newline() << "static void unregister_tracepoint_probe_" << i << "(void) {"; + s.op->newline(1) << "(void) unregister_trace_" << p->tracepoint_name << "(enter_tracepoint_probe_" << i << ");"; s.op->newline(-1) << "}"; s.op->newline(); @@ -9780,7 +9785,7 @@ tracepoint_derived_probe_group::emit_module_decls (systemtap_session& s) // emit an array of registration functions for easy init/shutdown s.op->newline() << "static struct stap_tracepoint_probe {"; s.op->newline(1) << "int (*reg)(void);"; - s.op->newline(0) << "int (*unreg)(void);"; + s.op->newline(0) << "void (*unreg)(void);"; s.op->newline(-1) << "} stap_tracepoint_probes[] = {"; s.op->indent(1); for (unsigned i = 0; i < probes.size(); ++i) diff --git a/testsuite/buildok/task-embedded.stp b/testsuite/buildok/task-embedded.stp index 4d1f5300..d35f3e0d 100755 --- a/testsuite/buildok/task-embedded.stp +++ b/testsuite/buildok/task-embedded.stp @@ -14,6 +14,8 @@ probe begin { task_nice (0) + task_cpu (0) + task_open_file_handles (0) + - task_max_file_handles (0)) + task_max_file_handles (0) + + pid2task(0)) print (task_execname (0)) + print (pid2execname (0)) } diff --git a/testsuite/buildok/task_test.stp b/testsuite/buildok/task_test.stp index c8da7da5..792f96ea 100755 --- a/testsuite/buildok/task_test.stp +++ b/testsuite/buildok/task_test.stp @@ -16,5 +16,7 @@ probe begin { log(sprint(task_cpu(c))) log(sprint(task_open_file_handles(c))) log(sprint(task_max_file_handles(c))) + log(sprint(pid2task(pid()))) + log(sprint(pid2execname(pid()))) exit() } |