]> sourceware.org Git - systemtap.git/commitdiff
Remove arch specific _stp_probing_32bit_app() and _stp_get_regparm().
authorMark Wielaard <mjw@redhat.com>
Mon, 19 Sep 2011 13:42:19 +0000 (15:42 +0200)
committerMark Wielaard <mjw@redhat.com>
Mon, 19 Sep 2011 13:52:40 +0000 (15:52 +0200)
Both functions were doing more than necessary and didn't actually need
access to the current regs. _STP_PROBE_STATE_USER_MODE tells us whether
the current probe triggered in user mode. _stp_is_compat_task() tells
us whether the current task is a 32-on-64 process.

* runtime/compatdefs.h (_stp_is_compat_task): Defined also when CONFIG_COMPAT
  is undefined (to always return false).
* runtime/loc2c-runtime.h: u_fetch_register() and u_store_register() are
  only called from user space dwarf context. Only needs _stp_is_compat_task()
  test.
* runtime/regs.c: Remove arch specific _stp_probing_32bit_app() and
  _stp_get_regparm() functions.
* tapset/i386/registers.stp (_stp_arg): Check regparm directly.
* tapset/powerpc/registers.stp (probing_32bit_app): Use _stp_is_compat_task()
  test.
* tapset/s390/registers.stp (probing_32bit_app): Likewise.
* tapset/x86_64/registers.stp (_stp_arg): Check regparm directly.
  (probing_32bit_app): Use _stp_is_compat_task() test.
  (regparm): Likewise.

runtime/compatdefs.h
runtime/loc2c-runtime.h
runtime/regs.c
tapset/i386/registers.stp
tapset/powerpc/registers.stp
tapset/s390/registers.stp
tapset/x86_64/registers.stp

index 4d5de3236a9cd84d370fff2e53edc832d9152570..23850be3eac82810f2c556596aef8021038789aa 100644 (file)
@@ -34,6 +34,13 @@ static inline int _stp_is_compat_task(void)
   return test_thread_flag(TIF_32BIT);
 }
 
+#else
+
+static inline int _stp_is_compat_task(void)
+{
+  return 0;
+}
+
 #endif /* CONFIG_COMPAT */
 
 /* task_pt_regs is used in some core tapset functions, so try to make
index ef7d279e8a06c26ef74066884d04daece2d1549b..d11f28f4734ba6e338c0b5de363f108c35273a89 100644 (file)
@@ -327,8 +327,8 @@ static void ursl_store64 (const struct usr_regset_lut* lut,unsigned lutsize,  in
 
 #elif defined (__x86_64__)
 
-#define u_fetch_register(regno) (_stp_probing_32bit_app(c->uregs) ? ursl_fetch32(url_i386, ARRAY_SIZE(url_i386), EM_386, regno) : ursl_fetch64(url_x86_64, ARRAY_SIZE(url_x86_64), EM_X86_64, regno))
-#define u_store_register(regno,value)  (_stp_probing_32bit_app(c->uregs) ? ursl_store32(url_i386, ARRAY_SIZE(url_i386), EM_386, regno, value) : ursl_store64(url_x86_64, ARRAY_SIZE(url_x86_64), EM_X86_64, regno, value))
+#define u_fetch_register(regno) (_stp_is_compat_task() ? ursl_fetch32(url_i386, ARRAY_SIZE(url_i386), EM_386, regno) : ursl_fetch64(url_x86_64, ARRAY_SIZE(url_x86_64), EM_X86_64, regno))
+#define u_store_register(regno,value)  (_stp_is_compat_task() ? ursl_store32(url_i386, ARRAY_SIZE(url_i386), EM_386, regno, value) : ursl_store64(url_x86_64, ARRAY_SIZE(url_x86_64), EM_X86_64, regno, value))
 
 #endif
 
index fe2184a6b0dbb2175888efe6beca23c311aa89cb..5cf39fa33f8e716f7bcaace9d4eb91d611a7ca00 100644 (file)
@@ -220,13 +220,6 @@ static void _stp_print_regs(struct pt_regs * regs)
 
 #elif defined (__powerpc64__)
 
-static int _stp_probing_32bit_app(struct pt_regs *regs)
-{
-       if (!regs)
-               return 0;
-       return (user_mode(regs) && test_tsk_thread_flag(current, TIF_32BIT));
-}
-
 static void _stp_print_regs(struct pt_regs * regs)
 {
        int i;
@@ -382,18 +375,6 @@ static long _stp_get_sp(struct pt_regs *regs)
        return EREG(sp, regs);
 }
 
-static int _stp_get_regparm(int regparm, struct pt_regs *regs)
-{
-       if (regparm == 0) {
-               /* Default */
-               if (user_mode(regs))
-                       return 0;
-               else
-                       // Kernel is built with -mregparm=3.
-                       return 3;
-       } else
-               return (regparm & _STP_REGPARM_MASK);
-}
 #endif /* __i386__ */
 
 #ifdef __x86_64__
