aboutsummaryrefslogtreecommitdiff
path: root/sim/common
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>1997-08-27 04:44:41 +0000
committerAndrew Cagney <cagney@redhat.com>1997-08-27 04:44:41 +0000
commitfafce69ab16b45fb1ac6bd2ec5afc8e8dbed0374 (patch)
treeeaab2b03e17f79cd61e73a0b510942da3f20dcc3 /sim/common
parent9f64f00adaa7fb89b13ed291a778a262260dc409 (diff)
downloadgdb-fafce69ab16b45fb1ac6bd2ec5afc8e8dbed0374.zip
gdb-fafce69ab16b45fb1ac6bd2ec5afc8e8dbed0374.tar.gz
gdb-fafce69ab16b45fb1ac6bd2ec5afc8e8dbed0374.tar.bz2
Add ABFD argument to sim_create_inferior. Document.
Add file sim-hload.c - generic load for hardware only simulators. Review each simulators sim_open, sim_load, sim_create_inferior so that they more closely match required behavour.
Diffstat (limited to 'sim/common')
-rw-r--r--sim/common/.Sanitize1
-rw-r--r--sim/common/ChangeLog22
-rw-r--r--sim/common/Make-common.in117
-rw-r--r--sim/common/sim-config.c60
-rw-r--r--sim/common/sim-config.h3
-rw-r--r--sim/common/sim-utils.c52
-rw-r--r--sim/common/sim-utils.h70
7 files changed, 193 insertions, 132 deletions
diff --git a/sim/common/.Sanitize b/sim/common/.Sanitize
index d5deb38..8687f1d 100644
--- a/sim/common/.Sanitize
+++ b/sim/common/.Sanitize
@@ -64,6 +64,7 @@ sim-events.c
sim-events.h
sim-fpu.c
sim-fpu.h
+sim-hload.c
sim-inline.c
sim-inline.h
sim-io.c
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index b4dd678..9693743 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,25 @@
+Wed Aug 27 11:55:35 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * sim-utils.c (sim_analyze_program): Add prog_name argument.
+ Update STATE_PROG_BFD when needed with a dup'd copy of the
+ program.
+
+ * sim-config.c (sim_config): Delete ABFD argument, use
+ STATE_PROG_BFD directly.
+
+Tue Aug 26 12:55:26 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * run.c (main): Pass the open ABFD to sim_create_inferior.
+
+ * nrun.c (main): Determine prog_bfd. Pass to sim_create_inferior
+ and sim_load.
+ (bfd.h): Include.
+
+ * sim-hload.c (sim_load): New file. Implement generic sim_load for
+ hardware only simulator targets.
+
+ * Make-common.in (sim-hload.o): Add rule.
+
Wed Aug 27 09:51:42 1997 Andrew Cagney <cagney@b1.cygnus.com>
* sim-utils.c (sim_copy_argv): Rewrite to match malloc strategy
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 7db8ba7..4e15424 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -132,7 +132,7 @@ all: libsim.a run $(SIM_EXTRA_ALL)
libsim.a: $(LIB_OBJS)
rm -f libsim.a
- $(AR) $(ARFLAGS) libsim.a $(LIB_OBJS)
+ $(AR) $(AR_FLAGS) libsim.a $(LIB_OBJS)
$(RANLIB) libsim.a
run: $(SIM_RUN_OBJS) libsim.a $(LIBDEPS)
@@ -181,6 +181,9 @@ sim_main_headers = \
$(srcdir)/../common/sim-trace.h \
$(srcdir)/../common/sim-profile.h \
$(srcdir)/../common/sim-engine.h \
+ $(srcdir)/../common/sim-events.h \
+ $(srcdir)/../common/sim-watch.h \
+ $(srcdir)/../common/sim-assert.h \
tconfig.h
sim-assert_h = $(srcdir)/../common/sim-assert.h
@@ -209,69 +212,41 @@ BUILT_SRC_FROM_COMMON= \
sim-config.c \
sim-io.c
-sim-abort.o: sim-abort.c \
+sim-abort.o: $(srcdir)/../common/sim-abort.c \
$(SIM_EXTRA_DEPS)
-sim-abort.c: $(srcdir)/../common/sim-abort.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-abort.c $(ALL_CFLAGS)
-sim-bits.o: sim-bits.c $(sim-bits_h) $(sim-n-bits_h) $(sim-assert_h) \
+sim-bits.o: $(srcdir)/../common/sim-bits.c $(sim-bits_h) $(sim-n-bits_h) \
$(SIM_EXTRA_DEPS)
-sim-bits.c: $(srcdir)/../common/sim-bits.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-bits.c $(ALL_CFLAGS)
-sim-config.o: sim-config.c $(sim-config_h) $(sim-nconfig_h) $(sim-assert_h) \
+sim-config.o: $(srcdir)/../common/sim-config.c $(sim-config_h) $(sim-nconfig_h) \
$(SIM_EXTRA_DEPS)
-sim-config.c: $(srcdir)/../common/sim-config.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-config.c $(ALL_CFLAGS)
-sim-core.o: sim-core.c $(sim-core_h) $(sim-n-core_h) \
+sim-core.o: $(srcdir)/../common/sim-core.c $(sim-core_h) $(sim-n-core_h) \
$(SIM_EXTRA_DEPS)
-sim-core.c: $(srcdir)/../common/sim-core.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-core.c $(ALL_CFLAGS)
-sim-endian.o: sim-endian.c $(sim-endian_h) $(sim-n-endian_h) $(sim-assert_h) \
+sim-endian.o: $(srcdir)/../common/sim-endian.c $(sim-endian_h) $(sim-n-endian_h) \
$(SIM_EXTRA_DEPS)
-sim-endian.c: $(srcdir)/../common/sim-endian.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-endian.c $(ALL_CFLAGS)
-sim-engine.o: sim-engine.c $(sim_main_headers) $(sim-engine_h) $(sim-assert_h) \
+sim-engine.o: $(srcdir)/../common/sim-engine.c $(sim_main_headers) $(sim-engine_h) \
$(SIM_EXTRA_DEPS)
-sim-engine.c: $(srcdir)/../common/sim-engine.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-engine.c $(ALL_CFLAGS)
-sim-events.o: sim-events.c $(sim-events_h) $(sim-assert_h) \
+sim-events.o: $(srcdir)/../common/sim-events.c $(sim-events_h) \
$(SIM_EXTRA_DEPS)
-sim-events.c: $(srcdir)/../common/sim-events.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-events.c $(ALL_CFLAGS)
-sim-fpu.o: sim-fpu.c $(sim-fpu_h) $(sim-assert_h) \
+sim-fpu.o: $(srcdir)/../common/sim-fpu.c $(sim-fpu_h) \
$(SIM_EXTRA_DEPS)
-sim-fpu.c: $(srcdir)/../common/sim-fpu.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-fpu.c $(ALL_CFLAGS)
+
+sim-hload.o: $(srcdir)/../common/sim-hload.c $(sim-assert_h) \
+ $(SIM_EXTRA_DEPS)
+ $(CC) -c $(srcdir)/../common/sim-hload.c $(ALL_CFLAGS)
sim-inline.c: $(srcdir)/../common/sim-inline.c
rm -f $@ tmp-$@
@@ -279,13 +254,9 @@ sim-inline.c: $(srcdir)/../common/sim-inline.c
cat $(srcdir)/../common/$@ >> tmp-$@
$(srcdir)/../../move-if-change tmp-$@ $@
-sim-io.o: sim-io.c $(sim_main_headers) $(sim-io_h) $(sim-assert_h) \
+sim-io.o: $(srcdir)/../common/sim-io.c $(sim_main_headers) $(sim-io_h) \
$(SIM_EXTRA_DEPS)
-sim-io.c: $(srcdir)/../common/sim-io.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-io.c $(ALL_CFLAGS)
sim-module.o: $(srcdir)/../common/sim-module.c $(sim_main_headers) \
$(sim-io_h) $(SIM_EXTRA_DEPS)
@@ -295,37 +266,21 @@ sim-options.o: $(srcdir)/../common/sim-options.c $(sim_main_headers) \
$(sim-options_h) $(sim-io_h) $(SIM_EXTRA_DEPS)
$(CC) -c $(srcdir)/../common/sim-options.c $(ALL_CFLAGS)
-sim-reason.o: sim-reason.c $(sim_main_headers) $(sim-assert_h) \
+sim-reason.o: $(srcdir)/../common/sim-reason.c $(sim_main_headers) \
$(SIM_EXTRA_DEPS)
-sim-reason.c: $(srcdir)/../common/sim-reason.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-reason.c $(ALL_CFLAGS)
-sim-resume.o: sim-resume.c $(sim_main_headers) $(sim-assert_h) \
+sim-resume.o: $(srcdir)/../common/sim-resume.c $(sim_main_headers) \
$(SIM_EXTRA_DEPS)
-sim-resume.c: $(srcdir)/../common/sim-resume.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-resume.c $(ALL_CFLAGS)
-sim-run.o: sim-run.c $(sim_main_headers) $(sim-assert_h) \
+sim-run.o: $(srcdir)/../common/sim-run.c $(sim_main_headers) \
$(SIM_EXTRA_DEPS)
-sim-run.c: $(srcdir)/../common/sim-run.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-run.c $(ALL_CFLAGS)
-sim-stop.o: sim-stop.c $(sim_main_headers) $(sim-assert_h) \
+sim-stop.o: $(srcdir)/../common/sim-stop.c $(sim_main_headers) \
$(SIM_EXTRA_DEPS)
-sim-stop.c: $(srcdir)/../common/sim-stop.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-stop.c $(ALL_CFLAGS)
sim-trace.o: $(srcdir)/../common/sim-trace.c $(sim_main_headers) \
$(sim-options_h) $(sim-io_h) $(SIM_EXTRA_DEPS)
@@ -343,6 +298,10 @@ sim-utils.o: $(srcdir)/../common/sim-utils.c $(sim_main_headers) \
$(SIM_EXTRA_DEPS)
$(CC) -c $(srcdir)/../common/sim-utils.c $(ALL_CFLAGS)
+sim-watch.o: $(srcdir)/../common/sim-watch.c $(sim_main_headers) \
+ $(SIM_EXTRA_DEPS)
+ $(CC) -c $(srcdir)/../common/sim-watch.c $(ALL_CFLAGS)
+
sim-load.o: $(srcdir)/../common/sim-load.c
$(CC) -c $(srcdir)/../common/sim-load.c $(ALL_CFLAGS)
diff --git a/sim/common/sim-config.c b/sim/common/sim-config.c
index 5f2efc3..04ad95f 100644
--- a/sim/common/sim-config.c
+++ b/sim/common/sim-config.c
@@ -132,45 +132,15 @@ config_floating_point_to_a (int floating_point)
SIM_RC
-sim_config (SIM_DESC sd,
- struct _bfd *abfd)
+sim_config (SIM_DESC sd)
{
int prefered_target_byte_order;
- /* clone the bfd struct (or open prog_name directly) */
- {
- const char *prog_name;
- if (STATE_PROG_ARGV (sd) == NULL)
- {
- if (abfd != NULL)
- prog_name = bfd_get_filename (abfd);
- else
- prog_name = NULL;
- }
- else
- prog_name = *STATE_PROG_ARGV (sd);
- if (prog_name != NULL)
- {
- abfd = bfd_openr (prog_name, 0);
- if (abfd == NULL)
- {
- sim_io_eprintf (sd, "%s: can't open \"%s\": %s\n",
- STATE_MY_NAME (sd),
- prog_name,
- bfd_errmsg (bfd_get_error ()));
- return SIM_RC_FAIL;
- }
- STATE_PROG_BFD (sd) = abfd;
- }
- else
- STATE_PROG_BFD (sd) = NULL;
- }
-
/* extract all relevant information */
- if (abfd == NULL)
+ if (STATE_PROG_BFD (sd) == NULL)
prefered_target_byte_order = 0;
else
- prefered_target_byte_order = (bfd_little_endian(abfd)
+ prefered_target_byte_order = (bfd_little_endian(STATE_PROG_BFD (sd))
? LITTLE_ENDIAN
: BIG_ENDIAN);
@@ -210,16 +180,16 @@ sim_config (SIM_DESC sd,
/* verify the target byte order */
if (CURRENT_TARGET_BYTE_ORDER == 0)
{
- sim_io_eprintf (sd, "target byte order unspecified");
+ sim_io_eprintf (sd, "Target byte order unspecified\n");
return SIM_RC_FAIL;
}
if (CURRENT_TARGET_BYTE_ORDER != current_target_byte_order)
- sim_io_eprintf (sd, "target (%s) and configured (%s) byte order in conflict",
+ sim_io_eprintf (sd, "Target (%s) and configured (%s) byte order in conflict\n",
config_byte_order_to_a (current_target_byte_order),
config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER));
if (prefered_target_byte_order != 0
&& CURRENT_TARGET_BYTE_ORDER != prefered_target_byte_order)
- sim_io_eprintf (sd, "target (%s) and specified (%s) byte order in conflict",
+ sim_io_eprintf (sd, "Target (%s) and specified (%s) byte order in conflict\n",
config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER),
config_byte_order_to_a (prefered_target_byte_order));
@@ -233,12 +203,12 @@ sim_config (SIM_DESC sd,
/* verify the stdio */
if (CURRENT_STDIO == 0)
{
- sim_io_eprintf (sd, "target standard IO unspecified");
+ sim_io_eprintf (sd, "Target standard IO unspecified\n");
return SIM_RC_FAIL;
}
if (CURRENT_STDIO != current_stdio)
{
- sim_io_eprintf (sd, "target (%s) and configured (%s) standard IO in conflict",
+ sim_io_eprintf (sd, "Target (%s) and configured (%s) standard IO in conflict\n",
config_stdio_to_a (CURRENT_STDIO),
config_stdio_to_a (current_stdio));
return SIM_RC_FAIL;
@@ -249,7 +219,7 @@ sim_config (SIM_DESC sd,
if (WITH_TARGET_WORD_MSB != 0
&& WITH_TARGET_WORD_MSB != (WITH_TARGET_WORD_BITSIZE - 1))
{
- sim_io_eprintf (sd, "target bitsize (%d) contradicts target most significant bit (%d)",
+ sim_io_eprintf (sd, "Target bitsize (%d) contradicts target most significant bit (%d)\n",
WITH_TARGET_WORD_BITSIZE, WITH_TARGET_WORD_MSB);
return SIM_RC_FAIL;
}
@@ -281,12 +251,12 @@ sim_config (SIM_DESC sd,
/* verify the environment */
if (CURRENT_ENVIRONMENT == 0)
{
- sim_io_eprintf (sd, "target environment unspecified");
+ sim_io_eprintf (sd, "Target environment unspecified\n");
return SIM_RC_FAIL;
}
if (CURRENT_ENVIRONMENT != current_environment)
{
- sim_io_eprintf (sd, "target (%s) and configured (%s) environment in conflict",
+ sim_io_eprintf (sd, "Target (%s) and configured (%s) environment in conflict\n",
config_environment_to_a (CURRENT_ENVIRONMENT),
config_environment_to_a (current_environment));
return SIM_RC_FAIL;
@@ -310,12 +280,12 @@ sim_config (SIM_DESC sd,
/* verify the alignment */
if (CURRENT_ALIGNMENT == 0)
{
- sim_io_eprintf (sd, "target alignment unspecified");
+ sim_io_eprintf (sd, "Target alignment unspecified\n");
return SIM_RC_FAIL;
}
if (CURRENT_ALIGNMENT != current_alignment)
{
- sim_io_eprintf (sd, "target (%s) and configured (%s) alignment in conflict",
+ sim_io_eprintf (sd, "Target (%s) and configured (%s) alignment in conflict\n",
config_alignment_to_a (CURRENT_ALIGNMENT),
config_alignment_to_a (current_alignment));
return SIM_RC_FAIL;
@@ -332,12 +302,12 @@ sim_config (SIM_DESC sd,
/* verify the floating point */
if (CURRENT_FLOATING_POINT == 0)
{
- sim_io_eprintf (sd, "target floating-point unspecified");
+ sim_io_eprintf (sd, "Target floating-point unspecified\n");
return SIM_RC_FAIL;
}
if (CURRENT_FLOATING_POINT != current_floating_point)
{
- sim_io_eprintf (sd, "target (%s) and configured (%s) floating-point in conflict",
+ sim_io_eprintf (sd, "Target (%s) and configured (%s) floating-point in conflict\n",
config_alignment_to_a (CURRENT_FLOATING_POINT),
config_alignment_to_a (current_floating_point));
return SIM_RC_FAIL;
diff --git a/sim/common/sim-config.h b/sim/common/sim-config.h
index 157eb1d..59a8c37 100644
--- a/sim/common/sim-config.h
+++ b/sim/common/sim-config.h
@@ -546,8 +546,7 @@ extern int current_stdio;
/* complete/verify/print the simulator configuration */
extern SIM_RC sim_config
-(SIM_DESC sd,
- struct _bfd *abfd);
+(SIM_DESC sd);
extern void print_sim_config (SIM_DESC sd);
diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c
index e0432f8..a0b582d 100644
--- a/sim/common/sim-utils.c
+++ b/sim/common/sim-utils.c
@@ -119,9 +119,7 @@ char **
sim_copy_argv (argv)
char **argv;
{
- int i;
int argc;
- int len;
char **copy;
if (argv == NULL)
@@ -149,16 +147,56 @@ sim_copy_argv (argv)
return copy;
}
-/* Analyze a bfd and set various fields in the state struct. */
+/* Analyze a prog_name/prog_bfd and set various fields in the state
+ struct. */
-void
-sim_analyze_program (sd, prog_bfd)
+SIM_RC
+sim_analyze_program (sd, prog_name, prog_bfd)
SIM_DESC sd;
+ char *prog_name;
bfd *prog_bfd;
{
asection *s;
-
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
+
+ if (prog_bfd != NULL)
+ {
+ if (prog_bfd == STATE_PROG_BFD (sd))
+ /* already analyzed */
+ return SIM_RC_OK;
+ else
+ /* duplicate needed, save the name of the file to be re-opened */
+ prog_name = bfd_get_filename (prog_bfd);
+ }
+
+ /* do we need to duplicate anything? */
+ if (prog_name == NULL)
+ return SIM_RC_OK;
+
+ /* open a new copy of the prog_bfd */
+ prog_bfd = bfd_openr (prog_name, 0);
+ if (prog_bfd == NULL)
+ {
+ sim_io_eprintf (sd, "%s: can't open \"%s\": %s\n",
+ STATE_MY_NAME (sd),
+ prog_name,
+ bfd_errmsg (bfd_get_error ()));
+ return SIM_RC_FAIL;
+ }
+ if (!bfd_check_format (prog_bfd, bfd_object))
+ {
+ sim_io_eprintf (sd, "%s: \"%s\" is not an object file: %s\n",
+ STATE_MY_NAME (sd),
+ prog_name,
+ bfd_errmsg (bfd_get_error ()));
+ bfd_close (prog_bfd);
+ return SIM_RC_FAIL;
+ }
+
+
+ /* update the sim structure */
+ if (STATE_PROG_BFD (sd) != NULL)
+ bfd_close (STATE_PROG_BFD (sd));
STATE_PROG_BFD (sd) = prog_bfd;
STATE_START_ADDR (sd) = bfd_get_start_address (prog_bfd);
@@ -170,6 +208,8 @@ sim_analyze_program (sd, prog_bfd)
STATE_TEXT_END (sd) = STATE_TEXT_START (sd) + bfd_section_size (prog_bfd, s);
break;
}
+
+ return SIM_RC_OK;
}
/* Simulator timing support. */
diff --git a/sim/common/sim-utils.h b/sim/common/sim-utils.h
new file mode 100644
index 0000000..5fc3efd
--- /dev/null
+++ b/sim/common/sim-utils.h
@@ -0,0 +1,70 @@
+/* Miscellaneous simulator utilities.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ Contributed by Cygnus Support.
+
+This file is part of GDB, the GNU debugger.
+
+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, 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. */
+
+#ifndef SIM_UTILS_H
+#define SIM_UTILS_H
+
+/* Memory management with an allocator that clears memory before use. */
+
+void *zalloc (unsigned long size);
+
+#define ZALLOC(TYPE) (TYPE*)zalloc(sizeof (TYPE))
+
+void zfree(void*);
+
+/* Turn VALUE into a string with commas. */
+char *sim_add_commas (char *, int, unsigned long);
+
+/* Utilities for elapsed time reporting. */
+
+/* Opaque type, known only inside sim_elapsed_time_foo fns. */
+typedef unsigned long SIM_ELAPSED_TIME;
+
+/* Get reference point for future call to sim_time_elapsed. */
+SIM_ELAPSED_TIME sim_elapsed_time_get (void);
+
+/* Elapsed time in milliseconds since START. */
+unsigned long sim_elapsed_time_since (SIM_ELAPSED_TIME start);
+
+/* Utilities for manipulating the load image. */
+
+SIM_RC sim_analyze_program (SIM_DESC sd, char *prog_name,
+ struct _bfd *prog_bfd);
+
+char **sim_copy_argv (char **argv);
+
+/* Load program PROG into the simulator.
+ If PROG_BFD is non-NULL, the file has already been opened.
+ If VERBOSE_P is non-zero statistics are printed of each loaded section
+ and the transfer rate (for consistency with gdb).
+ If this fails an error message is printed and NULL is returned.
+ If it succeeds the bfd is returned. */
+
+struct _bfd *sim_load_file (SIM_DESC sd, const char *myname,
+ host_callback *callback, char *prog,
+ struct _bfd *prog_bfd, int verbose_p);
+
+/* These are defined in callback.c as cover functions to the vprintf
+ callbacks. */
+
+void sim_cb_printf (host_callback *, const char *, ...);
+void sim_cb_eprintf (host_callback *, const char *, ...);
+
+#endif