* remote-sim.c (gdbsim_wait): Pass target signal numbers to
authorMark Mitchell <mark@codesourcery.com>
Mon, 28 Nov 2005 18:33:03 +0000 (18:33 +0000)
committerMark Mitchell <mark@codesourcery.com>
Mon, 28 Nov 2005 18:33:03 +0000 (18:33 +0000)
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_*.

15 files changed:
gdb/ChangeLog
gdb/remote-sim.c
sim/arm/ChangeLog
sim/arm/wrapper.c
sim/common/ChangeLog
sim/common/sim-reason.c
sim/common/sim-signal.c
sim/common/sim-signal.h
sim/d10v/ChangeLog
sim/d10v/interp.c
sim/erc32/ChangeLog
sim/erc32/interf.c
sim/ppc/ChangeLog
sim/ppc/psim.c
sim/ppc/sim_calls.c

index 2246d8dddcdcafdaf907da6df1a541e8a0f181e8..d630731680a1465b753364f538565a96f1f477c1 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-28  Mark Mitchell  <mark@codesourcery.com>
+
+       * 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  <cgf@timesys.com>
 
        * win32-nat.c (env_sort): New function.
index 6341b3c07f6d0cf3f408ce2ebcaf6221f1c92e16..e6fc0bdd0e1896fa6521c17e33c84e8f47c3d982 100644 (file)
@@ -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:
index 0e32a659025b76e78ee6d446328fc1e4a0c61a6c..84bdf6ecf65360c9d57ca07180c9b97731ea03ca 100644 (file)
@@ -1,3 +1,10 @@
+2005-11-23  Mark Mitchell  <mark@codesourcery.com>
+
+       * 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  <sjackman@gmail.com>
 
        * sim/arm/armos.c: Include limits.h
index 9736add9b11d70457e1d3fa7feafa05286518cb6..4133110a54a5e72ba54d7e3d537f23d83eab8949 100644 (file)
 #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;
     }
index 5e4e5a487430e5d5dc6e7db7a71eae9179c2e7b3..c27e7d7551db76c282497620f0da7deff5de0138 100644 (file)
@@ -1,3 +1,10 @@
+2005-11-28  Mark Mitchell  <mark@codesourcery.com>
+
+       * 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  <hp@bitrange.com>
 
        * sim-load.c (xprintf, eprintf): Remove fallout from ANSI_PROTOTYPES
index b540df32f6eb7668f4e03e33e6551f672d002937..383df02fb88b2fdb7c55883e1d2c48fd0c36a475 100644 (file)
@@ -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 ();
index 77709b17e7a2721ad448fb238a0fd48f4f420f08..e8fd10cffee28a0a987c43d9d636715857ea9c1f 100644 (file)
@@ -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;
+}
index 272e17dad0514ac0d4de1f4d95edc4c48770945a..8dd0d8f875c7ebc18f31218ab9e1e0450c292d1a 100644 (file)
@@ -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 */
index 6662d8b20f66f1067715338a4ab8cc83dd1fc903..b1a5b54efce940f5277658598f5e215bdc6da310 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-28  Mark Mitchell  <mark@codesourcery.com>
+
+       * interp.c (gdb/signals.h): Include it.
+       (sim_stop_reason): Use TARGET_SIGNAL_*.
+
 2005-03-23  Mark Kettenis  <kettenis@gnu.org>
 
        * configure: Regenerate.
index e4bae222eeee93bcd81fe6c39c779a57da39b7c8..26f36ec5cf58a0ea986cb13f0d6c5815e5a62e59 100644 (file)
@@ -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;
index 7bf7bc2053f59673762920bdec6b4cb5139f115f..4636b902dca4051aa94c8916f8afe2f2a9080453 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-28  Mark Mitchell  <mark@codesourcery.com>
+
+       * interf.c: (gdb/signals.h): Include it.
+       (sim_stop_reason): Use TARGET_SIGNAL_*.
+
 2005-07-08  Ben Elliston  <bje@au.ibm.com>
 
        * func.c: Remove ANSI_PROTOTYPES conditional code.
index 3d535744d6aa1dbdf0f4b89110dcfea96c647f87..fe075e1f286b23f2acb11158047ead2fe37dbf8f 100644 (file)
@@ -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;
index fe32804f21cf060ccc9bb6c6e38c23ef7a4e8c07..285cfa222370d5440627d782658b150fc7739b66 100644 (file)
@@ -1,3 +1,9 @@
+2005-11-28  Mark Mitchell  <mark@codesourcery.com>
+
+       * 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  <bje@au.ibm.com>
 
        * hw_htab.c (bfd_get_section_lma): Remove macro; use BFD's.
index a574fe77941b6515b0bde9c038a5998e6400cc95..e2eac2a87c72d8ddcd285aeba4504155bbaa8bbf 100644 (file)
@@ -572,7 +572,7 @@ cntrl_c_simulation(void *data)
   psim_halt(system,
            psim_nr_cpus(system),
            was_continuing,
-           SIGINT);
+           TARGET_SIGNAL_INT);
 }
 
 INLINE_PSIM\
index 08feb39ab760130c64bcadbe05abe175c84a9298..781ff055f5c3b95dc7a6a15c5ddb3a7722cf9f03 100644 (file)
@@ -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;