/* Simulator tracing/debugging support.
- Copyright (C) 1997, 1998 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.
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.
+the Free Software Foundation; either version 3 of the License, 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. */
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sim-main.h"
#include "sim-io.h"
OPTION_TRACE_RANGE,
OPTION_TRACE_FUNCTION,
OPTION_TRACE_DEBUG,
- OPTION_TRACE_FILE
+ OPTION_TRACE_FILE,
+ OPTION_TRACE_VPU,
+ OPTION_TRACE_SYSCALL
};
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, 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. */
static SIM_RC
-set_trace_option_mask (sd, name, mask, arg)
- SIM_DESC sd;
- const char *name;
- int mask;
- const char *arg;
+set_trace_option_mask (SIM_DESC sd, const char *name, int mask, const char *arg)
{
int trace_nr;
int cpu_nr;
}
}
}
- }
+ }
return SIM_RC_OK;
}
/* Set one trace option based on its IDX value. */
static SIM_RC
-set_trace_option (sd, name, idx, arg)
- SIM_DESC sd;
- const char *name;
- int idx;
- const char *arg;
+set_trace_option (SIM_DESC sd, const char *name, int idx, const char *arg)
{
return set_trace_option_mask (sd, name, 1 << idx, arg);
}
char *arg, int is_command)
{
int n;
- int cpu_nr;
switch (opt)
{
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);
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
{
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;
case OPTION_TRACE_RANGE :
if (WITH_TRACE)
{
+ int cpu_nr;
char *chp = arg;
unsigned long start,end;
start = strtoul (chp, &chp, 0);
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)))
abort ();
}
}
-
+
static const char *
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);
return num;
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,
last_input = TRACE_INPUT_IDX (data);
trace_results (sd, cpu, trace_idx, last_input);
-}
+}
void
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,
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,
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,
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,
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,
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,
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,
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,
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)
if (bfd_find_nearest_line (STATE_PROG_BFD (CPU_STATE (cpu)),
STATE_TEXT_SECTION (CPU_STATE (cpu)),
- (struct symbol_cache_entry **) 0,
+ (struct bfd_symbol **) 0,
pc - STATE_TEXT_START (CPU_STATE (cpu)),
&pc_filename, &pc_function, &pc_linenum))
{