Fix typo; pass trace_line request as arg; pass common stuff in static struct
This commit is contained in:
parent
a77241718f
commit
d0adfefd44
3 changed files with 36 additions and 27 deletions
|
@ -262,22 +262,16 @@ trace_uninstall (SIM_DESC sd)
|
|||
}
|
||||
|
||||
void
|
||||
trace_one_insn (SIM_DESC sd, sim_cpu *cpu, const char *filename,
|
||||
int linenum, int idecode, address_word pc, const char *name)
|
||||
trace_one_insn (SIM_DESC sd, sim_cpu *cpu, address_word pc,
|
||||
int line_p, const TRACE_INSN_DATA *insn_data)
|
||||
{
|
||||
if (idecode)
|
||||
trace_printf(sd, cpu, "%s:%-*d 0x%.*lx (decode) %s\n",
|
||||
filename,
|
||||
SIZE_LINE_NUMBER, linenum,
|
||||
if (!line_p)
|
||||
trace_printf(sd, cpu, "trace-%s: %s:%-*d 0x%.*lx %s\n",
|
||||
insn_data->phase,
|
||||
*(insn_data->p_filename),
|
||||
SIZE_LINE_NUMBER, insn_data->linenum,
|
||||
SIZE_PC, (long)pc,
|
||||
name);
|
||||
|
||||
else if (!TRACE_LINENUM_P (cpu))
|
||||
trace_printf(sd, cpu, "%s:%-*d 0x%.*lx %s\n",
|
||||
filename,
|
||||
SIZE_LINE_NUMBER, linenum,
|
||||
SIZE_PC, (long)pc,
|
||||
name);
|
||||
*(insn_data->p_name));
|
||||
|
||||
else
|
||||
{
|
||||
|
@ -315,10 +309,10 @@ trace_one_insn (SIM_DESC sd, sim_cpu *cpu, const char *filename,
|
|||
sprintf (p, "%s ", pc_function);
|
||||
p += strlen (p);
|
||||
}
|
||||
else if (filename)
|
||||
else if (pc_filename)
|
||||
{
|
||||
char *q = (char *) strrchr (filename, '/');
|
||||
sprintf (p, "%s ", (q) ? q+1 : filename);
|
||||
char *q = (char *) strrchr (pc_filename, '/');
|
||||
sprintf (p, "%s ", (q) ? q+1 : pc_filename);
|
||||
p += strlen (p);
|
||||
}
|
||||
|
||||
|
@ -327,10 +321,13 @@ trace_one_insn (SIM_DESC sd, sim_cpu *cpu, const char *filename,
|
|||
}
|
||||
}
|
||||
|
||||
trace_printf (sd, cpu, "0x%.*x %-*.*s %s\n",
|
||||
trace_printf (sd, cpu, "trace-%s: %s:%-*d 0x%.*x %-*.*s %s\n",
|
||||
insn_data->phase,
|
||||
*(insn_data->p_filename),
|
||||
SIZE_LINE_NUMBER, insn_data->linenum,
|
||||
SIZE_PC, (unsigned) pc,
|
||||
SIZE_LOCATION, SIZE_LOCATION, buf,
|
||||
name);
|
||||
*(insn_data->p_name));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,15 @@ typedef struct {
|
|||
FILE *trace_file;
|
||||
#define TRACE_FILE(t) ((t)->trace_file)
|
||||
} TRACE_DATA;
|
||||
|
||||
/* Structure containing constant stuff to pass to trace_one_insn */
|
||||
|
||||
typedef struct {
|
||||
const char *phase; /* which phase this in (decode,insn) */
|
||||
char **p_filename; /* ptr to filename insns where defined in */
|
||||
char **p_name; /* ptr to instruction name */
|
||||
int linenum; /* line number of line where insn is defined */
|
||||
} TRACE_INSN_DATA;
|
||||
|
||||
/* Usage macros. */
|
||||
|
||||
|
@ -113,9 +122,9 @@ struct _sim_cpu;
|
|||
/* Non-zero if "--trace-fpu" specified for CPU. */
|
||||
#define TRACE_FPU_P(cpu) TRACE_P (cpu, TRACE_FPU_IDX)
|
||||
|
||||
extern void trace_one_insn PARAMS ((SIM_DESC, sim_cpu *, const char *,
|
||||
int, int, address_word,
|
||||
const char *name));
|
||||
extern void trace_one_insn PARAMS ((SIM_DESC, sim_cpu *,
|
||||
address_word, int,
|
||||
const TRACE_INSN_DATA *));
|
||||
|
||||
extern void trace_printf PARAMS ((SIM_DESC, sim_cpu *, const char *, ...))
|
||||
__attribute__((format (printf, 3, 4)));
|
||||
|
|
|
@ -248,15 +248,18 @@ print_itrace(lf *file,
|
|||
table_entry *file_entry,
|
||||
int idecode)
|
||||
{
|
||||
const char *phase = (idecode) ? "DECODE" : "INSN";
|
||||
const char *phase_lc = (idecode) ? "decode" : "insn";
|
||||
lf_printf(file, "\n");
|
||||
lf_indent_suppress(file);
|
||||
lf_printf(file, "#if defined(WITH_TRACE)\n");
|
||||
lf_printf(file, "/* trace the instructions execution if enabled */\n");
|
||||
lf_printf(file, "if (TRACE_%s_P (CPU)) {\n", (idecode) ? "DECODE" : "INSN");
|
||||
lf_printf(file, " trace_one_insn (SD, CPU, \"%s\", %d, %d, %s, itable[MY_INDEX].name);\n",
|
||||
filter_filename(file_entry->file_name),
|
||||
file_entry->line_nr,
|
||||
idecode,
|
||||
lf_printf(file, "if (TRACE_%s_P (CPU)) {\n", phase);
|
||||
lf_printf(file, " static const TRACE_INSN_DATA my_insn_data = { \"%s\", &itable[MY_INDEX].file, &itable[MY_INDEX].name, %d };\n",
|
||||
phase_lc,
|
||||
file_entry->line_nr);
|
||||
|
||||
lf_printf(file, " trace_one_insn (SD, CPU, %s, TRACE_LINENUM_P (CPU), &my_insn_data);\n",
|
||||
(code & generate_with_semantic_delayed_branch) ? "cia.ip" : "cia");
|
||||
|
||||
lf_printf(file, "}\n");
|
||||
|
|
Loading…
Reference in a new issue