Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFA: fix simulator's handling of exceptions
@ 2001-05-05 14:00 Jim Blandy
  2001-05-07 12:30 ` Andrew Cagney
  0 siblings, 1 reply; 2+ messages in thread
From: Jim Blandy @ 2001-05-05 14:00 UTC (permalink / raw)
  To: gdb-patches

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


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

* Re: RFA: fix simulator's handling of exceptions
  2001-05-05 14:00 RFA: fix simulator's handling of exceptions Jim Blandy
@ 2001-05-07 12:30 ` Andrew Cagney
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cagney @ 2001-05-07 12:30 UTC (permalink / raw)
  To: Jim Blandy; +Cc: gdb-patches

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.

I'm not sure this is correct.  The mn10300 doesn't have an operating 
environment (user/supervisor modes).  Have a look at either the d10v or 
the tx39.

In general what happens is:

	o	simulator encounters a breakpoint

	o	simulator saves all state relevant
		to the breakpoint in case it has
		to be delivered

	o	breakpoint encountered (SIGBREAK)
		returned to GDB

	o	GDB checks to see if it is a
		breakpoint on its breakpoint list.

	o	if it is.
		Process the breakpoint and then,
		later when the target is resumed,
		pass in 0 as the signal.

	o	if it isn't
		Depending on the current state of
		SIGBREAK (according to (gdb) handle?)
		possibly resume the target with
		SIGBREAK as the signal.  The target
		simulator should then use that saved
		breakpoint state to deliver a breakpoint
		interrupt to the target.

Andrew


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

end of thread, other threads:[~2001-05-07 12:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-05 14:00 RFA: fix simulator's handling of exceptions Jim Blandy
2001-05-07 12:30 ` Andrew Cagney

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