This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA/ARM: Switch mode when setting PC


On Fri, Jan 16, 2004 at 02:14:56PM +0000, Richard Earnshaw wrote:
> Unless the "Thumb bit" is being stripped out by GDB, then I suspect that 
> this is a bug in the gdb/simulator binding layer.  Any attempt to force 
> the PC value by the debugger should be taken as a potential state change.  
> If that is not happening, then all sorts of things may not work.
> 
> I've suspected that there is a problem in the way that gdb drives the 
> simulator for a while now.

My understanding of the ARM architecture is of somewhat recent vintage,
so the following may be a load of crap.  For unrelated reasons I can't
test this in hardware yet.

The bx instruction sets the PC register to reg & 0xfffffffe.  It uses
reg & 0x1 to set the T bit.  So the value that gets written into the PC
register has its low bit clear, and the CPSR gets updated.  The low bit
of the actual PC register is ignored.  Isn't that correct?

If so, I think the interface is fine.  Certainly it corresponds to how
ptrace behaves on Linux; the value specified for the PC is written
directly to the PC, not parsed for the T bit.  If you want to change
the T bit, write to the CPSR.

Right now the address of a Thumb function is marked in the symbol table
by the msymbol "special" flag, not in the low bit of the address.  The
address points at the actual beginning of the instruction, so that's
what GDB writes into $pc.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]