All of lore.kernel.org
 help / color / mirror / Atom feed
From: DDD <dongdong.deng@windriver.com>
To: Mike Frysinger <vapier@gentoo.org>
Cc: Roland McGrath <roland@redhat.com>,
	Oleg Nesterov <oleg@redhat.com>,
	linux-kernel@vger.kernel.org,
	kgdb-bugreport@lists.sourceforge.net,
	Jason Wessel <jason.wessel@windriver.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-sh@vger.kernel.org, x86@kernel.org,
	Paul Mundt <lethal@linux-sh.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: [Kgdb-bugreport] [PATCH 5/5] kgdbts: unify/generalize gdb	breakpoint
Date: Tue, 19 Apr 2011 05:36:43 +0000	[thread overview]
Message-ID: <4DAD1F6B.2050006@windriver.com> (raw)
In-Reply-To: <1302760895-13459-6-git-send-email-vapier@gentoo.org>

Mike Frysinger wrote:
> The Blackfin arch, like the x86 arch, needs to adjust the PC manually
> after a breakpoint is hit as normally this is handled by the remote gdb.
> However, rather than starting another arch ifdef mess, create a common
> GDB_ADJUSTS_BREAK_OFFSET define for any arch to opt-in via their kgdb.h.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>


Acked-by: Dongdong Deng <dongdong.deng@windriver.com>


> ---
>  arch/blackfin/include/asm/kgdb.h |    1 +
>  arch/sh/include/asm/kgdb.h       |    1 +
>  arch/x86/include/asm/kgdb.h      |    1 +
>  drivers/misc/kgdbts.c            |   29 +++++++++++------------------
>  4 files changed, 14 insertions(+), 18 deletions(-)
> 
> diff --git a/arch/blackfin/include/asm/kgdb.h b/arch/blackfin/include/asm/kgdb.h
> index 3ac0c72..aaf8845 100644
> --- a/arch/blackfin/include/asm/kgdb.h
> +++ b/arch/blackfin/include/asm/kgdb.h
> @@ -108,6 +108,7 @@ static inline void arch_kgdb_breakpoint(void)
>  #else
>  # define CACHE_FLUSH_IS_SAFE	1
>  #endif
> +#define GDB_ADJUSTS_BREAK_OFFSET
>  #define HW_INST_WATCHPOINT_NUM	6
>  #define HW_WATCHPOINT_NUM	8
>  #define TYPE_INST_WATCHPOINT	0
> diff --git a/arch/sh/include/asm/kgdb.h b/arch/sh/include/asm/kgdb.h
> index 4235e22..f361395 100644
> --- a/arch/sh/include/asm/kgdb.h
> +++ b/arch/sh/include/asm/kgdb.h
> @@ -34,5 +34,6 @@ static inline void arch_kgdb_breakpoint(void)
>  
>  #define CACHE_FLUSH_IS_SAFE	1
>  #define BREAK_INSTR_SIZE	2
> +#define GDB_ADJUSTS_BREAK_OFFSET
>  
>  #endif /* __ASM_SH_KGDB_H */
> diff --git a/arch/x86/include/asm/kgdb.h b/arch/x86/include/asm/kgdb.h
> index 396f5b5..77e95f5 100644
> --- a/arch/x86/include/asm/kgdb.h
> +++ b/arch/x86/include/asm/kgdb.h
> @@ -77,6 +77,7 @@ static inline void arch_kgdb_breakpoint(void)
>  }
>  #define BREAK_INSTR_SIZE	1
>  #define CACHE_FLUSH_IS_SAFE	1
> +#define GDB_ADJUSTS_BREAK_OFFSET
>  
>  extern int kgdb_ll_trap(int cmd, const char *str,
>  			struct pt_regs *regs, long err, int trap, int sig);
> diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
> index 59c118c..d475ce0 100644
> --- a/drivers/misc/kgdbts.c
> +++ b/drivers/misc/kgdbts.c
> @@ -285,33 +285,26 @@ static void hw_break_val_write(void)
>  static int check_and_rewind_pc(char *put_str, char *arg)
>  {
>  	unsigned long addr = lookup_addr(arg);
> +	unsigned long ip;
>  	int offset = 0;
>  
>  	kgdb_hex2mem(&put_str[1], (char *)kgdbts_gdb_regs,
>  		 NUMREGBYTES);
>  	gdb_regs_to_pt_regs(kgdbts_gdb_regs, &kgdbts_regs);
> -	v2printk("Stopped at IP: %lx\n", instruction_pointer(&kgdbts_regs));
> -#ifdef CONFIG_X86
> -	/* On x86 a breakpoint stop requires it to be decremented */
> -	if (addr + 1 = kgdbts_regs.ip)
> -		offset = -1;
> -#elif defined(CONFIG_SUPERH)
> -	/* On SUPERH a breakpoint stop requires it to be decremented */
> -	if (addr + 2 = kgdbts_regs.pc)
> -		offset = -2;
> +	ip = instruction_pointer(&kgdbts_regs);
> +	v2printk("Stopped at IP: %lx\n", ip);
> +#ifdef GDB_ADJUSTS_BREAK_OFFSET
> +	/* On some arches, a breakpoint stop requires it to be decremented */
> +	if (addr + BREAK_INSTR_SIZE = ip)
> +		offset = -BREAK_INSTR_SIZE;
>  #endif
> -	if (strcmp(arg, "silent") &&
> -		instruction_pointer(&kgdbts_regs) + offset != addr) {
> +	if (strcmp(arg, "silent") && ip + offset != addr) {
>  		eprintk("kgdbts: BP mismatch %lx expected %lx\n",
> -			   instruction_pointer(&kgdbts_regs) + offset, addr);
> +			   ip + offset, addr);
>  		return 1;
>  	}
> -#ifdef CONFIG_X86
> -	/* On x86 adjust the instruction pointer if needed */
> -	kgdbts_regs.ip += offset;
> -#elif defined(CONFIG_SUPERH)
> -	kgdbts_regs.pc += offset;
> -#endif
> +	/* Readjust the instruction pointer if needed */
> +	instruction_pointer_set(&kgdbts_regs, ip + offset);
>  	return 0;
>  }
>  


