sim-trace.c: New file.
authorDavid Edelsohn <dje.gcc@gmail.com>
Thu, 17 Apr 1997 14:08:30 +0000 (14:08 +0000)
committerDavid Edelsohn <dje.gcc@gmail.com>
Thu, 17 Apr 1997 14:08:30 +0000 (14:08 +0000)
sim/common/.Sanitize
sim/common/ChangeLog
sim/common/Make-common.in
sim/common/sim-trace.c [new file with mode: 0644]

index b7b086a..06fb5fc 100644 (file)
@@ -60,6 +60,7 @@ sim-n-core.h
 sim-n-endian.h
 sim-options.c
 sim-options.h
+sim-trace.c
 sim-trace.h
 sim-types.h
 sim-utils.c
index 18d9906..b16dd69 100644 (file)
@@ -2,12 +2,12 @@ Thu Apr 17 02:25:11 1997  Doug Evans  <dje@canuck.cygnus.com>
 
        * sim-options.c, sim-options.h: New files.
        * sim-config.h (WITH_DEBUG): Provide default value of zero.
-       * Make-common.in (nrun.o): Add rule for.
+       * Make-common.in (nrun.o): Add rules for.
        * nrun.c: New file.
 
        * run.c (main): Check return value of sim_open.
 
-       * Make-common.in (sim-options.o, sim-load.o): Add rules for.
+       * Make-common.in (sim-options.o, sim-load.o, sim-trace.o): Add rules.
        (sim_main_headers): Add sim-trace.h.
        * run.c (exec_bfd, target_byte_order): Delete.
        (main): Pass -E <endian> to sim_open.  Delete code to load sections,
@@ -18,6 +18,7 @@ Thu Apr 17 02:25:11 1997  Doug Evans  <dje@canuck.cygnus.com>
        mem_size, memory [+ corresponding access macros].
        (sim_cpu_base): New typedef.
        * sim-trace.h: New file.
+       * sim-trace.c: New file.
        * sim-basics.h: #include it.
        * sim-load.c: New file.
 
index e4bdde6..521ecb2 100644 (file)
@@ -257,10 +257,14 @@ sim-io.c: $(srcdir)/../common/sim-io.c
        cat $(srcdir)/../common/$@ >> tmp-$@
        $(srcdir)/../../move-if-change tmp-$@ $@
 
-sim-options.o: $(srcdir)/../common/sim-options.c $(sim_headers) \
+sim-options.o: $(srcdir)/../common/sim-options.c $(sim_main_headers) \
          $(srcdir)/../common/sim-options.h
        $(CC) -c $(srcdir)/../common/sim-options.c $(ALL_CFLAGS)
 
+sim-trace.o: $(srcdir)/../common/sim-trace.c $(sim_main_headers) \
+         $(srcdir)/../common/sim-io.h
+       $(CC) -c $(srcdir)/../common/sim-trace.c $(ALL_CFLAGS)
+
 sim-utils.o: $(srcdir)/../common/sim-utils.c $(sim_main_headers) \
        $(SIM_EXTRA_DEPS)
        $(CC) -c $(srcdir)/../common/sim-utils.c $(ALL_CFLAGS)
diff --git a/sim/common/sim-trace.c b/sim/common/sim-trace.c
new file mode 100644 (file)
index 0000000..ffdaf32
--- /dev/null
@@ -0,0 +1,70 @@
+/* Simulator tracing/debugging support.
+   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.  */
+
+#include "sim-main.h"
+#include "sim-io.h"
+
+void
+trace_printf VPARAMS ((sim_cpu *cpu, const char *fmt, ...))
+{
+#ifndef __STDC__
+  sim_cpu *cpu;
+  const char *fmt;
+#endif
+  va_list ap;
+
+  VA_START (ap, fmt);
+#ifndef __STDC__
+  cpu = va_arg (ap, sim_cpu *);
+  fmt = va_arg (ap, const char *);
+#endif
+
+  if (CPU_TRACE_FILE (cpu) == NULL)
+    (* STATE_CALLBACK (CPU_STATE (cpu))->evprintf_filtered)
+      (STATE_CALLBACK (CPU_STATE (cpu)), fmt, ap);
+  else
+    vfprintf (CPU_TRACE_FILE (cpu), fmt, ap);
+
+  va_end (ap);
+}
+
+void
+debug_printf VPARAMS ((sim_cpu *cpu, const char *fmt, ...))
+{
+#ifndef __STDC__
+  sim_cpu *cpu;
+  const char *fmt;
+#endif
+  va_list ap;
+
+  VA_START (ap, fmt);
+#ifndef __STDC__
+  cpu = va_arg (ap, sim_cpu *);
+  fmt = va_arg (ap, const char *);
+#endif
+
+  if (CPU_DEBUG_FILE (cpu) == NULL)
+    (* STATE_CALLBACK (CPU_STATE (cpu))->evprintf_filtered)
+      (STATE_CALLBACK (CPU_STATE (cpu)), fmt, ap);
+  else
+    vfprintf (CPU_DEBUG_FILE (cpu), fmt, ap);
+
+  va_end (ap);
+}