Zitat von David McCullough <[EMAIL PROTECTED]>:
Ok,  time to checkout the old 2.4 code and compare that to the 2.6 code.
Everything I did with these devices was under 2.4.

Most of the gdb kernel side is in:

        linux-2.4.x/arch/m68knommu/kernel/ptrace.c

        check in and around these:

        PTRACE_PEEKTEXT
        PTRACE_PEEKDATA
        PTRACE_PEEKUSR (some magic numbers there)

Well, in linux-2.4.x the main entry function was called sys_ptrace() which is now arch_ptrace under linux-2.6.x. In linux-2.4.x there is some additional stuff done before the request gets evaluated by "switch(request)".

---snip---
        struct task_struct *child;
        int ret;

        lock_kernel();
        ret = -EPERM;
        if (request == PTRACE_TRACEME) {
                /* are we already being traced? */
                if (current->ptrace & PT_PTRACED)
                        goto out;
                /* set the ptrace bit in the process flags. */
                current->ptrace |= PT_PTRACED;
                ret = 0;
                goto out;
        }
        ret = -ESRCH;
        read_lock(&tasklist_lock);
        child = find_task_by_pid(pid);
        if (child)
                get_task_struct(child);
        read_unlock(&tasklist_lock);
        if (!child)
                goto out;

        ret = -EPERM;
        if (pid == 1)           /* you may not mess with init */
                goto out_tsk;

        if (request == PTRACE_ATTACH) {
                ret = ptrace_attach(child);
                goto out_tsk;
        }
        ret = -ESRCH;
        if (!(child->ptrace & PT_PTRACED))
                goto out_tsk;
        if (child->state != TASK_STOPPED) {
                if (request != PTRACE_KILL)
                        goto out_tsk;
        }
        if (child->p_pptr != current)
                goto out_tsk;

        switch (request) {
---snap---

This part is missing in the linux-2.6.x code. This is from the original code from uClinux-dist-20070130!!! I have also seen some differences between the uClinux-dist-20070130 code and the uClinux-dist-20070130-20071205.patch.gz. (for linux-2.6.x) I am not sure whether I should upgrade to the latest code (namely arch/m68knommu/kernel/ptrace.c, linux/ptrace.c, include/linux/ptrace.h) and whether this can be done easily, without applying the whole patch on my "production tree"?!?!? Any suggestions?

Ok,  all fairly straight forward.  Check out the ptrace API and see what
is right/wrong in there,

Hmmm....I debugged arch/m68knommu/ptrace.c:arch_ptrace. As soon as I connect from the host-gdb (by target remote <ip>:3000) to the target, arch_ptrace is getting called with argument "addr == 56" and "request == 3 (PTRACE_PEEKUSR)".
The code in arch_ptrace() says:

---snip---
case PTRACE_PEEKUSR: {
  unsigned long tmp;

  ret = -EIO;
  if ((addr & 3) || addr < 0 ||
        addr > sizeof(struct user) - 3)
            break;
---snap---

The AND-mask with 3 is due to address alignment I guess. As address equals to 56 the "break" gets called and that's it. I guess there is something wrong with this 56, isn't it?

Any comments on this are appreciated. With best regards,

Markus Franke



_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to