]> sourceware.org Git - systemtap.git/commitdiff
PR18630: New testcase for dwarfless parameters from a uprobe.
authorMartin Cermak <mcermak@redhat.com>
Tue, 14 Jul 2015 06:05:50 +0000 (08:05 +0200)
committerMartin Cermak <mcermak@redhat.com>
Tue, 14 Jul 2015 06:05:50 +0000 (08:05 +0200)
* tapset/s390/registers.stp: Remove constraint added by commit
  eefd579b blocking data acquistion from a uprobe. This is per
  PR18649#c1 and subsequent IRC chat with dsmith, the author
  of the constraint.
* testsuite/systemtap.base/uprobe_nd_params.exp: New testcase.

tapset/s390/registers.stp
testsuite/systemtap.base/uprobe_nd_params.exp [new file with mode: 0644]

index 3fd2560d9d86764f8a5d78a7c6291aa47892e6db..12b21e589697bd14eb91f66631ac2067ba6e1a39 100644 (file)
@@ -212,10 +212,6 @@ function _stp_arg2:long (argnum:long, sign_extend:long, truncate:long,
                error(sprintf("Cannot acces arg(%d)", argnum))
                return 0
        }
-       if (%{ CONTEXT->user_mode_p %}) {
-               error("Cannot access function args in user context");
-               return 0;
-       }
 
        /*
         * Why not use syscall_get_arguments() here? On the s390x,
@@ -272,7 +268,6 @@ function ulong_arg:long (argnum:long) {
 
 function longlong_arg:long (argnum:long) {
        if (probing_32bit_app()) {
-               /* TODO verify if this is correct for 31bit apps */
                highbits = _stp_arg2(argnum, 0, 1, 0)
                lowbits = _stp_arg2(argnum+1, 0, 1, 0)
                return ((highbits << 32) | lowbits)
diff --git a/testsuite/systemtap.base/uprobe_nd_params.exp b/testsuite/systemtap.base/uprobe_nd_params.exp
new file mode 100644 (file)
index 0000000..bc90af3
--- /dev/null
@@ -0,0 +1,100 @@
+set test "uprobe_nd_params"
+
+if {! [uprobes_p]} {
+    untested "$test (no uprobes support)"
+    return
+}
+
+set test_srcpath "[pwd]/test.c"
+set test_exepath "[pwd]/test"
+set test_stppath "[pwd]/test.stp"
+
+set test_fp [open $test_srcpath "w"]
+puts $test_fp "
+#include <limits.h>
+
+int fc1(int arg1, int arg2) { return 0; }
+int fc2(unsigned int arg1, unsigned int arg2) { return 0; }
+int fc3(long arg1, long arg2) { return 0; }
+int fc4(unsigned long arg1, unsigned long arg2) { return 0; }
+int fc5(long long arg1, long long arg2) { return 0; }
+int fc6(int *arg1, int *arg2) { return 0; }
+
+int main()
+{
+    int i = 7;
+    fc1(INT_MAX, -1);
+    fc2(UINT_MAX, -1);
+    fc3(LONG_MAX, -1);
+    fc4(ULONG_MAX, -1);
+    fc5(0x12345678deadbeefLL, (long long)-1);
+    fc6(&i, (int *)-1);
+    return 0;
+}
+"
+close $test_fp
+
+set script_fp [open $test_stppath "w"]
+puts $script_fp "
+probe process(\"$test_exepath\").function(\"fc1\") {
+    printf(\"%s;%d;%d;\\n\", ppfunc(), int_arg(1), s32_arg(1))
+}
+probe process(\"$test_exepath\").function(\"fc2\") {
+    printf(\"%s;%u;%u;\\n\", ppfunc(), uint_arg(1), u32_arg(1))
+}
+probe process(\"$test_exepath\").function(\"fc3\") {
+    printf(\"%s;%d;%d\\n\", ppfunc(), long_arg(1), long_arg(2))
+}
+probe process(\"$test_exepath\").function(\"fc4\") {
+    printf(\"%s;%u;%u;\\n\", ppfunc(), ulong_arg(1), ulong_arg(2))
+}
+probe process(\"$test_exepath\").function(\"fc5\") {
+%( CONFIG_64BIT == \"y\" %?
+    if(probing_32bit_app()) {
+        printf(\"%s;%x;%x;%x;%x;\\n\", ppfunc(), longlong_arg(1), ulonglong_arg(1),
+               s64_arg(1), u64_arg(1))
+    } else {
+        printf(\"%s;%x;%x;%x;%x;\\n\", ppfunc(), longlong_arg(1), ulonglong_arg(1),
+               s64_arg(1), u64_arg(1))
+    }
+%:
+    printf(\"%s;%x;%x;%x;%x;\\n\", ppfunc(), longlong_arg(1), ulonglong_arg(1),
+           s64_arg(1), u64_arg(1))
+%)
+}
+probe process(\"$test_exepath\").function(\"fc6\") {
+    printf(\"%s;%p;%p\\n\", ppfunc(), pointer_arg(1), pointer_arg(2))
+}
+"
+close $script_fp
+
+for {set i 0} {$i < [arch_compile_flags]} {incr i} {
+    set test_flags "compiler=gcc [arch_compile_flag $i]"
+    set res [target_compile $test_srcpath $test_exepath executable $test_flags]
+    if { $res != "" } {
+        fail "compiling test.c $test_flags"
+        catch {exec rm -f $test_srcpath}
+       return
+    } else {
+        pass "compiling test.c $test_flags"
+    }
+
+    set ok 0
+    spawn stap $test_stppath -c $test_exepath
+    expect {
+        -timeout 120
+        -re {fc1;(2147483647;){2}} { incr ok; exp_continue }
+        -re {fc2;(4294967295;){2}} { incr ok; exp_continue }
+        -re {fc3;(2147483647|9223372036854775807);-1} { incr ok; exp_continue }
+        -re {fc4;(4294967295;|18446744073709551615;){2}} { incr ok; exp_continue }
+        -re {fc5;(12345678deadbeef;){4}} { incr ok; exp_continue }
+        -re {fc6;0x[a-f0-9]+;0x[7]?[f]+} { incr ok; exp_continue }
+        timeout { fail "$test (timeout)" }
+        eof { }
+    }
+    catch { close }; catch { wait }
+    if {$ok == 6} { pass "$test" } { fail "$test" }
+}
+
+catch {exec rm -f $test_srcpath $test_exepath $test_stppath}
+
This page took 0.034886 seconds and 5 git commands to generate.