]> sourceware.org Git - systemtap.git/commitdiff
Uses upstream ia64 syscall functions.
authorDavid Smith <dsmith@redhat.com>
Mon, 20 Apr 2009 18:54:51 +0000 (13:54 -0500)
committerDavid Smith <dsmith@redhat.com>
Mon, 20 Apr 2009 18:54:51 +0000 (13:54 -0500)
2009-04-20  David Smith  <dsmith@redhat.com>

* runtime/syscall.h (syscall_get_nr): Uses upstream version of
syscall_get_nr() for ia64.
(syscall_get_arguments): Ditto.
(in_syscall): New ia64-only function from upstream.
(syscall_get_set_args_cb): Ditto.
(ia64_syscall_get_set_arguments): Ditto.
* runtime/task_finder.c (stap_register_task_finder_target):
Removed ia64 register cache.

runtime/syscall.h
runtime/task_finder.c

index 5e5383895e34cfdeb8bfb261cb8841bb7d0333a8..ffc21efcef67b372fb8065c32acabb029eb6d409 100644 (file)
@@ -124,6 +124,14 @@ syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
 static inline long
 syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
 {
+       if ((long)regs->cr_ifs < 0) /* Not a syscall */
+               return -1;
+
+#ifdef CONFIG_IA32_SUPPORT
+       if (IS_IA32_PROCESS(regs))
+               return regs->r1;
+#endif
+
        return regs->r15;
 }
 #endif
@@ -320,38 +328,119 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
 #endif
 
 #if defined(__ia64__)
-#define syscall_get_arguments(task, regs, i, n, args)          \
-       __ia64_syscall_get_arguments(task, regs, i, n, args, &c->unwaddr)
 
-static inline void
-__ia64_syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
-                            unsigned int i, unsigned int n,
-                            unsigned long *args, unsigned long **cache)
+/* Return TRUE if PT was created due to kernel-entry via a system-call.  */
+
+static inline int
+in_syscall (struct pt_regs *pt)
 {
-       if (i + n > 6) {
-               _stp_error("invalid syscall arg request");
+       return (long) pt->cr_ifs >= 0;
+}
+
+struct syscall_get_set_args {
+       unsigned int i;
+       unsigned int n;
+       unsigned long *args;
+       struct pt_regs *regs;
+       int rw;
+};
+
+static void syscall_get_set_args_cb(struct unw_frame_info *info, void *data)
+{
+       struct syscall_get_set_args *args = data;
+       struct pt_regs *pt = args->regs;
+       unsigned long *krbs, cfm, ndirty;
+       int i, count;
+
+       if (unw_unwind_to_user(info) < 0)
                return;
+
+       cfm = pt->cr_ifs;
+       krbs = (unsigned long *)info->task + IA64_RBS_OFFSET/8;
+       ndirty = ia64_rse_num_regs(krbs, krbs + (pt->loadrs >> 19));
+
+       count = 0;
+       if (in_syscall(pt))
+               count = min_t(int, args->n, cfm & 0x7f);
+
+       for (i = 0; i < count; i++) {
+               if (args->rw)
+                       *ia64_rse_skip_regs(krbs, ndirty + i + args->i) =
+                               args->args[i];
+               else
+                       args->args[i] = *ia64_rse_skip_regs(krbs,
+                               ndirty + i + args->i);
        }
-       switch (i) {
-       case 0:
-               if (!n--) break;
-               *args++ = ia64_fetch_register(32, regs, cache);
-       case 1:
-               if (!n--) break;
-               *args++ = ia64_fetch_register(33, regs, cache);
-       case 2:
-               if (!n--) break;
-               *args++ = ia64_fetch_register(34, regs, cache);
-       case 3:
-               if (!n--) break;
-               *args++ = ia64_fetch_register(35, regs, cache);
-       case 4:
-               if (!n--) break;
-               *args++ = ia64_fetch_register(36, regs, cache);
-       case 5:
-               if (!n--) break;
-               *args++ = ia64_fetch_register(37, regs, cache);
+
+       if (!args->rw) {
+               while (i < args->n) {
+                       args->args[i] = 0;
+                       i++;
+               }
+       }
+}
+
+void ia64_syscall_get_set_arguments(struct task_struct *task,
+       struct pt_regs *regs, unsigned int i, unsigned int n,
+       unsigned long *args, int rw)
+{
+       struct syscall_get_set_args data = {
+               .i = i,
+               .n = n,
+               .args = args,
+               .regs = regs,
+               .rw = rw,
+       };
+
+       if (task == current)
+               unw_init_running(syscall_get_set_args_cb, &data);
+       else {
+               struct unw_frame_info ufi;
+               memset(&ufi, 0, sizeof(ufi));
+               unw_init_from_blocked_task(&ufi, task);
+               syscall_get_set_args_cb(&ufi, &data);
+       }
+}
+
+static inline void syscall_get_arguments(struct task_struct *task,
+                                        struct pt_regs *regs,
+                                        unsigned int i, unsigned int n,
+                                        unsigned long *args)
+{
+       BUG_ON(i + n > 6);
+
+#ifdef CONFIG_IA32_SUPPORT
+       if (IS_IA32_PROCESS(regs)) {
+               switch (i + n) {
+               case 6:
+                       if (!n--) break;
+                       *args++ = regs->r13;
+               case 5:
+                       if (!n--) break;
+                       *args++ = regs->r15;
+               case 4:
+                       if (!n--) break;
+                       *args++ = regs->r14;
+               case 3:
+                       if (!n--) break;
+                       *args++ = regs->r10;
+               case 2:
+                       if (!n--) break;
+                       *args++ = regs->r9;
+               case 1:
+                       if (!n--) break;
+                       *args++ = regs->r11;
+               case 0:
+                       if (!n--) break;
+               default:
+                       BUG();
+                       break;
+               }
+
+               return;
        }
+#endif
+       ia64_syscall_get_set_arguments(task, regs, i, n, args, 0);
 }
 #endif
 
index fa6c296e25c204a880a2e3717dcb53261902ce69..93b89cb9def3e0b83f1f32489b65b6b37dd213b5 100644 (file)
@@ -1071,9 +1071,6 @@ __stp_utrace_task_finder_target_syscall_exit(enum utrace_resume_action action,
        int rc;
        struct mm_struct *mm;
        struct vm_area_struct *vma;
-#if defined(__ia64__)
-       struct { unsigned long *unwaddr; } _c = {.unwaddr = NULL}, *c = &_c;
-#endif
 
        if (atomic_read(&__stp_task_finder_state) != __STP_TF_RUNNING) {
                debug_task_finder_detach();
This page took 0.033419 seconds and 5 git commands to generate.