From: Mark Mitchell Date: Mon, 28 Nov 2005 18:33:03 +0000 (+0000) Subject: * remote-sim.c (gdbsim_wait): Pass target signal numbers to X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aba6488e0b73756f31f154d12a228baa82a68d8a;p=binutils-gdb.git * remote-sim.c (gdbsim_wait): Pass target signal numbers to sim_resume. Expect target signal numbers from sim_stop_reason. * wrapper.c (gdb/signals.h): Include it. (SIGTRAP): Don't define. (SIGBUS): Likewise. (sim_stop_reason): Use TARGET_SIGNAL_* instead of SIG*. * 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. * interp.c (gdb/signals.h): Include it. (sim_stop_reason): Use TARGET_SIGNAL_*. * interf.c: (gdb/signals.h): Include it. (sim_stop_reason): Use TARGET_SIGNAL_*. * sim_calls.c (gdb/signals.h): Include it. (sim_stop_reason): Use TARGET_SIGNAL_*. * psim.c (cntrl_c_simulation): Use TARGET_SIGNAL_*. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2246d8dddcd..d630731680a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +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-27 Christopher Faylor * win32-nat.c (env_sort): New function. diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 6341b3c07f6..e6fc0bdd0e1 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -674,8 +674,7 @@ gdbsim_wait (ptid_t ptid, struct target_waitstatus *status) #else prev_sigint = signal (SIGINT, gdbsim_cntrl_c); #endif - sim_resume (gdbsim_desc, resume_step, - target_signal_to_host (resume_siggnal)); + sim_resume (gdbsim_desc, resume_step, resume_siggnal); signal (SIGINT, prev_sigint); resume_step = 0; @@ -690,24 +689,20 @@ gdbsim_wait (ptid_t ptid, struct target_waitstatus *status) case sim_stopped: switch (sigrc) { - case SIGABRT: + case TARGET_SIGNAL_ABRT: quit (); break; - case SIGINT: - case SIGTRAP: + case TARGET_SIGNAL_INT: + case TARGET_SIGNAL_TRAP: 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); + status->value.sig = 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); + status->value.sig = sigrc; break; case sim_running: case sim_polling: diff --git a/sim/arm/ChangeLog b/sim/arm/ChangeLog index 0e32a659025..84bdf6ecf65 100644 --- a/sim/arm/ChangeLog +++ b/sim/arm/ChangeLog @@ -1,3 +1,10 @@ +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-16 Shaun Jackman * sim/arm/armos.c: Include limits.h diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c index 9736add9b11..4133110a54a 100644 --- a/sim/arm/wrapper.c +++ b/sim/arm/wrapper.c @@ -37,14 +37,7 @@ #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 +#include "gdb/signals.h" host_callback *sim_callback; @@ -910,7 +903,7 @@ sim_stop_reason (sd, reason, sigrc) if (stop_simulator) { *reason = sim_stopped; - *sigrc = SIGINT; + *sigrc = TARGET_SIGNAL_INT; } else if (state->EndCondition == 0) { @@ -921,10 +914,10 @@ sim_stop_reason (sd, reason, sigrc) { *reason = sim_stopped; if (state->EndCondition == RDIError_BreakpointReached) - *sigrc = SIGTRAP; + *sigrc = TARGET_SIGNAL_TRAP; else if ( state->EndCondition == RDIError_DataAbort || state->EndCondition == RDIError_AddressException) - *sigrc = SIGBUS; + *sigrc = TARGET_SIGNAL_BUS; else *sigrc = 0; } diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 5e4e5a48743..c27e7d7551d 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,10 @@ +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-07-10 Hans-Peter Nilsson * sim-load.c (xprintf, eprintf): Remove fallout from ANSI_PROTOTYPES diff --git a/sim/common/sim-reason.c b/sim/common/sim-reason.c index b540df32f6e..383df02fb88 100644 --- a/sim/common/sim-reason.c +++ b/sim/common/sim-reason.c @@ -35,21 +35,9 @@ sim_stop_reason (SIM_DESC sd, enum sim_stop *reason, int *sigrc) 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); + case sim_signalled : + *sigrc = sim_signal_to_target (sd, engine->sigrc); break; default : abort (); diff --git a/sim/common/sim-signal.c b/sim/common/sim-signal.c index 77709b17e7a..e8fd10cffee 100644 --- a/sim/common/sim-signal.c +++ b/sim/common/sim-signal.c @@ -77,7 +77,7 @@ sim_signal_to_host (SIM_DESC sd, SIM_SIGNAL sig) break; case SIM_SIGFPE: -#ifdef SIGXCPU +#ifdef SIGFPE return SIGFPE; #endif break; @@ -94,3 +94,42 @@ sim_signal_to_host (SIM_DESC sd, SIM_SIGNAL sig) 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; +} diff --git a/sim/common/sim-signal.h b/sim/common/sim-signal.h index 272e17dad05..8dd0d8f875c 100644 --- a/sim/common/sim-signal.h +++ b/sim/common/sim-signal.h @@ -21,6 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #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. */ @@ -45,5 +47,6 @@ typedef enum { } 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 */ diff --git a/sim/d10v/ChangeLog b/sim/d10v/ChangeLog index 6662d8b20f6..b1a5b54efce 100644 --- a/sim/d10v/ChangeLog +++ b/sim/d10v/ChangeLog @@ -1,3 +1,8 @@ +2005-11-28 Mark Mitchell + + * interp.c (gdb/signals.h): Include it. + (sim_stop_reason): Use TARGET_SIGNAL_*. + 2005-03-23 Mark Kettenis * configure: Regenerate. diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c index e4bae222eee..26f36ec5cf5 100644 --- a/sim/d10v/interp.c +++ b/sim/d10v/interp.c @@ -6,6 +6,7 @@ #include "d10v_sim.h" #include "gdb/sim-d10v.h" +#include "gdb/signals.h" enum _leftright { LEFT_FIRST, RIGHT_FIRST }; @@ -1277,17 +1278,13 @@ sim_stop_reason (sd, reason, sigrc) case SIG_D10V_BUS: *reason = sim_stopped; -#ifdef SIGBUS - *sigrc = SIGBUS; -#else - *sigrc = SIGSEGV; -#endif + *reson = TARGET_SIGNAL_BUS; break; default: /* some signal */ *reason = sim_stopped; if (stop_simulator && !State.exception) - *sigrc = SIGINT; + *sigrc = TARGET_SIGNAL_INT; else *sigrc = State.exception; break; diff --git a/sim/erc32/ChangeLog b/sim/erc32/ChangeLog index 7bf7bc2053f..4636b902dca 100644 --- a/sim/erc32/ChangeLog +++ b/sim/erc32/ChangeLog @@ -1,3 +1,8 @@ +2005-11-28 Mark Mitchell + + * interf.c: (gdb/signals.h): Include it. + (sim_stop_reason): Use TARGET_SIGNAL_*. + 2005-07-08 Ben Elliston * func.c: Remove ANSI_PROTOTYPES conditional code. diff --git a/sim/erc32/interf.c b/sim/erc32/interf.c index 3d535744d6a..fe075e1f286 100644 --- a/sim/erc32/interf.c +++ b/sim/erc32/interf.c @@ -33,6 +33,7 @@ #include "sim-config.h" #include "gdb/remote-sim.h" +#include "gdb/signals.h" #define PSR_CWP 0x7 @@ -386,16 +387,13 @@ sim_stop_reason(sd, reason, sigrc) switch (simstat) { case CTRL_C: *reason = sim_stopped; - *sigrc = SIGINT; + *sigrc = TARGET_SIGNAL_INT; break; case OK: case TIME_OUT: case BPT_HIT: *reason = sim_stopped; -#ifdef _WIN32 -#define SIGTRAP 5 -#endif - *sigrc = SIGTRAP; + *sigrc = TARGET_SIGNAL_TRAP; break; case ERROR: *sigrc = 0; diff --git a/sim/ppc/ChangeLog b/sim/ppc/ChangeLog index fe32804f21c..285cfa22237 100644 --- a/sim/ppc/ChangeLog +++ b/sim/ppc/ChangeLog @@ -1,3 +1,9 @@ +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_*. + 2005-07-15 Ben Elliston * hw_htab.c (bfd_get_section_lma): Remove macro; use BFD's. diff --git a/sim/ppc/psim.c b/sim/ppc/psim.c index a574fe77941..e2eac2a87c7 100644 --- a/sim/ppc/psim.c +++ b/sim/ppc/psim.c @@ -572,7 +572,7 @@ cntrl_c_simulation(void *data) psim_halt(system, psim_nr_cpus(system), was_continuing, - SIGINT); + TARGET_SIGNAL_INT); } INLINE_PSIM\ diff --git a/sim/ppc/sim_calls.c b/sim/ppc/sim_calls.c index 08feb39ab76..781ff055f5c 100644 --- a/sim/ppc/sim_calls.c +++ b/sim/ppc/sim_calls.c @@ -44,6 +44,7 @@ #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. */ @@ -197,13 +198,13 @@ sim_stop_reason (SIM_DESC sd, enum sim_stop *reason, int *sigrc) case was_continuing: *reason = sim_stopped; if (status.signal == 0) - *sigrc = SIGTRAP; + *sigrc = TARGET_SIGNAL_TRAP; else *sigrc = status.signal; break; case was_trap: *reason = sim_stopped; - *sigrc = SIGTRAP; + *sigrc = TARGET_SIGNAL_TRAP; break; case was_exited: *reason = sim_exited;