From 0410ff5addcba4c75dee4cee4b8435a8379e3cbb Mon Sep 17 00:00:00 2001
From: Thomas Chou <thomas@wytron.com.tw>
Date: Thu, 17 Jan 2008 20:21:43 +0800
Subject: [PATCH] nios2: add breakpoint pc offset

The breakpoint entry code has moved the PC on by 4 bytes, so we must
move it back.  This could be done on the host but we do it here because
monitor.S of JATG gdbserver does it.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 linux-2.6.x/arch/nios2nommu/kernel/traps.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/linux-2.6.x/arch/nios2nommu/kernel/traps.c b/linux-2.6.x/arch/nios2nommu/kernel/traps.c
index 6c55c04..e5471b9 100644
--- a/linux-2.6.x/arch/nios2nommu/kernel/traps.c
+++ b/linux-2.6.x/arch/nios2nommu/kernel/traps.c
@@ -182,13 +182,19 @@ asmlinkage void breakpoint_c(struct pt_regs *fp)
 {
 	siginfo_t info;
 
+/* 	The breakpoint entry code has moved the PC on by 4 bytes, so we must */
+/* 	move it back.  This could be done on the host but we do it here */
+/* 	because monitor.S of JATG gdbserver does it. */
+	fp->ea -= 4;
+
 /*
 	printk(KERN_DEBUG "Breakpoint detected, instr=0x%08x ea=0x%08x ra=0x%08x sp=0x%08x\n", *(u32*)((fp->ea)-4), *(u32*)(fp->ea), *(u32*)(fp->ra), *(u32*)(fp->sp));
 */
-
+	
 	info.si_code = TRAP_BRKPT;
 	info.si_signo = SIGTRAP;
 	info.si_errno = 0;
+	info.si_addr = (void *) fp->ea;
 
 	force_sig_info(info.si_signo, &info, current);
 }
-- 
1.5.3.3

