import gdb-1999-07-19 snapshot
[external/binutils.git] / sim / common / sim-trace.h
index e2fd4d5..14d277e 100644 (file)
@@ -1,5 +1,5 @@
 /* Simulator tracing/debugging support.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
 This file is part of GDB, the GNU debugger.
@@ -77,6 +77,16 @@ enum {
 #ifndef MAX_TRACE_VALUES
 #define MAX_TRACE_VALUES 32
 #endif
+
+/* The -t option only prints useful values.  It's easy to type and shouldn't
+   splat on the screen everything under the sun making nothing easy to
+   find.  */
+#define TRACE_USEFUL_MASK \
+((1 << TRACE_INSN_IDX) \
+ | (1 << TRACE_LINENUM_IDX) \
+ | (1 << TRACE_MEMORY_IDX) \
+ | (1 << TRACE_MODEL_IDX) \
+ | (1 << TRACE_EVENTS_IDX))
 \f
 /* Masks so WITH_TRACE can have symbolic values.
    The case choice here is on purpose.  The lowercase parts are args to
@@ -122,6 +132,9 @@ MODULE_INSTALL_FN trace_install;
 
 typedef struct _trace_data {
 
+  /* Global summary of all the current trace options */
+  char trace_any_p;
+
   /* Boolean array of specified tracing flags.  */
   /* ??? It's not clear that using an array vs a bit mask is faster.
      Consider the case where one wants to test whether any of several bits
@@ -134,7 +147,7 @@ typedef struct _trace_data {
   FILE *trace_file;
 #define TRACE_FILE(t) ((t)->trace_file)
 
-  /* Buffer to store the prefix to be printed before any trace line */
+  /* Buffer to store the prefix to be printed before any trace line */
   char trace_prefix[256];
 #define TRACE_PREFIX(t) ((t)->trace_prefix)
 
@@ -153,13 +166,16 @@ typedef struct _trace_data {
 #define TRACE_INPUT_FMT(t) ((t)->trace_input_fmt)
 #define TRACE_INPUT_SIZE(t) ((t)->trace_input_size)
 #define TRACE_INPUT_IDX(t) ((t)->trace_input_idx)
-  
+
   /* Category of trace being performed */
   int trace_idx;
 #define TRACE_IDX(t) ((t)->trace_idx)
-  
-} TRACE_DATA;
 
+  /* Trace range.
+     ??? Not all cpu's support this.  */
+  ADDR_RANGE range;
+#define TRACE_RANGE(t) (& (t)->range)
+} TRACE_DATA;
 \f
 /* System tracing support.  */
 
@@ -184,6 +200,7 @@ typedef struct _trace_data {
  && CPU_TRACE_FLAGS (cpu)[idx] != 0)
 
 /* Non-zero if --trace-<xxxx> was specified for CPU.  */
+#define TRACE_ANY_P(cpu)       ((WITH_TRACE) && (CPU_TRACE_DATA (cpu)->trace_any_p))
 #define TRACE_INSN_P(cpu)      TRACE_P (cpu, TRACE_INSN_IDX)
 #define TRACE_DECODE_P(cpu)    TRACE_P (cpu, TRACE_DECODE_IDX)
 #define TRACE_EXTRACT_P(cpu)   TRACE_P (cpu, TRACE_EXTRACT_IDX)
