]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - sim/common/sim-trace.c
Copyright year update in most files of the GDB Project.
[thirdparty/binutils-gdb.git] / sim / common / sim-trace.c
index 9bb24582cbeb712e0521aa5c2fb1ea0ecea09cf2..fc20d00576af62e28d8f865709a089a172f5c656 100644 (file)
@@ -1,6 +1,6 @@
 /* Simulator tracing/debugging support.
-   Copyright (C) 1997, 1998, 2001, 2007, 2008, 2009, 2010
-   Free Software Foundation, Inc.
+   Copyright (C) 1997-1998, 2001, 2007-2012 Free Software Foundation,
+   Inc.
    Contributed by Cygnus Support.
 
 This file is part of GDB, the GNU debugger.
@@ -77,7 +77,8 @@ enum {
   OPTION_TRACE_FUNCTION,
   OPTION_TRACE_DEBUG,
   OPTION_TRACE_FILE,
-  OPTION_TRACE_VPU
+  OPTION_TRACE_VPU,
+  OPTION_TRACE_SYSCALL
 };
 
 static const OPTION trace_options[] =
@@ -85,63 +86,66 @@ static const OPTION trace_options[] =
   /* This table is organized to group related instructions together.  */
   { {"trace", optional_argument, NULL, 't'},
       't', "on|off", "Trace useful things",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-insn", optional_argument, NULL, OPTION_TRACE_INSN},
       '\0', "on|off", "Perform instruction tracing",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-decode", optional_argument, NULL, OPTION_TRACE_DECODE},
       '\0', "on|off", "Trace instruction decoding",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-extract", optional_argument, NULL, OPTION_TRACE_EXTRACT},
       '\0', "on|off", "Trace instruction extraction",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-linenum", optional_argument, NULL, OPTION_TRACE_LINENUM},
       '\0', "on|off", "Perform line number tracing (implies --trace-insn)",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-memory", optional_argument, NULL, OPTION_TRACE_MEMORY},
       '\0', "on|off", "Trace memory operations",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-alu", optional_argument, NULL, OPTION_TRACE_ALU},
       '\0', "on|off", "Trace ALU operations",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-fpu", optional_argument, NULL, OPTION_TRACE_FPU},
       '\0', "on|off", "Trace FPU operations",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-vpu", optional_argument, NULL, OPTION_TRACE_VPU},
       '\0', "on|off", "Trace VPU operations",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-branch", optional_argument, NULL, OPTION_TRACE_BRANCH},
       '\0', "on|off", "Trace branching",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-semantics", optional_argument, NULL, OPTION_TRACE_SEMANTICS},
       '\0', "on|off", "Perform ALU, FPU, MEMORY, and BRANCH tracing",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-model", optional_argument, NULL, OPTION_TRACE_MODEL},
       '\0', "on|off", "Include model performance data",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-core", optional_argument, NULL, OPTION_TRACE_CORE},
       '\0', "on|off", "Trace core operations",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-events", optional_argument, NULL, OPTION_TRACE_EVENTS},
       '\0', "on|off", "Trace events",
-      trace_option_handler },
+      trace_option_handler, NULL },
+  { {"trace-syscall", optional_argument, NULL, OPTION_TRACE_SYSCALL},
+      '\0', "on|off", "Trace system calls",
+      trace_option_handler, NULL },
 #ifdef SIM_HAVE_ADDR_RANGE
   { {"trace-range", required_argument, NULL, OPTION_TRACE_RANGE},
       '\0', "START,END", "Specify range of addresses for instruction tracing",
-      trace_option_handler },
+      trace_option_handler, NULL },
 #if 0 /*wip*/
   { {"trace-function", required_argument, NULL, OPTION_TRACE_FUNCTION},
       '\0', "FUNCTION", "Specify function to trace",
-      trace_option_handler },
+      trace_option_handler, NULL },
 #endif
 #endif
   { {"trace-debug", optional_argument, NULL, OPTION_TRACE_DEBUG},
       '\0', "on|off", "Add information useful for debugging the simulator to the tracing output",
-      trace_option_handler },
+      trace_option_handler, NULL },
   { {"trace-file", required_argument, NULL, OPTION_TRACE_FILE},
       '\0', "FILE NAME", "Specify tracing output file",
-      trace_option_handler },
-  { {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL }
+      trace_option_handler, NULL },
+  { {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL, NULL }
 };
 
 /* Set/reset the trace options indicated in MASK.  */
@@ -214,7 +218,7 @@ set_trace_option_mask (SIM_DESC sd, const char *name, int mask, const char *arg)
                }
            }
        }
-    }  
+    }
 
   return SIM_RC_OK;
 }
