lkml.org 
[lkml]   [2008]   [Jun]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 28/60] microblaze_v4: ptrace support
    On Thu, Jun 26, 2008 at 02:29:57PM +0200, monstr@seznam.cz wrote:
    > +long arch_ptrace(struct task_struct *child, long request, long addr, long data)
    > +{
    > + int rval;
    > +
    > + switch (request) {
    > + unsigned long val, copied;
    > +
    > + case PTRACE_PEEKTEXT: /* read word at location addr. */
    > + case PTRACE_PEEKDATA:
    > + pr_debug("PEEKTEXT/PEEKDATA at %08lX\n", addr);
    > + copied = access_process_vm(child, addr, &val, sizeof(val), 0);
    > + rval = -EIO;
    > + if (copied != sizeof(val))
    > + break;
    > + rval = put_user(val, (unsigned long *)data);
    > + goto out;
    > +
    > + case PTRACE_POKETEXT: /* write the word at location addr. */
    > + case PTRACE_POKEDATA:
    > + pr_debug("POKETEXT/POKEDATA to %08lX\n", addr);
    > + rval = 0;
    > + if (access_process_vm(child, addr, &data, sizeof(data), 1)
    > + == sizeof(data))
    > + break;
    > + rval = -EIO;
    > + goto out;
    > +
    You can use generic_ptrace_peekdata()/generic_ptrace_pokedata() for
    these. Or kill them off and let ptrace_request() handle it.

    > + /* Continue and stop at next (return from) syscall */
    > + case PTRACE_SYSCALL:
    > + pr_debug("PTRACE_SYSCALL\n");
    > + case PTRACE_SINGLESTEP:
    > + pr_debug("PTRACE_SINGLESTEP\n");
    > + /* Restart after a signal. */
    > + case PTRACE_CONT:
    > + pr_debug("PTRACE_CONT\n");
    > + rval = -EIO;
    > + if (!valid_signal(data))
    > + break;
    > +
    > + if (request == PTRACE_SYSCALL)
    > + set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
    > + else
    > + clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
    > +
    > + child->exit_code = data;
    > + pr_debug("wakeup_process\n");
    > + wake_up_process(child);
    > + rval = 0;
    > + break;
    > +
    This is a reimplementation of ptrace_resume(), you can kill all of these
    off as well, as they are also handled generically these days.

    > + /*
    > + * make the child exit. Best I can do is send it a sigkill.
    > + * perhaps it should be put in the status that it wants to
    > + * exit.
    > + */
    > + case PTRACE_KILL:
    > + pr_debug("PTRACE_KILL\n");
    > + rval = 0;
    > + if (child->exit_state == EXIT_ZOMBIE) /* already dead */
    > + break;
    > + child->exit_code = SIGKILL;
    > + wake_up_process(child);
    > + break;
    > +
    > + case PTRACE_DETACH: /* detach a process that was attached. */
    > + pr_debug("PTRACE_DETACH\n");
    > + rval = ptrace_detach(child, data);
    > + break;
    > +
    > + default:
    > + rval = -EIO;
    > + goto out;
    > + }
    > + out:
    > + return rval;
    > +}
    > +
    Or rather, they would be, if you defaulted to ptrace_request() for the
    unhandled cases.


    \
     
     \ /
      Last update: 2008-06-28 07:05    [W:5.762 / U:0.608 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site