WARNING: multiple messages have this Message-ID (diff)
From: DDD <dongdong.deng@windriver.com>
To: Mike Frysinger <vapier@gentoo.org>
Cc: Roland McGrath <roland@redhat.com>,
	Oleg Nesterov <oleg@redhat.com>, <linux-kernel@vger.kernel.org>,
	<kgdb-bugreport@lists.sourceforge.net>,
	Jason Wessel <jason.wessel@windriver.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	<linux-sh@vger.kernel.org>, <x86@kernel.org>,
	Paul Mundt <lethal@linux-sh.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: [Kgdb-bugreport] [PATCH 5/5] kgdbts: unify/generalize gdb	breakpoint adjustment
Date: Tue, 19 Apr 2011 13:36:43 +0800	[thread overview]
Message-ID: <4DAD1F6B.2050006@windriver.com> (raw)
In-Reply-To: <1302760895-13459-6-git-send-email-vapier@gentoo.org>

Mike Frysinger wrote:
> The Blackfin arch, like the x86 arch, needs to adjust the PC manually
> after a breakpoint is hit as normally this is handled by the remote gdb.
> However, rather than starting another arch ifdef mess, create a common
> GDB_ADJUSTS_BREAK_OFFSET define for any arch to opt-in via their kgdb.h.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>


Acked-by: Dongdong Deng <dongdong.deng@windriver.com>


