X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fremote-sim.c;h=8bd1a65528bec2d99052d9c8313a8878947eb306;hb=a40805d4a73532dffc61e33f913e62b93214c998;hp=061469030206b9367c6e2efc6379f5cb1ebcbb0b;hpb=1eab8a48bf928ab7337833c785ec1316edbdbc8a;p=binutils-gdb.git
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 06146903020..8bd1a65528b 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -1,6 +1,6 @@
/* Generic remote debugging interface for simulators.
- Copyright (C) 1993-2014 Free Software Foundation, Inc.
+ Copyright (C) 1993-2015 Free Software Foundation, Inc.
Contributed by Cygnus Support.
Steve Chamberlain (sac@cygnus.com).
@@ -21,14 +21,14 @@
along with this program. If not, see . */
#include "defs.h"
+#include "gdb_bfd.h"
#include "inferior.h"
+#include "infrun.h"
#include "value.h"
-#include
#include
#include
#include
#include
-#include
#include "terminal.h"
#include "target.h"
#include "gdbcore.h"
@@ -36,7 +36,6 @@
#include "gdb/remote-sim.h"
#include "command.h"
#include "regcache.h"
-#include "gdb_assert.h"
#include "sim-regno.h"
#include "arch-utils.h"
#include "readline/readline.h"
@@ -72,9 +71,10 @@ static void gdb_os_error (host_callback *, const char *, ...)
static void gdbsim_kill (struct target_ops *);
-static void gdbsim_load (struct target_ops *self, char *prog, int fromtty);
+static void gdbsim_load (struct target_ops *self, const char *prog,
+ int fromtty);
-static void gdbsim_open (char *args, int from_tty);
+static void gdbsim_open (const char *args, int from_tty);
static void gdbsim_close (struct target_ops *self);
@@ -88,7 +88,7 @@ static void gdbsim_files_info (struct target_ops *target);
static void gdbsim_mourn_inferior (struct target_ops *target);
-static void gdbsim_stop (struct target_ops *self, ptid_t ptid);
+static void gdbsim_interrupt (struct target_ops *self, ptid_t ptid);
void simulator_command (char *args, int from_tty);
@@ -178,7 +178,7 @@ get_sim_inferior_data (struct inferior *inf, int sim_instance_needed)
a potential allocation of a sim_inferior_data struct in order to
avoid needlessly allocating that struct in the event that the sim
instance allocation fails. */
- if (sim_instance_needed == SIM_INSTANCE_NEEDED
+ if (sim_instance_needed == SIM_INSTANCE_NEEDED
&& (sim_data == NULL || sim_data->gdbsim_desc == NULL))
{
struct inferior *idup;
@@ -188,7 +188,7 @@ get_sim_inferior_data (struct inferior *inf, int sim_instance_needed)
inf->num);
idup = iterate_over_inferiors (check_for_duplicate_sim_descriptor,
- sim_desc);
+ sim_desc);
if (idup != NULL)
{
/* We don't close the descriptor due to the fact that it's
@@ -201,8 +201,8 @@ get_sim_inferior_data (struct inferior *inf, int sim_instance_needed)
error (
_("Inferior %d and inferior %d would have identical simulator state.\n"
"(This simulator does not support the running of more than one inferior.)"),
- inf->num, idup->num);
- }
+ inf->num, idup->num);
+ }
}
if (sim_data == NULL)
@@ -223,7 +223,7 @@ get_sim_inferior_data (struct inferior *inf, int sim_instance_needed)
else if (sim_desc)
{
/* This handles the case where sim_data was allocated prior to
- needing a sim instance. */
+ needing a sim instance. */
sim_data->gdbsim_desc = sim_desc;
}
@@ -243,7 +243,7 @@ get_sim_inferior_data_by_ptid (ptid_t ptid, int sim_instance_needed)
if (pid <= 0)
return NULL;
-
+
inf = find_inferior_pid (pid);
if (inf)
@@ -445,7 +445,7 @@ gdbsim_fetch_register (struct target_ops *ops,
case SIM_REGNO_DOES_NOT_EXIST:
{
/* For moment treat a `does not exist' register the same way
- as an ``unavailable'' register. */
+ as an ``unavailable'' register. */
gdb_byte buf[MAX_REGISTER_SIZE];
int nr_bytes;
@@ -453,7 +453,7 @@ gdbsim_fetch_register (struct target_ops *ops,
regcache_raw_supply (regcache, regno, buf);
break;
}
-
+
default:
{
static int warn_user = 1;
@@ -527,11 +527,11 @@ gdbsim_store_register (struct target_ops *ops,
internal_error (__FILE__, __LINE__,
_("Register size different to expected"));
if (nr_bytes < 0)
- internal_error (__FILE__, __LINE__,
- _("Register %d not updated"), regno);
+ internal_error (__FILE__, __LINE__,
+ _("Register %d not updated"), regno);
if (nr_bytes == 0)
- warning (_("Register %s not updated"),
- gdbarch_register_name (gdbarch, regno));
+ warning (_("Register %s not updated"),
+ gdbarch_register_name (gdbarch, regno));
if (remote_debug)
{
@@ -561,10 +561,10 @@ gdbsim_kill (struct target_ops *ops)
GDB's symbol tables to match. */
static void
-gdbsim_load (struct target_ops *self, char *args, int fromtty)
+gdbsim_load (struct target_ops *self, const char *args, int fromtty)
{
char **argv;
- char *prog;
+ const char *prog;
struct sim_inferior_data *sim_data
= get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NEEDED);
@@ -656,7 +656,7 @@ gdbsim_create_inferior (struct target_ops *target, char *exec_file, char *args,
insert_breakpoints (); /* Needed to get correct instruction
in cache. */
- clear_proceed_status ();
+ clear_proceed_status (0);
}
/* The open routine takes the rest of the parameters from the command,
@@ -665,13 +665,18 @@ gdbsim_create_inferior (struct target_ops *target, char *exec_file, char *args,
/* Called when selecting the simulator. E.g. (gdb) target sim name. */
static void
-gdbsim_open (char *args, int from_tty)
+gdbsim_open (const char *args, int from_tty)
{
int len;
char *arg_buf;
struct sim_inferior_data *sim_data;
+ const char *sysroot;
SIM_DESC gdbsim_desc;
+ sysroot = gdb_sysroot;
+ if (is_target_filename (sysroot))
+ sysroot += strlen (TARGET_SYSROOT_PREFIX);
+
if (remote_debug)
fprintf_unfiltered (gdb_stdlog,
"gdbsim_open: args \"%s\"\n", args ? args : "(null)");
@@ -689,7 +694,7 @@ gdbsim_open (char *args, int from_tty)
len = (7 + 1 /* gdbsim */
+ strlen (" -E little")
+ strlen (" --architecture=xxxxxxxxxx")
- + strlen (" --sysroot=") + strlen (gdb_sysroot) +
+ + strlen (" --sysroot=") + strlen (sysroot) +
+ (args ? strlen (args) : 0)
+ 50) /* slack */ ;
arg_buf = (char *) alloca (len);
@@ -716,7 +721,7 @@ gdbsim_open (char *args, int from_tty)
}
/* Pass along gdb's concept of the sysroot. */
strcat (arg_buf, " --sysroot=");
- strcat (arg_buf, gdb_sysroot);
+ strcat (arg_buf, sysroot);
/* finally, any explicit args */
if (args)
{
@@ -762,7 +767,7 @@ static int
gdbsim_close_inferior (struct inferior *inf, void *arg)
{
struct sim_inferior_data *sim_data = inferior_data (inf,
- sim_inferior_data_key);
+ sim_inferior_data_key);
if (sim_data != NULL)
{
ptid_t ptid = sim_data->remote_sim_ptid;
@@ -775,7 +780,7 @@ gdbsim_close_inferior (struct inferior *inf, void *arg)
Thus we need to verify the existence of an inferior using the
pid in question before setting inferior_ptid via
switch_to_thread() or mourning the inferior. */
- if (find_inferior_pid (ptid_get_pid (ptid)) != NULL)
+ if (find_inferior_ptid (ptid) != NULL)
{
switch_to_thread (ptid);
generic_mourn_inferior ();
@@ -882,24 +887,24 @@ gdbsim_resume (struct target_ops *ops,
either have multiple inferiors to resume or an error condition. */
if (sim_data)
- gdbsim_resume_inferior (find_inferior_pid (ptid_get_pid (ptid)), &rd);
+ gdbsim_resume_inferior (find_inferior_ptid (ptid), &rd);
else if (ptid_equal (ptid, minus_one_ptid))
iterate_over_inferiors (gdbsim_resume_inferior, &rd);
else
error (_("The program is not being run."));
}
-/* Notify the simulator of an asynchronous request to stop.
+/* Notify the simulator of an asynchronous request to interrupt.
- The simulator shall ensure that the stop request is eventually
+ The simulator shall ensure that the interrupt request is eventually
delivered to the simulator. If the call is made while the
- simulator is not running then the stop request is processed when
+ simulator is not running then the interrupt request is processed when
the simulator is next resumed.
For simulators that do not support this operation, just abort. */
static int
-gdbsim_stop_inferior (struct inferior *inf, void *arg)
+gdbsim_interrupt_inferior (struct inferior *inf, void *arg)
{
struct sim_inferior_data *sim_data
= get_sim_inferior_data (inf, SIM_INSTANCE_NEEDED);
@@ -919,23 +924,23 @@ gdbsim_stop_inferior (struct inferior *inf, void *arg)
}
static void
-gdbsim_stop (struct target_ops *self, ptid_t ptid)
+gdbsim_interrupt (struct target_ops *self, ptid_t ptid)
{
struct sim_inferior_data *sim_data;
if (ptid_equal (ptid, minus_one_ptid))
{
- iterate_over_inferiors (gdbsim_stop_inferior, NULL);
+ iterate_over_inferiors (gdbsim_interrupt_inferior, NULL);
}
else
{
- struct inferior *inf = find_inferior_pid (ptid_get_pid (ptid));
+ struct inferior *inf = find_inferior_ptid (ptid);
if (inf == NULL)
error (_("Can't stop pid %d. No inferior found."),
ptid_get_pid (ptid));
- gdbsim_stop_inferior (inf, NULL);
+ gdbsim_interrupt_inferior (inf, NULL);
}
}
@@ -963,7 +968,7 @@ gdb_os_poll_quit (host_callback *p)
static void
gdbsim_cntrl_c (int signo)
{
- gdbsim_stop (NULL, minus_one_ptid);
+ gdbsim_interrupt (NULL, minus_one_ptid);
}
static ptid_t
@@ -971,7 +976,7 @@ gdbsim_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *status, int options)
{
struct sim_inferior_data *sim_data;
- static RETSIGTYPE (*prev_sigint) ();
+ static sighandler_t prev_sigint;
int sigrc = 0;
enum sim_stop reason = sim_running;
@@ -1006,7 +1011,7 @@ gdbsim_wait (struct target_ops *ops,
prev_sigint = signal (SIGINT, gdbsim_cntrl_c);
#endif
sim_resume (sim_data->gdbsim_desc, sim_data->resume_step,
- sim_data->resume_siggnal);
+ sim_data->resume_siggnal);
signal (SIGINT, prev_sigint);
sim_data->resume_step = 0;
@@ -1198,14 +1203,14 @@ simulator_command (char *args, int from_tty)
{
/* PREVIOUSLY: The user may give a command before the simulator
- is opened. [...] (??? assuming of course one wishes to
- continue to allow commands to be sent to unopened simulators,
- which isn't entirely unreasonable). */
+ is opened. [...] (??? assuming of course one wishes to
+ continue to allow commands to be sent to unopened simulators,
+ which isn't entirely unreasonable). */
/* The simulator is a builtin abstraction of a remote target.
- Consistent with that model, access to the simulator, via sim
- commands, is restricted to the period when the channel to the
- simulator is open. */
+ Consistent with that model, access to the simulator, via sim
+ commands, is restricted to the period when the channel to the
+ simulator is open. */
error (_("Not connected to the simulator target"));
}
@@ -1321,7 +1326,7 @@ init_gdbsim_ops (void)
gdbsim_ops.to_load = gdbsim_load;
gdbsim_ops.to_create_inferior = gdbsim_create_inferior;
gdbsim_ops.to_mourn_inferior = gdbsim_mourn_inferior;
- gdbsim_ops.to_stop = gdbsim_stop;
+ gdbsim_ops.to_interrupt = gdbsim_interrupt;
gdbsim_ops.to_thread_alive = gdbsim_thread_alive;
gdbsim_ops.to_pid_to_str = gdbsim_pid_to_str;
gdbsim_ops.to_stratum = process_stratum;