Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@zwingli.cygnus.com>
To: gdb-patches@sources.redhat.com
Subject: RFA: fix simulator's handling of exceptions
Date: Sat, 05 May 2001 14:00:00 -0000	[thread overview]
Message-ID: <20010505210130.9FD755E9D5@zwingli.cygnus.com> (raw)

This patch could be totally inept, but with luck, you can see what I
have in mind.  Please clue me in.

2001-05-05  Jim Blandy  <jimb@redhat.com>

	* interp.c (program_interrupt): Don't try to emulate the
	processor's behavior when it hits a breakpoint, unless we're
	in the OPERATING_ENVIRONMENT. 

Index: sim/mn10300/interp.c
===================================================================
RCS file: /cvs/cvsfiles/devo/sim/mn10300/interp.c,v
retrieving revision 1.48
diff -c -r1.48 interp.c
*** sim/mn10300/interp.c	2000/05/29 18:53:02	1.48
--- sim/mn10300/interp.c	2001/05/05 20:58:50
***************
*** 1348,1376 ****
  
    /* avoid infinite recursion */
    if (in_interrupt)
      {
-       (*mn10300_callback->printf_filtered) (mn10300_callback, 
- 					    "ERROR: recursion in program_interrupt during software exception dispatch.");
-     }
-   else
-     {
-       in_interrupt = 1;
        /* copy NMI handler code from dv-mn103cpu.c */
        store_word (SP - 4, CIA_GET (cpu));
        store_half (SP - 8, PSW);
  
        /* Set the SYSEF flag in NMICR by backdoor method.  See
! 	 dv-mn103int.c:write_icr().  This is necessary because
           software exceptions are not modelled by actually talking to
           the interrupt controller, so it cannot set its own SYSEF
           flag. */
!      if ((NULL != board) && (strcmp(board, BOARD_AM32) == 0))
!        store_byte (0x34000103, 0x04);
!     }
  
!   PSW &= ~PSW_IE;
!   SP = SP - 8;
!   CIA_SET (cpu, 0x40000008);
  
    in_interrupt = 0;
    sim_engine_halt(sd, cpu, NULL, cia, sim_stopped, sig);
--- 1348,1382 ----
  
    /* avoid infinite recursion */
    if (in_interrupt)
+     (*mn10300_callback->printf_filtered) (mn10300_callback, 
+                                           "ERROR: recursion in program_interrupt during software exception dispatch.");
+ 
+   in_interrupt = 1;
+ 
+   /* Don't try to simulate the processor's response to the interrupt,
+      unless we're in OPERATING_ENVIRONMENT, where the sim is
+      explicitly responsible for such things.  When running under GDB,
+      we don't actually need this behavior, and if our SP is garbage,
+      the stores can raise exceptions of their own that mask the
+      underlying interrupt.  */
+   if (STATE_ENVIRONMENT (sd) == OPERATING_ENVIRONMENT)
      {
        /* copy NMI handler code from dv-mn103cpu.c */
        store_word (SP - 4, CIA_GET (cpu));
        store_half (SP - 8, PSW);
  
        /* Set the SYSEF flag in NMICR by backdoor method.  See
!          dv-mn103int.c:write_icr().  This is necessary because
           software exceptions are not modelled by actually talking to
           the interrupt controller, so it cannot set its own SYSEF
           flag. */
!       if ((NULL != board) && (strcmp(board, BOARD_AM32) == 0))
!         store_byte (0x34000103, 0x04);
  
!       PSW &= ~PSW_IE;
!       SP = SP - 8;
!       CIA_SET (cpu, 0x40000008);
!     }
  
    in_interrupt = 0;
    sim_engine_halt(sd, cpu, NULL, cia, sim_stopped, sig);


             reply	other threads:[~2001-05-05 14:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-05 14:00 Jim Blandy [this message]
2001-05-07 12:30 ` 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=20010505210130.9FD755E9D5@zwingli.cygnus.com \
    --to=jimb@zwingli.cygnus.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