Hi,
The previous version of 'kgdb' will not read the Nios's registers r17~r23.
http://www.alteraforum.com/forum/showpost.php?p=77003&postcount=20 But the kernel sometimes uses those for the locations of its local variables, so we must read and write the registers r17~r23. To do this, please add codes to the file 'entry.S'
handle_diverror:
call handle_illegal_c
br ret_from_exception
# ifdef CONFIG_KGDB
handle_kgdb_breakpoint:
SAVE_SWITCH_STACK // <-- Add this.
call kgdb_breakpoint_c
RESTORE_SWITCH_STACK // <-- Add this.
br ret_from_exception# endif
and modify the file 'kgdb.c' of the nios arch like
void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
{
gdb_regs = 0;
gdb_regs = regs->r1;
gdb_regs = regs->r2;
gdb_regs = regs->r3;
gdb_regs = regs->r4;
gdb_regs = regs->r5;
gdb_regs = regs->r6;
gdb_regs = regs->r7;
gdb_regs = regs->r8;
gdb_regs = regs->r9;
gdb_regs = regs->r10;
gdb_regs = regs->r11;
gdb_regs = regs->r12;
gdb_regs = regs->r13;
gdb_regs = regs->r14;
gdb_regs = regs->r15;
gdb_regs = regs->ra;
gdb_regs = regs->fp;
gdb_regs = regs->sp;
gdb_regs = regs->gp;
gdb_regs = regs->estatus;
gdb_regs = regs->ea;
gdb_regs = regs->ea;
{
struct switch_stack *swregs = (struct switch_stack *)regs;
swregs--;
gdb_regs = swregs->r16;
gdb_regs = swregs->r17;
gdb_regs = swregs->r18;
gdb_regs = swregs->r19;
gdb_regs = swregs->r20;
gdb_regs = swregs->r21;
gdb_regs = swregs->r22;
gdb_regs = swregs->r23;
}
}
void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs)
{
regs->r1 = gdb_regs;
regs->r2 = gdb_regs;
regs->r3 = gdb_regs;
regs->r4 = gdb_regs;
regs->r5 = gdb_regs;
regs->r6 = gdb_regs;
regs->r7 = gdb_regs;
regs->r8 = gdb_regs;
regs->r9 = gdb_regs;
regs->r10 = gdb_regs;
regs->r11 = gdb_regs;
regs->r12 = gdb_regs;
regs->r13 = gdb_regs;
regs->r14 = gdb_regs;
regs->r15 = gdb_regs;
regs->ra = gdb_regs;
regs->fp = gdb_regs;
regs->sp = gdb_regs;
regs->gp = gdb_regs;
regs->estatus = gdb_regs;
regs->ea = gdb_regs;
{
struct switch_stack *swregs = (struct switch_stack *)regs;
swregs--;
swregs->r16 = gdb_regs;
swregs->r17 = gdb_regs;
swregs->r18 = gdb_regs;
swregs->r19 = gdb_regs;
swregs->r20 = gdb_regs;
swregs->r21 = gdb_regs;
swregs->r22 = gdb_regs;
swregs->r23 = gdb_regs;
}
}
.
Kazu