[Sim] Patch for VPU tracing option

Ben Elliston
2001-02-21T19:43:00Z

The following patch implements a --trace-cpu option in the simulator,
useful for tracing vector instructions in targets that have VPUs.

I think this is a sensible addition to the sim options, so I've
primarily posted this for peer view. Okay to commit?

2001-02-22 Ben Elliston <bje@redhat.com>

* sim-trace.h (TRACE_VPU_IDX): Add.
(TRACE_vpu): Define.
(WITH_TRACE_VPU_P): Likewise.
(TRACE_VPU_P): Likewise.
* sim-trace.c (OPTION_TRACE_VPU): Define.
(trace_options): Add --trace-vpu.
(trace_option_handler): Handle OPTION_TRACE_VPU.
(trace_option_handler): Include VPU tracing in --trace-semantics.
(trace_idx_to_str): Handle TRACE_VPU_IDX.

Index: sim-trace.c
===================================================================
RCS file: /cvs/src/src/sim/common/sim-trace.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 sim-trace.c
--- sim-trace.c 1999/04/16 01:34:59 1.1.1.1
+++ sim-trace.c 2001/02/22 03:38:00
@@ -1,5 +1,5 @@
/* Simulator tracing/debugging support.
- Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2001 Free Software Foundation, Inc.
Contributed by Cygnus Support.

This file is part of GDB, the GNU debugger.
@@ -76,7 +76,8 @@
OPTION_TRACE_RANGE,
OPTION_TRACE_FUNCTION,
OPTION_TRACE_DEBUG,
- OPTION_TRACE_FILE
+ OPTION_TRACE_FILE,
+ OPTION_TRACE_VPU
};

static const OPTION trace_options[] =
@@ -106,6 +107,9 @@
{ {"trace-fpu", optional_argument, NULL, OPTION_TRACE_FPU},
'\0', "on|off", "Trace FPU operations",
trace_option_handler },
+ { {"trace-vpu", optional_argument, NULL, OPTION_TRACE_VPU},
+ '\0', "on|off", "Trace VPU operations",
+ trace_option_handler },
{ {"trace-branch", optional_argument, NULL, OPTION_TRACE_BRANCH},
'\0', "on|off", "Trace branching",
trace_option_handler },
@@ -322,6 +326,13 @@
sim_io_eprintf (sd, "FPU tracing not compiled in, `--trace-fpu' ignored\n");
break;

+ case OPTION_TRACE_VPU :
+ if (WITH_TRACE_VPU_P)
+ return set_trace_option (sd, "-vpu", TRACE_VPU_IDX, arg);
+ else
+ sim_io_eprintf (sd, "VPU tracing not compiled in, `--trace-vpu' ignored\n");
+ break;
+
case OPTION_TRACE_BRANCH :
if (WITH_TRACE_BRANCH_P)
return set_trace_option (sd, "-branch", TRACE_BRANCH_IDX, arg);
@@ -337,6 +348,7 @@
{
if (set_trace_option (sd, "-semantics", TRACE_ALU_IDX, arg) != SIM_RC_OK
|| set_trace_option (sd, "-semantics", TRACE_FPU_IDX, arg) != SIM_RC_OK
+ || set_trace_option (sd, "-semantics", TRACE_VPU_IDX, arg) != SIM_RC_OK
|| set_trace_option (sd, "-semantics", TRACE_MEMORY_IDX, arg) != SIM_RC_OK
|| set_trace_option (sd, "-semantics", TRACE_BRANCH_IDX, arg) != SIM_RC_OK)
return SIM_RC_FAIL;
@@ -617,6 +629,7 @@
case TRACE_EVENTS_IDX: return "events: ";
case TRACE_FPU_IDX: return "fpu: ";
case TRACE_BRANCH_IDX: return "branch: ";
+ case TRACE_VPU_IDX: return "vpu: ";
default:
sprintf (num, "?%d?", trace_idx);
return num;

Index: sim-trace.h
===================================================================
RCS file: /cvs/src/src/sim/common/sim-trace.h,v
retrieving revision 1.3
diff -u -r1.3 sim-trace.h
--- sim-trace.h 2001/02/21 21:35:41 1.3
+++ sim-trace.h 2001/02/22 03:38:01
@@ -1,5 +1,5 @@
/* Simulator tracing/debugging support.
- Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2001 Free Software Foundation, Inc.
Contributed by Cygnus Support.

This file is part of GDB, the GNU debugger.
@@ -63,6 +63,9 @@
/* Trace fpu operations. */
TRACE_FPU_IDX,

+ /* Trace vpu operations. */
+ TRACE_VPU_IDX,
+
/* Trace branching. */
TRACE_BRANCH_IDX,

@@ -100,6 +103,7 @@
#define TRACE_core (1 << TRACE_CORE_IDX)
#define TRACE_events (1 << TRACE_EVENTS_IDX)
#define TRACE_fpu (1 << TRACE_FPU_IDX)
+#define TRACE_vpu (1 << TRACE_VPU_IDX)
#define TRACE_branch (1 << TRACE_BRANCH_IDX)
#define TRACE_debug (1 << TRACE_DEBUG_IDX)

@@ -114,6 +118,7 @@
#define WITH_TRACE_CORE_P (WITH_TRACE & TRACE_core)
#define WITH_TRACE_EVENTS_P (WITH_TRACE & TRACE_events)
#define WITH_TRACE_FPU_P (WITH_TRACE & TRACE_fpu)
+#define WITH_TRACE_VPU_P (WITH_TRACE & TRACE_vpu)
#define WITH_TRACE_BRANCH_P (WITH_TRACE & TRACE_branch)
#define WITH_TRACE_DEBUG_P (WITH_TRACE & TRACE_debug)

@@ -210,12 +215,11 @@
#define TRACE_CORE_P(cpu) TRACE_P (cpu, TRACE_CORE_IDX)
#define TRACE_EVENTS_P(cpu) TRACE_P (cpu, TRACE_EVENTS_IDX)
#define TRACE_FPU_P(cpu) TRACE_P (cpu, TRACE_FPU_IDX)
+#define TRACE_VPU_P(cpu) TRACE_P (cpu, TRACE_VPU_IDX)
#define TRACE_BRANCH_P(cpu) TRACE_P (cpu, TRACE_BRANCH_IDX)
#define TRACE_DEBUG_P(cpu) TRACE_P (cpu, TRACE_DEBUG_IDX)
\f
-/* Traceing functions.
-
- */
+/* Tracing functions. */

/* Prime the trace buffers ready for any trace output.
Must be called prior to any other trace operation */