kgdbts: unify/generalize gdb breakpoint adjustment
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> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Jason Wessel <jason.wessel@windriver.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Acked-by: Paul Mundt <lethal@linux-sh.org> Acked-by: Dongdong Deng <dongdong.deng@windriver.com> Cc: Sergei Shtylyov <sshtylyov@mvista.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
3cea45c6ef
commit
63ab25ebbc
4 changed files with 14 additions and 18 deletions
|
@ -108,6 +108,7 @@ static inline void arch_kgdb_breakpoint(void)
|
||||||
#else
|
#else
|
||||||
# define CACHE_FLUSH_IS_SAFE 1
|
# define CACHE_FLUSH_IS_SAFE 1
|
||||||
#endif
|
#endif
|
||||||
|
#define GDB_ADJUSTS_BREAK_OFFSET
|
||||||
#define HW_INST_WATCHPOINT_NUM 6
|
#define HW_INST_WATCHPOINT_NUM 6
|
||||||
#define HW_WATCHPOINT_NUM 8
|
#define HW_WATCHPOINT_NUM 8
|
||||||
#define TYPE_INST_WATCHPOINT 0
|
#define TYPE_INST_WATCHPOINT 0
|
||||||
|
|
|
@ -34,5 +34,6 @@ static inline void arch_kgdb_breakpoint(void)
|
||||||
|
|
||||||
#define CACHE_FLUSH_IS_SAFE 1
|
#define CACHE_FLUSH_IS_SAFE 1
|
||||||
#define BREAK_INSTR_SIZE 2
|
#define BREAK_INSTR_SIZE 2
|
||||||
|
#define GDB_ADJUSTS_BREAK_OFFSET
|
||||||
|
|
||||||
#endif /* __ASM_SH_KGDB_H */
|
#endif /* __ASM_SH_KGDB_H */
|
||||||
|
|
|
@ -77,6 +77,7 @@ static inline void arch_kgdb_breakpoint(void)
|
||||||
}
|
}
|
||||||
#define BREAK_INSTR_SIZE 1
|
#define BREAK_INSTR_SIZE 1
|
||||||
#define CACHE_FLUSH_IS_SAFE 1
|
#define CACHE_FLUSH_IS_SAFE 1
|
||||||
|
#define GDB_ADJUSTS_BREAK_OFFSET
|
||||||
|
|
||||||
extern int kgdb_ll_trap(int cmd, const char *str,
|
extern int kgdb_ll_trap(int cmd, const char *str,
|
||||||
struct pt_regs *regs, long err, int trap, int sig);
|
struct pt_regs *regs, long err, int trap, int sig);
|
||||||
|
|
|
@ -285,33 +285,26 @@ static void hw_break_val_write(void)
|
||||||
static int check_and_rewind_pc(char *put_str, char *arg)
|
static int check_and_rewind_pc(char *put_str, char *arg)
|
||||||
{
|
{
|
||||||
unsigned long addr = lookup_addr(arg);
|
unsigned long addr = lookup_addr(arg);
|
||||||
|
unsigned long ip;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
kgdb_hex2mem(&put_str[1], (char *)kgdbts_gdb_regs,
|
kgdb_hex2mem(&put_str[1], (char *)kgdbts_gdb_regs,
|
||||||
NUMREGBYTES);
|
NUMREGBYTES);
|
||||||
gdb_regs_to_pt_regs(kgdbts_gdb_regs, &kgdbts_regs);
|
gdb_regs_to_pt_regs(kgdbts_gdb_regs, &kgdbts_regs);
|
||||||
v2printk("Stopped at IP: %lx\n", instruction_pointer(&kgdbts_regs));
|
ip = instruction_pointer(&kgdbts_regs);
|
||||||
#ifdef CONFIG_X86
|
v2printk("Stopped at IP: %lx\n", ip);
|
||||||
/* On x86 a breakpoint stop requires it to be decremented */
|
#ifdef GDB_ADJUSTS_BREAK_OFFSET
|
||||||
if (addr + 1 == kgdbts_regs.ip)
|
/* On some arches, a breakpoint stop requires it to be decremented */
|
||||||
offset = -1;
|
if (addr + BREAK_INSTR_SIZE == ip)
|
||||||
#elif defined(CONFIG_SUPERH)
|
offset = -BREAK_INSTR_SIZE;
|
||||||
/* On SUPERH a breakpoint stop requires it to be decremented */
|
|
||||||
if (addr + 2 == kgdbts_regs.pc)
|
|
||||||
offset = -2;
|
|
||||||
#endif
|
#endif
|
||||||
if (strcmp(arg, "silent") &&
|
if (strcmp(arg, "silent") && ip + offset != addr) {
|
||||||
instruction_pointer(&kgdbts_regs) + offset != addr) {
|
|
||||||
eprintk("kgdbts: BP mismatch %lx expected %lx\n",
|
eprintk("kgdbts: BP mismatch %lx expected %lx\n",
|
||||||
instruction_pointer(&kgdbts_regs) + offset, addr);
|
ip + offset, addr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_X86
|
/* Readjust the instruction pointer if needed */
|
||||||
/* On x86 adjust the instruction pointer if needed */
|
instruction_pointer_set(&kgdbts_regs, ip + offset);
|
||||||
kgdbts_regs.ip += offset;
|
|
||||||
#elif defined(CONFIG_SUPERH)
|
|
||||||
kgdbts_regs.pc += offset;
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue