mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-11-28 22:40:24 +00:00
Enable --trace-linenum support
This commit is contained in:
parent
0239838be4
commit
a77241718f
@ -1,3 +1,16 @@
|
||||
Tue May 6 06:14:01 1997 Mike Meissner <meissner@cygnus.com>
|
||||
|
||||
* sim-trace.c (toplevel): Include bfd.h.
|
||||
(trace_options): Note that --trace-linenum also turns on
|
||||
--trace-insn.
|
||||
(trace_option_handler): If --trace-linenum, also turn on
|
||||
--trace-insn.
|
||||
(trace_one_insn): New function to trace an instruction. Support
|
||||
--trace-linenum.
|
||||
|
||||
* sim-trace.h (TRACE_LINENUM_P): Define macro.
|
||||
(trace_one_insn): Declare function.
|
||||
|
||||
Mon May 5 14:08:34 1997 Mike Meissner <meissner@cygnus.com>
|
||||
|
||||
* sim-trace.h (__attribute__): Define as nothing if not GNU C or
|
||||
|
@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "sim-main.h"
|
||||
#include "sim-io.h"
|
||||
#include "sim-options.h"
|
||||
#include "bfd.h"
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
@ -30,6 +31,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_LOCATION
|
||||
#define SIZE_LOCATION 20
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_PC
|
||||
#define SIZE_PC 6
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_LINE_NUMBER
|
||||
#define SIZE_LINE_NUMBER 4
|
||||
#endif
|
||||
|
||||
static MODULE_UNINSTALL_FN trace_uninstall;
|
||||
|
||||
static DECLARE_OPTION_HANDLER (trace_option_handler);
|
||||
@ -61,7 +74,7 @@ static const OPTION trace_options[] =
|
||||
'\0', NULL, "Perform instruction extraction tracing",
|
||||
trace_option_handler },
|
||||
{ {"trace-linenum", no_argument, NULL, OPTION_TRACE_LINENUM},
|
||||
'\0', NULL, "Perform line number tracing",
|
||||
'\0', NULL, "Perform line number tracing (implies --trace-insn)",
|
||||
trace_option_handler },
|
||||
{ {"trace-memory", no_argument, NULL, OPTION_TRACE_MEMORY},
|
||||
'\0', NULL, "Perform memory tracing",
|
||||
@ -135,11 +148,14 @@ trace_option_handler (sd, opt, arg)
|
||||
break;
|
||||
|
||||
case OPTION_TRACE_LINENUM :
|
||||
if (WITH_TRACE_LINENUM_P)
|
||||
if (WITH_TRACE_LINENUM_P && WITH_TRACE_INSN_P)
|
||||
for (n = 0; n < MAX_NR_PROCESSORS; ++n)
|
||||
CPU_TRACE_FLAGS (STATE_CPU (sd, n))[TRACE_LINENUM_IDX] = 1;
|
||||
{
|
||||
CPU_TRACE_FLAGS (STATE_CPU (sd, n))[TRACE_LINENUM_IDX] = 1;
|
||||
CPU_TRACE_FLAGS (STATE_CPU (sd, n))[TRACE_INSN_IDX] = 1;
|
||||
}
|
||||
else
|
||||
sim_io_eprintf (sd, "Line number tracing not compiled in, `--trace-linenum' ignored\n");
|
||||
sim_io_eprintf (sd, "Line number or instruction tracing not compiled in, `--trace-linenum' ignored\n");
|
||||
break;
|
||||
|
||||
case OPTION_TRACE_MEMORY :
|
||||
@ -246,6 +262,79 @@ 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)
|
||||
{
|
||||
if (idecode)
|
||||
trace_printf(sd, cpu, "%s:%-*d 0x%.*lx (decode) %s\n",
|
||||
filename,
|
||||
SIZE_LINE_NUMBER, 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);
|
||||
|
||||
else
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
buf[0] = 0;
|
||||
if (STATE_TEXT_SECTION (CPU_STATE (cpu))
|
||||
&& pc >= STATE_TEXT_START (CPU_STATE (cpu))
|
||||
&& pc < STATE_TEXT_END (CPU_STATE (cpu)))
|
||||
{
|
||||
const char *pc_filename = (const char *)0;
|
||||
const char *pc_function = (const char *)0;
|
||||
unsigned int pc_linenum = 0;
|
||||
|
||||
if (bfd_find_nearest_line (STATE_PROG_BFD (CPU_STATE (cpu)),
|
||||
STATE_TEXT_SECTION (CPU_STATE (cpu)),
|
||||
(struct symbol_cache_entry **) 0,
|
||||
pc - STATE_TEXT_START (CPU_STATE (cpu)),
|
||||
&pc_filename, &pc_function, &pc_linenum))
|
||||
{
|
||||
char *p = buf;
|
||||
if (pc_linenum)
|
||||
{
|
||||
sprintf (p, "#%-*d ", SIZE_LINE_NUMBER, pc_linenum);
|
||||
p += strlen (p);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (p, "%-*s ", SIZE_LINE_NUMBER+1, "---");
|
||||
p += SIZE_LINE_NUMBER+2;
|
||||
}
|
||||
|
||||
if (pc_function)
|
||||
{
|
||||
sprintf (p, "%s ", pc_function);
|
||||
p += strlen (p);
|
||||
}
|
||||
else if (filename)
|
||||
{
|
||||
char *q = (char *) strrchr (filename, '/');
|
||||
sprintf (p, "%s ", (q) ? q+1 : filename);
|
||||
p += strlen (p);
|
||||
}
|
||||
|
||||
if (*p == ' ')
|
||||
*p = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
trace_printf (sd, cpu, "0x%.*x %-*.*s %s\n",
|
||||
SIZE_PC, (unsigned) pc,
|
||||
SIZE_LOCATION, SIZE_LOCATION, buf,
|
||||
name);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
trace_printf VPARAMS ((SIM_DESC sd, sim_cpu *cpu, const char *fmt, ...))
|
||||
{
|
||||
#ifndef __STDC__
|
||||
|
@ -106,11 +106,17 @@ struct _sim_cpu;
|
||||
|
||||
/* Non-zero if "--trace-insn" specified for CPU. */
|
||||
#define TRACE_INSN_P(cpu) TRACE_P (cpu, TRACE_INSN_IDX)
|
||||
/* Non-zero if "--trace-linenum" specified for CPU. */
|
||||
#define TRACE_LINENUM_P(cpu) TRACE_P (cpu, TRACE_LINENUM_IDX)
|
||||
/* Non-zero if "--trace-decode" specified for CPU. */
|
||||
#define TRACE_DECODE_P(cpu) TRACE_P (cpu, TRACE_DECODE_IDX)
|
||||
/* 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_printf PARAMS ((SIM_DESC, sim_cpu *, const char *, ...))
|
||||
__attribute__((format (printf, 3, 4)));
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
Tue May 6 06:12:04 1997 Mike Meissner <meissner@cygnus.com>
|
||||
|
||||
* igen.c (print_itrace): Call trace_one_insn to trace
|
||||
instructions, rather than doing it directly.
|
||||
|
||||
Mon May 5 14:11:46 1997 Mike Meissner <meissner@cygnus.com>
|
||||
|
||||
* gen-engine.c (engine_switch_leaf): Remove extra %s.
|
||||
|
@ -64,14 +64,14 @@ print_semantic_function_formal(lf *file)
|
||||
{
|
||||
int nr;
|
||||
if ((code & generate_with_icache))
|
||||
nr = lf_printf(file, "SIM_DESC sd,\n %sidecode_cache *cache_entry,\n instruction_address cia",
|
||||
global_name_prefix);
|
||||
nr = lf_printf(file, "SIM_DESC sd,\n %sidecode_cache *cache_entry,\n %sinstruction_address cia",
|
||||
global_name_prefix, global_name_prefix);
|
||||
else if (generate_smp)
|
||||
nr = lf_printf(file, "sim_cpu *cpu,\n %sinstruction_word instruction,\n instruction_address cia",
|
||||
global_name_prefix);
|
||||
nr = lf_printf(file, "sim_cpu *cpu,\n %sinstruction_word instruction,\n %sinstruction_address cia",
|
||||
global_name_prefix, global_name_prefix);
|
||||
else
|
||||
nr = lf_printf(file, "SIM_DESC sd,\n %sinstruction_word instruction,\n instruction_address cia",
|
||||
global_name_prefix);
|
||||
nr = lf_printf(file, "SIM_DESC sd,\n %sinstruction_word instruction,\n %sinstruction_address cia",
|
||||
global_name_prefix, global_name_prefix);
|
||||
return nr;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ int
|
||||
print_semantic_function_type(lf *file)
|
||||
{
|
||||
int nr;
|
||||
nr = lf_printf(file, "instruction_address");
|
||||
nr = lf_printf(file, "%sinstruction_address", global_name_prefix);
|
||||
return nr;
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ print_icache_function_formal(lf *file)
|
||||
else
|
||||
nr += lf_printf(file, "SIM_DESC sd,\n");
|
||||
nr += lf_printf(file, " %sinstruction_word instruction,\n", global_name_prefix);
|
||||
nr += lf_printf(file, " instruction_address cia,\n");
|
||||
nr += lf_printf(file, " %sinstruction_address cia,\n", global_name_prefix);
|
||||
nr += lf_printf(file, " %sidecode_cache *cache_entry", global_name_prefix);
|
||||
return nr;
|
||||
}
|
||||
@ -248,18 +248,17 @@ print_itrace(lf *file,
|
||||
table_entry *file_entry,
|
||||
int idecode)
|
||||
{
|
||||
const char *object = 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", object);
|
||||
lf_printf(file, " trace_printf (CPU,\n");
|
||||
lf_printf(file, " \"%s:%d:0x%%08lx:%%s\\n\", %s, %s);\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,
|
||||
((code & generate_with_semantic_delayed_branch) ? "(long)cia.ip" : "(long)cia"),
|
||||
"itable[MY_INDEX].name");
|
||||
idecode,
|
||||
(code & generate_with_semantic_delayed_branch) ? "cia.ip" : "cia");
|
||||
|
||||
lf_printf(file, "}\n");
|
||||
lf_indent_suppress(file);
|
||||
lf_printf(file, "#endif\n");
|
||||
|
Loading…
Reference in New Issue
Block a user