From 48ae80573e73e0a7fcbf435d089f90e803b3a088 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Mon, 17 Mar 1997 14:23:31 +0000 Subject: [PATCH] * remote-sim.h: Delete - moved to ../include/remote-sim.h. * Makefile.in (remote_utils_h): Update path to remote-sim.h. * remote-sim.c (flush_stdout, write_stderr, flush_stderr, vprintf_filtered, evprintf_filtered): Callbacks that accept varargs. --- gdb/ChangeLog | 12 +++++ gdb/remote-sim.c | 87 ++++++++++++++++++++++++++++++++ gdb/remote-sim.h | 129 ----------------------------------------------- 3 files changed, 99 insertions(+), 129 deletions(-) delete mode 100644 gdb/remote-sim.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 722efff8f32..6a84e5af63f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +Mon Mar 17 15:00:16 1997 Andrew Cagney + + * remote-sim.h: Delete - moved to ../include/remote-sim.h. + + * Makefile.in (remote_utils_h): Update path to remote-sim.h. + +Fri Mar 7 20:55:28 1997 Andrew Cagney + + * remote-sim.c (flush_stdout, write_stderr, flush_stderr, + vprintf_filtered, evprintf_filtered): Callbacks that accept + varargs. + Sat Mar 15 00:50:46 1997 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) * breakpoint.c (insert_breakpoints, watchpoint_check, diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 3d4a960b468..db2ba63b465 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -46,8 +46,19 @@ static void end_callbacks PARAMS ((void)); static int gdb_os_write_stdout PARAMS ((host_callback *, const char *, int)); +static void gdb_os_flush_stdout PARAMS ((host_callback *)); + +static int gdb_os_write_stderr PARAMS ((host_callback *, const char *, int)); + +static void gdb_os_flush_stderr PARAMS ((host_callback *)); + +/* printf_filtered is depreciated */ static void gdb_os_printf_filtered PARAMS ((host_callback *, const char *, ...)); +static void gdb_os_vprintf_filtered PARAMS ((host_callback *, const char *, void *)); + +static void gdb_os_evprintf_filtered PARAMS ((host_callback *, const char *, void *)); + static void gdb_os_error PARAMS ((host_callback *, const char *, ...)); static void gdbsim_fetch_register PARAMS ((int regno)); @@ -137,7 +148,12 @@ init_callbacks () 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; sim_set_callbacks (gdbsim_desc, &gdb_callback); callbacks_initialized = 1; @@ -179,6 +195,47 @@ gdb_os_write_stdout (p, buf, len) return len; } +/* GDB version of os_flush_stdout callback. */ + +static void +gdb_os_flush_stdout (p) + host_callback *p; +{ + gdb_flush (gdb_stdout); +} + +/* GDB version of os_write_stderr callback. */ + +static int +gdb_os_write_stderr (p, buf, len) + host_callback *p; + const char *buf; + int len; +{ + int i; + char b[2]; + + for (i = 0; i < len; i++) + { + b[0] = buf[i]; + b[1] = 0; + if (target_output_hook) + target_output_hook (b); + else + fputs_filtered (b, gdb_stderr); + } + return len; +} + +/* GDB version of os_flush_stderr callback. */ + +static void +gdb_os_flush_stderr (p) + host_callback *p; +{ + gdb_flush (gdb_stderr); +} + /* GDB version of printf_filtered callback. */ /* VARARGS */ @@ -206,6 +263,36 @@ gdb_os_printf_filtered (p, va_alist) va_end (args); } +/* GDB version of error vprintf_filtered. */ + +/* VARARGS */ +static void +#ifdef ANSI_PROTOTYPES +gdb_os_vprintf_filtered (host_callback *p, const char *format, void *ap) +#else +gdb_os_vprintf_filtered (p, ap) + host_callback *p; + void *ap; +#endif +{ + vfprintf_filtered (gdb_stdout, format, (va_list)ap); +} + +/* GDB version of error evprintf_filtered. */ + +/* VARARGS */ +static void +#ifdef ANSI_PROTOTYPES +gdb_os_evprintf_filtered (host_callback *p, const char *format, void *ap) +#else +gdb_os_vprintf_filtered (p, ap) + host_callback *p; + void *ap; +#endif +{ + vfprintf_filtered (gdb_stderr, format, (va_list)ap); +} + /* GDB version of error callback. */ /* VARARGS */ diff --git a/gdb/remote-sim.h b/gdb/remote-sim.h deleted file mode 100644 index 49beb80ac1b..00000000000 --- a/gdb/remote-sim.h +++ /dev/null @@ -1,129 +0,0 @@ -/* This file defines the interface between the simulator and gdb. - Copyright (C) 1993, 1994, 1996, 1997 Free Software Foundation, Inc. - -This file is part of GDB. - -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 2 of the License, or -(at your option) any later version. - -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. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#if !defined (REMOTE_SIM_H) -#define REMOTE_SIM_H 1 - -/* This file is used when building stand-alone simulators, so isolate this - file from gdb. */ - -/* Pick up CORE_ADDR_TYPE if defined (from gdb), otherwise use same value as - gdb does (unsigned int - from defs.h). */ - -#ifndef CORE_ADDR_TYPE -typedef unsigned int SIM_ADDR; -#else -typedef CORE_ADDR_TYPE SIM_ADDR; -#endif - -/* Semi-opaque type used as result of sim_open and passed back to all - other routines. "desc" is short for "descriptor". - It is up to each simulator to define `sim_state'. */ - -typedef struct sim_state *SIM_DESC; - -/* Main simulator entry points. */ - -/* Initialize the simulator. This function is called when the simulator - is selected from the command line. ARGV is passed from the command line - and can be used to select whatever run time options the simulator provides. - ARGV is the standard NULL terminated array of pointers, with argv[0] - being the program name. - The result is a descriptor that must be passed back to the other sim_foo - functions. */ - -SIM_DESC sim_open PARAMS ((char **argv)); - -/* Terminate usage of the simulator. This may involve freeing target memory - and closing any open files and mmap'd areas. You cannot assume sim_kill - has already been called. - QUITTING is non-zero if we cannot hang on errors. */ - -void sim_close PARAMS ((SIM_DESC sd, int quitting)); - -/* Load program PROG into the simulator. - Return non-zero if you wish the caller to handle it - (it is done this way because most simulators can use gr_load_image, - but defining it as a callback seems awkward). */ - -int sim_load PARAMS ((SIM_DESC sd, char *prog, int from_tty)); - -/* Prepare to run the simulated program. - START_ADDRESS is, yes, you guessed it, the start address of the program. - ARGV and ENV are NULL terminated lists of pointers. - Gdb will set the start address via sim_store_register as well, but - standalone versions of existing simulators are not set up to cleanly call - sim_store_register, so the START_ADDRESS argument is there as a - workaround. */ - -void sim_create_inferior PARAMS ((SIM_DESC sd, SIM_ADDR start_address, - char **argv, char **env)); - -/* Kill the running program. - This may involve closing any open files and deleting any mmap'd areas. */ - -void sim_kill PARAMS ((SIM_DESC sd)); - -/* Read LENGTH bytes of the simulated program's memory and store in BUF. - Result is number of bytes read, or zero if error. */ - -int sim_read PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)); - -/* Store LENGTH bytes from BUF in the simulated program's memory. - Result is number of bytes write, or zero if error. */ - -int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)); - -/* Fetch register REGNO and store the raw value in BUF. */ - -void sim_fetch_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf)); - -/* Store register REGNO from BUF (in raw format). */ - -void sim_store_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf)); - -/* Print some interesting information about the simulator. - VERBOSE is non-zero for the wordy version. */ - -void sim_info PARAMS ((SIM_DESC sd, int verbose)); - -/* Fetch why the program stopped. - SIGRC will contain either the argument to exit() or the signal number. */ - -enum sim_stop { sim_exited, sim_stopped, sim_signalled }; - -void sim_stop_reason PARAMS ((SIM_DESC sd, enum sim_stop *reason, int *sigrc)); - -/* Run (or resume) the program. */ - -void sim_resume PARAMS ((SIM_DESC sd, int step, int siggnal)); - -/* Passthru for other commands that the simulator might support. - If SD is NULL, the command is to be interpreted as refering to - the global state, however the simulator defines that. */ - -void sim_do_command PARAMS ((SIM_DESC sd, char *cmd)); - -/* Provide simulator with a standard host_callback_struct. - If SD is NULL, the command is to be interpreted as refering to - the global state, however the simulator defines that. */ - -void sim_set_callbacks PARAMS ((SIM_DESC sd, struct host_callback_struct *)); - -#endif /* !defined (REMOTE_SIM_H) */ -- 2.30.2