@@ -233,7 +237,6 @@ trace_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
                      char *arg, int is_command)
 {
   int n;
-  int cpu_nr;
 
   switch (opt)
     {
@@ -332,6 +335,13 @@ trace_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
        sim_io_eprintf (sd, "Branch tracing not compiled in, `--trace-branch' ignored\n");
       break;
 
+    case OPTION_TRACE_SYSCALL :
+      if (WITH_TRACE_SYSCALL_P)
+       return set_trace_option (sd, "-syscall", TRACE_SYSCALL_IDX, arg);
+      else
+       sim_io_eprintf (sd, "System call tracing not compiled in, `--trace-syscall' ignored\n");
+      break;
+
     case OPTION_TRACE_SEMANTICS :
       if (WITH_TRACE_ALU_P
          && WITH_TRACE_FPU_P
@@ -353,6 +363,7 @@ trace_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
     case OPTION_TRACE_RANGE :
       if (WITH_TRACE)
        {
+         int cpu_nr;
          char *chp = arg;
          unsigned long start,end;
          start = strtoul (chp, &chp, 0);
@@ -513,7 +524,7 @@ save_data (SIM_DESC sd,
           TRACE_DATA *data,
           data_fmt fmt,
           long size,
-          void *buf)
+          const void *buf)
 {
   int i = TRACE_INPUT_IDX (data);
   if (i == sizeof (TRACE_INPUT_FMT (data)))
@@ -605,7 +616,7 @@ print_data (SIM_DESC sd,
       abort ();
     }
 }
-                 
+
 static const char *
 trace_idx_to_str (int trace_idx)
 {
@@ -621,6 +632,7 @@ trace_idx_to_str (int trace_idx)
     case TRACE_EVENTS_IDX:  return "events:  ";
     case TRACE_FPU_IDX:     return "fpu:     ";
     case TRACE_BRANCH_IDX:  return "branch:  ";
+    case TRACE_SYSCALL_IDX: return "syscall: ";
     case TRACE_VPU_IDX:     return "vpu:     ";
     default:
       sprintf (num, "?%d?", trace_idx);
@@ -1021,7 +1033,7 @@ trace_result_word1 (SIM_DESC sd,
   save_data (sd, data, trace_fmt_word, sizeof (unsigned_word), &r0);
 
   trace_results (sd, cpu, trace_idx, last_input);
-}            
+}
 
 void
 trace_result0 (SIM_DESC sd,
@@ -1035,7 +1047,7 @@ trace_result0 (SIM_DESC sd,
   last_input = TRACE_INPUT_IDX (data);
 
   trace_results (sd, cpu, trace_idx, last_input);
-}            
+}
 
 void
 trace_result_word2 (SIM_DESC sd,
@@ -1053,7 +1065,7 @@ trace_result_word2 (SIM_DESC sd,
   save_data (sd, data, trace_fmt_word, sizeof (r1), &r1);
 
   trace_results (sd, cpu, trace_idx, last_input);
-}            
+}
 
 void
 trace_result_word4 (SIM_DESC sd,
@@ -1075,7 +1087,7 @@ trace_result_word4 (SIM_DESC sd,
   save_data (sd, data, trace_fmt_word, sizeof (r3), &r3);
 
   trace_results (sd, cpu, trace_idx, last_input);
-}            
+}
 
 void
 trace_result_bool1 (SIM_DESC sd,
@@ -1091,7 +1103,7 @@ trace_result_bool1 (SIM_DESC sd,
   save_data (sd, data, trace_fmt_bool, sizeof (r0), &r0);
 
   trace_results (sd, cpu, trace_idx, last_input);
-}            
+}
 
 void
 trace_result_addr1 (SIM_DESC sd,
@@ -1107,7 +1119,7 @@ trace_result_addr1 (SIM_DESC sd,
   save_data (sd, data, trace_fmt_addr, sizeof (r0), &r0);
 
   trace_results (sd, cpu, trace_idx, last_input);
-}            
+}
 
 void
 trace_result_fp1 (SIM_DESC sd,
@@ -1123,7 +1135,7 @@ trace_result_fp1 (SIM_DESC sd,
   save_data (sd, data, trace_fmt_fp, sizeof (fp_word), &f0);
 
   trace_results (sd, cpu, trace_idx, last_input);
-}            
+}
 
 void
 trace_result_fp2 (SIM_DESC sd,
@@ -1141,7 +1153,7 @@ trace_result_fp2 (SIM_DESC sd,
   save_data (sd, data, trace_fmt_fp, sizeof (f1), &f1);
 
   trace_results (sd, cpu, trace_idx, last_input);
-}            
+}
 
 void
 trace_result_fpu1 (SIM_DESC sd,
@@ -1159,7 +1171,7 @@ trace_result_fpu1 (SIM_DESC sd,
   save_data (sd, data, trace_fmt_fp, sizeof (double), &d);
 
   trace_results (sd, cpu, trace_idx, last_input);
-}            
+}
 
 void
 trace_result_string1 (SIM_DESC sd,
@@ -1175,7 +1187,7 @@ trace_result_string1 (SIM_DESC sd,
   save_data (sd, data, trace_fmt_string, strlen (s0) + 1, s0);
 
   trace_results (sd, cpu, trace_idx, last_input);
-}            
+}
 
 void
 trace_result_word1_string1 (SIM_DESC sd,
@@ -1193,7 +1205,7 @@ trace_result_word1_string1 (SIM_DESC sd,
   save_data (sd, data, trace_fmt_string, strlen (s0) + 1, s0);
 
   trace_results (sd, cpu, trace_idx, last_input);
-}            
+}
 \f
 void
 trace_vprintf (SIM_DESC sd, sim_cpu *cpu, const char *fmt, va_list ap)