@@ -410,13 +391,6 @@ static long _stp_get_sp(struct pt_regs *regs)
        return RREG(sp, regs);
 }
 
-static int _stp_probing_32bit_app(struct pt_regs *regs)
-{
-       if (!regs)
-               return 0;
-       return (user_mode(regs) && test_tsk_thread_flag(current, TIF_IA32));
-}
-
 /* Ensure that the upper 32 bits of val are a sign-extension of the lower 32. */
 static int64_t __stp_sign_extend32(int64_t val)
 {
@@ -424,17 +398,6 @@ static int64_t __stp_sign_extend32(int64_t val)
        return *val_ptr32;
 }
 
-static int _stp_get_regparm(int regparm, struct pt_regs *regs)
-{
-       if (regparm == 0) {
-               /* Default */
-               if (_stp_probing_32bit_app(regs))
-                       return 0;
-               else
-                       return 6;
-       } else
-               return (regparm & _STP_REGPARM_MASK);
-}
 #endif /* __x86_64__ */
 
 #if defined(__i386__) || defined(__x86_64__)
index 2703e9c431939307e643dc6fdc82b467fbbd8bf1..f615b4e91dbd666ad2dc164bcba07c308faa4be1 100644 (file)
@@ -131,7 +131,14 @@ function _stp_arg:long (argnum:long) %{ /* pure */
        if (THIS->argnum < 1)
                goto bad_argnum;
        n = (int) THIS->argnum;
-       nr_regargs = _stp_get_regparm(CONTEXT->regparm, regs);
+       if (CONTEXT->regparm == 0) {
+               /* Default */
+               if (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)
+                       nr_regargs = 0;
+               else
+                       nr_regargs = 3;
+       } else
+               nr_regargs = (CONTEXT->regparm & _STP_REGPARM_MASK);
        result = _stp_get_arg32_by_number(n, nr_regargs, regs, &val);
        switch (result) {
        case 0:
index 555c71dba58f34ba79b7c6733761b3032e0bf057..3f91c7bce1e7d5a694357537d84af3d7581d2533 100644 (file)
@@ -60,7 +60,7 @@ function _stp_register_regs() {
 
 function probing_32bit_app() %{ /* pure */
         THIS->__retvalue = ((CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)
-                           && _stp_probing_32bit_app(CONTEXT->uregs));
+                           && _stp_is_compat_task());
 %}
 
 function _stp_get_register_by_offset:long (offset:long) %{ /* pure */
index 695b64a4ee5728335f9ccc32ed577d7b382b3250..af654e7fe4b8c0c97b3bd9695e9f9a8dec280483 100644 (file)
@@ -44,9 +44,8 @@ function _stp_register_regs() {
  */
 function probing_32bit_app() %{ /* pure */
        if ((CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)
-           && CONTEXT->uregs)
-               THIS->__retvalue = (user_mode(CONTEXT->uregs) &&
-                               test_tsk_thread_flag(current, TIF_31BIT));
+           && _stp_is_compat_task())
+               THIS->__retvalue = 1;
        else
                THIS->__retvalue = 0;
 %}
index 7ebaa48b29bd4a2d962a41eb870c61a094d7a696..329ec257e4749aa11e61b23a8c8837ef4cc04edf 100644 (file)
@@ -136,8 +136,17 @@ function _stp_arg:long (argnum:long, sign_extend:long, truncate:long) %{ /* pure
        if (THIS->argnum < 1)
                goto bad_argnum;
        n = (int) THIS->argnum;
-       nr_regargs = _stp_get_regparm(CONTEXT->regparm, regs);
-       if (_stp_probing_32bit_app(regs)) {
+       if (CONTEXT->regparm == 0) {
+               /* Default */
+               if ((CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)
+                   && _stp_is_compat_task())
+                       nr_regargs = 0;
+               else
+                       nr_regargs = 6;
+       } else
+               nr_regargs = (CONTEXT->regparm & _STP_REGPARM_MASK);
+       if ((CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)
+           && _stp_is_compat_task()) {
                argsz = sizeof(int);
                result = _stp_get_arg32_by_number(n, nr_regargs, regs, &val);
        } else
@@ -193,7 +202,7 @@ deref_fault: /* branched to from kread() */
 
 function probing_32bit_app() %{ /* pure */
        THIS->__retvalue = ((CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)
-                           && _stp_probing_32bit_app(CONTEXT->uregs));
+                           && _stp_is_compat_task());
 %}
 
 /* Return the value of function arg #argnum (1=first arg) as a signed int. */
@@ -253,8 +262,7 @@ function fastcall() %{ /* pure */ %}
 
 function regparm(n:long) %{
        if ((CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)
-           && _stp_probing_32bit_app(CONTEXT->uregs) &&
-                                       (THIS->n < 0 || THIS->n > 3)) {
+           && _stp_is_compat_task() && (THIS->n < 0 || THIS->n > 3)) {
                snprintf(CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
                        "For -m32 programs, "
                        "regparm value must be in the range 0-3.");
This page took 0.03961 seconds and 5 git commands to generate.