aboutsummaryrefslogtreecommitdiff
path: root/sim/common/sim-trace.c
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>1998-03-13 20:39:00 +0000
committerFred Fish <fnf@specifix.com>1998-03-13 20:39:00 +0000
commit93f75411f6c54ef8e94712aa06f792fc6eafa413 (patch)
tree6099086da9bd5da396a0da40cbe61350893d5b85 /sim/common/sim-trace.c
parent2b9cac47f502ffbd0a5810d05a86463fd583e71c (diff)
downloadgdb-93f75411f6c54ef8e94712aa06f792fc6eafa413.zip
gdb-93f75411f6c54ef8e94712aa06f792fc6eafa413.tar.gz
gdb-93f75411f6c54ef8e94712aa06f792fc6eafa413.tar.bz2
* sim-base.h (struct sim_state_base): Add prog_syms and
define macro STATE_PROG_SYMS. * sim-trace.c (trace_one_insn): Add variables abfd, symsize, symbol_count, and asymbols. Call bfd_get_symtab_upper_bound and bfd_canonicalize_symtab, to get symbol table on first use and preserve it via STATE_PROG_SYMS for future calls to bfd_find_nearest_line.
Diffstat (limited to 'sim/common/sim-trace.c')
-rw-r--r--sim/common/sim-trace.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/sim/common/sim-trace.c b/sim/common/sim-trace.c
index 60a8f8c..2e9e979 100644
--- a/sim/common/sim-trace.c
+++ b/sim/common/sim-trace.c
@@ -192,11 +192,8 @@ set_trace_option (sd, name, idx, arg)
static SIM_RC
-trace_option_handler (sd, opt, arg, is_command)
- SIM_DESC sd;
- int opt;
- char *arg;
- int is_command;
+trace_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
+ char *arg, int is_command)
{
int n;
@@ -344,7 +341,7 @@ trace_install (SIM_DESC sd)
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
- sim_add_option_table (sd, trace_options);
+ sim_add_option_table (sd, NULL, trace_options);
memset (STATE_TRACE_DATA (sd), 0, sizeof (* STATE_TRACE_DATA (sd)));
for (i = 0; i < MAX_NR_PROCESSORS; ++i)
memset (CPU_TRACE_DATA (STATE_CPU (sd, i)), 0,
@@ -592,10 +589,32 @@ trace_prefix (SIM_DESC sd,
const char *pc_filename = (const char *)0;
const char *pc_function = (const char *)0;
unsigned int pc_linenum = 0;
+ bfd *abfd;
+ asymbol **asymbols;
- if (bfd_find_nearest_line (STATE_PROG_BFD (CPU_STATE (cpu)),
+ abfd = STATE_PROG_BFD (CPU_STATE (cpu));
+ asymbols = STATE_PROG_SYMS (CPU_STATE (cpu));
+ if (asymbols == NULL)
+ {
+ long symsize;
+ long symbol_count;
+
+ symsize = bfd_get_symtab_upper_bound (abfd);
+ if (symsize < 0)
+ {
+ sim_engine_abort (sd, cpu, 0, "could not read symbols\n");
+ }
+ asymbols = (asymbol **) xmalloc (symsize);
+ symbol_count = bfd_canonicalize_symtab (abfd, asymbols);
+ if (symbol_count < 0)
+ {
+ sim_engine_abort (sd, cpu, 0, "could not canonicalize symbols\n");
+ }
+ STATE_PROG_SYMS (CPU_STATE (cpu)) = asymbols;
+ }
+ if (bfd_find_nearest_line (abfd,
STATE_TEXT_SECTION (CPU_STATE (cpu)),
- (struct symbol_cache_entry **) 0,
+ asymbols,
pc - STATE_TEXT_START (CPU_STATE (cpu)),
&pc_filename, &pc_function, &pc_linenum))
{