@@ -204,21 +221,22 @@ typedef struct _trace_data {
 /* Prime the trace buffers ready for any trace output.
    Must be called prior to any other trace operation */
 extern void trace_prefix PARAMS ((SIM_DESC sd,
-                                 sim_cpu * cpu,
-                                 address_word cia,
+                                 sim_cpu *cpu,
+                                 sim_cia cia,
+                                 address_word pc,
                                  int print_linenum_p,
                                  const char *file_name,
                                  int line_nr,
                                  const char *fmt,
                                  ...))
-       __attribute__((format (printf, 7, 8)));
+       __attribute__((format (printf, 8, 9)));
 
 /* Generic trace print, assumes trace_prefix() has been called */
 
 extern void trace_generic PARAMS ((SIM_DESC sd,
                                   sim_cpu *cpu,
                                   int trace_idx,
-                                  char *fmt,
+                                  const char *fmt,
                                   ...))
      __attribute__((format (printf, 4, 5)));
 
@@ -228,15 +246,18 @@ extern void trace_generic PARAMS ((SIM_DESC sd,
 extern void trace_input0 PARAMS ((SIM_DESC sd,
                                  sim_cpu *cpu,
                                  int trace_idx));
+
 extern void trace_input_word1 PARAMS ((SIM_DESC sd,
                                       sim_cpu *cpu,
                                       int trace_idx,
                                       unsigned_word d0));
+
 extern void trace_input_word2 PARAMS ((SIM_DESC sd,
                                       sim_cpu *cpu,
                                       int trace_idx,
                                       unsigned_word d0,
                                       unsigned_word d1));
+
 extern void trace_input_word3 PARAMS ((SIM_DESC sd,
                                       sim_cpu *cpu,
                                       int trace_idx,
@@ -244,6 +265,24 @@ extern void trace_input_word3 PARAMS ((SIM_DESC sd,
                                       unsigned_word d1,
                                       unsigned_word d2));
 
+extern void trace_input_word4 PARAMS ((SIM_DESC sd,
+                                      sim_cpu *cpu,
+                                      int trace_idx,
+                                      unsigned_word d0,
+                                      unsigned_word d1,
+                                      unsigned_word d2,
+                                      unsigned_word d3));
+
+extern void trace_input_addr1 PARAMS ((SIM_DESC sd,
+                                      sim_cpu *cpu,
+                                      int trace_idx,
+                                      address_word d0));
+
+extern void trace_input_bool1 PARAMS ((SIM_DESC sd,
+                                      sim_cpu *cpu,
+                                      int trace_idx,
+                                      int d0));
+
 extern void trace_input_fp1 PARAMS ((SIM_DESC sd,
                                     sim_cpu *cpu,
                                     int trace_idx,
@@ -282,16 +321,50 @@ extern void trace_input_fpu3 PARAMS ((SIM_DESC sd,
 
 /* Other trace_input{_<fmt><nr-inputs>} functions can go here */
 
+extern void trace_result0 PARAMS ((SIM_DESC sd,
+                                  sim_cpu *cpu,
+                                  int trace_idx));
+
 extern void trace_result_word1 PARAMS ((SIM_DESC sd,
                                        sim_cpu *cpu,
                                        int trace_idx,
                                        unsigned_word r0));
 
+extern void trace_result_word2 PARAMS ((SIM_DESC sd,
+                                       sim_cpu *cpu,
+                                       int trace_idx,
+                                       unsigned_word r0,
+                                       unsigned_word r1));
+
+extern void trace_result_word4 PARAMS ((SIM_DESC sd,
+                                       sim_cpu *cpu,
+                                       int trace_idx,
+                                       unsigned_word r0,
+                                       unsigned_word r1,
+                                       unsigned_word r2,
+                                       unsigned_word r3));
+
+extern void trace_result_bool1 PARAMS ((SIM_DESC sd,
+                                       sim_cpu *cpu,
+                                       int trace_idx,
+                                       int r0));
+
+extern void trace_result_addr1 PARAMS ((SIM_DESC sd,
+                                       sim_cpu *cpu,
+                                       int trace_idx,
+                                       address_word r0));
+
 extern void trace_result_fp1 PARAMS ((SIM_DESC sd,
                                      sim_cpu *cpu,
                                      int trace_idx,
                                      fp_word f0));
 
+extern void trace_result_fp2 PARAMS ((SIM_DESC sd,
+                                     sim_cpu *cpu,
+                                     int trace_idx,
+                                     fp_word f0,
+                                     fp_word f1));
+
 extern void trace_result_fpu1 PARAMS ((SIM_DESC sd,
                                       sim_cpu *cpu,
                                       int trace_idx,
@@ -312,6 +385,7 @@ extern void trace_result_word1_string1 PARAMS ((SIM_DESC sd,
 
 
 /* Macro's for tracing ALU instructions */
+
 #define TRACE_ALU_INPUT0() \
 do { \
   if (TRACE_ALU_P (CPU)) \
@@ -336,14 +410,113 @@ do { \
     trace_input_word3 (SD, CPU, TRACE_ALU_IDX, (V0), (V1), (V2)); \
 } while (0)
 
-#define TRACE_ALU_RESULT(R0) \
+#define TRACE_ALU_INPUT4(V0,V1,V2,V3) \
+do { \
+  if (TRACE_ALU_P (CPU)) \
+    trace_input_word4 (SD, CPU, TRACE_ALU_IDX, (V0), (V1), (V2), (V3)); \
+} while (0)
+
+#define TRACE_ALU_RESULT(R0) TRACE_ALU_RESULT1(R0)
+
+#define TRACE_ALU_RESULT0() \
+do { \
+  if (TRACE_ALU_P (CPU)) \
+    trace_result0 (SD, CPU, TRACE_ALU_IDX); \
+} while (0)
+
+#define TRACE_ALU_RESULT1(R0) \
 do { \
   if (TRACE_ALU_P (CPU)) \
     trace_result_word1 (SD, CPU, TRACE_ALU_IDX, (R0)); \
 } while (0)
 
+#define TRACE_ALU_RESULT2(R0,R1) \
+do { \
+  if (TRACE_ALU_P (CPU)) \
+    trace_result_word2 (SD, CPU, TRACE_ALU_IDX, (R0), (R1)); \
+} while (0)
+
+#define TRACE_ALU_RESULT4(R0,R1,R2,R3) \
+do { \
+  if (TRACE_ALU_P (CPU)) \
+    trace_result_word4 (SD, CPU, TRACE_ALU_IDX, (R0), (R1), (R2), (R3)); \
+} while (0)
+
+
+/* Macro's for tracing FPU instructions */
+
+#define TRACE_FP_INPUT0() \
+do { \
+  if (TRACE_FPU_P (CPU)) \
+    trace_input0 (SD, CPU, TRACE_FPU_IDX); \
+} while (0)
+    
+#define TRACE_FP_INPUT1(V0) \
+do { \
+  if (TRACE_FPU_P (CPU)) \
+    trace_input_fp1 (SD, CPU, TRACE_FPU_IDX, (V0)); \
+} while (0)
+
+#define TRACE_FP_INPUT2(V0,V1) \
+do { \
+  if (TRACE_FPU_P (CPU)) \
+    trace_input_fp2 (SD, CPU, TRACE_FPU_IDX, (V0), (V1)); \
+} while (0)
+
+#define TRACE_FP_INPUT3(V0,V1,V2) \
+do { \
+  if (TRACE_FPU_P (CPU)) \
+    trace_input_fp3 (SD, CPU, TRACE_FPU_IDX, (V0), (V1), (V2)); \
+} while (0)
+
+#define TRACE_FP_INPUT_WORD1(V0) \
+do { \
+  if (TRACE_FPU_P (CPU)) \
+    trace_input_word1 (SD, CPU, TRACE_FPU_IDX, (V0)); \
+} while (0)
+    
+#define TRACE_FP_RESULT(R0) \
+do { \
+  if (TRACE_FPU_P (CPU)) \
+    trace_result_fp1 (SD, CPU, TRACE_FPU_IDX, (R0)); \
+} while (0)
+
+#define TRACE_FP_RESULT2(R0,R1) \
+do { \
+  if (TRACE_FPU_P (CPU)) \
+    trace_result_fp2 (SD, CPU, TRACE_FPU_IDX, (R0), (R1)); \
+} while (0)
+
+#define TRACE_FP_RESULT_BOOL(R0) \
+do { \
+  if (TRACE_FPU_P (CPU)) \
+    trace_result_bool1 (SD, CPU, TRACE_FPU_IDX, (R0)); \
+} while (0)
+
+#define TRACE_FP_RESULT_WORD(R0) \
+do { \
+  if (TRACE_FPU_P (CPU)) \
+    trace_result_word1 (SD, CPU, TRACE_FPU_IDX, (R0)); \
+} while (0)
+
+
+/* Macros for tracing branches */
+
+#define TRACE_BRANCH_INPUT(COND) \
+do { \
+  if (TRACE_BRANCH_P (CPU)) \
+    trace_input_bool1 (SD, CPU, TRACE_BRANCH_IDX, (COND)); \
+} while (0)
+
+#define TRACE_BRANCH_RESULT(DEST) \
+do { \
+  if (TRACE_BRANCH_P (CPU)) \
+    trace_result_addr1 (SD, CPU, TRACE_BRANCH_IDX, (DEST)); \
+} while (0)
+
 \f
-/* The function trace_one_insn has been replaced by trace_generic */
+/* The function trace_one_insn has been replaced by the function pair
+   trace_prefix() + trace_generic() */
 extern void trace_one_insn PARAMS ((SIM_DESC sd,
                                    sim_cpu * cpu,
                                    address_word cia,