> ---
>  arch/blackfin/include/asm/kgdb.h |    1 +
>  arch/sh/include/asm/kgdb.h       |    1 +
>  arch/x86/include/asm/kgdb.h      |    1 +
>  drivers/misc/kgdbts.c            |   29 +++++++++++------------------
>  4 files changed, 14 insertions(+), 18 deletions(-)
> 
> diff --git a/arch/blackfin/include/asm/kgdb.h b/arch/blackfin/include/asm/kgdb.h
> index 3ac0c72..aaf8845 100644
> --- a/arch/blackfin/include/asm/kgdb.h
> +++ b/arch/blackfin/include/asm/kgdb.h
> @@ -108,6 +108,7 @@ static inline void arch_kgdb_breakpoint(void)
>  #else
>  # define CACHE_FLUSH_IS_SAFE	1
>  #endif
> +#define GDB_ADJUSTS_BREAK_OFFSET
>  #define HW_INST_WATCHPOINT_NUM	6
>  #define HW_WATCHPOINT_NUM	8
>  #define TYPE_INST_WATCHPOINT	0
> diff --git a/arch/sh/include/asm/kgdb.h b/arch/sh/include/asm/kgdb.h
> index 4235e22..f361395 100644
> --- a/arch/sh/include/asm/kgdb.h
> +++ b/arch/sh/include/asm/kgdb.h
> @@ -34,5 +34,6 @@ static inline void arch_kgdb_breakpoint(void)
>  
>  #define CACHE_FLUSH_IS_SAFE	1
>  #define BREAK_INSTR_SIZE	2
> +#define GDB_ADJUSTS_BREAK_OFFSET
>  
>  #endif /* __ASM_SH_KGDB_H */
> diff --git a/arch/x86/include/asm/kgdb.h b/arch/x86/include/asm/kgdb.h
> index 396f5b5..77e95f5 100644
> --- a/arch/x86/include/asm/kgdb.h
> +++ b/arch/x86/include/asm/kgdb.h
> @@ -77,6 +77,7 @@ static inline void arch_kgdb_breakpoint(void)
>  }
>  #define BREAK_INSTR_SIZE	1
>  #define CACHE_FLUSH_IS_SAFE	1
> +#define GDB_ADJUSTS_BREAK_OFFSET
>  
>  extern int kgdb_ll_trap(int cmd, const char *str,
>  			struct pt_regs *regs, long err, int trap, int sig);
> diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
> index 59c118c..d475ce0 100644
> --- a/drivers/misc/kgdbts.c
> +++ b/drivers/misc/kgdbts.c
> @@ -285,33 +285,26 @@ static void hw_break_val_write(void)
>  static int check_and_rewind_pc(char *put_str, char *arg)
>  {
>  	unsigned long addr = lookup_addr(arg);
> +	unsigned long ip;
>  	int offset = 0;
>  
>  	kgdb_hex2mem(&put_str[1], (char *)kgdbts_gdb_regs,
>  		 NUMREGBYTES);
>  	gdb_regs_to_pt_regs(kgdbts_gdb_regs, &kgdbts_regs);
> -	v2printk("Stopped at IP: %lx\n", instruction_pointer(&kgdbts_regs));
> -#ifdef CONFIG_X86
> -	/* On x86 a breakpoint stop requires it to be decremented */
> -	if (addr + 1 == kgdbts_regs.ip)
> -		offset = -1;
> -#elif defined(CONFIG_SUPERH)
> -	/* On SUPERH a breakpoint stop requires it to be decremented */
> -	if (addr + 2 == kgdbts_regs.pc)
> -		offset = -2;
> +	ip = instruction_pointer(&kgdbts_regs);
> +	v2printk("Stopped at IP: %lx\n", ip);
> +#ifdef GDB_ADJUSTS_BREAK_OFFSET
> +	/* On some arches, a breakpoint stop requires it to be decremented */
> +	if (addr + BREAK_INSTR_SIZE == ip)
> +		offset = -BREAK_INSTR_SIZE;
>  #endif
> -	if (strcmp(arg, "silent") &&
> -		instruction_pointer(&kgdbts_regs) + offset != addr) {
> +	if (strcmp(arg, "silent") && ip + offset != addr) {
>  		eprintk("kgdbts: BP mismatch %lx expected %lx\n",
> -			   instruction_pointer(&kgdbts_regs) + offset, addr);
> +			   ip + offset, addr);
>  		return 1;
>  	}
> -#ifdef CONFIG_X86
> -	/* On x86 adjust the instruction pointer if needed */
> -	kgdbts_regs.ip += offset;
> -#elif defined(CONFIG_SUPERH)
> -	kgdbts_regs.pc += offset;
> -#endif
> +	/* Readjust the instruction pointer if needed */
> +	instruction_pointer_set(&kgdbts_regs, ip + offset);
>  	return 0;
>  }
>  


  parent reply	other threads:[~2011-04-19  5:36 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-14  6:01 [PATCH 0/5] ptrace low level unification Mike Frysinger
2011-04-14  6:01 ` Mike Frysinger
2011-04-14  6:01 ` [PATCH 1/5] asm-generic/ptrace.h: start a common low level ptrace helper Mike Frysinger
2011-04-14  6:01   ` Mike Frysinger
2011-04-14 18:09   ` [PATCH 1/5] asm-generic/ptrace.h: start a common low level Oleg Nesterov
2011-04-14 18:09     ` [PATCH 1/5] asm-generic/ptrace.h: start a common low level ptrace helper Oleg Nesterov
2011-04-14 18:16     ` Mike Frysinger
2011-04-14 18:16       ` Mike Frysinger
2011-04-14  6:01 ` [PATCH 2/5] Blackfin: convert to asm-generic ptrace.h Mike Frysinger
2011-04-14  6:01   ` Mike Frysinger
2011-04-14  6:01 ` [PATCH 3/5] x86: " Mike Frysinger
2011-04-14  6:01   ` Mike Frysinger
2011-04-14 14:16   ` [Kgdb-bugreport] " Sergei Shtylyov
2011-04-14 14:16     ` Sergei Shtylyov
2011-04-14 17:05     ` H. Peter Anvin
2011-04-14 17:05       ` H. Peter Anvin
2011-04-14 17:38       ` Sergei Shtylyov
2011-04-14 17:38         ` Sergei Shtylyov
2011-04-14  6:01 ` [PATCH 4/5] sh: " Mike Frysinger
2011-04-14  6:01   ` Mike Frysinger
2011-04-14 14:22   ` [Kgdb-bugreport] " Sergei Shtylyov
2011-04-14 14:22     ` Sergei Shtylyov
2011-04-16 19:17     ` Paul Mundt
2011-04-16 19:17       ` Paul Mundt
2011-04-14  6:01 ` [PATCH 5/5] kgdbts: unify/generalize gdb breakpoint adjustment Mike Frysinger
2011-04-14  6:01   ` Mike Frysinger
2011-04-18  8:29   ` Paul Mundt
2011-04-18  8:29     ` Paul Mundt
2011-06-16 15:07     ` Arnd Bergmann
2011-06-16 15:07       ` Arnd Bergmann
2011-06-16 20:06       ` Mike Frysinger
2011-06-16 20:06         ` Mike Frysinger
2011-06-16 20:07         ` Mike Frysinger
2011-06-16 20:07           ` Mike Frysinger
2011-06-16 20:21           ` Arnd Bergmann
2011-06-16 20:21             ` Arnd Bergmann
2011-06-16 20:29             ` Mike Frysinger
2011-06-16 20:29               ` Mike Frysinger
2011-04-19  5:36   ` DDD [this message]
2011-04-19  5:36     ` [Kgdb-bugreport] " DDD

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=4DAD1F6B.2050006@windriver.com \
    --to=dongdong.deng@windriver.com \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=jason.wessel@windriver.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=roland@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=vapier@gentoo.org \
    --cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.