* 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_*.
This commit is contained in:
Mark Mitchell 2005-11-28 18:33:03 +00:00
parent 274b5ecdd7
commit aba6488e0b
15 changed files with 100 additions and 51 deletions

View 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.

View 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:

View 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

View File

@ -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;
}

View 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

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

View 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;
}

View 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 */

View 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.

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

View 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.

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

View 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.

View 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\

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