]> sourceware.org Git - systemtap.git/commitdiff
PR10977: new address size tapset functions
authorFelix Lu <flu@redhat.com>
Wed, 26 Aug 2015 16:45:18 +0000 (12:45 -0400)
committerFelix Lu <flu@redhat.com>
Wed, 26 Aug 2015 16:45:18 +0000 (12:45 -0400)
- new tapset functions get arch_bytes() and uarch_bytes() to obtain
  address size for kernel and user space.

NEWS
tapset/arm/registers.stp
tapset/arm64/registers.stp
tapset/i386/registers.stp
tapset/ia64/registers.stp
tapset/powerpc/registers.stp
tapset/s390/registers.stp
tapset/x86_64/registers.stp
testsuite/buildok/arch_bytes.stp [new file with mode: 0755]
testsuite/systemtap.examples/general/tapset/python2.stp
testsuite/systemtap.examples/general/tapset/python3.stp

diff --git a/NEWS b/NEWS
index f97fa7a48d2cf1fc3a2bfb99ee5c2c58b04d9c26..0f79f471723d43cb5bf2e9d3d0b291a1a6daa61c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 * What's new in version 2.9
 
+- New tapset functions arch_bytes() and uarch_bytes() to obtain address size
+  for kernel and user space respectively.
+
 - New tapset function switch_file() allows control over rotation
   of output files.
 
index 208fa36eae5e9348b8945790a2961f2a7e13e818..9f9ec88332d77ebe155aa8f8239bdcff90d75888 100644 (file)
@@ -95,6 +95,18 @@ function _stp_probing_kernel:long () {
        return !user_mode();
 }
 
