2005-11-28 Mark Mitchell * remote-sim.c (gdbsim_wait): Pass target signal numbers to sim_resume. Expect target signal numbers from sim_stop_reason. 2005-11-23 Mark Mitchell * wrapper.c (gdb/signals.h): Include it. (SIGTRAP): Don't define. (SIGBUS): Likewise. (sim_stop_reason): Use TARGET_SIGNAL_* instead of SIG*. 2005-11-28 Mark Mitchell * sim-reason.c (sim_stop_reason): Use sim_signal_to_target, not sim_signal_to_host. * sim-signal.c (sim_signal_to_host): Fix typo. (sim_signal_to_target): New function. 2005-11-28 Mark Mitchell * interp.c (gdb/signals.h): Include it. (sim_stop_reason): Use TARGET_SIGNAL_*. 2005-11-28 Mark Mitchell * interf.c: (gdb/signals.h): Include it. (sim_stop_reason): Use TARGET_SIGNAL_*. 2005-11-28 Mark Mitchell * sim_calls.c (gdb/signals.h): Include it. (sim_stop_reason): Use TARGET_SIGNAL_*. * psim.c (cntrl_c_simulation): Use TARGET_SIGNAL_*. Index: gdb/remote-sim.c =================================================================== RCS file: /cvs/src/src/gdb/remote-sim.c,v retrieving revision 1.49 diff -c -5 -p -r1.49 remote-sim.c *** gdb/remote-sim.c 19 Jun 2005 20:08:37 -0000 1.49 --- gdb/remote-sim.c 28 Nov 2005 18:29:28 -0000 *************** gdbsim_wait (ptid_t ptid, struct target_ *** 672,683 **** prev_sigint = osa.sa_handler; } #else prev_sigint = signal (SIGINT, gdbsim_cntrl_c); #endif ! sim_resume (gdbsim_desc, resume_step, ! target_signal_to_host (resume_siggnal)); signal (SIGINT, prev_sigint); resume_step = 0; sim_stop_reason (gdbsim_desc, &reason, &sigrc); --- 672,682 ---- prev_sigint = osa.sa_handler; } #else prev_sigint = signal (SIGINT, gdbsim_cntrl_c); #endif ! sim_resume (gdbsim_desc, resume_step, resume_siggnal); signal (SIGINT, prev_sigint); resume_step = 0; sim_stop_reason (gdbsim_desc, &reason, &sigrc); *************** gdbsim_wait (ptid_t ptid, struct target_ *** 688,715 **** status->value.integer = sigrc; break; case sim_stopped: switch (sigrc) { ! case SIGABRT: quit (); break; ! case SIGINT: ! case SIGTRAP: default: status->kind = TARGET_WAITKIND_STOPPED; ! /* The signal in sigrc is a host signal. That probably ! should be fixed. */ ! status->value.sig = target_signal_from_host (sigrc); break; } break; case sim_signalled: status->kind = TARGET_WAITKIND_SIGNALLED; ! /* The signal in sigrc is a host signal. That probably ! should be fixed. */ ! status->value.sig = target_signal_from_host (sigrc); break; case sim_running: case sim_polling: /* FIXME: Is this correct? */ break; --- 687,710 ---- status->value.integer = sigrc; break; case sim_stopped: switch (sigrc) { ! case TARGET_SIGNAL_ABRT: quit (); break; ! case TARGET_SIGNAL_INT: ! case TARGET_SIGNAL_TRAP: default: status->kind = TARGET_WAITKIND_STOPPED; ! status->value.sig = sigrc; break; } break; case sim_signalled: status->kind = TARGET_WAITKIND_SIGNALLED; ! status->value.sig = sigrc; break; case sim_running: case sim_polling: /* FIXME: Is this correct? */ break; Index: sim/arm/wrapper.c =================================================================== RCS file: /cvs/src/src/sim/arm/wrapper.c,v retrieving revision 1.30 diff -c -5 -p -r1.30 wrapper.c *** sim/arm/wrapper.c 12 May 2005 07:36:59 -0000 1.30 --- sim/arm/wrapper.c 28 Nov 2005 18:29:29 -0000 *************** *** 35,52 **** #include "dbg_rdi.h" #include "ansidecl.h" #include "sim-utils.h" #include "run-sim.h" #include "gdb/sim-arm.h" ! ! #ifndef SIGTRAP ! #define SIGTRAP 5 ! #endif ! ! #ifndef SIGBUS ! #define SIGBUS SIGSEGV ! #endif host_callback *sim_callback; static struct ARMul_State *state; --- 35,45 ---- #include "dbg_rdi.h" #include "ansidecl.h" #include "sim-utils.h" #include "run-sim.h" #include "gdb/sim-arm.h" ! #include "gdb/signals.h" host_callback *sim_callback; static struct ARMul_State *state; *************** sim_stop_reason (sd, reason, sigrc) *** 908,932 **** int *sigrc; { if (stop_simulator) { *reason = sim_stopped; ! *sigrc = SIGINT; } else if (state->EndCondition == 0) { *reason = sim_exited; *sigrc = state->Reg[0] & 255; } else { *reason = sim_stopped; if (state->EndCondition == RDIError_BreakpointReached) ! *sigrc = SIGTRAP; else if ( state->EndCondition == RDIError_DataAbort || state->EndCondition == RDIError_AddressException) ! *sigrc = SIGBUS; else *sigrc = 0; } } --- 901,925 ---- int *sigrc; { if (stop_simulator) { *reason = sim_stopped; ! *sigrc = TARGET_SIGNAL_INT; } else if (state->EndCondition == 0) { *reason = sim_exited; *sigrc = state->Reg[0] & 255; } else { *reason = sim_stopped; if (state->EndCondition == RDIError_BreakpointReached) ! *sigrc = TARGET_SIGNAL_TRAP; else if ( state->EndCondition == RDIError_DataAbort || state->EndCondition == RDIError_AddressException) ! *sigrc = TARGET_SIGNAL_BUS; else *sigrc = 0; } } Index: sim/common/sim-reason.c =================================================================== RCS file: /cvs/src/src/sim/common/sim-reason.c,v retrieving revision 1.1.1.1 diff -c -5 -p -r1.1.1.1 sim-reason.c *** sim/common/sim-reason.c 16 Apr 1999 01:34:58 -0000 1.1.1.1 --- sim/common/sim-reason.c 28 Nov 2005 18:29:31 -0000 *************** sim_stop_reason (SIM_DESC sd, enum sim_s *** 33,57 **** switch (*reason) { case sim_exited : *sigrc = engine->sigrc; break; - case sim_signalled : - /* ??? See the comment below case `sim_signalled' in - gdb/remote-sim.c:gdbsim_wait. - ??? Consider the case of the target requesting that it - kill(2) itself with SIGNAL. That SIGNAL, being target - specific, will not correspond to either of the SIM_SIGNAL - enum nor the HOST_SIGNAL. A mapping from TARGET_SIGNAL to - HOST_SIGNAL is needed. */ - *sigrc = sim_signal_to_host (sd, engine->sigrc); - break; case sim_stopped : ! /* The gdb/simulator interface calls for us to return the host ! version of the signal which gdb then converts into the ! target's version. This is obviously a bit clumsy. */ ! *sigrc = sim_signal_to_host (sd, engine->sigrc); break; default : abort (); } } --- 33,45 ---- switch (*reason) { case sim_exited : *sigrc = engine->sigrc; break; case sim_stopped : ! case sim_signalled : ! *sigrc = sim_signal_to_target (sd, engine->sigrc); break; default : abort (); } } Index: sim/common/sim-signal.c =================================================================== RCS file: /cvs/src/src/sim/common/sim-signal.c,v retrieving revision 1.1.1.1 diff -c -5 -p -r1.1.1.1 sim-signal.c *** sim/common/sim-signal.c 16 Apr 1999 01:34:59 -0000 1.1.1.1 --- sim/common/sim-signal.c 28 Nov 2005 18:29:31 -0000 *************** sim_signal_to_host (SIM_DESC sd, SIM_SIG *** 75,85 **** return SIGXCPU; #endif break; case SIM_SIGFPE: ! #ifdef SIGXCPU return SIGFPE; #endif break; case SIM_SIGNONE: --- 75,85 ---- return SIGXCPU; #endif break; case SIM_SIGFPE: ! #ifdef SIGFPE return SIGFPE; #endif break; case SIM_SIGNONE: *************** sim_signal_to_host (SIM_DESC sd, SIM_SIG *** 92,96 **** --- 92,135 ---- return SIGHUP; /* FIXME: Suggestions? */ #else return 1; #endif } + + int + sim_signal_to_target (SIM_DESC sd, SIM_SIGNAL sig) + { + switch (sig) + { + case SIM_SIGINT : + return TARGET_SIGNAL_INT; + + case SIM_SIGABRT : + return TARGET_SIGNAL_ABRT; + + case SIM_SIGILL : + return TARGET_SIGNAL_ILL; + + case SIM_SIGTRAP : + return TARGET_SIGNAL_TRAP; + + case SIM_SIGBUS : + return TARGET_SIGNAL_BUS; + + case SIM_SIGSEGV + return TARGET_SIGNAL_SEGV; + + case SIM_SIGXCPU : + return TARGET_SIGNAL_XCPU; + + case SIM_SIGFPE: + return TARGET_SIGNAL_FPE; + break; + + case SIM_SIGNONE: + return TARGET_SIGNAL_0; + break; + } + + sim_io_eprintf (sd, "sim_signal_to_host: unknown signal: %d\n", sig); + return TARGET_SIGNAL_HUP; + } Index: sim/common/sim-signal.h =================================================================== RCS file: /cvs/src/src/sim/common/sim-signal.h,v retrieving revision 1.1.1.1 diff -c -5 -p -r1.1.1.1 sim-signal.h *** sim/common/sim-signal.h 16 Apr 1999 01:34:59 -0000 1.1.1.1 --- sim/common/sim-signal.h 28 Nov 2005 18:29:31 -0000 *************** with this program; if not, write to the *** 19,28 **** --- 19,30 ---- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef SIM_SIGNAL_H #define SIM_SIGNAL_H + #include "gdb/signals.h" + /* Signals we use. This provides a layer between our values and host/target values. */ typedef enum { SIM_SIGNONE = 64, *************** typedef enum { *** 43,49 **** --- 45,52 ---- /* simulation aborted */ SIM_SIGABRT } SIM_SIGNAL; int sim_signal_to_host (SIM_DESC sd, SIM_SIGNAL); + enum target_signal sim_signal_to_target (SIM_DESC sd, SIM_SIGNAL); #endif /* SIM_SIGNAL_H */ Index: sim/d10v/interp.c =================================================================== RCS file: /cvs/src/src/sim/d10v/interp.c,v retrieving revision 1.16 diff -c -5 -p -r1.16 interp.c *** sim/d10v/interp.c 29 Jun 2004 00:54:00 -0000 1.16 --- sim/d10v/interp.c 28 Nov 2005 18:29:31 -0000 *************** *** 4,13 **** --- 4,14 ---- #include "gdb/callback.h" #include "gdb/remote-sim.h" #include "d10v_sim.h" #include "gdb/sim-d10v.h" + #include "gdb/signals.h" enum _leftright { LEFT_FIRST, RIGHT_FIRST }; static char *myname; static SIM_OPEN_KIND sim_kind; *************** sim_stop_reason (sd, reason, sigrc) *** 1275,1295 **** *sigrc = GPR (0); break; case SIG_D10V_BUS: *reason = sim_stopped; ! #ifdef SIGBUS ! *sigrc = SIGBUS; ! #else ! *sigrc = SIGSEGV; ! #endif break; default: /* some signal */ *reason = sim_stopped; if (stop_simulator && !State.exception) ! *sigrc = SIGINT; else *sigrc = State.exception; break; } --- 1276,1292 ---- *sigrc = GPR (0); break; case SIG_D10V_BUS: *reason = sim_stopped; ! *reson = TARGET_SIGNAL_BUS; break; default: /* some signal */ *reason = sim_stopped; if (stop_simulator && !State.exception) ! *sigrc = TARGET_SIGNAL_INT; else *sigrc = State.exception; break; } Index: sim/erc32/interf.c =================================================================== RCS file: /cvs/src/src/sim/erc32/interf.c,v retrieving revision 1.5 diff -c -5 -p -r1.5 interf.c *** sim/erc32/interf.c 7 Mar 2005 11:09:05 -0000 1.5 --- sim/erc32/interf.c 28 Nov 2005 18:29:31 -0000 *************** *** 31,40 **** --- 31,41 ---- #include "bfd.h" #include #include "sim-config.h" #include "gdb/remote-sim.h" + #include "gdb/signals.h" #define PSR_CWP 0x7 #define VAL(x) strtol(x,(char **)NULL,0) *************** sim_stop_reason(sd, reason, sigrc) *** 384,403 **** { switch (simstat) { case CTRL_C: *reason = sim_stopped; ! *sigrc = SIGINT; break; case OK: case TIME_OUT: case BPT_HIT: *reason = sim_stopped; ! #ifdef _WIN32 ! #define SIGTRAP 5 ! #endif ! *sigrc = SIGTRAP; break; case ERROR: *sigrc = 0; *reason = sim_exited; } --- 385,401 ---- { switch (simstat) { case CTRL_C: *reason = sim_stopped; ! *sigrc = TARGET_SIGNAL_INT; break; case OK: case TIME_OUT: case BPT_HIT: *reason = sim_stopped; ! *sigrc = TARGET_SIGNAL_TRAP; break; case ERROR: *sigrc = 0; *reason = sim_exited; } Index: sim/ppc/psim.c =================================================================== RCS file: /cvs/src/src/sim/ppc/psim.c,v retrieving revision 1.5 diff -c -5 -p -r1.5 psim.c *** sim/ppc/psim.c 20 Apr 2005 22:33:08 -0000 1.5 --- sim/ppc/psim.c 28 Nov 2005 18:29:32 -0000 *************** cntrl_c_simulation(void *data) *** 570,580 **** { psim *system = data; psim_halt(system, psim_nr_cpus(system), was_continuing, ! SIGINT); } INLINE_PSIM\ (void) psim_stop(psim *system) --- 570,580 ---- { psim *system = data; psim_halt(system, psim_nr_cpus(system), was_continuing, ! TARGET_SIGNAL_INT); } INLINE_PSIM\ (void) psim_stop(psim *system) Index: sim/ppc/sim_calls.c =================================================================== RCS file: /cvs/src/src/sim/ppc/sim_calls.c,v retrieving revision 1.11 diff -c -5 -p -r1.11 sim_calls.c *** sim/ppc/sim_calls.c 11 Nov 2004 21:58:57 -0000 1.11 --- sim/ppc/sim_calls.c 28 Nov 2005 18:29:32 -0000 *************** *** 42,51 **** --- 42,52 ---- #include "libiberty.h" #include "bfd.h" #include "gdb/callback.h" #include "gdb/remote-sim.h" + #include "gdb/signals.h" /* Define the rate at which the simulator should poll the host for a quit. */ #ifndef POLL_QUIT_INTERVAL #define POLL_QUIT_INTERVAL 0x20 *************** sim_stop_reason (SIM_DESC sd, enum sim_s *** 195,211 **** switch (status.reason) { case was_continuing: *reason = sim_stopped; if (status.signal == 0) ! *sigrc = SIGTRAP; else *sigrc = status.signal; break; case was_trap: *reason = sim_stopped; ! *sigrc = SIGTRAP; break; case was_exited: *reason = sim_exited; *sigrc = status.signal; break; --- 196,212 ---- switch (status.reason) { case was_continuing: *reason = sim_stopped; if (status.signal == 0) ! *sigrc = TARGET_SIGNAL_TRAP; else *sigrc = status.signal; break; case was_trap: *reason = sim_stopped; ! *sigrc = TARGET_SIGNAL_TRAP; break; case was_exited: *reason = sim_exited; *sigrc = status.signal; break;