From e9b2f57903bf6272c0365833d328a106b7f8ff5a Mon Sep 17 00:00:00 2001 From: David Edelsohn Date: Thu, 17 Apr 1997 14:08:30 +0000 Subject: [PATCH] sim-trace.c: New file. --- sim/common/.Sanitize | 1 + sim/common/ChangeLog | 5 ++-- sim/common/Make-common.in | 6 +++- sim/common/sim-trace.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 sim/common/sim-trace.c diff --git a/sim/common/.Sanitize b/sim/common/.Sanitize index b7b086a..06fb5fc 100644 --- a/sim/common/.Sanitize +++ b/sim/common/.Sanitize @@ -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 diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 18d9906..b16dd69 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -2,12 +2,12 @@ Thu Apr 17 02:25:11 1997 Doug Evans * 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 to sim_open. Delete code to load sections, @@ -18,6 +18,7 @@ Thu Apr 17 02:25:11 1997 Doug Evans 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. diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in index e4bdde6..521ecb2 100644 --- a/sim/common/Make-common.in +++ b/sim/common/Make-common.in @@ -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 index 0000000..ffdaf32 --- /dev/null +++ b/sim/common/sim-trace.c @@ -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); +} -- 2.7.4