+function arch_bytes:long() %{ /* pure */
+  STAP_RETVALUE = sizeof(long);
+%}
+
+function uarch_bytes:long() {
+  if (!user_mode()) {
+    error("requires user mode")
+    return 0
+  } else
+    return 4
+}
+
 /* Return the named register value as a signed value. */
 function register:long (name:string) {
        if (!registers_valid()) {
index 8d90208fb6d8dcf30450f7120a3674c2d263a468..999b88543f5df623aeca04d067decf66eb68e850 100644 (file)
@@ -46,6 +46,18 @@ function probing_32bit_app:long() %{ /* pure */
         STAP_RETVALUE = (CONTEXT->user_mode_p && _stp_is_compat_task());
 %}
 
+function arch_bytes:long() %{ /* pure */
+  STAP_RETVALUE = sizeof(long);
+%}
+
+function uarch_bytes:long() {
+  if (!user_mode()) {
+    error("requires user mode")
+    return 0
+  } else
+    return probing_32bit_app() ? 4 : 8
+}
+
 function _stp_get_register_by_offset:long (offset:long) %{ /* pure */
        long value;
        struct pt_regs *regs;
index 8149b485a8a7f84444c47e09073e5eb1c922c6b1..d10c1b65c65a24861a609a77df561e753f898f33 100644 (file)
@@ -73,6 +73,18 @@ function _stp_probing_kernel:long () {
        return !user_mode();
 }
 
+function arch_bytes:long() %{ /* pure */
+  STAP_RETVALUE = sizeof(long);
+%}
+
+function uarch_bytes:long() {
+  if (!user_mode()) {
+    error("requires user mode")
+    return 0
+  } else
+    return 4
+}
+
 /*
  * esp and ss aren't saved on a breakpoint in kernel mode, so
  * the pre-trap stack pointer is &regs->sp.
index 40a2b32e9022673795070483b607f42763f38f45..16fd009ded272d6811ea70bbac2f9390f6866984 100644 (file)
@@ -8,6 +8,22 @@ function _stp_sign_extend32:long (value:long) {
        return value
 }
 
+function probing_32bit_app:long() %{ /* pure */
+       STAP_RETVALUE = (CONTEXT->user_mode_p && _stp_is_compat_task());
+%}
+
+function arch_bytes:long() %{ /* pure */
+  STAP_RETVALUE = sizeof(long);
+%}
+
+function uarch_bytes:long() {
+  if (!user_mode()) {
+    error("requires user mode")
+    return 0
+  } else
+    return probing_32bit_app() ? 4 : 8
+}
+
 /*
  * Return the value of function arg #argnum (1=first arg). If
  * truncate=1, mask off the top 32 bits. If sign_extend=1 and
index 3adcc736685fbbc912343d84be104b4fd1219ab8..86035afbbb88ca5880569aac57a175522e373944 100644 (file)
@@ -61,6 +61,18 @@ function probing_32bit_app:long() %{ /* pure */
         STAP_RETVALUE = (CONTEXT->user_mode_p && _stp_is_compat_task());
 %}
 
+function arch_bytes:long() %{ /* pure */
+  STAP_RETVALUE = sizeof(long);
+%}
+
+function uarch_bytes:long() {
+  if (!user_mode()) {
+    error("requires user mode")
+    return 0
+  } else
+    return probing_32bit_app() ? 4 : 8
+}
+
 function _stp_get_register_by_offset:long (offset:long) %{ /* pure */
        long value;
        struct pt_regs *regs;
index 12b21e589697bd14eb91f66631ac2067ba6e1a39..03b515cb332b49ab4f1417aed446aad952893fc6 100644 (file)
@@ -125,6 +125,18 @@ function _stp_probing_kernel: long () {
        return !user_mode();
 }
 
+function arch_bytes:long() %{ /* pure */
+  STAP_RETVALUE = sizeof(long);
+%}
+
+function uarch_bytes:long() {
+  if (!user_mode()) {
+    error("requires user mode")
+    return 0
+  } else
+    return probing_32bit_app() ? 4 : 8
+}
+
 function _stp_get_register_by_offset:long (offset:long) %{ /* pure */
        long value;
        struct pt_regs *regs;
index 0620b9b71de2e8e8d60d6752f82c491541bf6a3f..fec276b2cd283a4543ff082cf235a58001497c41 100644 (file)
@@ -205,6 +205,18 @@ function probing_32bit_app:long() %{ /* pure */
        STAP_RETVALUE = (CONTEXT->user_mode_p && _stp_is_compat_task());
 %}
 
+function arch_bytes:long() %{ /* pure */
+  STAP_RETVALUE = sizeof(long);
+%}
+
+function uarch_bytes:long() {
+  if (!user_mode()) {
+    error("requires user mode")
+    return 0
+  } else
+    return probing_32bit_app() ? 4 : 8
+}
+
 /* Return the value of function arg #argnum (1=first arg) as a signed int. */
 function int_arg:long (argnum:long) {
        return _stp_arg2(argnum, 1, 1, 0)
diff --git a/testsuite/buildok/arch_bytes.stp b/testsuite/buildok/arch_bytes.stp
new file mode 100755 (executable)
index 0000000..e61f669
--- /dev/null
@@ -0,0 +1,6 @@
+#! stap -p4
+
+probe begin {
+  println(arch_bytes())
+  println(uarch_bytes())
+}
index 90eef1c314efc52c52721a5e1bd86d2c7ef97d2d..32d036a3b4bd803e319e96541c749bf6548c5378 100644 (file)
@@ -69,7 +69,7 @@ function get_sequence_item (tuple, i, seq_type) {
     else if (seq_type == "list")
        ob_items = @cast (tuple, "PyListObject", @PYTHON2_LIBRARY)->ob_item;
 
-    ob_item = user_long (ob_items + (i * %{ sizeof (intptr_t) %}))
+    ob_item = user_long (ob_items + (i * uarch_bytes()))
     return ob_item
 }
 
@@ -292,7 +292,7 @@ function python2_backtrace_one_frame (frame, skip_name)
     for (i = 0; i < co_argcount; i++) {
        if (i == 0) print ("(");
        arg_name_str = user_string (@cast (get_sequence_item (co_varnames, i, "tuple"), "PyStringObject", @PYTHON2_LIBRARY)->ob_sval)
-       arg_value = user_long (f_localsplus + (i * %{ sizeof (intptr_t) %}))
+       arg_value = user_long (f_localsplus + (i * uarch_bytes()))
        arg_type_name_str = get_type (arg_value)
        printf ("%s:%s ", arg_name_str, arg_type_name_str)
     }
@@ -337,7 +337,7 @@ function python2_getvar_one_frame (frame, match_args, variable, skip_name)
        arg_name_str = user_string (@cast (get_sequence_item (co_varnames, i, "tuple"), "PyStringObject", @PYTHON2_LIBRARY)->ob_sval)
        if (! wildcard_match (arg_name_str, variable))
            continue
-       arg_value = user_long (f_localsplus + (i * %{ sizeof (intptr_t) %}))
+       arg_value = user_long (f_localsplus + (i * uarch_bytes()))
        arg_type_name_str = get_type (arg_value)
        next_var = 0
        foreach ([var, file] in python2_vars_seen)
index fcb6cb222a4e6d604e7ca111f518e75589462e3a..1198f030346ba122640198afcc7683e0dc760d49 100644 (file)
@@ -101,7 +101,7 @@ function p3_get_sequence_item (tuple, i, seq_type) {
     else if (seq_type == "list")
        ob_items = @cast (tuple, "PyListObject", @PYTHON3_LIBRARY)->ob_item;
 
-    ob_item = user_long (ob_items + (i * %{ sizeof (intptr_t) %}))
+    ob_item = user_long (ob_items + (i * uarch_bytes()))
     return ob_item
 }
 
@@ -291,7 +291,7 @@ function python3_backtrace_one_frame (frame, match_filename)
     for (i = 0; i < co_argcount; i++) {
        if (i == 0) print ("(");
        arg_name_str = get_unicode (p3_get_sequence_item (co_varnames, i, "tuple"))
-       arg_value = user_long (f_localsplus + (i * %{ sizeof (intptr_t) %}))
+       arg_value = user_long (f_localsplus + (i * uarch_bytes()))
        arg_type_name_str = p3_get_type (arg_value)
        printf ("%s:%s ", arg_name_str, arg_type_name_str)
     }
@@ -336,7 +336,7 @@ function python3_getvar_one_frame (frame, match_args, variable, match_filename)
        arg_name_str = get_unicode (p3_get_sequence_item (co_varnames, i, "tuple"))
        if (! wildcard_match (arg_name_str, variable))
            continue
-       arg_value = user_long (f_localsplus + (i * %{ sizeof (intptr_t) %}))
+       arg_value = user_long (f_localsplus + (i * uarch_bytes()))
        arg_type_name_str = p3_get_type (arg_value)
        next_var = 0
        foreach ([var, file] in python3_vars_seen)
This page took 0.050259 seconds and 5 git commands to generate.