Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Wilson <wilson@redhat.com>
To: gdb-patches@sources.redhat.com
Cc: wilson@redhat.com
Subject: v850 simulator patch for trap instruction
Date: Thu, 26 Sep 2002 16:26:00 -0000	[thread overview]
Message-ID: <xwuit0s8h9m.fsf@tonopah.toronto.redhat.com> (raw)

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;
      }



             reply	other threads:[~2002-09-26 23:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-26 16:26 Jim Wilson [this message]
2002-09-26 18:53 ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xwuit0s8h9m.fsf@tonopah.toronto.redhat.com \
    --to=wilson@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox