On Thu, 2007-02-15 at 22:22 +0300, Sergei Shtylyov wrote:
> Hello.
> 
> Kevin Hilman wrote:
> > Without the CPSR register, gdb is unable to correctly step over a
> > conditional branch.  This is because it cannot see the condition code
> > bits, and thus cannot determine which side of the branch to place the
> > breakpoint.
> 
> > This patch fixes the register layout of the registers passed to the host
> > gdb so that CPSR is properly interpreted.
> 
> > Index: linux-2.6.18/include/asm-arm/kgdb.h
> > ===================================================================
> > --- linux-2.6.18.orig/include/asm-arm/kgdb.h
> > +++ linux-2.6.18/include/asm-arm/kgdb.h
> > @@ -52,15 +52,27 @@ extern int kgdb_fault_expected;
> >  #endif /* !__ASSEMBLY__ */
> >  
> >  /*
> > - * From Amit S. Kale:
> > + * From Kevin Hilman:
> >   *
> > - * In the register packet, words 0-15 are R0 to R10, FP, IP, SP, LR, PC. 
> > But
> > - * Register 16 isn't cpsr. GDB passes CPSR in word 25. There are 9 words in
> > - * between which are unused. Passing only 26 words to gdb is sufficient.
> > - * GDB can figure out that floating point registers are not passed.
> > - * GDB_MAX_REGS should be 26.
> > + * gdb is expecting the following registers layout.
> > + *
> > + * r0-r15: 1 long word each
> > + * f0-f7:  unused, 3 long words each !!
> 
>     Now that's really strange. :-/

It's the NWFPE extended format.

> 
> > + * fps:    unused, 1 long word
> > + * cpsr:   1 long word
> > + *
> > + * Even though f0-f7 and fps are not used, they need to be
> > + * present in the registers sent for correct processing in
> > + * the host-side gdb.  
> > + *
> > + * In particular, it is crucial that CPSR is in the right place,
> > + * otherwise gdb will not be able to correctly interpret stepping over
> > + * conditional branches.
> >   */
> > -#define    GDB_MAX_REGS            (26)
> > +#define _GP_REGS           16
> > +#define _FP_REGS           8
> > +#define _EXTRA_REGS                2
> > +#define    GDB_MAX_REGS            (_GP_REGS + (_FP_REGS * 3) + 
> > _EXTRA_REGS)
> >  
> >  #define    KGDB_MAX_NO_CPUS        1
> >  #define    BUFMAX                  400
> > Index: linux-2.6.18/arch/arm/kernel/kgdb.c
> > ===================================================================
> > --- linux-2.6.18.orig/arch/arm/kernel/kgdb.c
> > +++ linux-2.6.18/arch/arm/kernel/kgdb.c
> > @@ -78,7 +78,7 @@ void gdb_regs_to_regs(unsigned long *gdb
> >     kernel_regs->ARM_sp = gdb_regs[_SP];
> >     kernel_regs->ARM_lr = gdb_regs[_LR];
> >     kernel_regs->ARM_pc = gdb_regs[_PC];
> > -   kernel_regs->ARM_cpsr = gdb_regs[GDB_MAX_REGS - 1];
> > +   kernel_regs->ARM_cpsr = gdb_regs[_CPSR];
> >  }
> 
>     It's not that this change matters, since _CPSR is still defined as 
> GDB_MAX_REGS-1. :-)

Right, but it's more readable, and consistent with the rest of the code.

Kevin



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Kgdb-bugreport mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

Reply via email to