From: Andrew Cagney Date: Tue, 20 May 1997 00:05:27 +0000 (+0000) Subject: Depreciate sim_set_callbacks() function. Set simulator callbacks X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=24aa2b57afc51bb0d47d8a3cfa470ad40a36cc6b;p=binutils-gdb.git Depreciate sim_set_callbacks() function. Set simulator callbacks during sim_open(). --- diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 8a7d1df63d9..df595ef4c0f 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -161,8 +161,6 @@ init_callbacks () gdb_callback.error = gdb_os_error; gdb_callback.poll_quit = gdb_os_poll_quit; gdb_callback.magic = HOST_CALLBACK_MAGIC; - sim_set_callbacks (gdbsim_desc, &gdb_callback); - callbacks_initialized = 1; } } @@ -497,8 +495,6 @@ gdbsim_open (args, from_tty) if (gdbsim_desc != NULL) unpush_target (&gdbsim_ops); - init_callbacks (); - len = 7 + 1 + (args ? strlen (args) : 0) + 50; arg_buf = (char *) alloca (len); sprintf (arg_buf, "gdbsim%s%s", @@ -514,7 +510,9 @@ gdbsim_open (args, from_tty) error ("Insufficient memory available to allocate simulator arg list."); make_cleanup (freeargv, (char *) argv); - gdbsim_desc = sim_open (SIM_OPEN_DEBUG, argv); + init_callbacks (); + gdbsim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback, argv); + if (gdbsim_desc == 0) error ("unable to create simulator instance"); diff --git a/include/ChangeLog b/include/ChangeLog index f42db31163e..c370eeca48b 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +Tue May 20 09:32:22 1997 Andrew Cagney + + * remote-sim.h (sim_open): Add callback struct. + Mon May 19 19:14:44 1997 Andrew Cagney * remote-sim.h: Pass SD into sim_size. diff --git a/include/remote-sim.h b/include/remote-sim.h index 201e531ecfd..45abd4bb651 100644 --- a/include/remote-sim.h +++ b/include/remote-sim.h @@ -61,13 +61,14 @@ struct _bfd; is selected from the gdb command line. KIND specifies how the simulator will be used. Currently there are only two kinds: standalone and debug. + CALLBACK provides a standard host callback. ARGV is passed from the command line and can be used to select whatever run time options the simulator provides. It 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 ((SIM_OPEN_KIND kind, char **argv)); +SIM_DESC sim_open PARAMS ((SIM_OPEN_KIND kind, struct host_callback_struct *callback, char **argv)); /* Terminate usage of the simulator. This may involve freeing target memory @@ -163,7 +164,10 @@ 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. */ + the global state, however the simulator defines that. + + This function is depreciated. Callbacks are set as part of + sim_open. */ void sim_set_callbacks PARAMS ((SIM_DESC sd, struct host_callback_struct *)); diff --git a/sim/common/run.c b/sim/common/run.c index 9728a32f28b..dff278d2fb7 100644 --- a/sim/common/run.c +++ b/sim/common/run.c @@ -56,9 +56,6 @@ extern host_callback default_callback; static char *myname; -/* bfd descriptor of the executable. Same name as gdb uses. */ -bfd *exec_bfd; - /* NOTE: sim_size() and sim_trace() are going away */ extern void sim_size PARAMS ((int i)); @@ -102,8 +99,10 @@ main (ac, av) /* The first element of sim_open's argv is the program name. */ no_args[0] = av[0]; +#ifdef SIM_HAVE_BIENDIAN no_args[1] = "-E"; no_args[2] = "set-later"; +#endif /* FIXME: This is currently being rewritten to have each simulator do all argv processing. */ @@ -120,10 +119,13 @@ main (ac, av) { int len = strlen (av[0]) + strlen (optarg); char *argbuf = (char *) alloca (len + 2 + 50); + sprintf (argbuf, "%s %s", av[0], optarg); +#ifdef SIM_HAVE_BIENDIAN /* The desired endianness must be passed to sim_open. The value for "set-later" is set when we know what it is. - -e support isn't yet part of the published interface. */ - sprintf (argbuf, "%s %s -E set-later", av[0], optarg); + -E support isn't yet part of the published interface. */ + strcat (argbuf, " -E set-later"); +#endif sim_argv = buildargv (argbuf); } break; @@ -179,10 +181,7 @@ main (ac, av) printf ("%s %s\n", myname, name); } - sim_set_callbacks (NULL, &default_callback); - default_callback.init (&default_callback); - - exec_bfd = abfd = bfd_openr (name, 0); + abfd = bfd_openr (name, 0); if (!abfd) { fprintf (stderr, "%s: can't open %s: %s\n", @@ -197,6 +196,7 @@ main (ac, av) exit (1); } +#ifdef SIM_HAVE_BIENDIAN /* The endianness must be passed to sim_open because one may wish to examine/set registers before calling sim_load [which is the other place where one can determine endianness]. We previously passed the @@ -208,10 +208,12 @@ main (ac, av) sim_argv[i] = "big"; else sim_argv[i] = "little"; +#endif /* Ensure that any run-time initialisation that needs to be performed by the simulator can occur. */ - sd = sim_open (SIM_OPEN_STANDALONE, sim_argv); + default_callback.init (&default_callback); + sd = sim_open (SIM_OPEN_STANDALONE, &default_callback, sim_argv); if (sd == 0) exit (1); diff --git a/sim/tic80/ChangeLog b/sim/tic80/ChangeLog index ac4fd965471..bd62e585496 100644 --- a/sim/tic80/ChangeLog +++ b/sim/tic80/ChangeLog @@ -1,3 +1,8 @@ +Tue May 20 09:33:31 1997 Andrew Cagney + + * sim-calls.c (sim_set_callback): Delete. + (sim_open): Add/install callback argument. + Mon May 19 18:59:33 1997 Mike Meissner * configure.in: Check for getpid, kill functions. diff --git a/sim/tic80/sim-calls.c b/sim/tic80/sim-calls.c index 192d4c44240..e62ca13dbe2 100644 --- a/sim/tic80/sim-calls.c +++ b/sim/tic80/sim-calls.c @@ -50,11 +50,12 @@ struct sim_state simulation = { 0 }; SIM_DESC -sim_open (SIM_OPEN_KIND kind, char **argv) +sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *callback, char **argv) { SIM_DESC sd = &simulation; STATE_OPEN_KIND (sd) = kind; STATE_MAGIC (sd) = SIM_MAGIC_NUMBER; + STATE_CALLBACK (&simulation) = callback; if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK) return 0; @@ -241,10 +242,3 @@ sim_do_command (SIM_DESC sd, char *cmd) if (sim_args_command (sd, cmd) != SIM_RC_OK) sim_io_eprintf (sd, "Unknown command `%s'\n", cmd); } - - -void -sim_set_callbacks (SIM_DESC sd, host_callback *callback) -{ - STATE_CALLBACK (sd) = callback; -}