forked from luck/tmp_suning_uos_patched
sh: kgdb: Individual register get/set support.
This updates sh following the generic kgdb changes adding support for individual register get/set for kgdb/kdb use. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
This commit is contained in:
parent
14f087d839
commit
fd03e81812
|
@ -4,18 +4,6 @@
|
||||||
#include <asm/cacheflush.h>
|
#include <asm/cacheflush.h>
|
||||||
#include <asm/ptrace.h>
|
#include <asm/ptrace.h>
|
||||||
|
|
||||||
/* Same as pt_regs but has vbr in place of syscall_nr */
|
|
||||||
struct kgdb_regs {
|
|
||||||
unsigned long regs[16];
|
|
||||||
unsigned long pc;
|
|
||||||
unsigned long pr;
|
|
||||||
unsigned long sr;
|
|
||||||
unsigned long gbr;
|
|
||||||
unsigned long mach;
|
|
||||||
unsigned long macl;
|
|
||||||
unsigned long vbr;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum regnames {
|
enum regnames {
|
||||||
GDB_R0, GDB_R1, GDB_R2, GDB_R3, GDB_R4, GDB_R5, GDB_R6, GDB_R7,
|
GDB_R0, GDB_R1, GDB_R2, GDB_R3, GDB_R4, GDB_R5, GDB_R6, GDB_R7,
|
||||||
GDB_R8, GDB_R9, GDB_R10, GDB_R11, GDB_R12, GDB_R13, GDB_R14, GDB_R15,
|
GDB_R8, GDB_R9, GDB_R10, GDB_R11, GDB_R12, GDB_R13, GDB_R14, GDB_R15,
|
||||||
|
@ -23,7 +11,12 @@ enum regnames {
|
||||||
GDB_PC, GDB_PR, GDB_SR, GDB_GBR, GDB_MACH, GDB_MACL, GDB_VBR,
|
GDB_PC, GDB_PR, GDB_SR, GDB_GBR, GDB_MACH, GDB_MACL, GDB_VBR,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUMREGBYTES ((GDB_VBR + 1) * 4)
|
#define _GP_REGS 16
|
||||||
|
#define _EXTRA_REGS 7
|
||||||
|
#define GDB_SIZEOF_REG sizeof(u32)
|
||||||
|
|
||||||
|
#define DBG_MAX_REG_NUM (_GP_REGS + _EXTRA_REGS)
|
||||||
|
#define NUMREGBYTES (DBG_MAX_REG_NUM * sizeof(GDB_SIZEOF_REG))
|
||||||
|
|
||||||
static inline void arch_kgdb_breakpoint(void)
|
static inline void arch_kgdb_breakpoint(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* SuperH KGDB support
|
* SuperH KGDB support
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008 - 2009 Paul Mundt
|
* Copyright (C) 2008 - 2012 Paul Mundt
|
||||||
*
|
*
|
||||||
* Single stepping taken from the old stub by Henry Bell and Jeremy Siegel.
|
* Single stepping taken from the old stub by Henry Bell and Jeremy Siegel.
|
||||||
*
|
*
|
||||||
|
@ -164,36 +164,60 @@ static void undo_single_step(struct pt_regs *linux_regs)
|
||||||
stepped_opcode = 0;
|
stepped_opcode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
|
struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = {
|
||||||
|
{ "r0", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[0]) },
|
||||||
|
{ "r1", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[1]) },
|
||||||
|
{ "r2", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[2]) },
|
||||||
|
{ "r3", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[3]) },
|
||||||
|
{ "r4", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[4]) },
|
||||||
|
{ "r5", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[5]) },
|
||||||
|
{ "r6", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[6]) },
|
||||||
|
{ "r7", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[7]) },
|
||||||
|
{ "r8", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[8]) },
|
||||||
|
{ "r9", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[9]) },
|
||||||
|
{ "r10", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[10]) },
|
||||||
|
{ "r11", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[11]) },
|
||||||
|
{ "r12", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[12]) },
|
||||||
|
{ "r13", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[13]) },
|
||||||
|
{ "r14", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[14]) },
|
||||||
|
{ "r15", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[15]) },
|
||||||
|
{ "pc", GDB_SIZEOF_REG, offsetof(struct pt_regs, pc) },
|
||||||
|
{ "pr", GDB_SIZEOF_REG, offsetof(struct pt_regs, pr) },
|
||||||
|
{ "sr", GDB_SIZEOF_REG, offsetof(struct pt_regs, sr) },
|
||||||
|
{ "gbr", GDB_SIZEOF_REG, offsetof(struct pt_regs, gbr) },
|
||||||
|
{ "mach", GDB_SIZEOF_REG, offsetof(struct pt_regs, mach) },
|
||||||
|
{ "macl", GDB_SIZEOF_REG, offsetof(struct pt_regs, macl) },
|
||||||
|
{ "vbr", GDB_SIZEOF_REG, -1 },
|
||||||
|
};
|
||||||
|
|
||||||
|
int dbg_set_reg(int regno, void *mem, struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
int i;
|
if (regno < 0 || regno >= DBG_MAX_REG_NUM)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
if (dbg_reg_def[regno].offset != -1)
|
||||||
gdb_regs[GDB_R0 + i] = regs->regs[i];
|
memcpy((void *)regs + dbg_reg_def[regno].offset, mem,
|
||||||
|
dbg_reg_def[regno].size);
|
||||||
|
|
||||||
gdb_regs[GDB_PC] = regs->pc;
|
return 0;
|
||||||
gdb_regs[GDB_PR] = regs->pr;
|
|
||||||
gdb_regs[GDB_SR] = regs->sr;
|
|
||||||
gdb_regs[GDB_GBR] = regs->gbr;
|
|
||||||
gdb_regs[GDB_MACH] = regs->mach;
|
|
||||||
gdb_regs[GDB_MACL] = regs->macl;
|
|
||||||
|
|
||||||
__asm__ __volatile__ ("stc vbr, %0" : "=r" (gdb_regs[GDB_VBR]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs)
|
char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
int i;
|
if (regno >= DBG_MAX_REG_NUM || regno < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
if (dbg_reg_def[regno].size != -1)
|
||||||
regs->regs[GDB_R0 + i] = gdb_regs[GDB_R0 + i];
|
memcpy(mem, (void *)regs + dbg_reg_def[regno].offset,
|
||||||
|
dbg_reg_def[regno].size);
|
||||||
|
|
||||||
regs->pc = gdb_regs[GDB_PC];
|
switch (regno) {
|
||||||
regs->pr = gdb_regs[GDB_PR];
|
case GDB_VBR:
|
||||||
regs->sr = gdb_regs[GDB_SR];
|
__asm__ __volatile__ ("stc vbr, %0" : "=r" (mem));
|
||||||
regs->gbr = gdb_regs[GDB_GBR];
|
break;
|
||||||
regs->mach = gdb_regs[GDB_MACH];
|
}
|
||||||
regs->macl = gdb_regs[GDB_MACL];
|
|
||||||
|
return dbg_reg_def[regno].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
|
void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user