public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: Roland McGrath <roland@redhat.com>, linux-m68k@vger.kernel.org
Subject: Re: m68k ptrace code
Date: Wed, 5 Aug 2009 17:27:49 +0200	[thread overview]
Message-ID: <20090805152749.GE6476@lst.de> (raw)
In-Reply-To: <m263g8gf3e.fsf@igel.home>

Hi Andreas,

On Mon, May 11, 2009 at 11:32:05AM +0200, Andreas Schwab wrote:
> > Looks good to me, except you also want to nix PTRACE_KILL from your switch
> > so the generic code handles it.  Same goes for {PEEK,POKE}{DATA,TEXT} too.
> > Also note that you have to define a PTRACE_SINGLEBLOCK value in
> > asm/ptrace.h (new request code in your ptrace syscall ABI) to make
> > user_enable_block_step() get used by anything.
> 
> Thanks for your comments.  I have made these changes and verified with
> the ptrace testsuite that the singleblock request works correctly.
> There are a few failures in the testsuite, which I haven't analyzed yet,
> but none are regressions.

Any reason why this has never been commited?

> 
> Andreas.
> ---
> >From 2fd8c8e890bb4cff1175a7e37cc8cafbe663ef8a Mon Sep 17 00:00:00 2001
> From: Andreas Schwab <schwab@linux-m68k.org>
> Date: Sun, 10 May 2009 21:14:52 +0200
> Subject: [PATCH] m68k: use generic code for ptrace requests
> 
> Remove all but PTRACE_{PEEK,POKE}USR and PTRACE_{GET,SET}{REGS,FPREGS}
> from arch_ptrace and let the rest be handled by generic code.  Define
> PTRACE_SINGLEBLOCK to enable singleblock tracing.
> 
> Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
> ---
>  arch/m68k/include/asm/ptrace.h |   13 +++++++
>  arch/m68k/kernel/ptrace.c      |   75 +++++++++++----------------------------
>  2 files changed, 34 insertions(+), 54 deletions(-)
> 
> diff --git a/arch/m68k/include/asm/ptrace.h b/arch/m68k/include/asm/ptrace.h
> index 8c9194b..eef9309 100644
> --- a/arch/m68k/include/asm/ptrace.h
> +++ b/arch/m68k/include/asm/ptrace.h
> @@ -71,6 +71,8 @@ struct switch_stack {
>  #define PTRACE_GETFPREGS          14
>  #define PTRACE_SETFPREGS          15
>  
> +#define PTRACE_SINGLEBLOCK	33	/* resume execution until next branch */
> +
>  #ifdef __KERNEL__
>  
>  #ifndef PS_S
> @@ -82,6 +84,17 @@ struct switch_stack {
>  #define instruction_pointer(regs) ((regs)->pc)
>  #define profile_pc(regs) instruction_pointer(regs)
>  extern void show_regs(struct pt_regs *);
> +
> +/*
> + * These are defined as per linux/ptrace.h, which see.
> + */
> +#define arch_has_single_step()	(1)
> +extern void user_enable_single_step(struct task_struct *);
> +extern void user_disable_single_step(struct task_struct *);
> +
> +#define arch_has_block_step()	(1)
> +extern void user_enable_block_step(struct task_struct *);
> +
>  #endif /* __KERNEL__ */
>  #endif /* __ASSEMBLY__ */
>  #endif /* _M68K_PTRACE_H */
> diff --git a/arch/m68k/kernel/ptrace.c b/arch/m68k/kernel/ptrace.c
> index 2075543..bd08420 100644
> --- a/arch/m68k/kernel/ptrace.c
> +++ b/arch/m68k/kernel/ptrace.c
> @@ -35,7 +35,9 @@
>  #define SR_MASK 0x001f
>  
>  /* sets the trace bits. */
> -#define TRACE_BITS 0x8000
> +#define TRACE_BITS 0xC000
> +#define T1_BIT 0x8000
> +#define T0_BIT 0x4000
>  
>  /* Find the stack offset for a register, relative to thread.esp0. */
>  #define PT_REG(reg)	((long)&((struct pt_regs *)0)->reg)
> @@ -118,18 +120,30 @@ void ptrace_disable(struct task_struct *child)
>  	singlestep_disable(child);
>  }
>  
> +void user_enable_single_step(struct task_struct *child)
> +{
> +	unsigned long tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16);
> +	put_reg(child, PT_SR, tmp | (T1_BIT << 16));
> +	set_tsk_thread_flag(child, TIF_DELAYED_TRACE);
> +}
> +
> +void user_enable_block_step(struct task_struct *child)
> +{
> +	unsigned long tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16);
> +	put_reg(child, PT_SR, tmp | (T0_BIT << 16));
> +}
> +
> +void user_disable_single_step(struct task_struct *child)
> +{
> +	singlestep_disable(child);
> +}
> +
>  long arch_ptrace(struct task_struct *child, long request, long addr, long data)
>  {
>  	unsigned long tmp;
>  	int i, ret = 0;
>  
>  	switch (request) {
> -	/* when I and D space are separate, these will need to be fixed. */
> -	case PTRACE_PEEKTEXT:	/* read word at location addr. */
> -	case PTRACE_PEEKDATA:
> -		ret = generic_ptrace_peekdata(child, addr, data);
> -		break;
> -
>  	/* read the word at location addr in the USER area. */
>  	case PTRACE_PEEKUSR:
>  		if (addr & 3)
> @@ -153,12 +167,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
>  		ret = put_user(tmp, (unsigned long *)data);
>  		break;
>  
> -	/* when I and D space are separate, this will have to be fixed. */
> -	case PTRACE_POKETEXT:	/* write the word at location addr. */
> -	case PTRACE_POKEDATA:
> -		ret = generic_ptrace_pokedata(child, addr, data);
> -		break;
> -
>  	case PTRACE_POKEUSR:	/* write the word at location addr in the USER area */
>  		if (addr & 3)
>  			goto out_eio;
> @@ -185,47 +193,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
>  			goto out_eio;
>  		break;
>  
> -	case PTRACE_SYSCALL:	/* continue and stop at next (return from) syscall */
> -	case PTRACE_CONT:	/* restart after signal. */
> -		if (!valid_signal(data))
> -			goto out_eio;
> -
> -		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;
> -		singlestep_disable(child);
> -		wake_up_process(child);
> -		break;
> -
> -	/*
> -	 * 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:
> -		if (child->exit_state == EXIT_ZOMBIE) /* already dead */
> -			break;
> -		child->exit_code = SIGKILL;
> -		singlestep_disable(child);
> -		wake_up_process(child);
> -		break;
> -
> -	case PTRACE_SINGLESTEP:	/* set the trap flag. */
> -		if (!valid_signal(data))
> -			goto out_eio;
> -
> -		clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
> -		tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16);
> -		put_reg(child, PT_SR, tmp);
> -		set_tsk_thread_flag(child, TIF_DELAYED_TRACE);
> -
> -		child->exit_code = data;
> -		/* give it a chance to run. */
> -		wake_up_process(child);
> -		break;
> -
>  	case PTRACE_GETREGS:	/* Get all gp regs from the child. */
>  		for (i = 0; i < 19; i++) {
>  			tmp = get_reg(child, i);
> -- 
> 1.6.3
> 
> 
> -- 
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
---end quoted text---

  reply	other threads:[~2009-08-05 15:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090427191230.GA1657@lst.de>
2009-04-27 19:14 ` m68k ptrace code Christoph Hellwig
2009-05-10 19:32   ` Andreas Schwab
2009-05-10 23:18     ` Roland McGrath
2009-05-11  9:32       ` Andreas Schwab
2009-08-05 15:27         ` Christoph Hellwig [this message]
2009-08-05 21:12           ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090805152749.GE6476@lst.de \
    --to=hch@lst.de \
    --cc=linux-m68k@vger.kernel.org \
    --cc=roland@redhat.com \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox