Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* v850 simulator patch for trap instruction
@ 2002-09-26 16:26 Jim Wilson
  2002-09-26 18:53 ` Andrew Cagney
  0 siblings, 1 reply; 2+ messages in thread
From: Jim Wilson @ 2002-09-26 16:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: wilson

The v850 architecture manual says that a trap instruction sets the pc to
0x40 or 0x50 depending on the trap code.  The v850 simulator is setting the
PC to a value 4 bytes too small.

Here is a simple example.
	.global _main
	.text
_main:
	trap 0x1
	.offset 0x40
	halt
If I assemble this testcase, and run it on the simuator with --trace, I get
insn:     0x000000 ---   _main          trap 1             - trap
insn:     0x00003c ---   _main          nop                - nop
insn:     0x00003e ---   _main          nop                - nop
insn:     0x000040 ---   _main          halt               - halt
program stopped with signal 5.

This shows that the simulator branches to the wrong address, since it
executed two nops before reaching the trap handler address.

This patch fixes the problem.  I have tested this with a gdb make check
and there are no regressions.

2002-09-26  Jim Wilson  <wilson@redhat.com>

	* simops (OP_10007E0): Don't subtract 4 from PC.

Index: simops.c
===================================================================
RCS file: /cvs/src/src/sim/v850/simops.c,v
retrieving revision 1.3
diff -p -r1.3 simops.c
*** simops.c	29 Aug 2002 16:59:20 -0000	1.3
--- simops.c	26 Sep 2002 23:17:47 -0000
*************** OP_10007E0 ()
*** 1880,1886 ****
        ECR |= 0x40 + OP[0];
        /* Flag that we are now doing exception processing.  */
        PSW |= PSW_EP | PSW_ID;
!       PC = ((OP[0] < 0x10) ? 0x40 : 0x50) - 4;
  
        return 0;
      }
--- 1880,1886 ----
        ECR |= 0x40 + OP[0];
        /* Flag that we are now doing exception processing.  */
        PSW |= PSW_EP | PSW_ID;
!       PC = (OP[0] < 0x10) ? 0x40 : 0x50;
  
        return 0;
      }



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: v850 simulator patch for trap instruction
  2002-09-26 16:26 v850 simulator patch for trap instruction Jim Wilson
@ 2002-09-26 18:53 ` Andrew Cagney
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cagney @ 2002-09-26 18:53 UTC (permalink / raw)
  To: Jim Wilson; +Cc: gdb-patches

> 2002-09-26  Jim Wilson  <wilson@redhat.com>
> 
> 	* simops (OP_10007E0): Don't subtract 4 from PC.
> 
Yep, ok.  Feel free to add yourself to gdb/MAINTAINERS file, under write 
after approval, as an obvious fix.

Andrew



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-09-27  1:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-26 16:26 v850 simulator patch for trap instruction Jim Wilson
2002-09-26 18:53 ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox