From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20898 invoked by alias); 26 Sep 2002 23:26:19 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 20888 invoked from network); 26 Sep 2002 23:26:18 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 26 Sep 2002 23:26:18 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu-dmz.redhat.com [172.16.52.200]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id g8QN89i27451 for ; Thu, 26 Sep 2002 19:08:09 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id g8QNQGl27998 for ; Thu, 26 Sep 2002 19:26:16 -0400 Received: from tonopah.toronto.redhat.com (tonopah.toronto.redhat.com [172.16.14.91]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id g8QNQEw17206; Thu, 26 Sep 2002 16:26:15 -0700 Received: (from wilson@localhost) by tonopah.toronto.redhat.com (8.11.6/8.11.6) id g8QNQDN17693; Thu, 26 Sep 2002 19:26:13 -0400 X-Authentication-Warning: tonopah.toronto.redhat.com: wilson set sender to wilson@redhat.com using -f To: gdb-patches@sources.redhat.com cc: wilson@redhat.com Subject: v850 simulator patch for trap instruction From: Jim Wilson Date: Thu, 26 Sep 2002 16:26:00 -0000 Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-09/txt/msg00651.txt.bz2 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 * 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; }