binutils-gdb/gdb/remote-sim.c

1359 lines
39 KiB
C
Raw Normal View History

/* Generic remote debugging interface for simulators.
2002-01-19 04:32:43 +01:00
Copyright (C) 1993-2017 Free Software Foundation, Inc.
2002-01-19 04:32:43 +01:00
Contributed by Cygnus Support.
Steve Chamberlain (sac@cygnus.com).
1999-07-07 22:19:36 +02:00
This file is part of GDB.
1999-07-07 22:19:36 +02:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
1999-07-07 22:19:36 +02:00
(at your option) any later version.
1999-07-07 22:19:36 +02:00
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
1999-07-07 22:19:36 +02:00
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "gdb_bfd.h"
#include "inferior.h"
Add new infrun.h header. Move infrun.c declarations out of inferior.h to a new infrun.h file. Tested by building on: i686-w64-mingw32, enable-targets=all x86_64-linux, enable-targets=all i586-pc-msdosdjgpp And also grepped the whole tree for each symbol moved to find where infrun.h might be necessary. gdb/ 2014-05-22 Pedro Alves <palves@redhat.com> * inferior.h (debug_infrun, debug_displaced, stop_on_solib_events) (sync_execution, sched_multi, step_stop_if_no_debug, non_stop) (disable_randomization, enum exec_direction_kind) (execution_direction, stop_registers, start_remote) (clear_proceed_status, proceed, resume, user_visible_resume_ptid) (wait_for_inferior, normal_stop, get_last_target_status) (prepare_for_detach, fetch_inferior_event, init_wait_for_inferior) (insert_step_resume_breakpoint_at_sal) (follow_inferior_reset_breakpoints, stepping_past_instruction_at) (set_step_info, print_stop_event, signal_stop_state) (signal_print_state, signal_pass_state, signal_stop_update) (signal_print_update, signal_pass_update) (update_signals_program_target, clear_exit_convenience_vars) (displaced_step_dump_bytes, update_observer_mode) (signal_catch_update, gdb_signal_from_command): Move declarations ... * infrun.h: ... to this new file. * amd64-tdep.c: Include infrun.h. * annotate.c: Include infrun.h. * arch-utils.c: Include infrun.h. * arm-linux-tdep.c: Include infrun.h. * arm-tdep.c: Include infrun.h. * break-catch-sig.c: Include infrun.h. * breakpoint.c: Include infrun.h. * common/agent.c: Include infrun.h instead of inferior.h. * corelow.c: Include infrun.h. * event-top.c: Include infrun.h. * go32-nat.c: Include infrun.h. * i386-tdep.c: Include infrun.h. * inf-loop.c: Include infrun.h. * infcall.c: Include infrun.h. * infcmd.c: Include infrun.h. * infrun.c: Include infrun.h. * linux-fork.c: Include infrun.h. * linux-nat.c: Include infrun.h. * linux-thread-db.c: Include infrun.h. * monitor.c: Include infrun.h. * nto-tdep.c: Include infrun.h. * procfs.c: Include infrun.h. * record-btrace.c: Include infrun.h. * record-full.c: Include infrun.h. * remote-m32r-sdi.c: Include infrun.h. * remote-mips.c: Include infrun.h. * remote-notif.c: Include infrun.h. * remote-sim.c: Include infrun.h. * remote.c: Include infrun.h. * reverse.c: Include infrun.h. * rs6000-tdep.c: Include infrun.h. * s390-linux-tdep.c: Include infrun.h. * solib-irix.c: Include infrun.h. * solib-osf.c: Include infrun.h. * solib-svr4.c: Include infrun.h. * target.c: Include infrun.h. * top.c: Include infrun.h. * windows-nat.c: Include infrun.h. * mi/mi-interp.c: Include infrun.h. * mi/mi-main.c: Include infrun.h. * python/py-threadevent.c: Include infrun.h.
2014-05-22 13:29:11 +02:00
#include "infrun.h"
#include "value.h"
#include <ctype.h>
#include <fcntl.h>
#include <signal.h>
#include <setjmp.h>
#include "terminal.h"
#include "target.h"
#include "gdbcore.h"
#include "gdb/callback.h"
#include "gdb/remote-sim.h"
#include "command.h"
#include "regcache.h"
#include "sim-regno.h"
#include "arch-utils.h"
#include "readline/readline.h"
#include "gdbthread.h"
/* Prototypes */
2000-05-28 03:12:42 +02:00
extern void _initialize_remote_sim (void);
1999-05-25 20:09:09 +02:00
2000-05-28 03:12:42 +02:00
static void init_callbacks (void);
2000-05-28 03:12:42 +02:00
static void end_callbacks (void);
2000-05-28 03:12:42 +02:00
static int gdb_os_write_stdout (host_callback *, const char *, int);
2000-05-28 03:12:42 +02:00
static void gdb_os_flush_stdout (host_callback *);
2000-05-28 03:12:42 +02:00
static int gdb_os_write_stderr (host_callback *, const char *, int);
2000-05-28 03:12:42 +02:00
static void gdb_os_flush_stderr (host_callback *);
2000-05-28 03:12:42 +02:00
static int gdb_os_poll_quit (host_callback *);
/* printf_filtered is depreciated. */
2000-05-28 03:12:42 +02:00
static void gdb_os_printf_filtered (host_callback *, const char *, ...);
2000-05-28 03:12:42 +02:00
static void gdb_os_vprintf_filtered (host_callback *, const char *, va_list);
2000-05-28 03:12:42 +02:00
static void gdb_os_evprintf_filtered (host_callback *, const char *, va_list);
static void gdb_os_error (host_callback *, const char *, ...)
ATTRIBUTE_NORETURN;
static void gdbsim_kill (struct target_ops *);
static void gdbsim_load (struct target_ops *self, const char *prog,
int fromtty);
static void gdbsim_open (const char *args, int from_tty);
static void gdbsim_close (struct target_ops *self);
static void gdbsim_detach (struct target_ops *ops, const char *args,
int from_tty);
static void gdbsim_prepare_to_store (struct target_ops *self,
struct regcache *regcache);
2000-05-28 03:12:42 +02:00
static void gdbsim_files_info (struct target_ops *target);
static void gdbsim_mourn_inferior (struct target_ops *target);
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
static void gdbsim_interrupt (struct target_ops *self, ptid_t ptid);
2000-05-28 03:12:42 +02:00
void simulator_command (char *args, int from_tty);
/* Naming convention:
sim_* are the interface to the simulator (see remote-sim.h).
gdbsim_* are stuff which is internal to gdb. */
/* Forward data declarations */
extern struct target_ops gdbsim_ops;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
static const struct inferior_data *sim_inferior_data_key;
/* Simulator-specific, per-inferior state. */
struct sim_inferior_data {
/* Flag which indicates whether or not the program has been loaded. */
int program_loaded;
/* Simulator descriptor for this inferior. */
SIM_DESC gdbsim_desc;
/* This is the ptid we use for this particular simulator instance. Its
value is somewhat arbitrary, as the simulator target don't have a
notion of tasks or threads, but we need something non-null to place
in inferior_ptid. For simulators which permit multiple instances,
we also need a unique identifier to use for each inferior. */
ptid_t remote_sim_ptid;
/* Signal with which to resume. */
enum gdb_signal resume_siggnal;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
/* Flag which indicates whether resume should step or not. */
int resume_step;
};
/* Flag indicating the "open" status of this module. It's set to 1
in gdbsim_open() and 0 in gdbsim_close(). */
static int gdbsim_is_open = 0;
/* Value of the next pid to allocate for an inferior. As indicated
elsewhere, its initial value is somewhat arbitrary; it's critical
though that it's not zero or negative. */
static int next_pid;
#define INITIAL_PID 42000
/* Argument list to pass to sim_open(). It is allocated in gdbsim_open()
and deallocated in gdbsim_close(). The lifetime needs to extend beyond
the call to gdbsim_open() due to the fact that other sim instances other
than the first will be allocated after the gdbsim_open() call. */
static char **sim_argv = NULL;
/* OS-level callback functions for write, flush, etc. */
static host_callback gdb_callback;
static int callbacks_initialized = 0;
/* Callback for iterate_over_inferiors. It checks to see if the sim
descriptor passed via ARG is the same as that for the inferior
designated by INF. Return true if so; false otherwise. */
static int
check_for_duplicate_sim_descriptor (struct inferior *inf, void *arg)
{
struct sim_inferior_data *sim_data;
SIM_DESC new_sim_desc = (SIM_DESC) arg;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
sim_data = ((struct sim_inferior_data *)
inferior_data (inf, sim_inferior_data_key));
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
return (sim_data != NULL && sim_data->gdbsim_desc == new_sim_desc);
}
/* Flags indicating whether or not a sim instance is needed. One of these
flags should be passed to get_sim_inferior_data(). */
enum {SIM_INSTANCE_NOT_NEEDED = 0, SIM_INSTANCE_NEEDED = 1};
/* Obtain pointer to per-inferior simulator data, allocating it if necessary.
Attempt to open the sim if SIM_INSTANCE_NEEDED is true. */
static struct sim_inferior_data *
get_sim_inferior_data (struct inferior *inf, int sim_instance_needed)
{
SIM_DESC sim_desc = NULL;
struct sim_inferior_data *sim_data
= (struct sim_inferior_data *) inferior_data (inf, sim_inferior_data_key);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
/* Try to allocate a new sim instance, if needed. We do this ahead of
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
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
&& (sim_data == NULL || sim_data->gdbsim_desc == NULL))
{
struct inferior *idup;
sim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback, exec_bfd, sim_argv);
if (sim_desc == NULL)
error (_("Unable to create simulator instance for inferior %d."),
inf->num);
idup = iterate_over_inferiors (check_for_duplicate_sim_descriptor,
sim_desc);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
if (idup != NULL)
{
/* We don't close the descriptor due to the fact that it's
shared with some other inferior. If we were to close it,
that might needlessly muck up the other inferior. Of
course, it's possible that the damage has already been
done... Note that it *will* ultimately be closed during
cleanup of the other inferior. */
sim_desc = NULL;
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);
}
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
}
if (sim_data == NULL)
{
replace XZALLOC with XCNEW This replaces XZALLOC with XCNEW and removes XZALLOC. This change is purely mechanical. 2014-01-13 Tom Tromey <tromey@redhat.com> * defs.h (XZALLOC): Remove. * ada-lang.c (get_ada_inferior_data): Use XCNEW, not XZALLOC. * ada-tasks.c (get_ada_tasks_pspace_data): Likewise. (get_ada_tasks_inferior_data): Likewise. * auto-load.c (get_auto_load_pspace_data): Likewise. * auxv.c (get_auxv_inferior_data): Likewise. * bfd-target.c (target_bfd_reopen): Likewise. * breakpoint.c (get_catch_syscall_inferior_data): Likewise. (deprecated_insert_raw_breakpoint): Likewise. * bsd-uthread.c (bsd_uthread_pid_to_str): Likewise. * corelow.c (core_open): Likewise. * darwin-nat.c (darwin_check_new_threads): Likewise. (darwin_attach_pid): Likewise. * dummy-frame.c (dummy_frame_push): Likewise. * dwarf2-frame.c (dwarf2_frame_cache): Likewise. * dwarf2loc.c (allocate_piece_closure): Likewise. * elfread.c (elf_symfile_segments): Likewise. * eval.c (ptrmath_type_p): Likewise. * exceptions.c (EXCEPTIONS_SIGJMP_BUF): Likewise. * gdbtypes.c (alloc_type_arch): Likewise. (alloc_type_instance): Likewise. * hppa-tdep.c (hppa_gdbarch_init): Likewise. * inf-child.c (inf_child_can_use_agent): Likewise. * inflow.c (get_inflow_inferior_data): Likewise. * infrun.c (save_infcall_suspend_state): Likewise. * jit.c (jit_reader_load): Likewise. (get_jit_objfile_data): Likewise. (get_jit_program_space_data): Likewise. (jit_object_open_impl): Likewise. (jit_symtab_open_impl): Likewise. (jit_block_open_impl): Likewise. (jit_frame_sniffer): Likewise. * linux-fork.c (add_fork): Likewise. * maint.c (make_command_stats_cleanup): Likewise. * objfiles.c (get_objfile_pspace_data): Likewise. * opencl-lang.c (struct lval_closure): Likewise. * osdata.c (osdata_start_osdata): Likewise. * progspace.c (new_address_space): Likewise. (add_program_space): Likewise. * remote-sim.c (get_sim_inferior_data): Likewise. * sh-tdep.c (sh_gdbarch_init): Likewise. * skip.c (Ignore): Likewise. (skip_delete_command): Likewise. * solib-aix.c (get_solib_aix_inferior_data): Likewise. (library_list_start_library): Likewise. (solib_aix_current_sos): Likewise. * solib-darwin.c (get_darwin_info): Likewise. (darwin_current_sos): Likewise. * solib-dsbt.c (get_dsbt_info): Likewise. * solib-ia64-hpux.c (new_so_list): Likewise. (ia64_hpux_get_solib_linkage_addr): Likewise. * solib-spu.c (append_ocl_sos): Likewise. (spu_current_sos): Likewise. * solib-svr4.c (get_svr4_info): Likewise. (svr4_keep_data_in_core): Likewise. (library_list_start_library): Likewise. (svr4_default_sos): Likewise. (svr4_read_so_list): Likewise. * solib-target.c (library_list_start_library): Likewise. (solib_target_current_sos): Likewise. * sparc-tdep.c (sparc32_gdbarch_init): Likewise. * symfile-debug.c (install_symfile_debug_logging): Likewise. * symfile.c (default_symfile_segments): Likewise. * target-descriptions.c (tdesc_data_init): Likewise. (tdesc_create_reg): Likewise. (struct tdesc_type *): Likewise. (tdesc_create_vector): Likewise. (tdesc_set_struct_size): Likewise. (struct tdesc_type *): Likewise. (tdesc_free_feature): Likewise. (tdesc_create_feature): Likewise. * windows-nat.c (windows_add_thread): Likewise. (windows_make_so): Likewise. * xml-support.c (gdb_xml_body_text): Likewise. (gdb_xml_create_parser_and_cleanup): Likewise. (xml_process_xincludes): Likewise. * xml-syscall.c (allocate_syscalls_info): Likewise. (syscall_create_syscall_desc): Likewise.
2013-12-28 23:31:01 +01:00
sim_data = XCNEW(struct sim_inferior_data);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
set_inferior_data (inf, sim_inferior_data_key, sim_data);
/* Allocate a ptid for this inferior. */
sim_data->remote_sim_ptid = ptid_build (next_pid, 0, next_pid);
next_pid++;
/* Initialize the other instance variables. */
sim_data->program_loaded = 0;
sim_data->gdbsim_desc = sim_desc;
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
sim_data->resume_siggnal = GDB_SIGNAL_0;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
sim_data->resume_step = 0;
}
else if (sim_desc)
{
/* This handles the case where sim_data was allocated prior to
needing a sim instance. */
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
sim_data->gdbsim_desc = sim_desc;
}
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
return sim_data;
}
/* Return pointer to per-inferior simulator data using PTID to find the
inferior in question. Return NULL when no inferior is found or
when ptid has a zero or negative pid component. */
static struct sim_inferior_data *
get_sim_inferior_data_by_ptid (ptid_t ptid, int sim_instance_needed)
{
struct inferior *inf;
int pid = ptid_get_pid (ptid);
if (pid <= 0)
return NULL;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
inf = find_inferior_pid (pid);
if (inf)
return get_sim_inferior_data (inf, sim_instance_needed);
else
return NULL;
}
/* Free the per-inferior simulator data. */
static void
sim_inferior_data_cleanup (struct inferior *inf, void *data)
{
struct sim_inferior_data *sim_data = (struct sim_inferior_data *) data;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
if (sim_data != NULL)
{
if (sim_data->gdbsim_desc)
{
sim_close (sim_data->gdbsim_desc, 0);
sim_data->gdbsim_desc = NULL;
}
xfree (sim_data);
}
}
static void
dump_mem (const gdb_byte *buf, int len)
{
fputs_unfiltered ("\t", gdb_stdlog);
if (len == 8 || len == 4)
{
uint32_t l[2];
memcpy (l, buf, len);
fprintf_unfiltered (gdb_stdlog, "0x%08x", l[0]);
if (len == 8)
fprintf_unfiltered (gdb_stdlog, " 0x%08x", l[1]);
}
else
{
int i;
for (i = 0; i < len; i++)
fprintf_unfiltered (gdb_stdlog, "0x%02x ", buf[i]);
}
fputs_unfiltered ("\n", gdb_stdlog);
}
/* Initialize gdb_callback. */
static void
2000-07-30 03:48:28 +02:00
init_callbacks (void)
{
1999-07-07 22:19:36 +02:00
if (!callbacks_initialized)
{
gdb_callback = default_callback;
gdb_callback.init (&gdb_callback);
gdb_callback.write_stdout = gdb_os_write_stdout;
gdb_callback.flush_stdout = gdb_os_flush_stdout;
gdb_callback.write_stderr = gdb_os_write_stderr;
gdb_callback.flush_stderr = gdb_os_flush_stderr;
gdb_callback.printf_filtered = gdb_os_printf_filtered;
gdb_callback.vprintf_filtered = gdb_os_vprintf_filtered;
gdb_callback.evprintf_filtered = gdb_os_evprintf_filtered;
gdb_callback.error = gdb_os_error;
gdb_callback.poll_quit = gdb_os_poll_quit;
gdb_callback.magic = HOST_CALLBACK_MAGIC;
callbacks_initialized = 1;
}
}
/* Release callbacks (free resources used by them). */
static void
2000-07-30 03:48:28 +02:00
end_callbacks (void)
{
if (callbacks_initialized)
{
gdb_callback.shutdown (&gdb_callback);
callbacks_initialized = 0;
}
}
/* GDB version of os_write_stdout callback. */
1999-07-07 22:19:36 +02:00
static int
2000-07-30 03:48:28 +02:00
gdb_os_write_stdout (host_callback *p, const char *buf, int len)
{
int i;
char b[2];
2000-02-02 01:21:19 +01:00
ui_file_write (gdb_stdtarg, buf, len);
return len;
}
/* GDB version of os_flush_stdout callback. */
static void
2000-07-30 03:48:28 +02:00
gdb_os_flush_stdout (host_callback *p)
{
1999-11-17 03:31:06 +01:00
gdb_flush (gdb_stdtarg);
}
/* GDB version of os_write_stderr callback. */
1999-07-07 22:19:36 +02:00
static int
2000-07-30 03:48:28 +02:00
gdb_os_write_stderr (host_callback *p, const char *buf, int len)
{
int i;
char b[2];
1999-07-07 22:19:36 +02:00
for (i = 0; i < len; i++)
{
b[0] = buf[i];
b[1] = 0;
fputs_unfiltered (b, gdb_stdtargerr);
}
return len;
}
/* GDB version of os_flush_stderr callback. */
static void
2000-07-30 03:48:28 +02:00
gdb_os_flush_stderr (host_callback *p)
{
gdb_flush (gdb_stdtargerr);
}
/* GDB version of printf_filtered callback. */
static void
1999-07-07 22:19:36 +02:00
gdb_os_printf_filtered (host_callback * p, const char *format,...)
{
va_list args;
va_start (args, format);
vfprintf_filtered (gdb_stdout, format, args);
va_end (args);
}
/* GDB version of error vprintf_filtered. */
static void
1999-07-07 22:19:36 +02:00
gdb_os_vprintf_filtered (host_callback * p, const char *format, va_list ap)
{
vfprintf_filtered (gdb_stdout, format, ap);
}
/* GDB version of error evprintf_filtered. */
static void
1999-07-07 22:19:36 +02:00
gdb_os_evprintf_filtered (host_callback * p, const char *format, va_list ap)
{
vfprintf_filtered (gdb_stderr, format, ap);
}
/* GDB version of error callback. */
static void
gdb_os_error (host_callback * p, const char *format, ...)
{
va_list args;
va_start (args, format);
verror (format, args);
va_end (args);
}
int
one2one_register_sim_regno (struct gdbarch *gdbarch, int regnum)
{
/* Only makes sense to supply raw registers. */
gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch));
return regnum;
}
static void
* corelow.c (get_core_registers): Adjust. (core_file_thread_alive): Rename to... (core_thread_alive): ... this. (core_pid_to_str): Try gdbarch_core_pid_to_str first. (init_core_ops): Adjust. (coreops_suppress_target): Delete. (_initialize_corelow): Unconditionally add core_ops. * procfs.c: Include "inf-child.h". (procfs_ops): Delete. (init_procfs_ops): Delete. Reimplement as... (procfs_target): ... this, inheriting from inf-child. (procfs_attach, procfs_detach, procfs_fetch_registers): Adjust. (procfs_prepare_to_store): Delete. (procfs_store_registers, procfs_resume): Adjust. (procfs_open): Delete. (procfs_suppress_run): Delete. (procfs_can_run): Delete. (procfs_mourn_inferior): Adjust. (procfs_init_inferior): Add target_ops parameter. Adjust. (procfs_create_inferior): Don't pass procfs_init_inferior to fork_inferior. Instead call it after fork_inferior returns. (procfs_find_new_threads): Adjust. (_initialize_procfs): Adjust to use procfs_target instead of init_procfs_ops. * sol-thread.c (orig_core_ops, sol_core_ops): Delete. (lwp_to_thread): Use target_thread_alive. (sol_thread_open): Delete. (sol_thread_attach): Delete. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers): Adjust to use find_target_beneath. (sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete. (sol_thread_xfer_partial): Adjust to use find_target_beneath. (sol_thread_files_info, sol_thread_kill_inferior): Delete. (check_for_thread_db): New. (sol_thread_notice_signals, sol_thread_create_inferior): Delete. (sol_thread_new_objfile): Call check_for_thread_db. (sol_thread_mourn_inferior): Adjust to use find_target_beneath. (sol_thread_can_run): Delete. (sol_thread_alive): Adjust to use find_target_beneath. (sol_thread_stop): Delete. (rw_common): Use target_write_memory or target_read_memory. (ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers. (ps_lsetregs, ps_lsetfpregs): Use target_store_registers. (solaris_pid_to_str): Remove check for libthread_db initialization failing. (sol_find_new_threads): Remove check for libthread_db initialization failing, or for an invalid inferior_ptid. Adjust to use find_target_beneath. (sol_core_open, sol_core_close, sol_core_detach, sol_core_files_info, sol_find_memory_regions, sol_make_note_section, ignore): Delete. (init_sol_thread_ops): Make it a thread_stratum target. Remove unneeded callback settings. (init_sol_core_ops): Delete. (_initialize_sol_thread): No longer call init_sol_core_ops, set procfs_suppress_run, or hack with core_ops. * target.h (struct target_ops): Add a target_ops * parameter to to_resume, to_fetch_registers, to_store_registers, to_thread_alive and to_find_new_threads. (target_fetch_registers, target_store_registers) (target_thread_alive, target_find_new_threads): Redeclare as function. * target.c (update_current_target): Do not inherit or de_fault to_resume, to_fetch_registers, to_store_registers, to_thread_alive, to_find_new_threads. (target_resume): Adjust. (target_thread_alive, target_find_new_threads): New. (debug_to_resume, debug_to_fetch_registers): Delete. (target_fetch_registers): New. (debug_to_store_registers): Delete. (target_store_registers): New. (debug_to_thread_alive, debug_to_find_new_threads): Delete. (setup_target_debug): Adjust. * gdbcore.h (core_ops): Delete declaration. * inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c, inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c, i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c, hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c, nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c, alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c, bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c, hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c, ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c, m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c, mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c, ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c, shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c, vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes. * gdbarch.sh (core_pid_to_str): New gdbarch callback. * gdbarch.h, gdbarch.c: Regenerate. * sol2-tdep.c: Include "inferior.h". (sol2_core_pid_to_str): New. * sol2-tdep.h (sol2_core_pid_to_str): Declare. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it. * i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
gdbsim_fetch_register (struct target_ops *ops,
struct regcache *regcache, int regno)
{
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
struct gdbarch *gdbarch = get_regcache_arch (regcache);
Use ptid from regcache in almost all remaining nat files This patch contains almost all of the remaining changes needed to make to_fetch_registers/to_store_registers/to_prepare_to_store independent of inferior_ptid. It contains only some "trivial" changes, the more complicated ones are in separate patches. gdb/ChangeLog: * i386-linux-nat.c (fetch_register, store_register, i386_linux_fetch_inferior_registers, i386_linux_store_inferior_registers): Use ptid from regcache. * ia64-linux-nat.c (ia64_linux_fetch_register, ia64_linux_store_register): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register, inf_ptrace_store_register): Likewise. * m32r-linux-nat.c (m32r_linux_fetch_inferior_registers, m32r_linux_store_inferior_registers): Likewise. * m68k-bsd-nat.c (m68kbsd_fetch_inferior_registers, m68kbsd_store_inferior_registers): Likewise. * m68k-linux-nat.c (fetch_register, store_register, m68k_linux_fetch_inferior_registers, m68k_linux_store_inferior_registers): Likewise. * m88k-bsd-nat.c (m88kbsd_fetch_inferior_registers, m88kbsd_store_inferior_registers): Likewise. * mips-fbsd-nat.c (mips_fbsd_fetch_inferior_registers, mips_fbsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers, mips64_linux_regsets_store_registers): Likewise. * mips-nbsd-nat.c (mipsnbsd_fetch_inferior_registers, mipsnbsd_store_inferior_registers): Likewise. * mips-obsd-nat.c (mips64obsd_fetch_inferior_registers, mips64obsd_store_inferior_registers): Likewise. * nto-procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * ppc-fbsd-nat.c (ppcfbsd_fetch_inferior_registers, ppcfbsd_store_inferior_registers): Likewise. * ppc-linux-nat.c (ppc_linux_fetch_inferior_registers, ppc_linux_store_inferior_registers): Likewise. * ppc-nbsd-nat.c (ppcnbsd_fetch_inferior_registers, ppcnbsd_store_inferior_registers): Likewise. * ppc-obsd-nat.c (ppcobsd_fetch_registers, ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * ravenscar-thread.c (ravenscar_fetch_registers, ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. * record-btrace.c (record_btrace_fetch_registers, record_btrace_store_registers, record_btrace_prepare_to_store): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Lookup inferior using ptid from regcache, instead of current_inferior. * remote.c (remote_fetch_registers, remote_store_registers): Use ptid from regcache. * rs6000-nat.c (fetch_register, store_register): Likewise. * s390-linux-nat.c (s390_linux_fetch_inferior_registers, s390_linux_store_inferior_registers): Likewise. * sh-nbsd-nat.c (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers, sol_thread_store_registers): Likewise. * sparc-nat.c (sparc_fetch_inferior_registers, sparc_store_inferior_registers): Likewise. * tilegx-linux-nat.c (fetch_inferior_registers, store_inferior_registers): Likewise. * vax-bsd-nat.c (vaxbsd_fetch_inferior_registers, vaxbsd_store_inferior_registers): Likewise. * xtensa-linux-nat.c (fetch_gregs, store_gregs, fetch_xtregs, store_xtregs): Likewise.
2017-03-20 22:37:36 +01:00
struct inferior *inf = find_inferior_ptid (regcache_get_ptid (regcache));
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct sim_inferior_data *sim_data
Use ptid from regcache in almost all remaining nat files This patch contains almost all of the remaining changes needed to make to_fetch_registers/to_store_registers/to_prepare_to_store independent of inferior_ptid. It contains only some "trivial" changes, the more complicated ones are in separate patches. gdb/ChangeLog: * i386-linux-nat.c (fetch_register, store_register, i386_linux_fetch_inferior_registers, i386_linux_store_inferior_registers): Use ptid from regcache. * ia64-linux-nat.c (ia64_linux_fetch_register, ia64_linux_store_register): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register, inf_ptrace_store_register): Likewise. * m32r-linux-nat.c (m32r_linux_fetch_inferior_registers, m32r_linux_store_inferior_registers): Likewise. * m68k-bsd-nat.c (m68kbsd_fetch_inferior_registers, m68kbsd_store_inferior_registers): Likewise. * m68k-linux-nat.c (fetch_register, store_register, m68k_linux_fetch_inferior_registers, m68k_linux_store_inferior_registers): Likewise. * m88k-bsd-nat.c (m88kbsd_fetch_inferior_registers, m88kbsd_store_inferior_registers): Likewise. * mips-fbsd-nat.c (mips_fbsd_fetch_inferior_registers, mips_fbsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers, mips64_linux_regsets_store_registers): Likewise. * mips-nbsd-nat.c (mipsnbsd_fetch_inferior_registers, mipsnbsd_store_inferior_registers): Likewise. * mips-obsd-nat.c (mips64obsd_fetch_inferior_registers, mips64obsd_store_inferior_registers): Likewise. * nto-procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * ppc-fbsd-nat.c (ppcfbsd_fetch_inferior_registers, ppcfbsd_store_inferior_registers): Likewise. * ppc-linux-nat.c (ppc_linux_fetch_inferior_registers, ppc_linux_store_inferior_registers): Likewise. * ppc-nbsd-nat.c (ppcnbsd_fetch_inferior_registers, ppcnbsd_store_inferior_registers): Likewise. * ppc-obsd-nat.c (ppcobsd_fetch_registers, ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * ravenscar-thread.c (ravenscar_fetch_registers, ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. * record-btrace.c (record_btrace_fetch_registers, record_btrace_store_registers, record_btrace_prepare_to_store): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Lookup inferior using ptid from regcache, instead of current_inferior. * remote.c (remote_fetch_registers, remote_store_registers): Use ptid from regcache. * rs6000-nat.c (fetch_register, store_register): Likewise. * s390-linux-nat.c (s390_linux_fetch_inferior_registers, s390_linux_store_inferior_registers): Likewise. * sh-nbsd-nat.c (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers, sol_thread_store_registers): Likewise. * sparc-nat.c (sparc_fetch_inferior_registers, sparc_store_inferior_registers): Likewise. * tilegx-linux-nat.c (fetch_inferior_registers, store_inferior_registers): Likewise. * vax-bsd-nat.c (vaxbsd_fetch_inferior_registers, vaxbsd_store_inferior_registers): Likewise. * xtensa-linux-nat.c (fetch_gregs, store_gregs, fetch_xtregs, store_xtregs): Likewise.
2017-03-20 22:37:36 +01:00
= get_sim_inferior_data (inf, SIM_INSTANCE_NEEDED);
1999-07-07 22:19:36 +02:00
if (regno == -1)
{
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
for (regno = 0; regno < gdbarch_num_regs (gdbarch); regno++)
* corelow.c (get_core_registers): Adjust. (core_file_thread_alive): Rename to... (core_thread_alive): ... this. (core_pid_to_str): Try gdbarch_core_pid_to_str first. (init_core_ops): Adjust. (coreops_suppress_target): Delete. (_initialize_corelow): Unconditionally add core_ops. * procfs.c: Include "inf-child.h". (procfs_ops): Delete. (init_procfs_ops): Delete. Reimplement as... (procfs_target): ... this, inheriting from inf-child. (procfs_attach, procfs_detach, procfs_fetch_registers): Adjust. (procfs_prepare_to_store): Delete. (procfs_store_registers, procfs_resume): Adjust. (procfs_open): Delete. (procfs_suppress_run): Delete. (procfs_can_run): Delete. (procfs_mourn_inferior): Adjust. (procfs_init_inferior): Add target_ops parameter. Adjust. (procfs_create_inferior): Don't pass procfs_init_inferior to fork_inferior. Instead call it after fork_inferior returns. (procfs_find_new_threads): Adjust. (_initialize_procfs): Adjust to use procfs_target instead of init_procfs_ops. * sol-thread.c (orig_core_ops, sol_core_ops): Delete. (lwp_to_thread): Use target_thread_alive. (sol_thread_open): Delete. (sol_thread_attach): Delete. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers): Adjust to use find_target_beneath. (sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete. (sol_thread_xfer_partial): Adjust to use find_target_beneath. (sol_thread_files_info, sol_thread_kill_inferior): Delete. (check_for_thread_db): New. (sol_thread_notice_signals, sol_thread_create_inferior): Delete. (sol_thread_new_objfile): Call check_for_thread_db. (sol_thread_mourn_inferior): Adjust to use find_target_beneath. (sol_thread_can_run): Delete. (sol_thread_alive): Adjust to use find_target_beneath. (sol_thread_stop): Delete. (rw_common): Use target_write_memory or target_read_memory. (ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers. (ps_lsetregs, ps_lsetfpregs): Use target_store_registers. (solaris_pid_to_str): Remove check for libthread_db initialization failing. (sol_find_new_threads): Remove check for libthread_db initialization failing, or for an invalid inferior_ptid. Adjust to use find_target_beneath. (sol_core_open, sol_core_close, sol_core_detach, sol_core_files_info, sol_find_memory_regions, sol_make_note_section, ignore): Delete. (init_sol_thread_ops): Make it a thread_stratum target. Remove unneeded callback settings. (init_sol_core_ops): Delete. (_initialize_sol_thread): No longer call init_sol_core_ops, set procfs_suppress_run, or hack with core_ops. * target.h (struct target_ops): Add a target_ops * parameter to to_resume, to_fetch_registers, to_store_registers, to_thread_alive and to_find_new_threads. (target_fetch_registers, target_store_registers) (target_thread_alive, target_find_new_threads): Redeclare as function. * target.c (update_current_target): Do not inherit or de_fault to_resume, to_fetch_registers, to_store_registers, to_thread_alive, to_find_new_threads. (target_resume): Adjust. (target_thread_alive, target_find_new_threads): New. (debug_to_resume, debug_to_fetch_registers): Delete. (target_fetch_registers): New. (debug_to_store_registers): Delete. (target_store_registers): New. (debug_to_thread_alive, debug_to_find_new_threads): Delete. (setup_target_debug): Adjust. * gdbcore.h (core_ops): Delete declaration. * inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c, inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c, i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c, hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c, nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c, alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c, bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c, hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c, ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c, m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c, mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c, ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c, shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c, vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes. * gdbarch.sh (core_pid_to_str): New gdbarch callback. * gdbarch.h, gdbarch.c: Regenerate. * sol2-tdep.c: Include "inferior.h". (sol2_core_pid_to_str): New. * sol2-tdep.h (sol2_core_pid_to_str): Declare. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it. * i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
gdbsim_fetch_register (ops, regcache, regno);
return;
}
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
switch (gdbarch_register_sim_regno (gdbarch, regno))
{
case LEGACY_SIM_REGNO_IGNORE:
break;
case SIM_REGNO_DOES_NOT_EXIST:
{
/* For moment treat a `does not exist' register the same way
as an ``unavailable'' register. */
Use gdb_byte for bytes from the program being debugged. gdb_byte should be used for bytes from the program being debugged. We have many places using char or unsigned char instead all over the existing ports, and more ends up added over time due to copy/paste as new code is based on old code. I've greped the tree for "char buf[", and fixed all I found. Tested by building with --enable-targets=all. 2013-03-01 Pedro Alves <palves@redhat.com> Use gdb_byte for bytes from the program being debugged. * arm-tdep.c (arm_store_return_value, arm_get_longjmp_target): Change type of local 'buf' to gdb_byte. * avr-tdep.c (avr_frame_prev_register, avr_push_dummy_call): Likewise. * bfin-tdep.c (bfin_push_dummy_call): Likewise. * cris-tdep.c (cris_sigcontext_addr) (cris_sigtramp_frame_unwind_cache): Likewise. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp) (frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache): Likewise. * frv-tdep.c (frv_pseudo_register_write, frv_analyze_prologue): Likewise. * hppa-hpux-tdep.c (hppa32_hpux_find_global_pointer) (hppa32_hpux_search_dummy_call_sequence) (hppa_hpux_supply_save_state): Likewise. * hppa-linux-tdep.c (insns_match_pattern) (hppa_linux_find_global_pointer): Likewise. * hppa-tdep.c (hppa_in_function_epilogue_p) (skip_prologue_hard_way, hppa_frame_cache): Likewise. * i386-nto-tdep.c (i386nto_sigcontext_addr): Likewise. * i386fbsd-tdep.c (i386fbsd_supply_uthread) (i386fbsd_collect_uthread): Likewise. * ia64-hpux-tdep.c (ia64_hpux_push_dummy_code): Likewise. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Likewise. * ia64-tdep.c (examine_prologue, ia64_frame_cache) (ia64_frame_prev_register, ia64_sigtramp_frame_cache) (ia64_sigtramp_frame_prev_register, ia64_access_reg) (ia64_access_rse_reg, ia64_libunwind_frame_this_id) (ia64_libunwind_frame_prev_register) (ia64_libunwind_sigtramp_frame_this_id) (ia64_find_global_pointer_from_dynamic_section) (find_extant_func_descr, find_func_descr, ia64_dummy_id) (ia64_unwind_pc): Likewise. * iq2000-tdep.c (iq2000_store_return_value): Likewise. * m68hc11-tdep.c (m68hc11_push_dummy_call) (m68hc11_extract_return_value): Likewise. * m68klinux-nat.c (fetch_register, store_register): Likewise. * mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_cr32_write) (mep_get_insn, mep_push_dummy_call): Likewise. * mips-linux-tdep.c (mips_linux_get_longjmp_target) (mips_linux_in_dynsym_stub): Likewise. * mn10300-tdep.c (mep_pseudo_cr32_write): Likewise. * ppc-linux-nat.c (fetch_register, store_register): Likewise. * regcache.c (dump_endian_bytes): Change type of parameter 'buf' to gdb_byte. * remote-mips.c (mips_set_register): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. * score-tdep.c (score7_fetch_inst): Change type of parameter 'memblock' and local 'buf' to gdb_byte. (score7_malloc_and_get_memblock): Change return type to gdb_byte. Change type of local 'buf' to gdb_byte. Adjust. (score7_adjust_memblock_ptr): Change type of parameter 'memblock' to gdb_byte**. (score7_analyze_prologue): Change type of 'memblock' and 'memblock_ptr' locals to gdb_byte*. * sh64-tdep.c (sh64_extract_return_value) (sh64_store_return_value): Change type of local 'buf' to gdb_byte. * solib-darwin.c (darwin_current_sos, darwin_read_exec_load_addr): * solib-pa64.c (pa64_solib_create_inferior_hook) (pa64_open_symbol_file_object): Remove local 'buf'. * solib-som.c (som_solib_create_inferior_hook, link_map_start) (som_open_symbol_file_object): Likewise. * solib-spu.c (spu_current_sos): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. * spu-multiarch.c (parse_spufs_run, spu_fetch_registers) (spu_store_registers): Likewise. * target.c (debug_print_register): Likewise. * tic6x-tdep.c (tic6x_get_longjmp_target): Likewise. * xstormy16-tdep.c (xstormy16_store_return_value) (xstormy16_push_dummy_call, xstormy16_resolve_jmp_table_entry) (xstormy16_find_jmp_table_entry): Likewise.
2013-03-01 16:38:27 +01:00
gdb_byte buf[MAX_REGISTER_SIZE];
int nr_bytes;
memset (buf, 0, MAX_REGISTER_SIZE);
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
regcache_raw_supply (regcache, regno, buf);
break;
}
default:
{
static int warn_user = 1;
Use gdb_byte for bytes from the program being debugged. gdb_byte should be used for bytes from the program being debugged. We have many places using char or unsigned char instead all over the existing ports, and more ends up added over time due to copy/paste as new code is based on old code. I've greped the tree for "char buf[", and fixed all I found. Tested by building with --enable-targets=all. 2013-03-01 Pedro Alves <palves@redhat.com> Use gdb_byte for bytes from the program being debugged. * arm-tdep.c (arm_store_return_value, arm_get_longjmp_target): Change type of local 'buf' to gdb_byte. * avr-tdep.c (avr_frame_prev_register, avr_push_dummy_call): Likewise. * bfin-tdep.c (bfin_push_dummy_call): Likewise. * cris-tdep.c (cris_sigcontext_addr) (cris_sigtramp_frame_unwind_cache): Likewise. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp) (frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache): Likewise. * frv-tdep.c (frv_pseudo_register_write, frv_analyze_prologue): Likewise. * hppa-hpux-tdep.c (hppa32_hpux_find_global_pointer) (hppa32_hpux_search_dummy_call_sequence) (hppa_hpux_supply_save_state): Likewise. * hppa-linux-tdep.c (insns_match_pattern) (hppa_linux_find_global_pointer): Likewise. * hppa-tdep.c (hppa_in_function_epilogue_p) (skip_prologue_hard_way, hppa_frame_cache): Likewise. * i386-nto-tdep.c (i386nto_sigcontext_addr): Likewise. * i386fbsd-tdep.c (i386fbsd_supply_uthread) (i386fbsd_collect_uthread): Likewise. * ia64-hpux-tdep.c (ia64_hpux_push_dummy_code): Likewise. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Likewise. * ia64-tdep.c (examine_prologue, ia64_frame_cache) (ia64_frame_prev_register, ia64_sigtramp_frame_cache) (ia64_sigtramp_frame_prev_register, ia64_access_reg) (ia64_access_rse_reg, ia64_libunwind_frame_this_id) (ia64_libunwind_frame_prev_register) (ia64_libunwind_sigtramp_frame_this_id) (ia64_find_global_pointer_from_dynamic_section) (find_extant_func_descr, find_func_descr, ia64_dummy_id) (ia64_unwind_pc): Likewise. * iq2000-tdep.c (iq2000_store_return_value): Likewise. * m68hc11-tdep.c (m68hc11_push_dummy_call) (m68hc11_extract_return_value): Likewise. * m68klinux-nat.c (fetch_register, store_register): Likewise. * mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_cr32_write) (mep_get_insn, mep_push_dummy_call): Likewise. * mips-linux-tdep.c (mips_linux_get_longjmp_target) (mips_linux_in_dynsym_stub): Likewise. * mn10300-tdep.c (mep_pseudo_cr32_write): Likewise. * ppc-linux-nat.c (fetch_register, store_register): Likewise. * regcache.c (dump_endian_bytes): Change type of parameter 'buf' to gdb_byte. * remote-mips.c (mips_set_register): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. * score-tdep.c (score7_fetch_inst): Change type of parameter 'memblock' and local 'buf' to gdb_byte. (score7_malloc_and_get_memblock): Change return type to gdb_byte. Change type of local 'buf' to gdb_byte. Adjust. (score7_adjust_memblock_ptr): Change type of parameter 'memblock' to gdb_byte**. (score7_analyze_prologue): Change type of 'memblock' and 'memblock_ptr' locals to gdb_byte*. * sh64-tdep.c (sh64_extract_return_value) (sh64_store_return_value): Change type of local 'buf' to gdb_byte. * solib-darwin.c (darwin_current_sos, darwin_read_exec_load_addr): * solib-pa64.c (pa64_solib_create_inferior_hook) (pa64_open_symbol_file_object): Remove local 'buf'. * solib-som.c (som_solib_create_inferior_hook, link_map_start) (som_open_symbol_file_object): Likewise. * solib-spu.c (spu_current_sos): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. * spu-multiarch.c (parse_spufs_run, spu_fetch_registers) (spu_store_registers): Likewise. * target.c (debug_print_register): Likewise. * tic6x-tdep.c (tic6x_get_longjmp_target): Likewise. * xstormy16-tdep.c (xstormy16_store_return_value) (xstormy16_push_dummy_call, xstormy16_resolve_jmp_table_entry) (xstormy16_find_jmp_table_entry): Likewise.
2013-03-01 16:38:27 +01:00
gdb_byte buf[MAX_REGISTER_SIZE];
int nr_bytes;
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
gdb_assert (regno >= 0 && regno < gdbarch_num_regs (gdbarch));
memset (buf, 0, MAX_REGISTER_SIZE);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
nr_bytes = sim_fetch_register (sim_data->gdbsim_desc,
gdbarch_register_sim_regno
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
(gdbarch, regno),
buf,
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
register_size (gdbarch, regno));
if (nr_bytes > 0
&& nr_bytes != register_size (gdbarch, regno) && warn_user)
{
fprintf_unfiltered (gdb_stderr,
"Size of register %s (%d/%d) "
"incorrect (%d instead of %d))",
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
gdbarch_register_name (gdbarch, regno),
regno,
gdbarch_register_sim_regno
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
(gdbarch, regno),
nr_bytes, register_size (gdbarch, regno));
warn_user = 0;
}
/* FIXME: cagney/2002-05-27: Should check `nr_bytes == 0'
indicating that GDB and the SIM have different ideas about
which registers are fetchable. */
/* Else if (nr_bytes < 0): an old simulator, that doesn't
think to return the register size. Just assume all is ok. */
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
regcache_raw_supply (regcache, regno, buf);
if (remote_debug)
{
fprintf_unfiltered (gdb_stdlog,
"gdbsim_fetch_register: %d", regno);
/* FIXME: We could print something more intelligible. */
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
dump_mem (buf, register_size (gdbarch, regno));
}
break;
}
}
}
static void
* corelow.c (get_core_registers): Adjust. (core_file_thread_alive): Rename to... (core_thread_alive): ... this. (core_pid_to_str): Try gdbarch_core_pid_to_str first. (init_core_ops): Adjust. (coreops_suppress_target): Delete. (_initialize_corelow): Unconditionally add core_ops. * procfs.c: Include "inf-child.h". (procfs_ops): Delete. (init_procfs_ops): Delete. Reimplement as... (procfs_target): ... this, inheriting from inf-child. (procfs_attach, procfs_detach, procfs_fetch_registers): Adjust. (procfs_prepare_to_store): Delete. (procfs_store_registers, procfs_resume): Adjust. (procfs_open): Delete. (procfs_suppress_run): Delete. (procfs_can_run): Delete. (procfs_mourn_inferior): Adjust. (procfs_init_inferior): Add target_ops parameter. Adjust. (procfs_create_inferior): Don't pass procfs_init_inferior to fork_inferior. Instead call it after fork_inferior returns. (procfs_find_new_threads): Adjust. (_initialize_procfs): Adjust to use procfs_target instead of init_procfs_ops. * sol-thread.c (orig_core_ops, sol_core_ops): Delete. (lwp_to_thread): Use target_thread_alive. (sol_thread_open): Delete. (sol_thread_attach): Delete. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers): Adjust to use find_target_beneath. (sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete. (sol_thread_xfer_partial): Adjust to use find_target_beneath. (sol_thread_files_info, sol_thread_kill_inferior): Delete. (check_for_thread_db): New. (sol_thread_notice_signals, sol_thread_create_inferior): Delete. (sol_thread_new_objfile): Call check_for_thread_db. (sol_thread_mourn_inferior): Adjust to use find_target_beneath. (sol_thread_can_run): Delete. (sol_thread_alive): Adjust to use find_target_beneath. (sol_thread_stop): Delete. (rw_common): Use target_write_memory or target_read_memory. (ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers. (ps_lsetregs, ps_lsetfpregs): Use target_store_registers. (solaris_pid_to_str): Remove check for libthread_db initialization failing. (sol_find_new_threads): Remove check for libthread_db initialization failing, or for an invalid inferior_ptid. Adjust to use find_target_beneath. (sol_core_open, sol_core_close, sol_core_detach, sol_core_files_info, sol_find_memory_regions, sol_make_note_section, ignore): Delete. (init_sol_thread_ops): Make it a thread_stratum target. Remove unneeded callback settings. (init_sol_core_ops): Delete. (_initialize_sol_thread): No longer call init_sol_core_ops, set procfs_suppress_run, or hack with core_ops. * target.h (struct target_ops): Add a target_ops * parameter to to_resume, to_fetch_registers, to_store_registers, to_thread_alive and to_find_new_threads. (target_fetch_registers, target_store_registers) (target_thread_alive, target_find_new_threads): Redeclare as function. * target.c (update_current_target): Do not inherit or de_fault to_resume, to_fetch_registers, to_store_registers, to_thread_alive, to_find_new_threads. (target_resume): Adjust. (target_thread_alive, target_find_new_threads): New. (debug_to_resume, debug_to_fetch_registers): Delete. (target_fetch_registers): New. (debug_to_store_registers): Delete. (target_store_registers): New. (debug_to_thread_alive, debug_to_find_new_threads): Delete. (setup_target_debug): Adjust. * gdbcore.h (core_ops): Delete declaration. * inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c, inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c, i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c, hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c, nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c, alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c, bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c, hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c, ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c, m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c, mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c, ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c, shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c, vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes. * gdbarch.sh (core_pid_to_str): New gdbarch callback. * gdbarch.h, gdbarch.c: Regenerate. * sol2-tdep.c: Include "inferior.h". (sol2_core_pid_to_str): New. * sol2-tdep.h (sol2_core_pid_to_str): Declare. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it. * i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
gdbsim_store_register (struct target_ops *ops,
struct regcache *regcache, int regno)
{
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
struct gdbarch *gdbarch = get_regcache_arch (regcache);
Use ptid from regcache in almost all remaining nat files This patch contains almost all of the remaining changes needed to make to_fetch_registers/to_store_registers/to_prepare_to_store independent of inferior_ptid. It contains only some "trivial" changes, the more complicated ones are in separate patches. gdb/ChangeLog: * i386-linux-nat.c (fetch_register, store_register, i386_linux_fetch_inferior_registers, i386_linux_store_inferior_registers): Use ptid from regcache. * ia64-linux-nat.c (ia64_linux_fetch_register, ia64_linux_store_register): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register, inf_ptrace_store_register): Likewise. * m32r-linux-nat.c (m32r_linux_fetch_inferior_registers, m32r_linux_store_inferior_registers): Likewise. * m68k-bsd-nat.c (m68kbsd_fetch_inferior_registers, m68kbsd_store_inferior_registers): Likewise. * m68k-linux-nat.c (fetch_register, store_register, m68k_linux_fetch_inferior_registers, m68k_linux_store_inferior_registers): Likewise. * m88k-bsd-nat.c (m88kbsd_fetch_inferior_registers, m88kbsd_store_inferior_registers): Likewise. * mips-fbsd-nat.c (mips_fbsd_fetch_inferior_registers, mips_fbsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers, mips64_linux_regsets_store_registers): Likewise. * mips-nbsd-nat.c (mipsnbsd_fetch_inferior_registers, mipsnbsd_store_inferior_registers): Likewise. * mips-obsd-nat.c (mips64obsd_fetch_inferior_registers, mips64obsd_store_inferior_registers): Likewise. * nto-procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * ppc-fbsd-nat.c (ppcfbsd_fetch_inferior_registers, ppcfbsd_store_inferior_registers): Likewise. * ppc-linux-nat.c (ppc_linux_fetch_inferior_registers, ppc_linux_store_inferior_registers): Likewise. * ppc-nbsd-nat.c (ppcnbsd_fetch_inferior_registers, ppcnbsd_store_inferior_registers): Likewise. * ppc-obsd-nat.c (ppcobsd_fetch_registers, ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * ravenscar-thread.c (ravenscar_fetch_registers, ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. * record-btrace.c (record_btrace_fetch_registers, record_btrace_store_registers, record_btrace_prepare_to_store): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Lookup inferior using ptid from regcache, instead of current_inferior. * remote.c (remote_fetch_registers, remote_store_registers): Use ptid from regcache. * rs6000-nat.c (fetch_register, store_register): Likewise. * s390-linux-nat.c (s390_linux_fetch_inferior_registers, s390_linux_store_inferior_registers): Likewise. * sh-nbsd-nat.c (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers, sol_thread_store_registers): Likewise. * sparc-nat.c (sparc_fetch_inferior_registers, sparc_store_inferior_registers): Likewise. * tilegx-linux-nat.c (fetch_inferior_registers, store_inferior_registers): Likewise. * vax-bsd-nat.c (vaxbsd_fetch_inferior_registers, vaxbsd_store_inferior_registers): Likewise. * xtensa-linux-nat.c (fetch_gregs, store_gregs, fetch_xtregs, store_xtregs): Likewise.
2017-03-20 22:37:36 +01:00
struct inferior *inf = find_inferior_ptid (regcache_get_ptid (regcache));
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct sim_inferior_data *sim_data
Use ptid from regcache in almost all remaining nat files This patch contains almost all of the remaining changes needed to make to_fetch_registers/to_store_registers/to_prepare_to_store independent of inferior_ptid. It contains only some "trivial" changes, the more complicated ones are in separate patches. gdb/ChangeLog: * i386-linux-nat.c (fetch_register, store_register, i386_linux_fetch_inferior_registers, i386_linux_store_inferior_registers): Use ptid from regcache. * ia64-linux-nat.c (ia64_linux_fetch_register, ia64_linux_store_register): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register, inf_ptrace_store_register): Likewise. * m32r-linux-nat.c (m32r_linux_fetch_inferior_registers, m32r_linux_store_inferior_registers): Likewise. * m68k-bsd-nat.c (m68kbsd_fetch_inferior_registers, m68kbsd_store_inferior_registers): Likewise. * m68k-linux-nat.c (fetch_register, store_register, m68k_linux_fetch_inferior_registers, m68k_linux_store_inferior_registers): Likewise. * m88k-bsd-nat.c (m88kbsd_fetch_inferior_registers, m88kbsd_store_inferior_registers): Likewise. * mips-fbsd-nat.c (mips_fbsd_fetch_inferior_registers, mips_fbsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers, mips64_linux_regsets_store_registers): Likewise. * mips-nbsd-nat.c (mipsnbsd_fetch_inferior_registers, mipsnbsd_store_inferior_registers): Likewise. * mips-obsd-nat.c (mips64obsd_fetch_inferior_registers, mips64obsd_store_inferior_registers): Likewise. * nto-procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * ppc-fbsd-nat.c (ppcfbsd_fetch_inferior_registers, ppcfbsd_store_inferior_registers): Likewise. * ppc-linux-nat.c (ppc_linux_fetch_inferior_registers, ppc_linux_store_inferior_registers): Likewise. * ppc-nbsd-nat.c (ppcnbsd_fetch_inferior_registers, ppcnbsd_store_inferior_registers): Likewise. * ppc-obsd-nat.c (ppcobsd_fetch_registers, ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * ravenscar-thread.c (ravenscar_fetch_registers, ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. * record-btrace.c (record_btrace_fetch_registers, record_btrace_store_registers, record_btrace_prepare_to_store): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Lookup inferior using ptid from regcache, instead of current_inferior. * remote.c (remote_fetch_registers, remote_store_registers): Use ptid from regcache. * rs6000-nat.c (fetch_register, store_register): Likewise. * s390-linux-nat.c (s390_linux_fetch_inferior_registers, s390_linux_store_inferior_registers): Likewise. * sh-nbsd-nat.c (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers, sol_thread_store_registers): Likewise. * sparc-nat.c (sparc_fetch_inferior_registers, sparc_store_inferior_registers): Likewise. * tilegx-linux-nat.c (fetch_inferior_registers, store_inferior_registers): Likewise. * vax-bsd-nat.c (vaxbsd_fetch_inferior_registers, vaxbsd_store_inferior_registers): Likewise. * xtensa-linux-nat.c (fetch_gregs, store_gregs, fetch_xtregs, store_xtregs): Likewise.
2017-03-20 22:37:36 +01:00
= get_sim_inferior_data (inf, SIM_INSTANCE_NEEDED);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
1999-07-07 22:19:36 +02:00
if (regno == -1)
{
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
for (regno = 0; regno < gdbarch_num_regs (gdbarch); regno++)
* corelow.c (get_core_registers): Adjust. (core_file_thread_alive): Rename to... (core_thread_alive): ... this. (core_pid_to_str): Try gdbarch_core_pid_to_str first. (init_core_ops): Adjust. (coreops_suppress_target): Delete. (_initialize_corelow): Unconditionally add core_ops. * procfs.c: Include "inf-child.h". (procfs_ops): Delete. (init_procfs_ops): Delete. Reimplement as... (procfs_target): ... this, inheriting from inf-child. (procfs_attach, procfs_detach, procfs_fetch_registers): Adjust. (procfs_prepare_to_store): Delete. (procfs_store_registers, procfs_resume): Adjust. (procfs_open): Delete. (procfs_suppress_run): Delete. (procfs_can_run): Delete. (procfs_mourn_inferior): Adjust. (procfs_init_inferior): Add target_ops parameter. Adjust. (procfs_create_inferior): Don't pass procfs_init_inferior to fork_inferior. Instead call it after fork_inferior returns. (procfs_find_new_threads): Adjust. (_initialize_procfs): Adjust to use procfs_target instead of init_procfs_ops. * sol-thread.c (orig_core_ops, sol_core_ops): Delete. (lwp_to_thread): Use target_thread_alive. (sol_thread_open): Delete. (sol_thread_attach): Delete. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers): Adjust to use find_target_beneath. (sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete. (sol_thread_xfer_partial): Adjust to use find_target_beneath. (sol_thread_files_info, sol_thread_kill_inferior): Delete. (check_for_thread_db): New. (sol_thread_notice_signals, sol_thread_create_inferior): Delete. (sol_thread_new_objfile): Call check_for_thread_db. (sol_thread_mourn_inferior): Adjust to use find_target_beneath. (sol_thread_can_run): Delete. (sol_thread_alive): Adjust to use find_target_beneath. (sol_thread_stop): Delete. (rw_common): Use target_write_memory or target_read_memory. (ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers. (ps_lsetregs, ps_lsetfpregs): Use target_store_registers. (solaris_pid_to_str): Remove check for libthread_db initialization failing. (sol_find_new_threads): Remove check for libthread_db initialization failing, or for an invalid inferior_ptid. Adjust to use find_target_beneath. (sol_core_open, sol_core_close, sol_core_detach, sol_core_files_info, sol_find_memory_regions, sol_make_note_section, ignore): Delete. (init_sol_thread_ops): Make it a thread_stratum target. Remove unneeded callback settings. (init_sol_core_ops): Delete. (_initialize_sol_thread): No longer call init_sol_core_ops, set procfs_suppress_run, or hack with core_ops. * target.h (struct target_ops): Add a target_ops * parameter to to_resume, to_fetch_registers, to_store_registers, to_thread_alive and to_find_new_threads. (target_fetch_registers, target_store_registers) (target_thread_alive, target_find_new_threads): Redeclare as function. * target.c (update_current_target): Do not inherit or de_fault to_resume, to_fetch_registers, to_store_registers, to_thread_alive, to_find_new_threads. (target_resume): Adjust. (target_thread_alive, target_find_new_threads): New. (debug_to_resume, debug_to_fetch_registers): Delete. (target_fetch_registers): New. (debug_to_store_registers): Delete. (target_store_registers): New. (debug_to_thread_alive, debug_to_find_new_threads): Delete. (setup_target_debug): Adjust. * gdbcore.h (core_ops): Delete declaration. * inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c, inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c, i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c, hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c, nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c, alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c, bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c, hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c, ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c, m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c, mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c, ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c, shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c, vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes. * gdbarch.sh (core_pid_to_str): New gdbarch callback. * gdbarch.h, gdbarch.c: Regenerate. * sol2-tdep.c: Include "inferior.h". (sol2_core_pid_to_str): New. * sol2-tdep.h (sol2_core_pid_to_str): Declare. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it. * i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
gdbsim_store_register (ops, regcache, regno);
return;
}
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
else if (gdbarch_register_sim_regno (gdbarch, regno) >= 0)
{
gdb_byte tmp[MAX_REGISTER_SIZE];
int nr_bytes;
* target.h (struct regcache): Add forward declaration. (struct target_ops): Add REGCACHE parameter to to_fetch_registers and to_store_registers target operations. (target_fetch_registers, target_store_registers): Update. * regcache.c (regcache_raw_read): Replace register_cached by regcache_valid_p. Pass regcache to target_fetch_registers. (regcache_raw_write): Pass regcache to target_store_registers. * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, store_regs, store_wmmx_regs): Replace register_cached by regcache_valid_p. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache to target_fetch_registers calls. * corelow.c (core_open): Likewise. * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * win32-nat.c (win32_resume): Likewise. * ia64-tdep.c (ia64_store_return_value): Pass current_regcache to target_store_registers call. * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. * inferior.h (store_inferior_registers): Update prototype. (fetch_inferior_registers): Likewise. * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. * mips-linux-nat.c (super_fetch_registers, super_store_registers): Update function pointer signatures. * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, use it instead of current_regcache, update calls. (aix_thread_store_registers): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, store_fpregs, fetch_register, fetch_regs, store_register, store_regs, fetch_wmmx_regs, store_wmmx_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers): Likewise. (store_register, store_regs, store_fp_register, store_fp_regs, armnbsd_store_registers): Likewise. * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * corelow.c (get_core_registers): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register, go32_store_registers): Likewise. * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. (hppabsd_store_registers): Likewise. * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. (hppa_hpux_fetch_inferior_registers): Likewise. (hppa_hpux_store_register): Likewise. (hppa_hpux_store_inferior_registers): Likewise. * hppa-linux-nat.c (fetch_register, store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * hpux-thread.c (hpux_thread_fetch_registers): Likewise. (hpux_thread_store_registers): Likewise. * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. (i386bsd_store_inferior_registers): Likewise. * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register, store_register, fetch_regs, store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_register): Likewise. (ia64_linux_store_registers): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. (inf_child_store_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_register): Likewise. (inf_ptrace_store_registers): Likewise. * infptrace.c (fetch_register, store_register): Likewise. (fetch_inferior_registers, store_inferior_registers): Likewise. * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. (m32r_linux_fetch_inferior_registers): Likewise. (m32r_linux_store_inferior_registers): Likewise. * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. (m68kbsd_store_inferior_registers): Likewise. * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, store_register, old_store_inferior_registers, fetch_regs, store_regs, fetch_fpregs, store_fpregs): Likewise. (m68k_linux_fetch_inferior_registers): Likewise. (m68k_linux_store_inferior_registers): Likewise. * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. (m88kbsd_store_inferior_registers): Likewise. * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. (mips64obsd_store_inferior_registers): Likewise. * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Likewise. (mips64_linux_store_registers): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. (monitor_fetch_registers, monitor_store_registers): Likewise. * nto-procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, fetch_register, supply_vrregset, fetch_altivec_registers, fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. (store_altivec_register, store_spe_register, store_register, fill_vrregset, store_altivec_registers, store_ppc_registers, ppc_linux_store_inferior_registers): Likewise. * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. (ppcnbsd_store_inferior_registers): Likewise. * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote.c (fetch_register_using_p, process_g_packet, fetch_registers_using_g, remote_fetch_registers): Likewise. (store_register_using_P, store_registers_using_G, remote_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, m32r_store_register, m32r_store_register): Likewise. * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * rs6000-nat.c (fetch_register, store_register): Likewise. (rs6000_fetch_inferior_registers): Likewise. (rs6000_store_inferior_registers): Likewise. * s390-nat.c (fetch_regs, store_regs): Likewise. (fetch_fpregs, store_fpregs): Likewise. (s390_linux_fetch_inferior_registers): Likewise. (s390_linux_store_inferior_registers): Likewise. * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sol-thread.c (sol_thread_fetch_registers): Likewise. (sol_thread_store_registers): Likewise. * sparc-nat.c (fetch_inferior_registers): Likewise. (store_inferior_registers): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. (spu_store_inferior_registers): Likewise. * target.c (debug_print_register): Likewise. (debug_to_fetch_registers, debug_to_store_registers): Likewise. * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. (vaxbsd_store_inferior_registers): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. (win32_fetch_inferior_registers): Likewise. (win32_store_inferior_registers): Likewise.
2007-05-06 16:34:38 +02:00
regcache_cooked_read (regcache, regno, tmp);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
nr_bytes = sim_store_register (sim_data->gdbsim_desc,
gdbarch_register_sim_regno
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
(gdbarch, regno),
tmp, register_size (gdbarch, regno));
if (nr_bytes > 0 && nr_bytes != register_size (gdbarch, regno))
internal_error (__FILE__, __LINE__,
2005-02-11 Andrew Cagney <cagney@gnu.org> Mark up error_no_arg, query, perror_with_name, complaint, and internal_error. * breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update. * cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update. * dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update. * exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update. * frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update. * gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update. * go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update. * i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update. * i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update. * infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update. * interps.c, language.c, linespec.c, linux-nat.c: Update. * m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update. * m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update. * macrotab.c, maint.c, mdebugread.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update. * mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update. * objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update. * parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update. * ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update. * regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update. * remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update. * s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update. * sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update. * solib-aix5.c, solib-svr4.c, solib.c, source.c: Update. * sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update. * symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update. * utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update. * win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update. * cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update. * cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update. * mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update. * tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 19:13:55 +01:00
_("Register size different to expected"));
if (nr_bytes < 0)
internal_error (__FILE__, __LINE__,
_("Register %d not updated"), regno);
if (nr_bytes == 0)
warning (_("Register %s not updated"),
gdbarch_register_name (gdbarch, regno));
if (remote_debug)
{
fprintf_unfiltered (gdb_stdlog, "gdbsim_store_register: %d", regno);
/* FIXME: We could print something more intelligible. */
2007-11-16 Markus Deuling <deuling@de.ibm.com> * m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at the current architecture by regcache. * ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register) (fetch_register, supply_vrregset, fetch_ppc_registers) (store_altivec_register, store_spe_register, store_register) (fill_vrregset, store_ppc_registers): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * win32-nat.c (do_win32_fetch_inferior_registers) (do_win32_store_inferior_registers): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * remote-m32r-sdi.c (m32r_fetch_registers) (m32r_store_registers): Likewise. * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by gdbarch. * user-regs.c (user_reg_map_name_to_regnum): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call) (ppc64_sysv_abi_return_value): Likewise. * m32c-tdep.c (m32c_register_reggroup_p): Likewise. * m2-lang.c (build_m2_types): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * gcore.c (derive_stack_segment): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter. (shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add gdbarch to GETREGS_SUPPLIES call.
2007-11-16 05:53:46 +01:00
dump_mem (tmp, register_size (gdbarch, regno));
}
}
}
/* Kill the running program. This may involve closing any open files
and releasing other resources acquired by the simulated program. */
static void
gdbsim_kill (struct target_ops *ops)
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "gdbsim_kill\n");
/* There is no need to `kill' running simulator - the simulator is
not running. Mourning it is enough. */
Consolidate target_mourn_inferior between GDB and gdbserver This patch consolidates the API of target_mourn_inferior between GDB and gdbserver, in my continuing efforts to make sharing the fork_inferior function possible between both. GDB's version of the function did not care about the inferior's ptid being mourned, but gdbserver's needed to know this information. Since it actually makes sense to pass the ptid as an argument, instead of depending on a global value directly (which GDB's version did), I decided to make the generic API to accept it. I then went on and extended all calls being made on GDB to include a ptid argument (which ended up being inferior_ptid most of the times, anyway), and now we have a more sane interface. On GDB's side, after talking to Pedro a bit about it, we decided that just an assertion to make sure that the ptid being passed is equal to inferior_ptid would be enough for now, on the GDB side. We can remove the assertion and perform more operations later if we ever pass anything different than inferior_ptid. Regression tested on our BuildBot, everything OK. I'd appreciate a special look at gdb/windows-nat.c's modification because I wasn't really sure what to do there. It seemed to me that maybe I should build a ptid out of the process information there, but then I am almost sure the assertion on GDB's side would trigger. gdb/ChangeLog: 2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com> * darwin-nat.c (darwin_kill_inferior): Adjusting call to target_mourn_inferior to include ptid_t argument. * fork-child.c (startup_inferior): Likewise. * gnu-nat.c (gnu_kill_inferior): Likewise. * inf-ptrace.c (inf_ptrace_kill): Likewise. * infrun.c (handle_inferior_event_1): Likewise. * linux-nat.c (linux_nat_attach): Likewise. (linux_nat_kill): Likewise. * nto-procfs.c (interrupt_query): Likewise. (procfs_interrupt): Likewise. (procfs_kill_inferior): Likewise. * procfs.c (procfs_kill_inferior): Likewise. * record.c (record_mourn_inferior): Likewise. * remote-sim.c (gdbsim_kill): Likewise. * remote.c (remote_detach_1): Likewise. (remote_kill): Likewise. * target.c (target_mourn_inferior): Change declaration to accept new ptid_t argument; use gdb_assert on it. * target.h (target_mourn_inferior): Move function prototype from here... * target/target.h (target_mourn_inferior): ... to here. Adjust it to accept new ptid_t argument. * windows-nat.c (get_windows_debug_event): Adjusting call to target_mourn_inferior to include ptid_t argument. gdb/gdbserver/ChangeLog: 2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com> * server.c (start_inferior): Call target_mourn_inferior instead of mourn_inferior; pass ptid_t argument to it. (resume): Likewise. (handle_target_event): Likewise. * target.c (target_mourn_inferior): New function. * target.h (mourn_inferior): Delete macro.
2016-09-12 05:45:31 +02:00
target_mourn_inferior (inferior_ptid);
}
/* Load an executable file into the target process. This is expected to
not only bring new code into the target process, but also to update
GDB's symbol tables to match. */
static void
gdbsim_load (struct target_ops *self, const char *args, int fromtty)
{
char **argv;
const char *prog;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct sim_inferior_data *sim_data
= get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NEEDED);
if (args == NULL)
error_no_arg (_("program to load"));
argv = gdb_buildargv (args);
make_cleanup_freeargv (argv);
prog = tilde_expand (argv[0]);
if (argv[1] != NULL)
error (_("GDB sim does not yet support a load offset."));
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "gdbsim_load: prog \"%s\"\n", prog);
/* FIXME: We will print two messages on error.
Need error to either not print anything if passed NULL or need
another routine that doesn't take any arguments. */
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
if (sim_load (sim_data->gdbsim_desc, prog, NULL, fromtty) == SIM_RC_FAIL)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("unable to load program"));
/* FIXME: If a load command should reset the targets registers then
a call to sim_create_inferior() should go here. */
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
sim_data->program_loaded = 1;
}
2001-05-04 06:15:33 +02:00
/* Start an inferior process and set inferior_ptid to its pid.
EXEC_FILE is the file to run.
ARGS is a string containing the arguments to the program.
ENV is the environment vector to pass. Errors reported with error().
On VxWorks and various standalone systems, we ignore exec_file. */
/* This is called not only when we first attach, but also when the
user types "run" after having attached. */
static void
C++-fy and prepare for sharing fork_inferior As a preparation for the next patch, which will move fork_inferior from GDB to common/ (and therefore share it with gdbserver), it is interesting to convert a few functions to C++. This patch touches functions related to parsing command-line arguments to the inferior (see gdb/fork-child.c:breakup_args), the way the arguments are stored on fork_inferior (using std::vector instead of char **), and the code responsible for dealing with argv also on gdbserver. I've taken this opportunity and decided to constify a few arguments to fork_inferior/create_inferior as well, in order to make the code cleaner. And now, on gdbserver, we're using xstrdup everywhere and aren't checking for memory allocation failures anymore, as requested by Pedro: <https://sourceware.org/ml/gdb-patches/2017-03/msg00191.html> Message-Id: <025ebdb9-90d9-d54a-c055-57ed2406b812@redhat.com> Pedro Alves wrote: > On the "== NULL" check: IIUC, the old NULL check was there to > handle strdup returning NULL due to out-of-memory. > See NULL checks and comments further above in this function. > Now that you're using a std::vector, that doesn't work or make > sense any longer, since if push_back fails to allocate space for > its internal buffer (with operator new), our operator new replacement > (common/new-op.c) calls malloc_failure, which aborts gdbserver. > > Not sure it makes sense to handle out-of-memory specially in > the gdb/rsp-facing functions nowadays (maybe git blame/log/patch > submission for that code shows some guidelines). Maybe (or, probably) > it's OK to stop caring about it, but then we should consistently remove > left over code, by using xstrdup instead and remove the NULL checks. IMO this refactoring was very good to increase the readability of the code as well, because some parts of the argument handling were unnecessarily confusing before. gdb/ChangeLog: 2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com> * common/common-utils.c (free_vector_argv): New function. * common/common-utils.h: Include <vector>. (free_vector_argv): New prototype. * darwin-nat.c (darwin_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * fork-child.c: Include <vector>. (breakup_args): Rewrite function, using C++. (fork_inferior): Rewrite function header, constify "exec_file_arg" and accept "std::string" for "allargs". Update the code to calculate "argv" based on "allargs". Update calls to "exec_fun" and "execvp". * gnu-nat.c (gnu_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * go32-nat.c (go32_create_inferior): Likewise. * inf-ptrace.c (inf_ptrace_create_inferior): Likewise. * infcmd.c (run_command_1): Constify "exec_file". Use "std::string" for inferior arguments. * inferior.h (fork_inferior): Update prototype. * linux-nat.c (linux_nat_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * nto-procfs.c (procfs_create_inferior): Likewise. * procfs.c (procfs_create_inferior): Likewise. * remote-sim.c (gdbsim_create_inferior): Likewise. * remote.c (extended_remote_run): Update code to accept "std::string" as argument. (extended_remote_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * rs6000-nat.c (super_create_inferior): Likewise. (rs6000_create_inferior): Likewise. * target.h (struct target_ops) <to_create_inferior>: Likewise. * windows-nat.c (windows_create_inferior): Likewise. gdb/gdbserver/ChangeLog: 2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com> * server.c: Include <vector>. <program_argv, wrapper_argv>: Convert to std::vector. (start_inferior): Rewrite function to use C++. (handle_v_run): Likewise. Update code that calculates the argv based on the vRun packet; use C++. (captured_main): Likewise.
2017-03-23 02:54:49 +01:00
gdbsim_create_inferior (struct target_ops *target, const char *exec_file,
const std::string &allargs, char **env, int from_tty)
{
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct sim_inferior_data *sim_data
= get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NEEDED);
int len;
1999-07-07 22:19:36 +02:00
char *arg_buf, **argv;
C++-fy and prepare for sharing fork_inferior As a preparation for the next patch, which will move fork_inferior from GDB to common/ (and therefore share it with gdbserver), it is interesting to convert a few functions to C++. This patch touches functions related to parsing command-line arguments to the inferior (see gdb/fork-child.c:breakup_args), the way the arguments are stored on fork_inferior (using std::vector instead of char **), and the code responsible for dealing with argv also on gdbserver. I've taken this opportunity and decided to constify a few arguments to fork_inferior/create_inferior as well, in order to make the code cleaner. And now, on gdbserver, we're using xstrdup everywhere and aren't checking for memory allocation failures anymore, as requested by Pedro: <https://sourceware.org/ml/gdb-patches/2017-03/msg00191.html> Message-Id: <025ebdb9-90d9-d54a-c055-57ed2406b812@redhat.com> Pedro Alves wrote: > On the "== NULL" check: IIUC, the old NULL check was there to > handle strdup returning NULL due to out-of-memory. > See NULL checks and comments further above in this function. > Now that you're using a std::vector, that doesn't work or make > sense any longer, since if push_back fails to allocate space for > its internal buffer (with operator new), our operator new replacement > (common/new-op.c) calls malloc_failure, which aborts gdbserver. > > Not sure it makes sense to handle out-of-memory specially in > the gdb/rsp-facing functions nowadays (maybe git blame/log/patch > submission for that code shows some guidelines). Maybe (or, probably) > it's OK to stop caring about it, but then we should consistently remove > left over code, by using xstrdup instead and remove the NULL checks. IMO this refactoring was very good to increase the readability of the code as well, because some parts of the argument handling were unnecessarily confusing before. gdb/ChangeLog: 2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com> * common/common-utils.c (free_vector_argv): New function. * common/common-utils.h: Include <vector>. (free_vector_argv): New prototype. * darwin-nat.c (darwin_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * fork-child.c: Include <vector>. (breakup_args): Rewrite function, using C++. (fork_inferior): Rewrite function header, constify "exec_file_arg" and accept "std::string" for "allargs". Update the code to calculate "argv" based on "allargs". Update calls to "exec_fun" and "execvp". * gnu-nat.c (gnu_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * go32-nat.c (go32_create_inferior): Likewise. * inf-ptrace.c (inf_ptrace_create_inferior): Likewise. * infcmd.c (run_command_1): Constify "exec_file". Use "std::string" for inferior arguments. * inferior.h (fork_inferior): Update prototype. * linux-nat.c (linux_nat_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * nto-procfs.c (procfs_create_inferior): Likewise. * procfs.c (procfs_create_inferior): Likewise. * remote-sim.c (gdbsim_create_inferior): Likewise. * remote.c (extended_remote_run): Update code to accept "std::string" as argument. (extended_remote_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * rs6000-nat.c (super_create_inferior): Likewise. (rs6000_create_inferior): Likewise. * target.h (struct target_ops) <to_create_inferior>: Likewise. * windows-nat.c (windows_create_inferior): Likewise. gdb/gdbserver/ChangeLog: 2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com> * server.c: Include <vector>. <program_argv, wrapper_argv>: Convert to std::vector. (start_inferior): Rewrite function to use C++. (handle_v_run): Likewise. Update code that calculates the argv based on the vRun packet; use C++. (captured_main): Likewise.
2017-03-23 02:54:49 +01:00
const char *args = allargs.c_str ();
if (exec_file == 0 || exec_bfd == 0)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
warning (_("No executable file specified."));
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
if (!sim_data->program_loaded)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
warning (_("No program loaded."));
if (remote_debug)
fprintf_unfiltered (gdb_stdlog,
"gdbsim_create_inferior: exec_file \"%s\", args \"%s\"\n",
(exec_file ? exec_file : "(NULL)"),
args);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
if (ptid_equal (inferior_ptid, sim_data->remote_sim_ptid))
gdbsim_kill (target);
remove_breakpoints ();
init_wait_for_inferior ();
if (exec_file != NULL)
{
C++-fy and prepare for sharing fork_inferior As a preparation for the next patch, which will move fork_inferior from GDB to common/ (and therefore share it with gdbserver), it is interesting to convert a few functions to C++. This patch touches functions related to parsing command-line arguments to the inferior (see gdb/fork-child.c:breakup_args), the way the arguments are stored on fork_inferior (using std::vector instead of char **), and the code responsible for dealing with argv also on gdbserver. I've taken this opportunity and decided to constify a few arguments to fork_inferior/create_inferior as well, in order to make the code cleaner. And now, on gdbserver, we're using xstrdup everywhere and aren't checking for memory allocation failures anymore, as requested by Pedro: <https://sourceware.org/ml/gdb-patches/2017-03/msg00191.html> Message-Id: <025ebdb9-90d9-d54a-c055-57ed2406b812@redhat.com> Pedro Alves wrote: > On the "== NULL" check: IIUC, the old NULL check was there to > handle strdup returning NULL due to out-of-memory. > See NULL checks and comments further above in this function. > Now that you're using a std::vector, that doesn't work or make > sense any longer, since if push_back fails to allocate space for > its internal buffer (with operator new), our operator new replacement > (common/new-op.c) calls malloc_failure, which aborts gdbserver. > > Not sure it makes sense to handle out-of-memory specially in > the gdb/rsp-facing functions nowadays (maybe git blame/log/patch > submission for that code shows some guidelines). Maybe (or, probably) > it's OK to stop caring about it, but then we should consistently remove > left over code, by using xstrdup instead and remove the NULL checks. IMO this refactoring was very good to increase the readability of the code as well, because some parts of the argument handling were unnecessarily confusing before. gdb/ChangeLog: 2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com> * common/common-utils.c (free_vector_argv): New function. * common/common-utils.h: Include <vector>. (free_vector_argv): New prototype. * darwin-nat.c (darwin_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * fork-child.c: Include <vector>. (breakup_args): Rewrite function, using C++. (fork_inferior): Rewrite function header, constify "exec_file_arg" and accept "std::string" for "allargs". Update the code to calculate "argv" based on "allargs". Update calls to "exec_fun" and "execvp". * gnu-nat.c (gnu_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * go32-nat.c (go32_create_inferior): Likewise. * inf-ptrace.c (inf_ptrace_create_inferior): Likewise. * infcmd.c (run_command_1): Constify "exec_file". Use "std::string" for inferior arguments. * inferior.h (fork_inferior): Update prototype. * linux-nat.c (linux_nat_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * nto-procfs.c (procfs_create_inferior): Likewise. * procfs.c (procfs_create_inferior): Likewise. * remote-sim.c (gdbsim_create_inferior): Likewise. * remote.c (extended_remote_run): Update code to accept "std::string" as argument. (extended_remote_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * rs6000-nat.c (super_create_inferior): Likewise. (rs6000_create_inferior): Likewise. * target.h (struct target_ops) <to_create_inferior>: Likewise. * windows-nat.c (windows_create_inferior): Likewise. gdb/gdbserver/ChangeLog: 2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com> * server.c: Include <vector>. <program_argv, wrapper_argv>: Convert to std::vector. (start_inferior): Rewrite function to use C++. (handle_v_run): Likewise. Update code that calculates the argv based on the vRun packet; use C++. (captured_main): Likewise.
2017-03-23 02:54:49 +01:00
len = strlen (exec_file) + 1 + allargs.size () + 1 + /*slop */ 10;
arg_buf = (char *) alloca (len);
arg_buf[0] = '\0';
strcat (arg_buf, exec_file);
strcat (arg_buf, " ");
strcat (arg_buf, args);
argv = gdb_buildargv (arg_buf);
1999-04-26 20:34:20 +02:00
make_cleanup_freeargv (argv);
}
else
argv = NULL;
if (!have_inferiors ())
init_thread_list ();
if (sim_create_inferior (sim_data->gdbsim_desc, exec_bfd, argv, env)
!= SIM_RC_OK)
error (_("Unable to create sim inferior."));
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
inferior_ptid = sim_data->remote_sim_ptid;
inferior_appeared (current_inferior (), ptid_get_pid (inferior_ptid));
add_thread_silent (inferior_ptid);
insert_breakpoints (); /* Needed to get correct instruction
in cache. */
clear_proceed_status (0);
}
/* The open routine takes the rest of the parameters from the command,
and (if successful) pushes a new target onto the stack.
Targets should supply this routine, if only to provide an error message. */
/* Called when selecting the simulator. E.g. (gdb) target sim name. */
static void
gdbsim_open (const char *args, int from_tty)
{
int len;
char *arg_buf;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct sim_inferior_data *sim_data;
const char *sysroot;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
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)");
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
/* Ensure that the sim target is not on the target stack. This is
necessary, because if it is on the target stack, the call to
push_target below will invoke sim_close(), thus freeing various
state (including a sim instance) that we allocate prior to
invoking push_target(). We want to delay the push_target()
operation until after we complete those operations which could
error out. */
if (gdbsim_is_open)
unpush_target (&gdbsim_ops);
1999-07-07 22:19:36 +02:00
len = (7 + 1 /* gdbsim */
+ strlen (" -E little")
+ strlen (" --architecture=xxxxxxxxxx")
+ strlen (" --sysroot=") + strlen (sysroot) +
+ (args ? strlen (args) : 0)
1999-07-07 22:19:36 +02:00
+ 50) /* slack */ ;
arg_buf = (char *) alloca (len);
1999-07-07 22:19:36 +02:00
strcpy (arg_buf, "gdbsim"); /* 7 */
/* Specify the byte order for the target when it is explicitly
specified by the user (not auto detected). */
switch (selected_byte_order ())
{
case BFD_ENDIAN_BIG:
strcat (arg_buf, " -E big");
break;
case BFD_ENDIAN_LITTLE:
strcat (arg_buf, " -E little");
break;
case BFD_ENDIAN_UNKNOWN:
break;
}
/* Specify the architecture of the target when it has been
explicitly specified */
if (selected_architecture_name () != NULL)
{
strcat (arg_buf, " --architecture=");
strcat (arg_buf, selected_architecture_name ());
}
/* Pass along gdb's concept of the sysroot. */
strcat (arg_buf, " --sysroot=");
strcat (arg_buf, sysroot);
/* finally, any explicit args */
if (args)
{
1999-07-07 22:19:36 +02:00
strcat (arg_buf, " "); /* 1 */
strcat (arg_buf, args);
}
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
sim_argv = gdb_buildargv (arg_buf);
init_callbacks ();
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
gdbsim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback, exec_bfd, sim_argv);
if (gdbsim_desc == 0)
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
{
freeargv (sim_argv);
sim_argv = NULL;
error (_("unable to create simulator instance"));
}
/* Reset the pid numberings for this batch of sim instances. */
next_pid = INITIAL_PID;
/* Allocate the inferior data, but do not allocate a sim instance
since we've already just done that. */
sim_data = get_sim_inferior_data (current_inferior (),
SIM_INSTANCE_NOT_NEEDED);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
sim_data->gdbsim_desc = gdbsim_desc;
push_target (&gdbsim_ops);
printf_filtered ("Connected to the simulator.\n");
/* There's nothing running after "target sim" or "load"; not until
"run". */
inferior_ptid = null_ptid;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
gdbsim_is_open = 1;
}
/* Callback for iterate_over_inferiors. Called (indirectly) by
gdbsim_close(). */
static int
gdbsim_close_inferior (struct inferior *inf, void *arg)
{
struct sim_inferior_data *sim_data
= (struct sim_inferior_data *) inferior_data (inf, sim_inferior_data_key);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
if (sim_data != NULL)
{
ptid_t ptid = sim_data->remote_sim_ptid;
sim_inferior_data_cleanup (inf, sim_data);
set_inferior_data (inf, sim_inferior_data_key, NULL);
/* Having a ptid allocated and stored in remote_sim_ptid does
not mean that a corresponding inferior was ever created.
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
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_ptid (ptid) != NULL)
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
{
switch_to_thread (ptid);
generic_mourn_inferior ();
}
}
return 0;
}
/* Close out all files and local state before this target loses control. */
static void
gdbsim_close (struct target_ops *self)
{
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct sim_inferior_data *sim_data
= get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NOT_NEEDED);
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "gdbsim_close\n");
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
iterate_over_inferiors (gdbsim_close_inferior, NULL);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
if (sim_argv != NULL)
{
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
freeargv (sim_argv);
sim_argv = NULL;
}
end_callbacks ();
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
gdbsim_is_open = 0;
}
/* Takes a program previously attached to and detaches it.
The program may resume execution (some targets do, some don't) and will
no longer stop on signals, etc. We better not have left any breakpoints
in the program or it'll die when it hits one. ARGS is arguments
typed by the user (e.g. a signal to send the process). FROM_TTY
says whether to be verbose or not. */
/* Terminate the open connection to the remote debugger.
Use this when you want to detach and do something else with your gdb. */
static void
constify to_detach This patch constifies the target_ops method to_detach. This is a small cleanup, but also, I think, a bug-prevention fix, since gdb already acts as if the "args" argument here was const. In particular, top.c:quit_force calls kill_or_detach via iterate_over_inferiors. kill_or_detach calls target_detach, passing the same argument each time. So, if one of these methods was not const-correct, then kill_or_detach would change its behavior in a strange way. I could not build every target I modified in this patch. I've inspected them all by hand, though. Many targets do not use the "args" parameter; a couple pass it to atoi; and a few pass it on to the to_detach method of the target beneath. The only code that required a real change was in linux-nat.c, and that only needed the introduction of a temporary variable for const-correctness. 2013-11-08 Tom Tromey <tromey@redhat.com> * aix-thread.c (aix_thread_detach): Update. * corelow.c (core_detach): Update. * darwin-nat.c (darwin_detach): Update. * dec-thread.c (dec_thread_detach): Update. * gnu-nat.c (gnu_detach): Update. * go32-nat.c (go32_detach): Update. * inf-ptrace.c (inf_ptrace_detach): Update. * inf-ttrace.c (inf_ttrace_detach): Update. * linux-fork.c (linux_fork_detach): Update. * linux-fork.h (linux_fork_detach): Update. * linux-nat.c (linux_nat_detach): Update. Introduce "tem" local for const-correctness. * linux-thread-db.c (thread_db_detach): Update. * monitor.c (monitor_detach): Update. * nto-procfs.c (procfs_detach): Update. * procfs.c (procfs_detach): Update. * record.c (record_detach): Update. * record.h (record_detach): Update. * remote-m32r-sdi.c (m32r_detach): Update. * remote-mips.c (mips_detach): Update. * remote-sim.c (gdbsim_detach): Update. * remote.c (remote_detach_1, remote_detach) (extended_remote_detach): Update. * sol-thread.c (sol_thread_detach): Update. * target.c (target_detach): Make "args" const. (init_dummy_target): Update. * target.h (struct target_ops) <to_detach>: Make argument const. (target_detach): Likewise. * windows-nat.c (windows_detach): Update.
2013-03-19 16:23:17 +01:00
gdbsim_detach (struct target_ops *ops, const char *args, int from_tty)
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "gdbsim_detach: args \"%s\"\n", args);
remove pop_target This patch fixes the target double-close problem (PR remote/15266), and in the process removes pop_target entire (PR remote/15256). The first issue is that pop_target calls target_close. However, it then calls unpush_target, which also calls target_close. This means targets must be able to be closed twice. Not only is this strange, but it also directly contradicts the contract of to_xclose targets. (We currently have just a single such target, and it is never pushed; but I plan to add more, and so this latent bug is triggered.) The second issue is that it seems to me that calling pop_target is often unsafe. This is what cropped up in 15256, where the remote target assumed that it could pop_target -- but there was another target higher on the stack, leading to confusion. But, it is always just as easy to call unpush_target as it is to call pop_target; and it is also safer. So, removing pop_target seemed like an improvement. Finally, this adds an assertion to target_close to ensure that no currently-pushed target can be closed. Built and regtested on x86-64 Fedora 18; both natively and using the native-gdbserver board file. PR remote/15256, PR remote/15266: * bfd-target.c (target_bfd_reopen): Initialize to_magic. * monitor.c (monitor_detach): Use unpush_target. * remote-m32r-sdi.c (m32r_detach): Use unpush_target. * remote-mips.c (mips_detach): Use unpush_target. Don't call mips_close. * remote-sim.c (gdbsim_detach): Use unpush_target. * target.c (pop_target): Remove. (pop_all_targets_above): Don't call target_close. (target_close): Assert that the target is unpushed. * target.h (pop_target): Don't declare. * tracepoint.c (tfile_open): Use unpush_target.
2013-07-25 16:34:51 +02:00
unpush_target (ops); /* calls gdbsim_close to do the real work */
if (from_tty)
printf_filtered ("Ending simulator %s debugging\n", target_shortname);
}
1999-07-07 22:19:36 +02:00
/* Resume execution of the target process. STEP says whether to single-step
or to run free; SIGGNAL is the signal value (e.g. SIGINT) to be given
to the target, or zero for no signal. */
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct resume_data
{
enum gdb_signal siggnal;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
int step;
};
static int
gdbsim_resume_inferior (struct inferior *inf, void *arg)
{
struct sim_inferior_data *sim_data
= get_sim_inferior_data (inf, SIM_INSTANCE_NOT_NEEDED);
struct resume_data *rd = (struct resume_data *) arg;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
if (sim_data)
{
sim_data->resume_siggnal = rd->siggnal;
sim_data->resume_step = rd->step;
if (remote_debug)
fprintf_unfiltered (gdb_stdlog,
_("gdbsim_resume: pid %d, step %d, signal %d\n"),
inf->pid, rd->step, rd->siggnal);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
}
/* When called from iterate_over_inferiors, a zero return causes the
iteration process to proceed until there are no more inferiors to
consider. */
return 0;
}
static void
gdbsim_resume (struct target_ops *ops,
ptid_t ptid, int step, enum gdb_signal siggnal)
{
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct resume_data rd;
struct sim_inferior_data *sim_data
= get_sim_inferior_data_by_ptid (ptid, SIM_INSTANCE_NOT_NEEDED);
rd.siggnal = siggnal;
rd.step = step;
/* We don't access any sim_data members within this function.
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
What's of interest is whether or not the call to
get_sim_inferior_data_by_ptid(), above, is able to obtain a
non-NULL pointer. If it managed to obtain a non-NULL pointer, we
know we have a single inferior to consider. If it's NULL, we
either have multiple inferiors to resume or an error condition. */
if (sim_data)
gdbsim_resume_inferior (find_inferior_ptid (ptid), &rd);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
else if (ptid_equal (ptid, minus_one_ptid))
iterate_over_inferiors (gdbsim_resume_inferior, &rd);
else
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("The program is not being run."));
}
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
/* Notify the simulator of an asynchronous request to interrupt.
1999-07-07 22:19:36 +02:00
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
The simulator shall ensure that the interrupt request is eventually
delivered to the simulator. If the call is made while the
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
simulator is not running then the interrupt request is processed when
the simulator is next resumed.
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
For simulators that do not support this operation, just abort. */
static int
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
gdbsim_interrupt_inferior (struct inferior *inf, void *arg)
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
{
struct sim_inferior_data *sim_data
= get_sim_inferior_data (inf, SIM_INSTANCE_NEEDED);
if (sim_data)
{
if (!sim_stop (sim_data->gdbsim_desc))
{
quit ();
}
}
/* When called from iterate_over_inferiors, a zero return causes the
iteration process to proceed until there are no more inferiors to
consider. */
return 0;
}
static void
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
gdbsim_interrupt (struct target_ops *self, ptid_t ptid)
{
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct sim_inferior_data *sim_data;
if (ptid_equal (ptid, minus_one_ptid))
{
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
iterate_over_inferiors (gdbsim_interrupt_inferior, NULL);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
}
else
{
struct inferior *inf = find_inferior_ptid (ptid);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
if (inf == NULL)
error (_("Can't stop pid %d. No inferior found."),
ptid_get_pid (ptid));
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
gdbsim_interrupt_inferior (inf, NULL);
}
}
/* GDB version of os_poll_quit callback.
Taken from gdb/util.c - should be in a library. */
static int
2000-07-30 03:48:28 +02:00
gdb_os_poll_quit (host_callback *p)
{
if (deprecated_ui_loop_hook != NULL)
deprecated_ui_loop_hook (0);
1999-04-26 20:34:20 +02:00
if (check_quit_flag ()) /* gdb's idea of quit */
return 1;
return 0;
}
/* Wait for inferior process to do something. Return pid of child,
or -1 in case of error; store status through argument pointer STATUS,
just as `wait' would. */
static void
2000-07-30 03:48:28 +02:00
gdbsim_cntrl_c (int signo)
{
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
gdbsim_interrupt (NULL, minus_one_ptid);
}
2001-05-04 06:15:33 +02:00
static ptid_t
* linux-nat.c (linux_nat_wait): Adjust. (linux_nat_pid_to_str): Adjust. Remove call to thread_db_init. * linux-nat.h (thread_db_init): Delete declaration. * linux-thread-db.c (target_beneath): Delete. (thread_db_init): Delete. (thread_db_detach): Use find_target_beneath. (thread_db_wait): Adjust interface. Use find_target_beneath. (thread_db_mourn_inferior): Use find_target_beneath. (thread_db_can_async_p, thread_db_is_async_p, thread_db_async) (thread_db_async_mask): Delete. (thread_db_pid_to_str): Adjust interface. Use find_target_beneath. (thread_db_get_thread_local_address): Adjust interface. Use find_target_beneath. (init_thread_db_ops): Delete references to delete functions. * target.c (update_current_target): Don't inherit or default to_wait. Don't inherit to_pid_to_str and to_get_thread_local_address. (target_translate_tls_address): Look for a pushed target that implements to_get_thread_local_address, and use it instead of checking for target_get_thread_local_address_p. (target_wait, target_pid_to_str): Reimplement as functions. (dummy_pid_to_str): New. (init_dummy_target): Register it. (debug_to_wait): Delete. * target.h (struct target_ops): Make to_wait, to_pid_to_str and to_get_thread_local_address accept a pointer to struct target_ops. (target_wait): Delete macro, and declare as function. (target_pid_to_str): Likewise. (target_get_thread_local_address) (target_get_thread_local_address_p): Delete. (noprocess): Add NORETURN and ATTR_NORETURN tags. * inf-ptrace.c (inf_ptrace_wait): Adjust. (inf_ptrace_pid_to_str): New. (inf_ptrace_target): Use inf_ptrace_pid_to_str. * aix-thread.c (aix_thread_wait, aix_thread_pid_to_str): Adjust. * bsd-kvm.c (bsd_kvm_pid_to_str): Adjust. * bsd-uthread.c (bsd_uthread_wait, bsd_uthread_pid_to_str): Adjust. * corelow.c (core_pid_to_str): Adjust. * darwin-nat.c (darwin_wait, darwin_pid_to_str): Adjust. * dec-thread.c (dec_thread_wait, dec_thread_pid_to_str): Adjust. * gnu-nat.c (gnu_wait, gnu_pid_to_str): Adjust. * go32-nat.c (go32_wait, go32_pid_to_str): Adjust. * hpux-thread.c (hpux_thread_wait): Adjust. * inf-ttrace.c (inf_ttrace_wait, inf_ttrace_pid_to_str): Adjust. * monitor.c (monitor_wait, monitor_pid_to_str): Adjust. * nto-procfs.c (procfs_wait, procfs_pid_to_str): Adjust. * procfs.c (procfs_pid_to_str): Adjust. * remote-m32r-sdi.c (m32r_wait, m32r_pid_to_str): Adjust. * remote-mips.c (mips_wait): Adjust. * remote-sim.c (gdbsim_wait, gdbsim_pid_to_str): Adjust. * remote.c (remote_wait, remote_pid_to_str) (remote_get_thread_local_address): Adjust. * rs6000-nat.c (rs6000_wait): Adjust. * sol-thread.c (procfs_pid_to_str): Adjust declaration. (sol_thread_wait, solaris_pid_to_str): Adjust. * spu-linux-nat.c (spu_child_wait): Adjust. * windows-nat.c (windows_wait, windows_pid_to_str): Adjust.
2009-02-06 23:21:26 +01:00
gdbsim_wait (struct target_ops *ops,
* target.h (TARGET_WNOHANG): New. * target.c (target_wait): Add `options' argument. Adjust. (struct target_ops) <to_wait>: Add `options' argument. (target_wait): Add `options' argument. * infrun.c (wait_for_inferior): Pass 0 as options to target_wait (blocking wait). (fetch_inferior_event): Pass TARGET_WNOHANG as options to target_wait. * fork-child.c (startup_inferior): Pass 0 as options to target_wait (blocking wait). * linux-nat.c (linux_nat_create_inferior): Remove async masking. (linux_nat_wait_1): Add `target_options' argument. Use it instead of checking on target_can_async_p. (linux_nat_wait): Add `target_options' argument. Adjust. * remote.c (remote_wait_ns): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. (remote_wait_as): Add `options' argument. Adjust to check on TARGET_WNOWAIT instead of checking on remote_is_async_p. If doing a blocking wait, keep waiting until an interesting event comes out. (remote_wait): Add `options' argument. Don't loop here if the target is in async mode, and a blocking wait has been requested. * top.c (deprecated_target_wait_hook): Add `options' argument. * linux-thread-db.c (thread_db_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ptrace.c (inf_ptrace_wait): Add `options' argument. * record.c (record_beneath_to_wait): Add `options' argument. (record_wait): Add `options' argument, and pass it down to the layer beneath. * bsd-uthread.c (bsd_uthread_wait): Add `options' argument. * darwin-nat.c (darwin_wait): Likewise. * defs.h (deprecated_target_wait_hook): Likewise. * gnu-nat.c (gnu_wait): Add `options' argument. * go32-nat.c (go32_wait): Likewise. * hpux-thread.c (hpux_thread_wait): Add `options' argument, and pass it down to the layer beneath. * inf-ttrace.c (inf_ttrace_wait): Add `options' argument. * monitor.c (monitor_wait): Likewise. * nto-procfs.c (procfs_wait): Likewise. * remote-mips.c (mips_wait): Add `options' argument. * remote-sim.c (gdbsim_wait): Likewise. * rs6000-nat.c (rs6000_wait): Add `options' argument. * sol-thread.c (sol_thread_wait): Add `options' argument, and pass it down to the layer beneath. * spu-linux-nat.c (spu_child_wait): Add `options' argument. * windows-nat.c (windows_wait): Likewise. * tui/tui-hooks.c (tui_target_wait_hook): Likewise. Adjust.
2009-05-21 17:48:42 +02:00
ptid_t ptid, struct target_waitstatus *status, int options)
{
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct sim_inferior_data *sim_data;
gdb: Use sighandler_t everywhere This fixes 14 build errors like these in C++ mode: src/gdb/extension.c: In function ‘void install_sigint_handler(const signal_handler*)’: src/gdb/extension.c:698:41: error: invalid conversion from ‘void (*)()’ to ‘__sighandler_t {aka void (*)(int)}’ [-fpermissive] signal (SIGINT, handler_state->handler); ^ In file included from build-gnulib/import/signal.h:52:0, from ../../src/gdb/extension.c:24: /usr/include/signal.h:102:23: error: initializing argument 2 of ‘void (* signal(int, __sighandler_t))(int)’ [-fpermissive] extern __sighandler_t signal (int __sig, __sighandler_t __handler) ^ Instead of this everywhere: - RETSIGTYPE (*handle_sigint_for_compare) () = handle_sigint; + RETSIGTYPE (*handle_sigint_for_compare) (int) = handle_sigint; Use sighandler_t (a GNU extension). That's OK to use unconditionaly because gnulib's signal.h replacement makes sure that it is available. gdb/ChangeLog: 2015-08-27 Pedro Alves <palves@redhat.com> * cp-support.c (gdb_demangle): Use sighandler_t. Remove cast. * extension-priv.h: Include signal.h. (struct signal_handler) <handler>: Change type to sighandler_t. * extension.c (install_gdb_sigint_handler): Use sighandler_t. * inflow.c (sigint_ours, sigquit_ours): Change type to sighandler_t. (child_terminal_inferior): Remove casts. (child_terminal_ours_1, new_tty): Use sighandler_t. Remove casts. (osig): Change type to sighandler_t. * nto-procfs.c (ofunc): Change type to sighandler_t. (procfs_wait): Remove casts. * remote-m32r-sdi.c (m32r_wait, m32r_load): Use sighandler_t. * remote-sim.c (gdbsim_wait): Use sighandler_t. * utils.c (wait_to_die_with_timeout): Use sighandler_t.
2015-08-27 14:26:23 +02:00
static sighandler_t prev_sigint;
int sigrc = 0;
enum sim_stop reason = sim_running;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
/* This target isn't able to (yet) resume more than one inferior at a time.
When ptid is minus_one_ptid, just use the current inferior. If we're
given an explicit pid, we'll try to find it and use that instead. */
if (ptid_equal (ptid, minus_one_ptid))
sim_data = get_sim_inferior_data (current_inferior (),
SIM_INSTANCE_NEEDED);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
else
{
sim_data = get_sim_inferior_data_by_ptid (ptid, SIM_INSTANCE_NEEDED);
if (sim_data == NULL)
error (_("Unable to wait for pid %d. Inferior not found."),
ptid_get_pid (ptid));
inferior_ptid = ptid;
}
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "gdbsim_wait\n");
#if defined (HAVE_SIGACTION) && defined (SA_RESTART)
{
struct sigaction sa, osa;
sa.sa_handler = gdbsim_cntrl_c;
sigemptyset (&sa.sa_mask);
sa.sa_flags = 0;
sigaction (SIGINT, &sa, &osa);
prev_sigint = osa.sa_handler;
}
#else
prev_sigint = signal (SIGINT, gdbsim_cntrl_c);
#endif
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
sim_resume (sim_data->gdbsim_desc, sim_data->resume_step,
sim_data->resume_siggnal);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
signal (SIGINT, prev_sigint);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
sim_data->resume_step = 0;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
sim_stop_reason (sim_data->gdbsim_desc, &reason, &sigrc);
switch (reason)
{
case sim_exited:
status->kind = TARGET_WAITKIND_EXITED;
status->value.integer = sigrc;
break;
case sim_stopped:
switch (sigrc)
{
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
case GDB_SIGNAL_ABRT:
quit ();
break;
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
case GDB_SIGNAL_INT:
case GDB_SIGNAL_TRAP:
default:
status->kind = TARGET_WAITKIND_STOPPED;
status->value.sig = (enum gdb_signal) sigrc;
break;
}
break;
case sim_signalled:
status->kind = TARGET_WAITKIND_SIGNALLED;
status->value.sig = (enum gdb_signal) sigrc;
break;
case sim_running:
case sim_polling:
/* FIXME: Is this correct? */
break;
}
2001-05-04 06:15:33 +02:00
return inferior_ptid;
}
/* Get ready to modify the registers array. On machines which store
individual registers, this doesn't need to do anything. On machines
which store all the registers in one fell swoop, this makes sure
that registers contains all the registers from the program being
debugged. */
static void
gdbsim_prepare_to_store (struct target_ops *self, struct regcache *regcache)
{
/* Do nothing, since we can store individual regs. */
}
/* Helper for gdbsim_xfer_partial that handles memory transfers.
Arguments are like target_xfer_partial. */
2000-10-12 23:39:21 +02:00
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
static enum target_xfer_status
gdbsim_xfer_memory (struct target_ops *target,
gdb_byte *readbuf, const gdb_byte *writebuf,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
{
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct sim_inferior_data *sim_data
= get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NOT_NEEDED);
Change to_xfer_partial 'len' type to ULONGEST. This patch changes to_xfer_partial's len's type to ULONGEST, and adjust its implementations. gdb: 2014-01-14 Yao Qi <yao@codesourcery.com> * target.h (target_xfer_partial_ftype): Update. (struct target_ops) <to_xfer_partial>: Change 'len' type to ULONGEST. * aix-thread.c (aix_thread_xfer_partial): Change type of argument 'len' to ULONGEST. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv): Likewise. (memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_write_inferior): Likewise. Use '%u'. (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Call pulongest instead of plongest. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory): Likewise. (ia64_hpux_xfer_solib_got): Likewise. (ia64_hpux_xfer_partial): Likewise. * ia64-linux-nat.c (ia64_linux_xfer_partial): * inf-ptrace.c (inf_ptrace_xfer_partial): * inf-ttrace.c (inf_ttrace_xfer_partial): * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_nat_xfer_partial): Likewise. (spu_enumerate_spu_ids, linux_proc_xfer_spu): Likewise. (linux_nat_xfer_osdata, linux_xfer_partial): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. Call pulongest instead of plongest. (gdbsim_xfer_partial): Likewise. * remote.c (remote_xfer_partial): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. * rs6000-aix-tdep.h (rs6000_aix_ld_info_to_xml): Update declaration. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * target.c (target_read_live_memory): Likewise. (memory_xfer_live_readonly_partial): Likewise. (memory_xfer_partial, memory_xfer_partial_1): Likewise. (target_xfer_partial, default_xfer_partial): Likewise. (current_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. Call pulongest instead of plongest. (windows_xfer_partial): Likewise. (windows_xfer_shared_libraries): Likewise.
2014-01-03 14:11:46 +01:00
int l;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
/* If this target doesn't have memory yet, return 0 causing the
request to be passed to a lower target, hopefully an exec
file. */
if (!target->to_has_memory (target))
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
return TARGET_XFER_EOF;
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
if (!sim_data->program_loaded)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("No program loaded."));
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
/* Note that we obtained the sim_data pointer above using
SIM_INSTANCE_NOT_NEEDED. We do this so that we don't needlessly
allocate a sim instance prior to loading a program. If we
get to this point in the code though, gdbsim_desc should be
non-NULL. (Note that a sim instance is needed in order to load
the program...) */
gdb_assert (sim_data->gdbsim_desc != NULL);
if (remote_debug)
remote-sim.c: cleanup debug output code. Manually tested with a --target=arm-eabi build, and doing $ arm-eabi-gcc ~/gdb/tests/main.c -o a.out -c -g $ ./gdb a.out ... (gdb) tar sim (gdb) load (gdb) set debug remote 1 (gdb) disassemble 0 Dump of assembler code for function main: gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x0, len 4, write 0 0x00000000 <+0>: 0xe1a0c00d mov r12, sp gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x4, len 4, write 0 0x00000004 <+4>: 0xe92dd800 push {r11, r12, lr, pc} gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x8, len 4, write 0 0x00000008 <+8>: 0xe24cb004 sub r11, r12, #4 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0xc, len 4, write 0 0x0000000c <+12>: 0xe24dd008 sub sp, sp, #8 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x10, len 4, write 0 0x00000010 <+16>: 0xe50b0010 str r0, [r11, #-16] gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x14, len 4, write 0 0x00000014 <+20>: 0xe50b1014 str r1, [r11, #-20] gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x18, len 4, write 0 0x00000018 <+24>: 0xe3a03000 mov r3, #0 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x1c, len 4, write 0 0x0000001c <+28>: 0xe1a00003 mov r0, r3 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x20, len 4, write 0 0x00000020 <+32>: 0xe24bd00c sub sp, r11, #12 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x24, len 4, write 0 0x00000024 <+36>: 0xe89da800 ldm sp, {r11, sp, pc} End of assembler dump. (gdb) p *0 = 1 gdbsim_xfer_inferior_memory: myaddr 0xc69bc0, memaddr 0x0, len 4, write 1 0x00000001 $1 = 1 Which happens to differ from before, I think due to stdout line buffering: (gdb) disassemble 0 Dump of assembler code for function main: 0x00000000 <+0>: gdbsim_xfer_inferior_memory: myaddr 0x0x7fffffffd400, memaddr 0x0, len 4, write 0 0xe1a0c00d But the new output looks reasonable to me, better even. gdb/ 2013-09-06 Pedro Alves <palves@redhat.com> * remote-sim.c (gdbsim_xfer_inferior_memory): Use host_address_to_string, and send debug output to gdb_stdlog.
2013-09-06 19:41:50 +02:00
fprintf_unfiltered (gdb_stdlog,
"gdbsim_xfer_memory: readbuf %s, writebuf %s, "
"memaddr %s, len %s\n",
host_address_to_string (readbuf),
host_address_to_string (writebuf),
remote-sim.c: cleanup debug output code. Manually tested with a --target=arm-eabi build, and doing $ arm-eabi-gcc ~/gdb/tests/main.c -o a.out -c -g $ ./gdb a.out ... (gdb) tar sim (gdb) load (gdb) set debug remote 1 (gdb) disassemble 0 Dump of assembler code for function main: gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x0, len 4, write 0 0x00000000 <+0>: 0xe1a0c00d mov r12, sp gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x4, len 4, write 0 0x00000004 <+4>: 0xe92dd800 push {r11, r12, lr, pc} gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x8, len 4, write 0 0x00000008 <+8>: 0xe24cb004 sub r11, r12, #4 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0xc, len 4, write 0 0x0000000c <+12>: 0xe24dd008 sub sp, sp, #8 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x10, len 4, write 0 0x00000010 <+16>: 0xe50b0010 str r0, [r11, #-16] gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x14, len 4, write 0 0x00000014 <+20>: 0xe50b1014 str r1, [r11, #-20] gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x18, len 4, write 0 0x00000018 <+24>: 0xe3a03000 mov r3, #0 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x1c, len 4, write 0 0x0000001c <+28>: 0xe1a00003 mov r0, r3 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x20, len 4, write 0 0x00000020 <+32>: 0xe24bd00c sub sp, r11, #12 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x24, len 4, write 0 0x00000024 <+36>: 0xe89da800 ldm sp, {r11, sp, pc} End of assembler dump. (gdb) p *0 = 1 gdbsim_xfer_inferior_memory: myaddr 0xc69bc0, memaddr 0x0, len 4, write 1 0x00000001 $1 = 1 Which happens to differ from before, I think due to stdout line buffering: (gdb) disassemble 0 Dump of assembler code for function main: 0x00000000 <+0>: gdbsim_xfer_inferior_memory: myaddr 0x0x7fffffffd400, memaddr 0x0, len 4, write 0 0xe1a0c00d But the new output looks reasonable to me, better even. gdb/ 2013-09-06 Pedro Alves <palves@redhat.com> * remote-sim.c (gdbsim_xfer_inferior_memory): Use host_address_to_string, and send debug output to gdb_stdlog.
2013-09-06 19:41:50 +02:00
paddress (target_gdbarch (), memaddr),
Change to_xfer_partial 'len' type to ULONGEST. This patch changes to_xfer_partial's len's type to ULONGEST, and adjust its implementations. gdb: 2014-01-14 Yao Qi <yao@codesourcery.com> * target.h (target_xfer_partial_ftype): Update. (struct target_ops) <to_xfer_partial>: Change 'len' type to ULONGEST. * aix-thread.c (aix_thread_xfer_partial): Change type of argument 'len' to ULONGEST. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv): Likewise. (memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_write_inferior): Likewise. Use '%u'. (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Call pulongest instead of plongest. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory): Likewise. (ia64_hpux_xfer_solib_got): Likewise. (ia64_hpux_xfer_partial): Likewise. * ia64-linux-nat.c (ia64_linux_xfer_partial): * inf-ptrace.c (inf_ptrace_xfer_partial): * inf-ttrace.c (inf_ttrace_xfer_partial): * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_nat_xfer_partial): Likewise. (spu_enumerate_spu_ids, linux_proc_xfer_spu): Likewise. (linux_nat_xfer_osdata, linux_xfer_partial): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. Call pulongest instead of plongest. (gdbsim_xfer_partial): Likewise. * remote.c (remote_xfer_partial): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. * rs6000-aix-tdep.h (rs6000_aix_ld_info_to_xml): Update declaration. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * target.c (target_read_live_memory): Likewise. (memory_xfer_live_readonly_partial): Likewise. (memory_xfer_partial, memory_xfer_partial_1): Likewise. (target_xfer_partial, default_xfer_partial): Likewise. (current_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. Call pulongest instead of plongest. (windows_xfer_partial): Likewise. (windows_xfer_shared_libraries): Likewise.
2014-01-03 14:11:46 +01:00
pulongest (len));
if (writebuf)
{
remote-sim.c: cleanup debug output code. Manually tested with a --target=arm-eabi build, and doing $ arm-eabi-gcc ~/gdb/tests/main.c -o a.out -c -g $ ./gdb a.out ... (gdb) tar sim (gdb) load (gdb) set debug remote 1 (gdb) disassemble 0 Dump of assembler code for function main: gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x0, len 4, write 0 0x00000000 <+0>: 0xe1a0c00d mov r12, sp gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x4, len 4, write 0 0x00000004 <+4>: 0xe92dd800 push {r11, r12, lr, pc} gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x8, len 4, write 0 0x00000008 <+8>: 0xe24cb004 sub r11, r12, #4 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0xc, len 4, write 0 0x0000000c <+12>: 0xe24dd008 sub sp, sp, #8 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x10, len 4, write 0 0x00000010 <+16>: 0xe50b0010 str r0, [r11, #-16] gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x14, len 4, write 0 0x00000014 <+20>: 0xe50b1014 str r1, [r11, #-20] gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x18, len 4, write 0 0x00000018 <+24>: 0xe3a03000 mov r3, #0 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x1c, len 4, write 0 0x0000001c <+28>: 0xe1a00003 mov r0, r3 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x20, len 4, write 0 0x00000020 <+32>: 0xe24bd00c sub sp, r11, #12 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x24, len 4, write 0 0x00000024 <+36>: 0xe89da800 ldm sp, {r11, sp, pc} End of assembler dump. (gdb) p *0 = 1 gdbsim_xfer_inferior_memory: myaddr 0xc69bc0, memaddr 0x0, len 4, write 1 0x00000001 $1 = 1 Which happens to differ from before, I think due to stdout line buffering: (gdb) disassemble 0 Dump of assembler code for function main: 0x00000000 <+0>: gdbsim_xfer_inferior_memory: myaddr 0x0x7fffffffd400, memaddr 0x0, len 4, write 0 0xe1a0c00d But the new output looks reasonable to me, better even. gdb/ 2013-09-06 Pedro Alves <palves@redhat.com> * remote-sim.c (gdbsim_xfer_inferior_memory): Use host_address_to_string, and send debug output to gdb_stdlog.
2013-09-06 19:41:50 +02:00
if (remote_debug && len > 0)
dump_mem (writebuf, len);
Change to_xfer_partial 'len' type to ULONGEST. This patch changes to_xfer_partial's len's type to ULONGEST, and adjust its implementations. gdb: 2014-01-14 Yao Qi <yao@codesourcery.com> * target.h (target_xfer_partial_ftype): Update. (struct target_ops) <to_xfer_partial>: Change 'len' type to ULONGEST. * aix-thread.c (aix_thread_xfer_partial): Change type of argument 'len' to ULONGEST. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv): Likewise. (memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_write_inferior): Likewise. Use '%u'. (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Call pulongest instead of plongest. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory): Likewise. (ia64_hpux_xfer_solib_got): Likewise. (ia64_hpux_xfer_partial): Likewise. * ia64-linux-nat.c (ia64_linux_xfer_partial): * inf-ptrace.c (inf_ptrace_xfer_partial): * inf-ttrace.c (inf_ttrace_xfer_partial): * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_nat_xfer_partial): Likewise. (spu_enumerate_spu_ids, linux_proc_xfer_spu): Likewise. (linux_nat_xfer_osdata, linux_xfer_partial): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. Call pulongest instead of plongest. (gdbsim_xfer_partial): Likewise. * remote.c (remote_xfer_partial): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. * rs6000-aix-tdep.h (rs6000_aix_ld_info_to_xml): Update declaration. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * target.c (target_read_live_memory): Likewise. (memory_xfer_live_readonly_partial): Likewise. (memory_xfer_partial, memory_xfer_partial_1): Likewise. (target_xfer_partial, default_xfer_partial): Likewise. (current_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. Call pulongest instead of plongest. (windows_xfer_partial): Likewise. (windows_xfer_shared_libraries): Likewise.
2014-01-03 14:11:46 +01:00
l = sim_write (sim_data->gdbsim_desc, memaddr, writebuf, len);
}
1999-07-07 22:19:36 +02:00
else
{
Change to_xfer_partial 'len' type to ULONGEST. This patch changes to_xfer_partial's len's type to ULONGEST, and adjust its implementations. gdb: 2014-01-14 Yao Qi <yao@codesourcery.com> * target.h (target_xfer_partial_ftype): Update. (struct target_ops) <to_xfer_partial>: Change 'len' type to ULONGEST. * aix-thread.c (aix_thread_xfer_partial): Change type of argument 'len' to ULONGEST. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv): Likewise. (memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_write_inferior): Likewise. Use '%u'. (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Call pulongest instead of plongest. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory): Likewise. (ia64_hpux_xfer_solib_got): Likewise. (ia64_hpux_xfer_partial): Likewise. * ia64-linux-nat.c (ia64_linux_xfer_partial): * inf-ptrace.c (inf_ptrace_xfer_partial): * inf-ttrace.c (inf_ttrace_xfer_partial): * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_nat_xfer_partial): Likewise. (spu_enumerate_spu_ids, linux_proc_xfer_spu): Likewise. (linux_nat_xfer_osdata, linux_xfer_partial): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. Call pulongest instead of plongest. (gdbsim_xfer_partial): Likewise. * remote.c (remote_xfer_partial): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. * rs6000-aix-tdep.h (rs6000_aix_ld_info_to_xml): Update declaration. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * target.c (target_read_live_memory): Likewise. (memory_xfer_live_readonly_partial): Likewise. (memory_xfer_partial, memory_xfer_partial_1): Likewise. (target_xfer_partial, default_xfer_partial): Likewise. (current_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. Call pulongest instead of plongest. (windows_xfer_partial): Likewise. (windows_xfer_shared_libraries): Likewise.
2014-01-03 14:11:46 +01:00
l = sim_read (sim_data->gdbsim_desc, memaddr, readbuf, len);
if (remote_debug && len > 0)
dump_mem (readbuf, len);
1999-07-07 22:19:36 +02:00
}
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
if (l > 0)
{
*xfered_len = (ULONGEST) l;
return TARGET_XFER_OK;
}
else if (l == 0)
return TARGET_XFER_EOF;
else
return TARGET_XFER_E_IO;
}
/* Target to_xfer_partial implementation. */
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
static enum target_xfer_status
gdbsim_xfer_partial (struct target_ops *ops, enum target_object object,
const char *annex, gdb_byte *readbuf,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
ULONGEST *xfered_len)
{
switch (object)
{
case TARGET_OBJECT_MEMORY:
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
return gdbsim_xfer_memory (ops, readbuf, writebuf, offset, len,
xfered_len);
default:
Replace -1 with TARGET_XFER_E_IO Hi, This patch replaces -1 with TARGET_XFER_E_IO in the implementations of to_xfer_partial and their callees. This change is quite mechanical, and makes the next patch shorter. gdb: 2014-02-07 Yao Qi <yao@codesourcery.com> * auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO. (ld_so_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (exec_xfer_partial): Likewise. * gnu-nat.c (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_proc_xfer_spu): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_qxfer): Likewise. (remote_write_qxfer, remote_read_qxfer): Likewise. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * target.c (memory_xfer_partial_1): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise.
2014-01-27 10:32:33 +01:00
return TARGET_XFER_E_IO;
}
}
static void
2000-07-30 03:48:28 +02:00
gdbsim_files_info (struct target_ops *target)
{
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct sim_inferior_data *sim_data
= get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NEEDED);
const char *file = "nothing";
if (exec_bfd)
file = bfd_get_filename (exec_bfd);
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "gdbsim_files_info: file \"%s\"\n", file);
if (exec_bfd)
{
fprintf_unfiltered (gdb_stdlog, "\tAttached to %s running program %s\n",
target_shortname, file);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
sim_info (sim_data->gdbsim_desc, 0);
}
}
/* Clear the simulator's notion of what the break points are. */
static void
gdbsim_mourn_inferior (struct target_ops *target)
1999-07-07 22:19:36 +02:00
{
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct sim_inferior_data *sim_data
= get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NOT_NEEDED);
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "gdbsim_mourn_inferior:\n");
remove_breakpoints ();
generic_mourn_inferior ();
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
delete_thread_silent (sim_data->remote_sim_ptid);
}
/* Pass the command argument through to the simulator verbatim. The
simulator must do any command interpretation work. */
void
2000-07-30 03:48:28 +02:00
simulator_command (char *args, int from_tty)
{
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct sim_inferior_data *sim_data;
/* We use inferior_data() instead of get_sim_inferior_data() here in
order to avoid attaching a sim_inferior_data struct to an
inferior unnecessarily. The reason we take such care here is due
to the fact that this function, simulator_command(), may be called
even when the sim target is not active. If we were to use
get_sim_inferior_data() here, it is possible that this call would
be made either prior to gdbsim_open() or after gdbsim_close(),
thus allocating memory that would not be garbage collected until
the ultimate destruction of the associated inferior. */
sim_data = ((struct sim_inferior_data *)
inferior_data (current_inferior (), sim_inferior_data_key));
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
if (sim_data == NULL || sim_data->gdbsim_desc == NULL)
{
/* 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). */
/* 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. */
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("Not connected to the simulator target"));
}
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
sim_do_command (sim_data->gdbsim_desc, args);
/* Invalidate the register cache, in case the simulator command does
something funny. */
1999-07-07 22:19:36 +02:00
registers_changed ();
}
static VEC (char_ptr) *
sim_command_completer (struct cmd_list_element *ignore, const char *text,
const char *word)
{
struct sim_inferior_data *sim_data;
char **tmp;
int i;
VEC (char_ptr) *result = NULL;
sim_data = ((struct sim_inferior_data *)
inferior_data (current_inferior (), sim_inferior_data_key));
if (sim_data == NULL || sim_data->gdbsim_desc == NULL)
return NULL;
tmp = sim_complete_command (sim_data->gdbsim_desc, text, word);
if (tmp == NULL)
return NULL;
/* Transform the array into a VEC, and then free the array. */
for (i = 0; tmp[i] != NULL; i++)
VEC_safe_push (char_ptr, result, tmp[i]);
xfree (tmp);
return result;
}
/* Check to see if a thread is still alive. */
static int
* corelow.c (get_core_registers): Adjust. (core_file_thread_alive): Rename to... (core_thread_alive): ... this. (core_pid_to_str): Try gdbarch_core_pid_to_str first. (init_core_ops): Adjust. (coreops_suppress_target): Delete. (_initialize_corelow): Unconditionally add core_ops. * procfs.c: Include "inf-child.h". (procfs_ops): Delete. (init_procfs_ops): Delete. Reimplement as... (procfs_target): ... this, inheriting from inf-child. (procfs_attach, procfs_detach, procfs_fetch_registers): Adjust. (procfs_prepare_to_store): Delete. (procfs_store_registers, procfs_resume): Adjust. (procfs_open): Delete. (procfs_suppress_run): Delete. (procfs_can_run): Delete. (procfs_mourn_inferior): Adjust. (procfs_init_inferior): Add target_ops parameter. Adjust. (procfs_create_inferior): Don't pass procfs_init_inferior to fork_inferior. Instead call it after fork_inferior returns. (procfs_find_new_threads): Adjust. (_initialize_procfs): Adjust to use procfs_target instead of init_procfs_ops. * sol-thread.c (orig_core_ops, sol_core_ops): Delete. (lwp_to_thread): Use target_thread_alive. (sol_thread_open): Delete. (sol_thread_attach): Delete. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers): Adjust to use find_target_beneath. (sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete. (sol_thread_xfer_partial): Adjust to use find_target_beneath. (sol_thread_files_info, sol_thread_kill_inferior): Delete. (check_for_thread_db): New. (sol_thread_notice_signals, sol_thread_create_inferior): Delete. (sol_thread_new_objfile): Call check_for_thread_db. (sol_thread_mourn_inferior): Adjust to use find_target_beneath. (sol_thread_can_run): Delete. (sol_thread_alive): Adjust to use find_target_beneath. (sol_thread_stop): Delete. (rw_common): Use target_write_memory or target_read_memory. (ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers. (ps_lsetregs, ps_lsetfpregs): Use target_store_registers. (solaris_pid_to_str): Remove check for libthread_db initialization failing. (sol_find_new_threads): Remove check for libthread_db initialization failing, or for an invalid inferior_ptid. Adjust to use find_target_beneath. (sol_core_open, sol_core_close, sol_core_detach, sol_core_files_info, sol_find_memory_regions, sol_make_note_section, ignore): Delete. (init_sol_thread_ops): Make it a thread_stratum target. Remove unneeded callback settings. (init_sol_core_ops): Delete. (_initialize_sol_thread): No longer call init_sol_core_ops, set procfs_suppress_run, or hack with core_ops. * target.h (struct target_ops): Add a target_ops * parameter to to_resume, to_fetch_registers, to_store_registers, to_thread_alive and to_find_new_threads. (target_fetch_registers, target_store_registers) (target_thread_alive, target_find_new_threads): Redeclare as function. * target.c (update_current_target): Do not inherit or de_fault to_resume, to_fetch_registers, to_store_registers, to_thread_alive, to_find_new_threads. (target_resume): Adjust. (target_thread_alive, target_find_new_threads): New. (debug_to_resume, debug_to_fetch_registers): Delete. (target_fetch_registers): New. (debug_to_store_registers): Delete. (target_store_registers): New. (debug_to_thread_alive, debug_to_find_new_threads): Delete. (setup_target_debug): Adjust. * gdbcore.h (core_ops): Delete declaration. * inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c, inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c, i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c, hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c, nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c, alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c, bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c, hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c, ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c, m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c, mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c, ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c, shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c, vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes. * gdbarch.sh (core_pid_to_str): New gdbarch callback. * gdbarch.h, gdbarch.c: Regenerate. * sol2-tdep.c: Include "inferior.h". (sol2_core_pid_to_str): New. * sol2-tdep.h (sol2_core_pid_to_str): Declare. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it. * i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
gdbsim_thread_alive (struct target_ops *ops, ptid_t ptid)
{
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
struct sim_inferior_data *sim_data
= get_sim_inferior_data_by_ptid (ptid, SIM_INSTANCE_NOT_NEEDED);
if (sim_data == NULL)
return 0;
if (ptid_equal (ptid, sim_data->remote_sim_ptid))
/* The simulators' task is always alive. */
return 1;
return 0;
}
/* Convert a thread ID to a string. Returns the string in a static
buffer. */
-Wwrite-strings: Constify target_pid_to_str and target_thread_extra_thread_info -Wwrite-strings flagged a missing cast for example here: static char * ravenscar_extra_thread_info (struct target_ops *self, struct thread_info *tp) { return "Ravenscar task"; Since callers are not supposed to free the string returned by these methods, change the methods' signature to return const strings. gdb/ChangeLog: 2017-04-05 Pedro Alves <palves@redhat.com> * aix-thread.c (aix_thread_pid_to_str) (aix_thread_extra_thread_info): Constify. * bsd-kvm.c (bsd_kvm_pid_to_str): Constify. * bsd-uthread.c (bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Constify. * corelow.c (core_pid_to_str): Constify. * darwin-nat.c (darwin_pid_to_str): Constify. * fbsd-nat.c (fbsd_pid_to_str): Constify. * fbsd-tdep.c (fbsd_core_pid_to_str, gdbarch_core_pid_to_str): Constify. * gnu-nat.c (gnu_pid_to_str): Constify. * go32-nat.c (go32_pid_to_str): Constify. * i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Constify. * inf-ptrace.c (inf_ptrace_pid_to_str): Constify. * inferior.c (inferior_pid_to_str): Constify. * linux-nat.c (linux_nat_pid_to_str): Constify. * linux-tdep.c (linux_core_pid_to_str): Constify. * linux-thread-db.c (thread_db_pid_to_str) (thread_db_extra_thread_info): Constify. * nto-tdep.c (nto_extra_thread_info): Constify. * nto-tdep.h (nto_extra_thread_info): Constify. * obsd-nat.c (obsd_pid_to_str): Constify. * procfs.c (procfs_pid_to_str): Constify. * ravenscar-thread.c (ravenscar_extra_thread_info) (ravenscar_pid_to_str): Constify. * remote-sim.c (gdbsim_pid_to_str): Constify. * remote.c (remote_threads_extra_info, remote_pid_to_str): Constify. * sol-thread.c (solaris_pid_to_str): Constify. * sol2-tdep.c (sol2_core_pid_to_str): Constify. * sol2-tdep.h (sol2_core_pid_to_str): Constify. * target.c (default_pid_to_str, target_pid_to_str) (normal_pid_to_str, default_pid_to_str): Constify. * target.h (target_ops::to_pid_to_str) (target_ops::to_extra_thread_info): Constify. (target_pid_to_str, normal_pid_to_str): Constify. * windows-nat.c (windows_pid_to_str): Constify. * gdbarch.sh (core_pid_to_str): Constify. * target-delegates.c: Regenerate. * gdbarch.h, gdbarch.c: Regenerate.
2017-04-05 20:21:34 +02:00
static const char *
* linux-nat.c (linux_nat_wait): Adjust. (linux_nat_pid_to_str): Adjust. Remove call to thread_db_init. * linux-nat.h (thread_db_init): Delete declaration. * linux-thread-db.c (target_beneath): Delete. (thread_db_init): Delete. (thread_db_detach): Use find_target_beneath. (thread_db_wait): Adjust interface. Use find_target_beneath. (thread_db_mourn_inferior): Use find_target_beneath. (thread_db_can_async_p, thread_db_is_async_p, thread_db_async) (thread_db_async_mask): Delete. (thread_db_pid_to_str): Adjust interface. Use find_target_beneath. (thread_db_get_thread_local_address): Adjust interface. Use find_target_beneath. (init_thread_db_ops): Delete references to delete functions. * target.c (update_current_target): Don't inherit or default to_wait. Don't inherit to_pid_to_str and to_get_thread_local_address. (target_translate_tls_address): Look for a pushed target that implements to_get_thread_local_address, and use it instead of checking for target_get_thread_local_address_p. (target_wait, target_pid_to_str): Reimplement as functions. (dummy_pid_to_str): New. (init_dummy_target): Register it. (debug_to_wait): Delete. * target.h (struct target_ops): Make to_wait, to_pid_to_str and to_get_thread_local_address accept a pointer to struct target_ops. (target_wait): Delete macro, and declare as function. (target_pid_to_str): Likewise. (target_get_thread_local_address) (target_get_thread_local_address_p): Delete. (noprocess): Add NORETURN and ATTR_NORETURN tags. * inf-ptrace.c (inf_ptrace_wait): Adjust. (inf_ptrace_pid_to_str): New. (inf_ptrace_target): Use inf_ptrace_pid_to_str. * aix-thread.c (aix_thread_wait, aix_thread_pid_to_str): Adjust. * bsd-kvm.c (bsd_kvm_pid_to_str): Adjust. * bsd-uthread.c (bsd_uthread_wait, bsd_uthread_pid_to_str): Adjust. * corelow.c (core_pid_to_str): Adjust. * darwin-nat.c (darwin_wait, darwin_pid_to_str): Adjust. * dec-thread.c (dec_thread_wait, dec_thread_pid_to_str): Adjust. * gnu-nat.c (gnu_wait, gnu_pid_to_str): Adjust. * go32-nat.c (go32_wait, go32_pid_to_str): Adjust. * hpux-thread.c (hpux_thread_wait): Adjust. * inf-ttrace.c (inf_ttrace_wait, inf_ttrace_pid_to_str): Adjust. * monitor.c (monitor_wait, monitor_pid_to_str): Adjust. * nto-procfs.c (procfs_wait, procfs_pid_to_str): Adjust. * procfs.c (procfs_pid_to_str): Adjust. * remote-m32r-sdi.c (m32r_wait, m32r_pid_to_str): Adjust. * remote-mips.c (mips_wait): Adjust. * remote-sim.c (gdbsim_wait, gdbsim_pid_to_str): Adjust. * remote.c (remote_wait, remote_pid_to_str) (remote_get_thread_local_address): Adjust. * rs6000-nat.c (rs6000_wait): Adjust. * sol-thread.c (procfs_pid_to_str): Adjust declaration. (sol_thread_wait, solaris_pid_to_str): Adjust. * spu-linux-nat.c (spu_child_wait): Adjust. * windows-nat.c (windows_wait, windows_pid_to_str): Adjust.
2009-02-06 23:21:26 +01:00
gdbsim_pid_to_str (struct target_ops *ops, ptid_t ptid)
{
return normal_pid_to_str (ptid);
}
/* Simulator memory may be accessed after the program has been loaded. */
static int
gdbsim_has_all_memory (struct target_ops *ops)
{
struct sim_inferior_data *sim_data
= get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NOT_NEEDED);
if (!sim_data->program_loaded)
return 0;
return 1;
}
static int
gdbsim_has_memory (struct target_ops *ops)
{
struct sim_inferior_data *sim_data
= get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NOT_NEEDED);
if (!sim_data->program_loaded)
return 0;
return 1;
}
/* Define the target subroutine names. */
1999-07-07 22:19:36 +02:00
struct target_ops gdbsim_ops;
static void
init_gdbsim_ops (void)
{
gdbsim_ops.to_shortname = "sim";
gdbsim_ops.to_longname = "simulator";
gdbsim_ops.to_doc = "Use the compiled-in simulator.";
gdbsim_ops.to_open = gdbsim_open;
gdbsim_ops.to_close = gdbsim_close;
gdbsim_ops.to_detach = gdbsim_detach;
gdbsim_ops.to_resume = gdbsim_resume;
gdbsim_ops.to_wait = gdbsim_wait;
gdbsim_ops.to_fetch_registers = gdbsim_fetch_register;
gdbsim_ops.to_store_registers = gdbsim_store_register;
gdbsim_ops.to_prepare_to_store = gdbsim_prepare_to_store;
gdbsim_ops.to_xfer_partial = gdbsim_xfer_partial;
1999-07-07 22:19:36 +02:00
gdbsim_ops.to_files_info = gdbsim_files_info;
gdb/ * breakpoint.c (deprecated_read_memory_nobpt): Update to use shadow_len. (insert_bp_location, reattach_breakpoints, remove_breakpoint) (delete_breakpoint): Update calls to changed methods. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (single_step_breakpoints, insert_single_step_breakpoint) (remove_single_step_breakpoints): New. * breakpoint.h (struct bp_target_info): New. (struct bp_location): Replace shadow_contents with target_info and overlay_target_info. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (insert_single_step_breakpoint, remove_single_step_breakpoints): New prototypes. * gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h. (memory_insert_breakpoint, memory_remove_breakpoint): Update second argument. * mem-break.c (default_memory_insert_breakpoint): Update. Set placed_address, placed_size, and shadow_len. (default_memory_remove_breakpoint): Update. Don't use BREAKPOINT_FROM_PC. (memory_insert_breakpoint, memory_remove_breakpoint): Update. * target.c (update_current_target): Update prototypes for changed functions. (debug_to_insert_breakpoint, debug_to_remove_breakpoint) (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Update. * target.h: Forward declare struct bp_target_info. (struct target_ops): Use a bp_target_info argument for to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint. (target_insert_breakpoint, target_remove_breakpoint) (target_insert_hw_breakpoint, target_remove_hw_breakpoint) (memory_insert_breakpoint, memory_remove_breakpoint) (default_memory_insert_breakpoint, default_memory_remove_breakpoint): Update. * config/i386/nm-i386.h: Forward declare struct bp_target_info. (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * alpha-tdep.c (alpha_software_single_step): Use insert_single_step_breakpoint and remove_single_step_breakpoints. Remove unused statics. * arm-tdep.c (arm_software_single_step): Likewise. Add a note. * cris-tdep.c (cris_software_single_step): Likewise. * mips-tdep.c (mips_software_single_step): Likewise. * rs6000-tdep.c (rs6000_software_single_step): Likewise. * sparc-tdep.c (sparc_software_single_step): Likewise. * wince.c (struct thread_info_struct): Remove step_prev. (undoSStep): Use remove_single_step_breakpoints. (wince_software_single_step): Use insert_single_step_breakpoint. * corelow.c (ignore): Remove unneeded prototype. Update arguments. * exec.c (ignore): Likewise. * sol-thread.c (ignore): Likewise. * procfs.c (dbx_link_shadow_contents): Delete. (dbx_link_bpt): New. (procfs_mourn_inferior): Remove it if necessary. (remove_dbx_link_breakpoint): Use it. (insert_dbx_link_bpt_in_file): Set it. (procfs_init_inferior): Don't update dbx_link_bpt_addr. * rs6000-nat.c (exec_one_dummy_insn): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * solib-irix.c (shadow_contents, breakpoint_addr): Delete. (base_breakpoint): New. (disable_break): Use it. (enable_break): Set it. * i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint) (ia64_memory_remove_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint) (m32r_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Likewise. Remove unnecessary prototypes. Use placed_address and placed_size. Removed useless read from memory. * nto-procfs.c (procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint): Update. * ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise. * remote-e7000.c (e7000_insert_breakpoint) (e7000_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint) (mips_remove_breakpoint): Likewise. * remote-rdp.c (remote_rdp_insert_breakpoint) (remote_rdp_remove_breakpoint): Likewise. (rdp_step): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint): Update. * remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint): Delete. (init_gdbsim_ops): Use memory_insert_breakpoint and memory_remove_breakpoint. * remote-st.c (st2000_insert_breakpoint) (st2000_remove_breakpoint): Update. Remove unused BREAKPOINT_FROM_PC. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Update. Use placed_address and placed_size. (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise. gdb/doc/ * gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert and remove breakpoint prototypes. (Watchpoints): Move description of target_insert_hw_breakpoint and target_remove_hw_breakpoint ... (Breakpoints): ... to here. Document target_insert_breakpoint and target_remove_breakpoint.
2006-04-18 21:20:08 +02:00
gdbsim_ops.to_insert_breakpoint = memory_insert_breakpoint;
gdbsim_ops.to_remove_breakpoint = memory_remove_breakpoint;
1999-07-07 22:19:36 +02:00
gdbsim_ops.to_kill = gdbsim_kill;
gdbsim_ops.to_load = gdbsim_load;
gdbsim_ops.to_create_inferior = gdbsim_create_inferior;
gdbsim_ops.to_mourn_inferior = gdbsim_mourn_inferior;
Fix interrupt-noterm.exp on targets always in non-stop With "maint set target-non-stop on" we get: @@ -66,13 +66,16 @@ Continuing. interrupt (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt -Program received signal SIGINT, Interrupt. -PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT -testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds +[process 12119] #1 stopped. +0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81 +81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) +FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout) +testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds That is, we get "[$thread] #1 stopped" instead of SIGINT. The issue is that we don't currently distinguish send "interrupt/ctrl-c" to target terminal vs "stop/pause" thread well; both cases go through "target_stop". And then, the native Linux backend (linux-nat.c) implements target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop mode. Since "maint set target-non-stop on" forces the backend to be always running in non-stop mode, even though the user-visible behavior is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of the SIGINT the test expects. Fix this by introducing a target_interrupt method to use in the "interrupt/ctrl-c" case, so "set non-stop off" can always work the same irrespective of "maint set target-non-stop on/off". I'm explictly considering changing the "set non-stop on" behavior as out of scope here. Most of the patch is an across-the-board rename of to_stop hook implementations to to_interrupt. The only targets where something more than a rename is being done are linux-nat.c and remote.c, which are the only targets that support async, and thus are the only ones the core side calls target_stop on. gdb/ChangeLog: 2015-08-07 Pedro Alves <palves@redhat.com> * darwin-nat.c (darwin_stop): Rename to ... (darwin_interrupt): ... this. (_initialize_darwin_inferior): Adjust. * gnu-nat.c (gnu_stop): Delete. (gnu_target): Don't install gnu_stop. * inf-ptrace.c (inf_ptrace_stop): Rename to ... (inf_ptrace_interrupt): ... this. (inf_ptrace_target): Adjust. * infcmd.c (interrupt_target_1): Use target_interrupt instead of target_stop. * linux-nat (linux_nat_stop): Rename to ... (linux_nat_interrupt): ... this. (linux_nat_stop): Reimplement. (linux_nat_add_target): Install linux_nat_interrupt. * nto-procfs.c (nto_interrupt_twice): Rename to ... (nto_handle_sigint_twice): ... this. (nto_interrupt): Rename to ... (nto_handle_sigint): ... this. Call target_interrupt instead of target_stop. (procfs_wait): Adjust. (procfs_stop): Rename to ... (procfs_interrupt): ... this. (init_procfs_targets): Adjust. * procfs.c (procfs_stop): Rename to ... (procfs_interrupt): ... this. (procfs_target): Adjust. * remote-m32r-sdi.c (m32r_stop): Rename to ... (m32r_interrupt): ... this. (init_m32r_ops): Adjust. * remote-sim.c (gdbsim_stop_inferior): Rename to ... (gdbsim_interrupt_inferior): ... this. (gdbsim_stop): Rename to ... (gdbsim_interrupt): ... this. (gdbsim_cntrl_c): Adjust. (init_gdbsim_ops): Adjust. * remote.c (sync_remote_interrupt): Adjust comments. (remote_stop_as): Rename to ... (remote_interrupt_as): ... this. (remote_stop): Adjust comment. (remote_interrupt): New function. (init_remote_ops): Install remote_interrupt. * target.c (target_interrupt): New function. * target.h (struct target_ops) <to_interrupt>: New field. (target_interrupt): New declaration. * windows-nat.c (windows_stop): Rename to ... (windows_interrupt): ... this. * target-delegates.c: Regenerate.
2015-08-06 19:22:58 +02:00
gdbsim_ops.to_interrupt = gdbsim_interrupt;
gdbsim_ops.to_thread_alive = gdbsim_thread_alive;
gdbsim_ops.to_pid_to_str = gdbsim_pid_to_str;
1999-07-07 22:19:36 +02:00
gdbsim_ops.to_stratum = process_stratum;
gdbsim_ops.to_has_all_memory = gdbsim_has_all_memory;
gdbsim_ops.to_has_memory = gdbsim_has_memory;
* target.h (struct target_ops): Make to_has_all_memory, to_has_memory, to_has_stack, to_has_registers and to_has_execution methods instead of variables. (target_has_all_memory_1, target_has_memory_1, target_has_stack_1) (target_has_registers_1, target_has_execution_1): Declare functions. (target_has_all_memory): Rewrite to call target_has_all_memory_1. (target_has_memory): Rewrite to call target_has_memory_1. (target_has_stack): Rewrite to call target_has_all_stack_1. (target_has_registers): Rewrite to call target_has_registers_1. (target_has_execution): Rewrite to call target_has_execution_1. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Declare. (target_mark_running, target_mark_exited): Delete declarations. * target.c (default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution): New. (target_has_all_memory_1, target_has_memory_1, target_has_stack_1, target_has_registers_1, target_has_execution_1): New. (add_target): Default the to_has_all_memory, to_has_all_memory, to_has_memory, to_has_stack, to_has_registers and to_has_execution callbacks to return 0. (update_current_target): Do not inherit to_has_all_memory, to_has_memory, to_has_stack, to_has_registers or to_has_execution. (target_mark_running, target_mark_exited): Delete. (memory_xfer_partial): Adjust. (target_read_memory, target_write_memory, target_search_memory): Dispatch to the the top-most target, not the flattened current_target. (target_info): Adjust. (init_dummy_target): Install return_zero as callback for to_has_all_memory, to_has_memory, to_has_stack, to_has_registers, to_has_execution. (set_maintenance_target_async_permitted): Use have_live_inferiors instead of target_has_execution. * target-memory.c (target_write_memory_blocks): Dispatch memory writes to the the top-most target, not the flattened current_target. * breakpoint.c (insert_breakpoints): Don't check for target_has_execution here. (update_global_location_list): Check if there are live inferiors to debug instead of target_has_execution. * infcmd.c (kill_command, detach_command): Check if there are inferiors instead of target_has_execution. * inferior.h (have_live_inferiors): Declare. * inferior.c (have_live_inferiors): New. * infrun.c (normal_stop): Don't check for target_has_execution to finish the thread states. * thread.c (is_thread_state, is_stopped, is_exited, is_running) (any_running, is_executing): Remove checks for target_has_execution. * top.c (kill_or_detach): Don't try to kill core inferiors. (quit_target): Don't check for target_has_execution. * corelow.c (core_has_memory, core_has_stack, core_has_registers): New. (init_core_ops): Install core_has_memory, core_has_stack and core_has_registers. * exec.c (exec_has_memory): New. (init_exec_ops): Install exec_has_memory. * remote.c (remote_add_inferior): Don't call target_mark_running. (remote_start_remote): Don't call target_mark_exited or call target_mark_running. (remote_open_1): Use have_inferiors instead of target_has_execution. Don't use target_mark_exited. (init_remote_ops): Install deafult_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution. * bsd-kvm.c (bsd_kvm_return_one): New. (bsd_kvm_add_target): Register bsd_kvm_return_one as to_has_memory, to_has_stack and to_has_registers callbacks. * remote-m32r-sdi.c (m32r_return_one): New. (init_m32r_ops): Register it. * inf-child.c (inf_child_target): Adjust to register default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution callbacks. * gnu-nat.c (init_gnu_ops): Likewise. * go32-nat.c (init_go32_ops): Likewise. * hpux-thread.c (init_hpux_thread_ops): Likewise. * monitor.c (init_base_monitor_ops): Likewise. * nto-procfs.c (init_procfs_ops): Likewise. * remote-mips.c (_initialize_remote_mips): Likewise. * windows-nat.c (init_windows_ops): Likewise. * remote-sim.c (gdbsim_create_inferior): Don't use target_mark_running or target_mark_exited. (gdbsim_mourn_inferior): Don't call target_mark_exited. (init_gdbsim_ops): Adjust to register default_child_has_all_memory, default_child_has_memory, default_child_has_stack, default_child_has_registers, default_child_has_execution callbacks. * linux-nat.c (linux_nat_xfer_partial): If reading memory, and there's no inferior selected, defer to a lower stratum.
2009-06-07 18:46:48 +02:00
gdbsim_ops.to_has_stack = default_child_has_stack;
gdbsim_ops.to_has_registers = default_child_has_registers;
gdbsim_ops.to_has_execution = default_child_has_execution;
1999-07-07 22:19:36 +02:00
gdbsim_ops.to_magic = OPS_MAGIC;
}
void
2000-07-30 03:48:28 +02:00
_initialize_remote_sim (void)
{
struct cmd_list_element *c;
1999-07-07 22:19:36 +02:00
init_gdbsim_ops ();
add_target (&gdbsim_ops);
c = add_com ("sim", class_obscure, simulator_command,
_("Send a command to the simulator."));
set_cmd_completer (c, sim_command_completer);
* remote-sim.c (program_loaded, gdbsim_desc, remote_sim_ptid) (resume_siggnal, resume_step): Move these static globals... (struct sim_inferior_data): ...into this new struct. (sim_inferior_data_key, next_pid, sim_argv, gdbsim_is_open): New static globals. (gdb_callback, callbacks_initialized): Move these globals to a point earlier in the file. (check_for_duplicate_sim_descriptor, get_sim_inferior_data) (get_sim_inferior_data_by_ptid, sim_inferior_data_cleanup) (gdbsim_close_inferior, gdbsim_resume_inferior) (gdbsim_stop_inferior): New functions. (SIM_INSTANCE_NOT_NEEDED, SIM_INSTANCE_NEEDED, INITIAL_PID): New constants. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_load) (gdbsim_create_inferior, gdbsim_open, gdbsim_close, gdbsim_resume) (gdbsim_stop, gdbsim_cntrl_c, gdbsim_wait) (gdbsim_xfer_inferior_memory, gdbsim_files_info) (gdbsim_mourn_inferior, simulator_command, gdbsim_thread_alive, (gdbsim_pid_to_str): Invoke `get_sim_inferior_data' to set new local variable `sim_data' in each of these functions. Use `sim_data' to reference former globals `program_loaded', `gdbsim_desc', `remote_sim_ptid', `resume_siggnal', and `resume_step'. (gdbsim_open): Remove local variable `argv'. Put results of call to `gdb_buildargv' in `sim_argv' rather than in `argv'. Don't make a cleanup for it. Free it though when a sim instance cannot be obtained. (gdbsim_close): Free sim_argv and null it out as appropriate. Close sim instances in all inferiors. (gdbsim_cntrl_c): Stop all inferiors. (gdbsim_wait): (_initialize_remote_sim): Initialize `sim_inferior_data_key'.
2010-08-10 02:19:26 +02:00
sim_inferior_data_key
= register_inferior_data_with_cleanup (NULL, sim_inferior_data_cleanup);
}