Re: single stepping mips remote programs built with gcc 4.0

Daniel Jacobowitz
2005-11-17T20:23:29Z

On Thu, Nov 17, 2005 at 12:13:48PM -0800, Newman, Sarah R wrote:
> Hi, I have a version of gdb from CVS on 8/29/2005. I have configured with the target as mips-elf and the host as cygwin and I am using it to connect to a remote mips system. All of my programs I am trying to run remotely have been built with GCC 4+. I am single stepping through code where part of it consists of something like the following in the disassembly listing:
>
> 00003dac <initialize()>:
> 00003dac: 24040001 li a0,1
> 00003db0: 08000deb j 000037ac <setArraySize(int, int)>
> 00003db4: 24050001 li a1,1
>
> 00003db8 <getCurrentBuffer2(int&)>:
> 00003db8: 3c02bd00 lui v0,0xbd00
>
> When stopped at the beginning of the function, I can tell by looking
> at the remote protocol debug output that a breakpoint is being set in
> memory at the location of getCurrentBuffer2, not setArraySize. We
> suspect that this may have to do with GCC 4+ doing straight jumps to
> other functions and not jump and link followed by jump register to
> leave the function. Has anyone else encountered this or found a
> solution?

Could you please build a debuggable GDB binary, and trace through
mips32_next_pc? It looks like it should handle the 'j' instruction
just fine:

case 2: /* J */
case 3: /* JAL */
{
unsigned long reg;
reg = jtype_target (inst) << 2;
/* Upper four bits get never changed... */
pc = reg + ((pc + 4) & 0xf0000000);
}
break;

J and JAL share a format, so this should be correct. It's as if the
value GDB is extracting for the instruction is incorrect.

--
Daniel Jacobowitz
CodeSourcery, LLC