diff options
author | Stan Cox <scox@redhat.com> | 2009-07-20 10:20:23 -0400 |
---|---|---|
committer | Stan Cox <scox@redhat.com> | 2009-07-20 10:20:23 -0400 |
commit | c3d506aed4f651a98d1afde2fe700822edf9e78e (patch) | |
tree | b37db67eb616fa62f0151f858210a37dd357c276 | |
parent | 3fba3a19ef634dcabd920656675be43aa81862af (diff) | |
download | systemtap-steved-c3d506aed4f651a98d1afde2fe700822edf9e78e.tar.gz systemtap-steved-c3d506aed4f651a98d1afde2fe700822edf9e78e.tar.xz systemtap-steved-c3d506aed4f651a98d1afde2fe700822edf9e78e.zip |
* tapsets.cxx (dwarf_builder::probe_table::convert_probe):
First check kprobe and utrace (did we arrive via stap?) then check
if probe arg matches mark("NAME")
* sdt.h (STAP_PROBE?_): Use STAP_GUARD for stap check, not gettid.
-rw-r--r-- | includes/sys/sdt.h | 24 | ||||
-rw-r--r-- | tapsets.cxx | 89 |
2 files changed, 54 insertions, 59 deletions
diff --git a/includes/sys/sdt.h b/includes/sys/sdt.h index 3b788b88..f179c2a7 100644 --- a/includes/sys/sdt.h +++ b/includes/sys/sdt.h @@ -247,11 +247,9 @@ extern long int syscall (long int __sysno, ...) __THROW; # if defined EXPERIMENTAL_KPROBE_SDT # define STAP_SYSCALL __NR_getegid # define STAP_GUARD 0x32425250 -# define GETTID 0 # elif defined EXPERIMENTAL_UTRACE_SDT # define STAP_SYSCALL 0xbead # define STAP_GUARD 0x33425250 -# define GETTID syscall(SYS_gettid) # endif #include <sys/syscall.h> @@ -259,13 +257,13 @@ extern long int syscall (long int __sysno, ...) __THROW; #define STAP_PROBE_(probe) \ do { \ STAP_PROBE_DATA(probe,STAP_SYSCALL,0); \ - syscall (STAP_SYSCALL, #probe, GETTID); \ + syscall (STAP_SYSCALL, #probe, STAP_GUARD); \ } while (0) #define STAP_PROBE1_(probe,label,parm1) \ do { \ STAP_PROBE_DATA(probe,STAP_GUARD,1); \ - syscall (STAP_SYSCALL, #probe, GETTID, (size_t)parm1); \ + syscall (STAP_SYSCALL, #probe, STAP_GUARD, (size_t)parm1); \ } while (0) #define STAP_PROBE2_(probe,label,parm1,parm2) \ @@ -274,7 +272,7 @@ do { \ size_t arg2 __attribute__((aligned(8)));} \ stap_probe2_args = {(size_t)parm1, (size_t)parm2}; \ STAP_PROBE_DATA(probe,STAP_GUARD,2); \ - syscall (STAP_SYSCALL, #probe, GETTID, &stap_probe2_args); \ + syscall (STAP_SYSCALL, #probe, STAP_GUARD, &stap_probe2_args); \ } while (0) #define STAP_PROBE3_(probe,label,parm1,parm2,parm3) \ @@ -284,7 +282,7 @@ do { \ size_t arg3 __attribute__((aligned(8)));} \ stap_probe3_args = {(size_t)parm1, (size_t)parm2, (size_t)parm3}; \ STAP_PROBE_DATA(probe,STAP_GUARD,3); \ - syscall (STAP_SYSCALL, #probe, GETTID, &stap_probe3_args); \ + syscall (STAP_SYSCALL, #probe, STAP_GUARD, &stap_probe3_args); \ } while (0) #define STAP_PROBE4_(probe,label,parm1,parm2,parm3,parm4) \ @@ -295,7 +293,7 @@ do { \ size_t arg4 __attribute__((aligned(8)));} \ stap_probe4_args = {(size_t)parm1, (size_t)parm2, (size_t)parm3, (size_t)parm4}; \ STAP_PROBE_DATA(probe,STAP_GUARD,4); \ - syscall (STAP_SYSCALL, #probe, GETTID,&stap_probe4_args); \ + syscall (STAP_SYSCALL, #probe, STAP_GUARD,&stap_probe4_args); \ } while (0) #define STAP_PROBE5_(probe,label,parm1,parm2,parm3,parm4,parm5) \ @@ -308,7 +306,7 @@ do { \ stap_probe5_args = {(size_t)parm1, (size_t)parm2, (size_t)parm3, (size_t)parm4, \ (size_t)parm5}; \ STAP_PROBE_DATA(probe,STAP_GUARD,5); \ - syscall (STAP_SYSCALL, #probe, GETTID, &stap_probe5_args); \ + syscall (STAP_SYSCALL, #probe, STAP_GUARD, &stap_probe5_args); \ } while (0) #define STAP_PROBE6_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6) \ @@ -322,7 +320,7 @@ do { \ stap_probe6_args = {(size_t)parm1, (size_t)parm2, (size_t)parm3, (size_t)parm4, \ (size_t)parm5, (size_t)parm6}; \ STAP_PROBE_DATA(probe,STAP_GUARD,6); \ - syscall (STAP_SYSCALL, #probe, GETTID, &stap_probe6_args); \ + syscall (STAP_SYSCALL, #probe, STAP_GUARD, &stap_probe6_args); \ } while (0) #define STAP_PROBE7_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7) \ @@ -337,7 +335,7 @@ do { \ stap_probe7_args = {(size_t)parm1, (size_t)parm2, (size_t)parm3, (size_t)parm4, \ (size_t)parm5, (size_t)parm6, (size_t)parm7}; \ STAP_PROBE_DATA(probe,STAP_GUARD,7); \ - syscall (STAP_SYSCALL, #probe, GETTID, &stap_probe7_args); \ + syscall (STAP_SYSCALL, #probe, STAP_GUARD, &stap_probe7_args); \ } while (0) #define STAP_PROBE8_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) \ @@ -353,7 +351,7 @@ do { \ stap_probe8_args = {(size_t)parm1, (size_t)parm2, (size_t)parm3, (size_t)parm4, \ (size_t)parm5, (size_t)parm6, (size_t)parm7, (size_t)parm8}; \ STAP_PROBE_DATA(probe,STAP_GUARD,8); \ - syscall (STAP_SYSCALL, #probe, GETTID, &stap_probe8_args); \ + syscall (STAP_SYSCALL, #probe, STAP_GUARD, &stap_probe8_args); \ } while (0) #define STAP_PROBE9_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) \ @@ -370,7 +368,7 @@ do { \ stap_probe9_args = {(size_t)parm1, (size_t)parm2, (size_t)parm3, (size_t)parm4, \ (size_t)parm5, (size_t)parm6, (size_t)parm7, (size_t)parm8, (size_t)parm9}; \ STAP_PROBE_DATA(probe,STAP_GUARD,9); \ - syscall (STAP_SYSCALL, #probe, GETTID, &stap_probe9_args); \ + syscall (STAP_SYSCALL, #probe, STAP_GUARD, &stap_probe9_args); \ } while (0) #define STAP_PROBE10_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10) \ @@ -388,7 +386,7 @@ do { \ stap_probe10_args = {(size_t)parm1, (size_t)parm2, (size_t)parm3, (size_t)parm4, \ (size_t)parm5, (size_t)parm6, (size_t)parm7, (size_t)parm8, (size_t)parm9, (size_t)parm10}; \ STAP_PROBE_DATA(probe,STAP_GUARD,10); \ - syscall (STAP_SYSCALL, #probe, GETTID, &stap_probe10_args); \ + syscall (STAP_SYSCALL, #probe, STAP_GUARD, &stap_probe10_args); \ } while (0) #endif diff --git a/tapsets.cxx b/tapsets.cxx index 4ef5ade6..83f35e17 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -798,6 +798,33 @@ void dwarf_builder::probe_table::convert_probe (probe *new_base) { block *b = ((block*)(new_base->body)); + + functioncall *fc = new functioncall; + fc->function = (probe_type == utrace_type) ? "_utrace_syscall_arg" : "ulong_arg"; + fc->tok = new_base->body->tok; + literal_number* num = new literal_number((probe_type == utrace_type) ? 0 : 1); + num->tok = new_base->body->tok; + fc->args.push_back(num); + + // Generate: if (arg1 != mark("label")) next; + functioncall *fcus = new functioncall; + fcus->function = "user_string"; + fcus->type = pe_string; + fcus->tok = new_base->body->tok; + fcus->args.push_back(fc); + + if_statement *is = new if_statement; + is->thenblock = new next_statement; + is->elseblock = NULL; + is->tok = new_base->body->tok; + comparison *be = new comparison; + be->op = "!="; + be->tok = new_base->body->tok; + be->left = fcus; + be->right = new literal_string(mark_name); + is->condition = be; + b->statements.insert(b->statements.begin(),(statement*) is); + if (probe_type == utrace_type) { // Generate: if ($syscall != 0xbead) next; @@ -818,8 +845,11 @@ dwarf_builder::probe_table::convert_probe (probe *new_base) besc->right = fake_syscall; issc->condition = besc; b->statements.insert(b->statements.begin(),(statement*) issc); - - // Generate: if (ulong_arg(2) != task_tid(task_current())) next; + } + + if (probe_type == kprobe_type) + { + // Generate: if (arg2 != kprobe_type) next; if_statement *istid = new if_statement; istid->thenblock = new next_statement; istid->elseblock = NULL; @@ -827,55 +857,22 @@ dwarf_builder::probe_table::convert_probe (probe *new_base) comparison *betid = new comparison; betid->op = "!="; betid->tok = new_base->body->tok; - functioncall* task_tid = new functioncall; - task_tid->tok = new_base->body->tok; - task_tid->function = "task_tid"; - task_tid->referent = 0; - functioncall* task_current = new functioncall; - task_current->tok = new_base->body->tok; - task_current->function = "task_current"; - task_current->referent = 0; - task_tid->args.push_back(task_current); - betid->left = task_tid; - functioncall *arg2tid = new functioncall; - arg2tid->tok = new_base->body->tok; - arg2tid->function = "_utrace_syscall_arg"; - arg2tid->tok = new_base->body->tok; - literal_number* littid = new literal_number(1); - littid->tok = new_base->body->tok; - arg2tid->args.push_back(littid); - betid->right = arg2tid; + functioncall *arg2 = new functioncall; + arg2->function = "ulong_arg"; + arg2->tok = new_base->body->tok; + literal_number* num = new literal_number(2); + num->tok = new_base->body->tok; + arg2->args.push_back(num); + + betid->left = arg2; + literal_number* littid = new literal_number(kprobe_type); + littid->tok = new_base->body->tok; + betid->right = littid; istid->condition = betid; b->statements.insert(b->statements.begin(),(statement*) istid); } - // Generate: if (arg1 != mark("label")) next; - functioncall *fc = new functioncall; - fc->function = (probe_type == utrace_type) ? "_utrace_syscall_arg" : "ulong_arg"; - fc->tok = new_base->body->tok; - literal_number* num = new literal_number((probe_type == utrace_type) ? 0 : 1); - num->tok = new_base->body->tok; - fc->args.push_back(num); - - functioncall *fcus = new functioncall; - fcus->function = "user_string"; - fcus->type = pe_string; - fcus->tok = new_base->body->tok; - fcus->args.push_back(fc); - - if_statement *is = new if_statement; - is->thenblock = new next_statement; - is->elseblock = NULL; - is->tok = new_base->body->tok; - comparison *be = new comparison; - be->op = "!="; - be->tok = new_base->body->tok; - be->left = fcus; - be->right = new literal_string(mark_name); - is->condition = be; - b->statements.insert(b->statements.begin(),(statement*) is); - #ifdef __i386__ if (probe_type == kprobe_type) { |