diff options
-rw-r--r-- | arch/sh/include/asm/kgdb.h | 19 | ||||
-rw-r--r-- | arch/sh/kernel/kgdb.c | 70 |
2 files changed, 53 insertions, 36 deletions
diff --git a/arch/sh/include/asm/kgdb.h b/arch/sh/include/asm/kgdb.h index f3613952d1ae..00485198f598 100644 --- a/arch/sh/include/asm/kgdb.h +++ b/arch/sh/include/asm/kgdb.h | |||
@@ -4,18 +4,6 @@ | |||
4 | #include <asm/cacheflush.h> | 4 | #include <asm/cacheflush.h> |
5 | #include <asm/ptrace.h> | 5 | #include <asm/ptrace.h> |
6 | 6 | ||
7 | /* Same as pt_regs but has vbr in place of syscall_nr */ | ||
8 | struct kgdb_regs { | ||
9 | unsigned long regs[16]; | ||
10 | unsigned long pc; | ||
11 | unsigned long pr; | ||
12 | unsigned long sr; | ||
13 | unsigned long gbr; | ||
14 | unsigned long mach; | ||
15 | unsigned long macl; | ||
16 | unsigned long vbr; | ||
17 | }; | ||
18 | |||
19 | enum regnames { | 7 | enum regnames { |
20 | GDB_R0, GDB_R1, GDB_R2, GDB_R3, GDB_R4, GDB_R5, GDB_R6, GDB_R7, | 8 | GDB_R0, GDB_R1, GDB_R2, GDB_R3, GDB_R4, GDB_R5, GDB_R6, GDB_R7, |
21 | GDB_R8, GDB_R9, GDB_R10, GDB_R11, GDB_R12, GDB_R13, GDB_R14, GDB_R15, | 9 | GDB_R8, GDB_R9, GDB_R10, GDB_R11, GDB_R12, GDB_R13, GDB_R14, GDB_R15, |
@@ -23,7 +11,12 @@ enum regnames { | |||
23 | GDB_PC, GDB_PR, GDB_SR, GDB_GBR, GDB_MACH, GDB_MACL, GDB_VBR, | 11 | GDB_PC, GDB_PR, GDB_SR, GDB_GBR, GDB_MACH, GDB_MACL, GDB_VBR, |
24 | }; | 12 | }; |
25 | 13 | ||
26 | #define NUMREGBYTES ((GDB_VBR + 1) * 4) | 14 | #define _GP_REGS 16 |
15 | #define _EXTRA_REGS 7 | ||
16 | #define GDB_SIZEOF_REG sizeof(u32) | ||
17 | |||
18 | #define DBG_MAX_REG_NUM (_GP_REGS + _EXTRA_REGS) | ||
19 | #define NUMREGBYTES (DBG_MAX_REG_NUM * sizeof(GDB_SIZEOF_REG)) | ||
27 | 20 | ||
28 | static inline void arch_kgdb_breakpoint(void) | 21 | static inline void arch_kgdb_breakpoint(void) |
29 | { | 22 | { |
diff --git a/arch/sh/kernel/kgdb.c b/arch/sh/kernel/kgdb.c index 93458880acad..d25b5ed68b24 100644 --- a/arch/sh/kernel/kgdb.c +++ b/arch/sh/kernel/kgdb.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * SuperH KGDB support | 2 | * SuperH KGDB support |
3 | * | 3 | * |
4 | * Copyright (C) 2008 - 2009 Paul Mundt | 4 | * Copyright (C) 2008 - 2012 Paul Mundt |
5 | * | 5 | * |
6 | * Single stepping taken from the old stub by Henry Bell and Jeremy Siegel. | 6 | * Single stepping taken from the old stub by Henry Bell and Jeremy Siegel. |
7 | * | 7 | * |
@@ -164,36 +164,60 @@ static void undo_single_step(struct pt_regs *linux_regs) | |||
164 | stepped_opcode = 0; | 164 | stepped_opcode = 0; |
165 | } | 165 | } |
166 | 166 | ||
167 | void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs) | 167 | struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = { |
168 | { | 168 | { "r0", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[0]) }, |
169 | int i; | 169 | { "r1", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[1]) }, |
170 | { "r2", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[2]) }, | ||
171 | { "r3", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[3]) }, | ||
172 | { "r4", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[4]) }, | ||
173 | { "r5", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[5]) }, | ||
174 | { "r6", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[6]) }, | ||
175 | { "r7", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[7]) }, | ||
176 | { "r8", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[8]) }, | ||
177 | { "r9", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[9]) }, | ||
178 | { "r10", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[10]) }, | ||
179 | { "r11", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[11]) }, | ||
180 | { "r12", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[12]) }, | ||
181 | { "r13", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[13]) }, | ||
182 | { "r14", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[14]) }, | ||
183 | { "r15", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[15]) }, | ||
184 | { "pc", GDB_SIZEOF_REG, offsetof(struct pt_regs, pc) }, | ||
185 | { "pr", GDB_SIZEOF_REG, offsetof(struct pt_regs, pr) }, | ||
186 | { "sr", GDB_SIZEOF_REG, offsetof(struct pt_regs, sr) }, | ||
187 | { "gbr", GDB_SIZEOF_REG, offsetof(struct pt_regs, gbr) }, | ||
188 | { "mach", GDB_SIZEOF_REG, offsetof(struct pt_regs, mach) }, | ||
189 | { "macl", GDB_SIZEOF_REG, offsetof(struct pt_regs, macl) }, | ||
190 | { "vbr", GDB_SIZEOF_REG, -1 }, | ||
191 | }; | ||
170 | 192 | ||
171 | for (i = 0; i < 16; i++) | 193 | int dbg_set_reg(int regno, void *mem, struct pt_regs *regs) |
172 | gdb_regs[GDB_R0 + i] = regs->regs[i]; | 194 | { |
195 | if (regno < 0 || regno >= DBG_MAX_REG_NUM) | ||
196 | return -EINVAL; | ||
173 | 197 | ||
174 | gdb_regs[GDB_PC] = regs->pc; | 198 | if (dbg_reg_def[regno].offset != -1) |
175 | gdb_regs[GDB_PR] = regs->pr; | 199 | memcpy((void *)regs + dbg_reg_def[regno].offset, mem, |
176 | gdb_regs[GDB_SR] = regs->sr; | 200 | dbg_reg_def[regno].size); |
177 | gdb_regs[GDB_GBR] = regs->gbr; | ||
178 | gdb_regs[GDB_MACH] = regs->mach; | ||
179 | gdb_regs[GDB_MACL] = regs->macl; | ||
180 | 201 | ||
181 | __asm__ __volatile__ ("stc vbr, %0" : "=r" (gdb_regs[GDB_VBR])); | 202 | return 0; |
182 | } | 203 | } |
183 | 204 | ||
184 | void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs) | 205 | char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs) |
185 | { | 206 | { |
186 | int i; | 207 | if (regno >= DBG_MAX_REG_NUM || regno < 0) |
208 | return NULL; | ||
187 | 209 | ||
188 | for (i = 0; i < 16; i++) | 210 | if (dbg_reg_def[regno].size != -1) |
189 | regs->regs[GDB_R0 + i] = gdb_regs[GDB_R0 + i]; | 211 | memcpy(mem, (void *)regs + dbg_reg_def[regno].offset, |
212 | dbg_reg_def[regno].size); | ||
213 | |||
214 | switch (regno) { | ||
215 | case GDB_VBR: | ||
216 | __asm__ __volatile__ ("stc vbr, %0" : "=r" (mem)); | ||
217 | break; | ||
218 | } | ||
190 | 219 | ||
191 | regs->pc = gdb_regs[GDB_PC]; | 220 | return dbg_reg_def[regno].name; |
192 | regs->pr = gdb_regs[GDB_PR]; | ||
193 | regs->sr = gdb_regs[GDB_SR]; | ||
194 | regs->gbr = gdb_regs[GDB_GBR]; | ||
195 | regs->mach = gdb_regs[GDB_MACH]; | ||
196 | regs->macl = gdb_regs[GDB_MACL]; | ||
197 | } | 221 | } |
198 | 222 | ||
199 | void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) | 223 | void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) |