From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jim Blandy To: gdb-patches@sources.redhat.com Subject: RFA: fix simulator's handling of exceptions Date: Sat, 05 May 2001 14:00:00 -0000 Message-id: <20010505210130.9FD755E9D5@zwingli.cygnus.com> X-SW-Source: 2001-05/msg00060.html 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 * 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);