GDB (xrefs)
|
#include "defs.h"
#include "inferior.h"
#include "value.h"
#include "gdb_string.h"
#include <ctype.h>
#include <fcntl.h>
#include <signal.h>
#include <setjmp.h>
#include <errno.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 "gdb_assert.h"
#include "sim-regno.h"
#include "arch-utils.h"
#include "readline/readline.h"
#include "gdbthread.h"
Go to the source code of this file.
Classes | |
struct | resume_data |
Defines | |
#define | INITIAL_PID 42000 |
Enumerations | |
enum | { SIM_INSTANCE_NOT_NEEDED = 0, SIM_INSTANCE_NEEDED = 1 } |
Functions | |
void | _initialize_remote_sim (void) |
static void | init_callbacks (void) |
static void | end_callbacks (void) |
static int | gdb_os_write_stdout (host_callback *, const char *, int) |
static void | gdb_os_flush_stdout (host_callback *) |
static int | gdb_os_write_stderr (host_callback *, const char *, int) |
static void | gdb_os_flush_stderr (host_callback *) |
static int | gdb_os_poll_quit (host_callback *) |
static void | gdb_os_printf_filtered (host_callback *, const char *,...) |
static void | gdb_os_vprintf_filtered (host_callback *, const char *, va_list) |
static void | gdb_os_evprintf_filtered (host_callback *, const char *, va_list) |
static void | gdb_os_error (host_callback *, const char *,...) |
static int | check_for_duplicate_sim_descriptor (struct inferior *inf, void *arg) |
static struct sim_inferior_data * | get_sim_inferior_data (struct inferior *inf, int sim_instance_needed) |
static struct sim_inferior_data * | get_sim_inferior_data_by_ptid (ptid_t ptid, int sim_instance_needed) |
static void | sim_inferior_data_cleanup (struct inferior *inf, void *data) |
static void | dump_mem (const gdb_byte *buf, int len) |
int | one2one_register_sim_regno (struct gdbarch *gdbarch, int regnum) |
static void | gdbsim_fetch_register (struct target_ops *ops, struct regcache *regcache, int regno) |
static void | gdbsim_store_register (struct target_ops *ops, struct regcache *regcache, int regno) |
static void | gdbsim_kill (struct target_ops *ops) |
static void | gdbsim_load (char *args, int fromtty) |
static void | gdbsim_create_inferior (struct target_ops *target, char *exec_file, char *args, char **env, int from_tty) |
static void | gdbsim_open (char *args, int from_tty) |
static int | gdbsim_close_inferior (struct inferior *inf, void *arg) |
static void | gdbsim_close (void) |
static void | gdbsim_detach (struct target_ops *ops, char *args, int from_tty) |
static int | gdbsim_resume_inferior (struct inferior *inf, void *arg) |
static void | gdbsim_resume (struct target_ops *ops, ptid_t ptid, int step, enum gdb_signal siggnal) |
static int | gdbsim_stop_inferior (struct inferior *inf, void *arg) |
static void | gdbsim_stop (ptid_t ptid) |
static void | gdbsim_cntrl_c (int signo) |
static ptid_t | gdbsim_wait (struct target_ops *ops, ptid_t ptid, struct target_waitstatus *status, int options) |
static void | gdbsim_prepare_to_store (struct regcache *regcache) |
static LONGEST | gdbsim_xfer_memory (struct target_ops *target, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST memaddr, LONGEST len) |
static LONGEST | gdbsim_xfer_partial (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len) |
static void | gdbsim_files_info (struct target_ops *target) |
static void | gdbsim_mourn_inferior (struct target_ops *target) |
void | simulator_command (char *args, int from_tty) |
static | VEC (char_ptr) |
static int | gdbsim_thread_alive (struct target_ops *ops, ptid_t ptid) |
static char * | gdbsim_pid_to_str (struct target_ops *ops, ptid_t ptid) |
static int | gdbsim_has_all_memory (struct target_ops *ops) |
static int | gdbsim_has_memory (struct target_ops *ops) |
static void | init_gdbsim_ops (void) |
Variables | |
static int | gdbsim_is_open = 0 |
static int | next_pid |
static char ** | sim_argv = NULL |
static host_callback | gdb_callback |
static int | callbacks_initialized = 0 |
struct target_ops | gdbsim_ops |
#define INITIAL_PID 42000 |
Definition at line 133 of file remote-sim.c.
Referenced by gdbsim_open().
anonymous enum |
Definition at line 163 of file remote-sim.c.
void _initialize_remote_sim | ( | void | ) |
Definition at line 1324 of file remote-sim.c.
References _, add_com(), add_target(), class_obscure, gdbsim_ops, init_gdbsim_ops(), sim_inferior_data_cleanup(), and simulator_command().
static int check_for_duplicate_sim_descriptor | ( | struct inferior * | inf, |
void * | arg | ||
) | [static] |
Definition at line 150 of file remote-sim.c.
Referenced by get_sim_inferior_data().
Definition at line 272 of file remote-sim.c.
References fprintf_unfiltered(), fputs_unfiltered(), gdb_stdlog, len, and memcpy().
Referenced by gdbsim_fetch_register(), gdbsim_store_register(), and gdbsim_xfer_memory().
static void end_callbacks | ( | void | ) | [static] |
Definition at line 322 of file remote-sim.c.
References callbacks_initialized, and gdb_callback.
Referenced by gdbsim_close().
static void gdb_os_error | ( | host_callback * | p, |
const char * | format, | ||
... | |||
) | [static] |
static void gdb_os_evprintf_filtered | ( | host_callback * | p, |
const char * | format, | ||
va_list | ap | ||
) | [static] |
Definition at line 399 of file remote-sim.c.
References gdb_stderr, and vfprintf_filtered().
Referenced by init_callbacks().
static void gdb_os_flush_stderr | ( | host_callback * | p | ) | [static] |
Definition at line 371 of file remote-sim.c.
References gdb_flush(), and gdb_stdtargerr.
Referenced by init_callbacks().
static void gdb_os_flush_stdout | ( | host_callback * | p | ) | [static] |
Definition at line 346 of file remote-sim.c.
References gdb_flush(), and gdb_stdtarg.
Referenced by init_callbacks().
static int gdb_os_poll_quit | ( | host_callback * | p | ) | [static] |
Definition at line 944 of file remote-sim.c.
References check_quit_flag(), clear_quit_flag(), and deprecated_ui_loop_hook.
Referenced by init_callbacks().
static void gdb_os_printf_filtered | ( | host_callback * | p, |
const char * | format, | ||
... | |||
) | [static] |
Definition at line 379 of file remote-sim.c.
References gdb_stdout, and vfprintf_filtered().
Referenced by init_callbacks().
static void gdb_os_vprintf_filtered | ( | host_callback * | p, |
const char * | format, | ||
va_list | ap | ||
) | [static] |
Definition at line 391 of file remote-sim.c.
References gdb_stdout, and vfprintf_filtered().
Referenced by init_callbacks().
static int gdb_os_write_stderr | ( | host_callback * | p, |
const char * | buf, | ||
int | len | ||
) | [static] |
Definition at line 354 of file remote-sim.c.
References fputs_unfiltered(), gdb_stdtargerr, and len.
Referenced by init_callbacks().
static int gdb_os_write_stdout | ( | host_callback * | p, |
const char * | buf, | ||
int | len | ||
) | [static] |
Definition at line 334 of file remote-sim.c.
References gdb_stdtarg, len, and ui_file_write().
Referenced by init_callbacks().
static void gdbsim_close | ( | void | ) | [static] |
Definition at line 789 of file remote-sim.c.
References current_inferior(), end_callbacks(), fprintf_unfiltered(), gdb_stdlog, gdbsim_close_inferior(), gdbsim_is_open, get_sim_inferior_data(), iterate_over_inferiors(), remote_debug, sim_argv, and SIM_INSTANCE_NOT_NEEDED.
Referenced by init_gdbsim_ops().
static int gdbsim_close_inferior | ( | struct inferior * | inf, |
void * | arg | ||
) | [static] |
Definition at line 760 of file remote-sim.c.
References find_inferior_pid(), generic_mourn_inferior(), ptid_get_pid(), sim_inferior_data_cleanup(), and switch_to_thread().
Referenced by gdbsim_close().
static void gdbsim_cntrl_c | ( | int | signo | ) | [static] |
Definition at line 962 of file remote-sim.c.
References gdbsim_stop(), and minus_one_ptid.
Referenced by gdbsim_wait().
static void gdbsim_create_inferior | ( | struct target_ops * | target, |
char * | exec_file, | ||
char * | args, | ||
char ** | env, | ||
int | from_tty | ||
) | [static] |
Definition at line 605 of file remote-sim.c.
References _, add_thread_silent(), clear_proceed_status(), current_inferior(), error(), exec_bfd, fprintf_unfiltered(), gdb_buildargv(), gdb_stdlog, gdbsim_kill(), get_sim_inferior_data(), have_inferiors(), inferior_appeared(), inferior_ptid, init_thread_list(), init_wait_for_inferior(), insert_breakpoints(), len, make_cleanup_freeargv(), ptid_equal(), ptid_get_pid(), remote_debug, remove_breakpoints(), SIM_INSTANCE_NEEDED, and warning().
Referenced by init_gdbsim_ops().
static void gdbsim_detach | ( | struct target_ops * | ops, |
char * | args, | ||
int | from_tty | ||
) | [static] |
Definition at line 820 of file remote-sim.c.
References fprintf_unfiltered(), gdb_stdlog, printf_filtered(), remote_debug, target_shortname, and unpush_target().
Referenced by init_gdbsim_ops().
static void gdbsim_fetch_register | ( | struct target_ops * | ops, |
struct regcache * | regcache, | ||
int | regno | ||
) | [static] |
Definition at line 425 of file remote-sim.c.
References current_inferior(), dump_mem(), fprintf_unfiltered(), gdb_assert, gdb_stderr, gdb_stdlog, gdbarch_num_regs(), gdbarch_register_name(), gdbarch_register_sim_regno(), get_regcache_arch(), get_sim_inferior_data(), LEGACY_SIM_REGNO_IGNORE, MAX_REGISTER_SIZE, memset(), regcache_raw_supply(), register_size(), remote_debug, SIM_INSTANCE_NEEDED, and SIM_REGNO_DOES_NOT_EXIST.
Referenced by init_gdbsim_ops().
static void gdbsim_files_info | ( | struct target_ops * | target | ) | [static] |
Definition at line 1129 of file remote-sim.c.
References current_inferior(), exec_bfd, fprintf_unfiltered(), gdb_stdlog, get_sim_inferior_data(), remote_debug, SIM_INSTANCE_NEEDED, and target_shortname.
Referenced by init_gdbsim_ops().
static int gdbsim_has_all_memory | ( | struct target_ops * | ops | ) | [static] |
Definition at line 1262 of file remote-sim.c.
References current_inferior(), get_sim_inferior_data(), and SIM_INSTANCE_NOT_NEEDED.
Referenced by init_gdbsim_ops().
static int gdbsim_has_memory | ( | struct target_ops * | ops | ) | [static] |
Definition at line 1274 of file remote-sim.c.
References current_inferior(), get_sim_inferior_data(), and SIM_INSTANCE_NOT_NEEDED.
Referenced by init_gdbsim_ops().
static void gdbsim_kill | ( | struct target_ops * | ops | ) | [static] |
Definition at line 547 of file remote-sim.c.
References fprintf_unfiltered(), gdb_stdlog, remote_debug, and target_mourn_inferior().
Referenced by gdbsim_create_inferior(), and init_gdbsim_ops().
static void gdbsim_load | ( | char * | args, |
int | fromtty | ||
) | [static] |
Definition at line 562 of file remote-sim.c.
References _, current_inferior(), error(), error_no_arg(), fprintf_unfiltered(), gdb_buildargv(), gdb_stdlog, get_sim_inferior_data(), make_cleanup_freeargv(), remote_debug, and SIM_INSTANCE_NEEDED.
Referenced by init_gdbsim_ops().
static void gdbsim_mourn_inferior | ( | struct target_ops * | target | ) | [static] |
Definition at line 1152 of file remote-sim.c.
References current_inferior(), delete_thread_silent(), fprintf_unfiltered(), gdb_stdlog, generic_mourn_inferior(), get_sim_inferior_data(), remote_debug, remove_breakpoints(), and SIM_INSTANCE_NOT_NEEDED.
Referenced by init_gdbsim_ops().
static void gdbsim_open | ( | char * | args, |
int | from_tty | ||
) | [static] |
Definition at line 666 of file remote-sim.c.
References _, current_inferior(), error(), exec_bfd, fprintf_unfiltered(), gdb_buildargv(), gdb_callback, gdb_stdlog, gdb_sysroot, gdbsim_is_open, gdbsim_ops, get_sim_inferior_data(), inferior_ptid, init_callbacks(), INITIAL_PID, len, next_pid, null_ptid, printf_filtered(), push_target(), remote_debug, selected_architecture_name(), selected_byte_order(), sim_argv, SIM_INSTANCE_NOT_NEEDED, and unpush_target().
Referenced by init_gdbsim_ops().
static char* gdbsim_pid_to_str | ( | struct target_ops * | ops, |
ptid_t | ptid | ||
) | [static] |
Definition at line 1254 of file remote-sim.c.
References normal_pid_to_str().
Referenced by init_gdbsim_ops().
static void gdbsim_prepare_to_store | ( | struct regcache * | regcache | ) | [static] |
Definition at line 1054 of file remote-sim.c.
Referenced by init_gdbsim_ops().
static void gdbsim_resume | ( | struct target_ops * | ops, |
ptid_t | ptid, | ||
int | step, | ||
enum gdb_signal | siggnal | ||
) | [static] |
Definition at line 865 of file remote-sim.c.
References _, error(), find_inferior_pid(), gdbsim_resume_inferior(), get_sim_inferior_data_by_ptid(), iterate_over_inferiors(), minus_one_ptid, ptid_equal(), ptid_get_pid(), resume_data::siggnal, SIM_INSTANCE_NOT_NEEDED, and resume_data::step.
Referenced by init_gdbsim_ops().
static int gdbsim_resume_inferior | ( | struct inferior * | inf, |
void * | arg | ||
) | [static] |
Definition at line 841 of file remote-sim.c.
References _, fprintf_unfiltered(), gdb_stdlog, get_sim_inferior_data(), inferior::pid, remote_debug, resume_data::siggnal, SIM_INSTANCE_NOT_NEEDED, and resume_data::step.
Referenced by gdbsim_resume().
static void gdbsim_stop | ( | ptid_t | ptid | ) | [static] |
Definition at line 920 of file remote-sim.c.
References _, error(), find_inferior_pid(), gdbsim_stop_inferior(), iterate_over_inferiors(), minus_one_ptid, ptid_equal(), and ptid_get_pid().
Referenced by gdbsim_cntrl_c(), and init_gdbsim_ops().
static int gdbsim_stop_inferior | ( | struct inferior * | inf, |
void * | arg | ||
) | [static] |
Definition at line 900 of file remote-sim.c.
References get_sim_inferior_data(), quit(), and SIM_INSTANCE_NEEDED.
Referenced by gdbsim_stop().
static void gdbsim_store_register | ( | struct target_ops * | ops, |
struct regcache * | regcache, | ||
int | regno | ||
) | [static] |
Definition at line 501 of file remote-sim.c.
References _, current_inferior(), dump_mem(), fprintf_unfiltered(), gdb_stdlog, gdbarch_num_regs(), gdbarch_register_name(), gdbarch_register_sim_regno(), get_regcache_arch(), get_sim_inferior_data(), internal_error(), MAX_REGISTER_SIZE, regcache_cooked_read(), register_size(), remote_debug, SIM_INSTANCE_NEEDED, and warning().
Referenced by init_gdbsim_ops().
static int gdbsim_thread_alive | ( | struct target_ops * | ops, |
ptid_t | ptid | ||
) | [static] |
Definition at line 1235 of file remote-sim.c.
References get_sim_inferior_data_by_ptid(), ptid_equal(), and SIM_INSTANCE_NOT_NEEDED.
Referenced by init_gdbsim_ops().
static ptid_t gdbsim_wait | ( | struct target_ops * | ops, |
ptid_t | ptid, | ||
struct target_waitstatus * | status, | ||
int | options | ||
) | [static] |
Definition at line 968 of file remote-sim.c.
References _, current_inferior(), error(), fprintf_unfiltered(), gdb_stdlog, gdbsim_cntrl_c(), get_sim_inferior_data(), get_sim_inferior_data_by_ptid(), inferior_ptid, target_waitstatus::integer, target_waitstatus::kind, minus_one_ptid, ptid_equal(), ptid_get_pid(), quit(), remote_debug, RETSIGTYPE, target_waitstatus::sig, SIM_INSTANCE_NEEDED, TARGET_WAITKIND_EXITED, TARGET_WAITKIND_SIGNALLED, TARGET_WAITKIND_STOPPED, and target_waitstatus::value.
Referenced by init_gdbsim_ops().
static LONGEST gdbsim_xfer_memory | ( | struct target_ops * | target, |
gdb_byte * | readbuf, | ||
const gdb_byte * | writebuf, | ||
ULONGEST | memaddr, | ||
LONGEST | len | ||
) | [static] |
Definition at line 1063 of file remote-sim.c.
References _, current_inferior(), dump_mem(), error(), fprintf_unfiltered(), gdb_assert, gdb_stdlog, get_sim_inferior_data(), host_address_to_string(), len, paddress(), plongest(), remote_debug, SIM_INSTANCE_NOT_NEEDED, target_gdbarch(), and target_ops::to_has_memory.
Referenced by gdbsim_xfer_partial().
static LONGEST gdbsim_xfer_partial | ( | struct target_ops * | ops, |
enum target_object | object, | ||
const char * | annex, | ||
gdb_byte * | readbuf, | ||
const gdb_byte * | writebuf, | ||
ULONGEST | offset, | ||
LONGEST | len | ||
) | [static] |
Definition at line 1114 of file remote-sim.c.
References gdbsim_xfer_memory(), and TARGET_OBJECT_MEMORY.
Referenced by init_gdbsim_ops().
static struct sim_inferior_data* get_sim_inferior_data | ( | struct inferior * | inf, |
int | sim_instance_needed | ||
) | [static, read] |
Definition at line 169 of file remote-sim.c.
References _, check_for_duplicate_sim_descriptor(), error(), exec_bfd, gdb_callback, iterate_over_inferiors(), next_pid, inferior::num, ptid_build(), sim_argv, SIM_INSTANCE_NEEDED, and XZALLOC.
Referenced by gdbsim_close(), gdbsim_create_inferior(), gdbsim_fetch_register(), gdbsim_files_info(), gdbsim_has_all_memory(), gdbsim_has_memory(), gdbsim_load(), gdbsim_mourn_inferior(), gdbsim_open(), gdbsim_resume_inferior(), gdbsim_stop_inferior(), gdbsim_store_register(), gdbsim_wait(), gdbsim_xfer_memory(), and get_sim_inferior_data_by_ptid().
static struct sim_inferior_data* get_sim_inferior_data_by_ptid | ( | ptid_t | ptid, |
int | sim_instance_needed | ||
) | [static, read] |
Definition at line 237 of file remote-sim.c.
References find_inferior_pid(), get_sim_inferior_data(), arm-linux::inf, inferior::pid, and ptid_get_pid().
Referenced by gdbsim_resume(), gdbsim_thread_alive(), and gdbsim_wait().
static void init_callbacks | ( | void | ) | [static] |
Definition at line 299 of file remote-sim.c.
References callbacks_initialized, gdb_callback, gdb_os_error(), gdb_os_evprintf_filtered(), gdb_os_flush_stderr(), gdb_os_flush_stdout(), gdb_os_poll_quit(), gdb_os_printf_filtered(), gdb_os_vprintf_filtered(), gdb_os_write_stderr(), and gdb_os_write_stdout().
Referenced by gdbsim_open().
static void init_gdbsim_ops | ( | void | ) | [static] |
Definition at line 1290 of file remote-sim.c.
References default_child_has_execution(), default_child_has_registers(), default_child_has_stack(), gdbsim_close(), gdbsim_create_inferior(), gdbsim_detach(), gdbsim_fetch_register(), gdbsim_files_info(), gdbsim_has_all_memory(), gdbsim_has_memory(), gdbsim_kill(), gdbsim_load(), gdbsim_mourn_inferior(), gdbsim_open(), gdbsim_ops, gdbsim_pid_to_str(), gdbsim_prepare_to_store(), gdbsim_resume(), gdbsim_stop(), gdbsim_store_register(), gdbsim_thread_alive(), gdbsim_wait(), gdbsim_xfer_partial(), memory_insert_breakpoint(), memory_remove_breakpoint(), OPS_MAGIC, process_stratum, target_ops::to_close, target_ops::to_create_inferior, target_ops::to_detach, target_ops::to_doc, target_ops::to_fetch_registers, target_ops::to_files_info, target_ops::to_has_all_memory, target_ops::to_has_execution, target_ops::to_has_memory, target_ops::to_has_registers, target_ops::to_has_stack, target_ops::to_insert_breakpoint, target_ops::to_kill, target_ops::to_load, target_ops::to_longname, target_ops::to_magic, target_ops::to_mourn_inferior, target_ops::to_open, target_ops::to_pid_to_str, target_ops::to_prepare_to_store, target_ops::to_remove_breakpoint, target_ops::to_resume, target_ops::to_shortname, target_ops::to_stop, target_ops::to_store_registers, target_ops::to_stratum, target_ops::to_thread_alive, target_ops::to_wait, and target_ops::to_xfer_partial.
Referenced by _initialize_remote_sim().
int one2one_register_sim_regno | ( | struct gdbarch * | gdbarch, |
int | regnum | ||
) |
Definition at line 417 of file remote-sim.c.
References gdb_assert, gdbarch_num_regs(), and regnum.
static void sim_inferior_data_cleanup | ( | struct inferior * | inf, |
void * | data | ||
) | [static] |
Definition at line 256 of file remote-sim.c.
References xfree().
Referenced by _initialize_remote_sim(), and gdbsim_close_inferior().
void simulator_command | ( | char * | args, |
int | from_tty | ||
) |
Definition at line 1169 of file remote-sim.c.
References _, current_inferior(), error(), and registers_changed().
Referenced by _initialize_remote_sim().
Definition at line 1207 of file remote-sim.c.
References current_inferior(), VEC, VEC_safe_push, and xfree().
int callbacks_initialized = 0 [static] |
Definition at line 143 of file remote-sim.c.
Referenced by end_callbacks(), and init_callbacks().
host_callback gdb_callback [static] |
Definition at line 142 of file remote-sim.c.
Referenced by end_callbacks(), gdbsim_open(), get_sim_inferior_data(), and init_callbacks().
int gdbsim_is_open = 0 [static] |
Definition at line 127 of file remote-sim.c.
Referenced by gdbsim_close(), and gdbsim_open().
struct target_ops gdbsim_ops |
Definition at line 1287 of file remote-sim.c.
Referenced by _initialize_remote_sim(), gdbsim_open(), and init_gdbsim_ops().
Definition at line 132 of file remote-sim.c.
Referenced by gdbsim_open(), and get_sim_inferior_data().
char** sim_argv = NULL [static] |
Definition at line 139 of file remote-sim.c.
Referenced by gdbsim_close(), gdbsim_open(), and get_sim_inferior_data().