binutils-gdb/gdb/remote-sim.c

1341 lines
38 KiB
C
Raw Normal View History

/* Generic remote debugging interface for simulators.
2002-01-19 04:32:43 +01:00
Copyright (C) 1993-2014 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 "inferior.h"
#include "value.h"
remove gdb_string.h This removes gdb_string.h. This patch is purely mechanical. I created it by running the two commands: git rm common/gdb_string.h perl -pi -e's/"gdb_string.h"/<string.h>/;' *.[chyl] */*.[chyl] 2013-11-18 Tom Tromey <tromey@redhat.com> * common/gdb_string.h: Remove. * aarch64-tdep.c: Use string.h, not gdb_string.h. * ada-exp.y: Use string.h, not gdb_string.h. * ada-lang.c: Use string.h, not gdb_string.h. * ada-lex.l: Use string.h, not gdb_string.h. * ada-typeprint.c: Use string.h, not gdb_string.h. * ada-valprint.c: Use string.h, not gdb_string.h. * aix-thread.c: Use string.h, not gdb_string.h. * alpha-linux-tdep.c: Use string.h, not gdb_string.h. * alpha-mdebug-tdep.c: Use string.h, not gdb_string.h. * alpha-nat.c: Use string.h, not gdb_string.h. * alpha-osf1-tdep.c: Use string.h, not gdb_string.h. * alpha-tdep.c: Use string.h, not gdb_string.h. * alphanbsd-tdep.c: Use string.h, not gdb_string.h. * amd64-dicos-tdep.c: Use string.h, not gdb_string.h. * amd64-linux-nat.c: Use string.h, not gdb_string.h. * amd64-linux-tdep.c: Use string.h, not gdb_string.h. * amd64-nat.c: Use string.h, not gdb_string.h. * amd64-sol2-tdep.c: Use string.h, not gdb_string.h. * amd64fbsd-tdep.c: Use string.h, not gdb_string.h. * amd64obsd-tdep.c: Use string.h, not gdb_string.h. * arch-utils.c: Use string.h, not gdb_string.h. * arm-linux-nat.c: Use string.h, not gdb_string.h. * arm-linux-tdep.c: Use string.h, not gdb_string.h. * arm-tdep.c: Use string.h, not gdb_string.h. * arm-wince-tdep.c: Use string.h, not gdb_string.h. * armbsd-tdep.c: Use string.h, not gdb_string.h. * armnbsd-nat.c: Use string.h, not gdb_string.h. * armnbsd-tdep.c: Use string.h, not gdb_string.h. * armobsd-tdep.c: Use string.h, not gdb_string.h. * avr-tdep.c: Use string.h, not gdb_string.h. * ax-gdb.c: Use string.h, not gdb_string.h. * ax-general.c: Use string.h, not gdb_string.h. * bcache.c: Use string.h, not gdb_string.h. * bfin-tdep.c: Use string.h, not gdb_string.h. * breakpoint.c: Use string.h, not gdb_string.h. * build-id.c: Use string.h, not gdb_string.h. * buildsym.c: Use string.h, not gdb_string.h. * c-exp.y: Use string.h, not gdb_string.h. * c-lang.c: Use string.h, not gdb_string.h. * c-typeprint.c: Use string.h, not gdb_string.h. * c-valprint.c: Use string.h, not gdb_string.h. * charset.c: Use string.h, not gdb_string.h. * cli-out.c: Use string.h, not gdb_string.h. * cli/cli-cmds.c: Use string.h, not gdb_string.h. * cli/cli-decode.c: Use string.h, not gdb_string.h. * cli/cli-dump.c: Use string.h, not gdb_string.h. * cli/cli-interp.c: Use string.h, not gdb_string.h. * cli/cli-logging.c: Use string.h, not gdb_string.h. * cli/cli-script.c: Use string.h, not gdb_string.h. * cli/cli-setshow.c: Use string.h, not gdb_string.h. * cli/cli-utils.c: Use string.h, not gdb_string.h. * coffread.c: Use string.h, not gdb_string.h. * common/common-utils.c: Use string.h, not gdb_string.h. * common/filestuff.c: Use string.h, not gdb_string.h. * common/linux-procfs.c: Use string.h, not gdb_string.h. * common/linux-ptrace.c: Use string.h, not gdb_string.h. * common/signals.c: Use string.h, not gdb_string.h. * common/vec.h: Use string.h, not gdb_string.h. * core-regset.c: Use string.h, not gdb_string.h. * corefile.c: Use string.h, not gdb_string.h. * corelow.c: Use string.h, not gdb_string.h. * cp-abi.c: Use string.h, not gdb_string.h. * cp-support.c: Use string.h, not gdb_string.h. * cp-valprint.c: Use string.h, not gdb_string.h. * cris-tdep.c: Use string.h, not gdb_string.h. * d-lang.c: Use string.h, not gdb_string.h. * dbxread.c: Use string.h, not gdb_string.h. * dcache.c: Use string.h, not gdb_string.h. * demangle.c: Use string.h, not gdb_string.h. * dicos-tdep.c: Use string.h, not gdb_string.h. * disasm.c: Use string.h, not gdb_string.h. * doublest.c: Use string.h, not gdb_string.h. * dsrec.c: Use string.h, not gdb_string.h. * dummy-frame.c: Use string.h, not gdb_string.h. * dwarf2-frame.c: Use string.h, not gdb_string.h. * dwarf2loc.c: Use string.h, not gdb_string.h. * dwarf2read.c: Use string.h, not gdb_string.h. * elfread.c: Use string.h, not gdb_string.h. * environ.c: Use string.h, not gdb_string.h. * eval.c: Use string.h, not gdb_string.h. * event-loop.c: Use string.h, not gdb_string.h. * exceptions.c: Use string.h, not gdb_string.h. * exec.c: Use string.h, not gdb_string.h. * expprint.c: Use string.h, not gdb_string.h. * f-exp.y: Use string.h, not gdb_string.h. * f-lang.c: Use string.h, not gdb_string.h. * f-typeprint.c: Use string.h, not gdb_string.h. * f-valprint.c: Use string.h, not gdb_string.h. * fbsd-nat.c: Use string.h, not gdb_string.h. * findcmd.c: Use string.h, not gdb_string.h. * findvar.c: Use string.h, not gdb_string.h. * fork-child.c: Use string.h, not gdb_string.h. * frame.c: Use string.h, not gdb_string.h. * frv-linux-tdep.c: Use string.h, not gdb_string.h. * frv-tdep.c: Use string.h, not gdb_string.h. * gdb.c: Use string.h, not gdb_string.h. * gdb_bfd.c: Use string.h, not gdb_string.h. * gdbarch.c: Use string.h, not gdb_string.h. * gdbtypes.c: Use string.h, not gdb_string.h. * gnu-nat.c: Use string.h, not gdb_string.h. * gnu-v2-abi.c: Use string.h, not gdb_string.h. * gnu-v3-abi.c: Use string.h, not gdb_string.h. * go-exp.y: Use string.h, not gdb_string.h. * go-lang.c: Use string.h, not gdb_string.h. * go32-nat.c: Use string.h, not gdb_string.h. * hppa-hpux-tdep.c: Use string.h, not gdb_string.h. * hppa-linux-nat.c: Use string.h, not gdb_string.h. * hppanbsd-tdep.c: Use string.h, not gdb_string.h. * hppaobsd-tdep.c: Use string.h, not gdb_string.h. * i386-cygwin-tdep.c: Use string.h, not gdb_string.h. * i386-dicos-tdep.c: Use string.h, not gdb_string.h. * i386-linux-nat.c: Use string.h, not gdb_string.h. * i386-linux-tdep.c: Use string.h, not gdb_string.h. * i386-nto-tdep.c: Use string.h, not gdb_string.h. * i386-sol2-tdep.c: Use string.h, not gdb_string.h. * i386-tdep.c: Use string.h, not gdb_string.h. * i386bsd-tdep.c: Use string.h, not gdb_string.h. * i386gnu-nat.c: Use string.h, not gdb_string.h. * i386nbsd-tdep.c: Use string.h, not gdb_string.h. * i386obsd-tdep.c: Use string.h, not gdb_string.h. * i387-tdep.c: Use string.h, not gdb_string.h. * ia64-libunwind-tdep.c: Use string.h, not gdb_string.h. * ia64-linux-nat.c: Use string.h, not gdb_string.h. * inf-child.c: Use string.h, not gdb_string.h. * inf-ptrace.c: Use string.h, not gdb_string.h. * inf-ttrace.c: Use string.h, not gdb_string.h. * infcall.c: Use string.h, not gdb_string.h. * infcmd.c: Use string.h, not gdb_string.h. * inflow.c: Use string.h, not gdb_string.h. * infrun.c: Use string.h, not gdb_string.h. * interps.c: Use string.h, not gdb_string.h. * iq2000-tdep.c: Use string.h, not gdb_string.h. * irix5-nat.c: Use string.h, not gdb_string.h. * jv-exp.y: Use string.h, not gdb_string.h. * jv-lang.c: Use string.h, not gdb_string.h. * jv-typeprint.c: Use string.h, not gdb_string.h. * jv-valprint.c: Use string.h, not gdb_string.h. * language.c: Use string.h, not gdb_string.h. * linux-fork.c: Use string.h, not gdb_string.h. * linux-nat.c: Use string.h, not gdb_string.h. * lm32-tdep.c: Use string.h, not gdb_string.h. * m2-exp.y: Use string.h, not gdb_string.h. * m2-typeprint.c: Use string.h, not gdb_string.h. * m32c-tdep.c: Use string.h, not gdb_string.h. * m32r-linux-nat.c: Use string.h, not gdb_string.h. * m32r-linux-tdep.c: Use string.h, not gdb_string.h. * m32r-rom.c: Use string.h, not gdb_string.h. * m32r-tdep.c: Use string.h, not gdb_string.h. * m68hc11-tdep.c: Use string.h, not gdb_string.h. * m68k-tdep.c: Use string.h, not gdb_string.h. * m68kbsd-tdep.c: Use string.h, not gdb_string.h. * m68klinux-nat.c: Use string.h, not gdb_string.h. * m68klinux-tdep.c: Use string.h, not gdb_string.h. * m88k-tdep.c: Use string.h, not gdb_string.h. * macrocmd.c: Use string.h, not gdb_string.h. * main.c: Use string.h, not gdb_string.h. * mdebugread.c: Use string.h, not gdb_string.h. * mem-break.c: Use string.h, not gdb_string.h. * memattr.c: Use string.h, not gdb_string.h. * memory-map.c: Use string.h, not gdb_string.h. * mep-tdep.c: Use string.h, not gdb_string.h. * mi/mi-cmd-break.c: Use string.h, not gdb_string.h. * mi/mi-cmd-disas.c: Use string.h, not gdb_string.h. * mi/mi-cmd-env.c: Use string.h, not gdb_string.h. * mi/mi-cmd-stack.c: Use string.h, not gdb_string.h. * mi/mi-cmd-var.c: Use string.h, not gdb_string.h. * mi/mi-cmds.c: Use string.h, not gdb_string.h. * mi/mi-console.c: Use string.h, not gdb_string.h. * mi/mi-getopt.c: Use string.h, not gdb_string.h. * mi/mi-interp.c: Use string.h, not gdb_string.h. * mi/mi-main.c: Use string.h, not gdb_string.h. * mi/mi-parse.c: Use string.h, not gdb_string.h. * microblaze-rom.c: Use string.h, not gdb_string.h. * microblaze-tdep.c: Use string.h, not gdb_string.h. * mingw-hdep.c: Use string.h, not gdb_string.h. * minidebug.c: Use string.h, not gdb_string.h. * minsyms.c: Use string.h, not gdb_string.h. * mips-irix-tdep.c: Use string.h, not gdb_string.h. * mips-linux-tdep.c: Use string.h, not gdb_string.h. * mips-tdep.c: Use string.h, not gdb_string.h. * mips64obsd-tdep.c: Use string.h, not gdb_string.h. * mipsnbsd-tdep.c: Use string.h, not gdb_string.h. * mipsread.c: Use string.h, not gdb_string.h. * mn10300-linux-tdep.c: Use string.h, not gdb_string.h. * mn10300-tdep.c: Use string.h, not gdb_string.h. * monitor.c: Use string.h, not gdb_string.h. * moxie-tdep.c: Use string.h, not gdb_string.h. * mt-tdep.c: Use string.h, not gdb_string.h. * nbsd-tdep.c: Use string.h, not gdb_string.h. * nios2-linux-tdep.c: Use string.h, not gdb_string.h. * nto-procfs.c: Use string.h, not gdb_string.h. * nto-tdep.c: Use string.h, not gdb_string.h. * objc-lang.c: Use string.h, not gdb_string.h. * objfiles.c: Use string.h, not gdb_string.h. * opencl-lang.c: Use string.h, not gdb_string.h. * osabi.c: Use string.h, not gdb_string.h. * osdata.c: Use string.h, not gdb_string.h. * p-exp.y: Use string.h, not gdb_string.h. * p-lang.c: Use string.h, not gdb_string.h. * p-typeprint.c: Use string.h, not gdb_string.h. * parse.c: Use string.h, not gdb_string.h. * posix-hdep.c: Use string.h, not gdb_string.h. * ppc-linux-nat.c: Use string.h, not gdb_string.h. * ppc-sysv-tdep.c: Use string.h, not gdb_string.h. * ppcfbsd-tdep.c: Use string.h, not gdb_string.h. * ppcnbsd-tdep.c: Use string.h, not gdb_string.h. * ppcobsd-tdep.c: Use string.h, not gdb_string.h. * printcmd.c: Use string.h, not gdb_string.h. * procfs.c: Use string.h, not gdb_string.h. * prologue-value.c: Use string.h, not gdb_string.h. * python/py-auto-load.c: Use string.h, not gdb_string.h. * python/py-gdb-readline.c: Use string.h, not gdb_string.h. * ravenscar-thread.c: Use string.h, not gdb_string.h. * regcache.c: Use string.h, not gdb_string.h. * registry.c: Use string.h, not gdb_string.h. * remote-fileio.c: Use string.h, not gdb_string.h. * remote-m32r-sdi.c: Use string.h, not gdb_string.h. * remote-mips.c: Use string.h, not gdb_string.h. * remote-sim.c: Use string.h, not gdb_string.h. * remote.c: Use string.h, not gdb_string.h. * reverse.c: Use string.h, not gdb_string.h. * rs6000-aix-tdep.c: Use string.h, not gdb_string.h. * ser-base.c: Use string.h, not gdb_string.h. * ser-go32.c: Use string.h, not gdb_string.h. * ser-mingw.c: Use string.h, not gdb_string.h. * ser-pipe.c: Use string.h, not gdb_string.h. * ser-tcp.c: Use string.h, not gdb_string.h. * ser-unix.c: Use string.h, not gdb_string.h. * serial.c: Use string.h, not gdb_string.h. * sh-tdep.c: Use string.h, not gdb_string.h. * sh64-tdep.c: Use string.h, not gdb_string.h. * shnbsd-tdep.c: Use string.h, not gdb_string.h. * skip.c: Use string.h, not gdb_string.h. * sol-thread.c: Use string.h, not gdb_string.h. * solib-dsbt.c: Use string.h, not gdb_string.h. * solib-frv.c: Use string.h, not gdb_string.h. * solib-osf.c: Use string.h, not gdb_string.h. * solib-spu.c: Use string.h, not gdb_string.h. * solib-target.c: Use string.h, not gdb_string.h. * solib.c: Use string.h, not gdb_string.h. * somread.c: Use string.h, not gdb_string.h. * source.c: Use string.h, not gdb_string.h. * sparc-nat.c: Use string.h, not gdb_string.h. * sparc-sol2-tdep.c: Use string.h, not gdb_string.h. * sparc-tdep.c: Use string.h, not gdb_string.h. * sparc64-tdep.c: Use string.h, not gdb_string.h. * sparc64fbsd-tdep.c: Use string.h, not gdb_string.h. * sparc64nbsd-tdep.c: Use string.h, not gdb_string.h. * sparcnbsd-tdep.c: Use string.h, not gdb_string.h. * spu-linux-nat.c: Use string.h, not gdb_string.h. * spu-multiarch.c: Use string.h, not gdb_string.h. * spu-tdep.c: Use string.h, not gdb_string.h. * stabsread.c: Use string.h, not gdb_string.h. * stack.c: Use string.h, not gdb_string.h. * std-regs.c: Use string.h, not gdb_string.h. * symfile.c: Use string.h, not gdb_string.h. * symmisc.c: Use string.h, not gdb_string.h. * symtab.c: Use string.h, not gdb_string.h. * target.c: Use string.h, not gdb_string.h. * thread.c: Use string.h, not gdb_string.h. * tilegx-linux-nat.c: Use string.h, not gdb_string.h. * tilegx-tdep.c: Use string.h, not gdb_string.h. * top.c: Use string.h, not gdb_string.h. * tracepoint.c: Use string.h, not gdb_string.h. * tui/tui-command.c: Use string.h, not gdb_string.h. * tui/tui-data.c: Use string.h, not gdb_string.h. * tui/tui-disasm.c: Use string.h, not gdb_string.h. * tui/tui-file.c: Use string.h, not gdb_string.h. * tui/tui-layout.c: Use string.h, not gdb_string.h. * tui/tui-out.c: Use string.h, not gdb_string.h. * tui/tui-regs.c: Use string.h, not gdb_string.h. * tui/tui-source.c: Use string.h, not gdb_string.h. * tui/tui-stack.c: Use string.h, not gdb_string.h. * tui/tui-win.c: Use string.h, not gdb_string.h. * tui/tui-windata.c: Use string.h, not gdb_string.h. * tui/tui-winsource.c: Use string.h, not gdb_string.h. * typeprint.c: Use string.h, not gdb_string.h. * ui-file.c: Use string.h, not gdb_string.h. * ui-out.c: Use string.h, not gdb_string.h. * user-regs.c: Use string.h, not gdb_string.h. * utils.c: Use string.h, not gdb_string.h. * v850-tdep.c: Use string.h, not gdb_string.h. * valarith.c: Use string.h, not gdb_string.h. * valops.c: Use string.h, not gdb_string.h. * valprint.c: Use string.h, not gdb_string.h. * value.c: Use string.h, not gdb_string.h. * varobj.c: Use string.h, not gdb_string.h. * vax-tdep.c: Use string.h, not gdb_string.h. * vaxnbsd-tdep.c: Use string.h, not gdb_string.h. * vaxobsd-tdep.c: Use string.h, not gdb_string.h. * windows-nat.c: Use string.h, not gdb_string.h. * xcoffread.c: Use string.h, not gdb_string.h. * xml-support.c: Use string.h, not gdb_string.h. * xstormy16-tdep.c: Use string.h, not gdb_string.h. * xtensa-linux-nat.c: Use string.h, not gdb_string.h.
2013-11-06 15:14:23 +01:00
#include <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"
/* 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 *);
2000-05-28 03:12:42 +02:00
static void gdbsim_load (char *prog, int fromtty);
2000-05-28 03:12:42 +02:00
static void gdbsim_open (char *args, int from_tty);
gdb/ Code cleanup. * bfd-target.c (target_bfd_xclose): Remove parameter quitting. * bsd-kvm.c (bsd_kvm_close): Likewise. * bsd-uthread.c (bsd_uthread_close): Likewise. * corelow.c (core_close): Likewise. (core_close_cleanup): Remove parameter quitting from a caller. * event-top.c (async_disconnect): Likewise. * exec.c (exec_close_1): Remove parameter quitting. * go32-nat.c (go32_close): Likewise. * linux-nat.c (linux_nat_close): Remove parameter quitting. Remove parameter quitting from a caller. * mips-linux-nat.c (super_close): Remove parameter quitting from the variable. (mips_linux_close): Remove parameter quitting. Remove parameter quitting from a caller. * monitor.c (monitor_close): Remove parameter quitting. * monitor.h (monitor_close): Likewise. * record-btrace.c (record_btrace_close): Likewise. * record-full.c (record_full_close): Likewise. * remote-m32r-sdi.c (m32r_close): Remove parameter quitting and remove it also from fprintf_unfiltered. * remote-mips.c (mips_close): Remove parameter quitting. (mips_detach): Remove parameter quitting from a caller. * remote-sim.c (gdbsim_close): Remove parameter quitting. (gdbsim_close): Remove duplicate function comment. Remove parameter quitting and remove it also from printf_filtered. * remote.c (remote_close): Remove parameter quitting. * solib-svr4.c (enable_break): Remove parameter quitting from a caller. * target.c (update_current_target): Remove parameter int from to_close de_fault. (push_target, unpush_target, pop_target): Remove parameter quitting from a caller. (pop_all_targets_above, pop_all_targets): Remove parameter quitting. Remove parameter quitting from a caller. (target_preopen): Remove parameter quitting from a caller. (target_close): Remove parameter quitting. Remove parameter quitting from a caller two times. Remove parameter quitting also from fprintf_unfiltered. * target.h (struct target_ops): Remove parameter quitting and as int from fields to_xclose and to_close. (extern struct target_ops current_target): (target_close, pop_all_targets): Remove parameter quitting. Update the comment. (pop_all_targets_above): Remove parameter quitting. * top.c (quit_target): Remove parameter quitting from a caller. * tracepoint.c (tfile_close): Remove parameter quitting. * windows-nat.c (windows_close): Remove parameter quitting.
2013-03-20 16:46:24 +01:00
static void gdbsim_close (void);
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);
static void gdbsim_stop (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 = arg;
sim_data = inferior_data (inf, sim_inferior_data_key);
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
= inferior_data (inf, sim_inferior_data_key);
/* 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
&& (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);
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);
}
}
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. */
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;
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 = data;
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);
* 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);
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;
}
* 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
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);
* 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);
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. */
target_mourn_inferior ();
}
/* 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 (char *args, int fromtty)
{
char **argv;
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
gdbsim_create_inferior (struct target_ops *target, char *exec_file, char *args,
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;
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)
{
1999-07-07 22:19:36 +02:00
len = strlen (exec_file) + 1 + strlen (args) + 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 ();
}
/* 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
2000-07-30 03:48:28 +02:00
gdbsim_open (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;
SIM_DESC gdbsim_desc;
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 (gdb_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, gdb_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 = inferior_data (inf,
sim_inferior_data_key);
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_pid (ptid_get_pid (ptid)) != NULL)
{
switch_to_thread (ptid);
generic_mourn_inferior ();
}
}
return 0;
}
/* Close out all files and local state before this target loses control. */
static void
gdb/ Code cleanup. * bfd-target.c (target_bfd_xclose): Remove parameter quitting. * bsd-kvm.c (bsd_kvm_close): Likewise. * bsd-uthread.c (bsd_uthread_close): Likewise. * corelow.c (core_close): Likewise. (core_close_cleanup): Remove parameter quitting from a caller. * event-top.c (async_disconnect): Likewise. * exec.c (exec_close_1): Remove parameter quitting. * go32-nat.c (go32_close): Likewise. * linux-nat.c (linux_nat_close): Remove parameter quitting. Remove parameter quitting from a caller. * mips-linux-nat.c (super_close): Remove parameter quitting from the variable. (mips_linux_close): Remove parameter quitting. Remove parameter quitting from a caller. * monitor.c (monitor_close): Remove parameter quitting. * monitor.h (monitor_close): Likewise. * record-btrace.c (record_btrace_close): Likewise. * record-full.c (record_full_close): Likewise. * remote-m32r-sdi.c (m32r_close): Remove parameter quitting and remove it also from fprintf_unfiltered. * remote-mips.c (mips_close): Remove parameter quitting. (mips_detach): Remove parameter quitting from a caller. * remote-sim.c (gdbsim_close): Remove parameter quitting. (gdbsim_close): Remove duplicate function comment. Remove parameter quitting and remove it also from printf_filtered. * remote.c (remote_close): Remove parameter quitting. * solib-svr4.c (enable_break): Remove parameter quitting from a caller. * target.c (update_current_target): Remove parameter int from to_close de_fault. (push_target, unpush_target, pop_target): Remove parameter quitting from a caller. (pop_all_targets_above, pop_all_targets): Remove parameter quitting. Remove parameter quitting from a caller. (target_preopen): Remove parameter quitting from a caller. (target_close): Remove parameter quitting. Remove parameter quitting from a caller two times. Remove parameter quitting also from fprintf_unfiltered. * target.h (struct target_ops): Remove parameter quitting and as int from fields to_xclose and to_close. (extern struct target_ops current_target): (target_close, pop_all_targets): Remove parameter quitting. Update the comment. (pop_all_targets_above): Remove parameter quitting. * top.c (quit_target): Remove parameter quitting from a caller. * tracepoint.c (tfile_close): Remove parameter quitting. * windows-nat.c (windows_close): Remove parameter quitting.
2013-03-20 16:46:24 +01:00
gdbsim_close (void)
{
* 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 = arg;
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_pid (ptid_get_pid (ptid)), &rd);
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."));
}
/* Notify the simulator of an asynchronous request to stop.
1999-07-07 22:19:36 +02:00
The simulator shall ensure that the stop request is eventually
delivered to the simulator. If the call is made while the
simulator is not running then the stop request is processed when
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
gdbsim_stop_inferior (struct inferior *inf, void *arg)
{
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
gdbsim_stop (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))
{
* 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_stop_inferior, NULL);
}
else
{
struct inferior *inf = find_inferior_pid (ptid_get_pid (ptid));
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
gdbsim_stop_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 */
{
clear_quit_flag (); /* we've stolen it */
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)
{
* 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_stop (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;
static RETSIGTYPE (*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);
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 = sigrc;
break;
}
break;
case sim_signalled:
status->kind = TARGET_WAITKIND_SIGNALLED;
status->value.sig = 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
static LONGEST
gdbsim_xfer_memory (struct target_ops *target,
gdb_byte *readbuf, const gdb_byte *writebuf,
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
ULONGEST memaddr, ULONGEST 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 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
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
}
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
return l;
}
/* Target to_xfer_partial implementation. */
static LONGEST
gdbsim_xfer_partial (struct target_ops *ops, enum target_object object,
const char *annex, gdb_byte *readbuf,
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
const gdb_byte *writebuf, ULONGEST offset, ULONGEST len)
{
switch (object)
{
case TARGET_OBJECT_MEMORY:
return gdbsim_xfer_memory (ops, readbuf, writebuf, offset, len);
default:
return -1;
}
}
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 = inferior_data (current_inferior (), sim_inferior_data_key);
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 = 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. */
static 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;
gdbsim_ops.to_stop = gdbsim_stop;
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);
}