aboutsummaryrefslogtreecommitdiff
path: root/sim/msp430
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-01-21 22:17:59 -0500
committerMike Frysinger <vapier@gentoo.org>2016-08-15 07:00:11 -0700
commit5357150c97899af2cc93072780a9c3a128c5b1ae (patch)
treef61415d77e934b9f54994e92e7f00b30da499890 /sim/msp430
parent31925464a80970e37c06192a0c49f8948a2f5da0 (diff)
downloadgdb-5357150c97899af2cc93072780a9c3a128c5b1ae.zip
gdb-5357150c97899af2cc93072780a9c3a128c5b1ae.tar.gz
gdb-5357150c97899af2cc93072780a9c3a128c5b1ae.tar.bz2
sim: unify symbol table handling
The common sim tracing code already handles loading and tracking of symbols from the target program so that it can show symbol info in trace/disassembly calls. Once we touch up the trace code and add a few API callbacks, ports don't need to do loading and searching of symbol tables themselves anymore.
Diffstat (limited to 'sim/msp430')
-rw-r--r--sim/msp430/ChangeLog10
-rw-r--r--sim/msp430/msp430-sim.c46
-rw-r--r--sim/msp430/sim-main.h8
3 files changed, 13 insertions, 51 deletions
diff --git a/sim/msp430/ChangeLog b/sim/msp430/ChangeLog
index 9f06b48..b78b96f 100644
--- a/sim/msp430/ChangeLog
+++ b/sim/msp430/ChangeLog
@@ -1,3 +1,13 @@
+2016-08-15 Mike Frysinger <vapier@gentoo.org>
+
+ * msp430-sim.c: Delete bfd.h include.
+ (lookup_symbol, msp430_sim_close): Delete.
+ (sim_open): Change lookup_symbol to trace_sym_value.
+ * sim-main.h (struct sim_state): Delete symbol_table and
+ number_of_symbols.
+ (STATE_SYMBOL_TABLE, STATE_NUM_SYMBOLS, msp430_sim_close,
+ SIM_CLOSE_HOOK): Delete.
+
2016-01-10 Mike Frysinger <vapier@gentoo.org>
* config.in, configure: Regenerate.
diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c
index 5a6b3ed..4971cb8 100644
--- a/sim/msp430/msp430-sim.c
+++ b/sim/msp430/msp430-sim.c
@@ -26,7 +26,6 @@
#include <inttypes.h>
#include <unistd.h>
#include <assert.h>
-#include "bfd.h"
#include "opcode/msp430-decode.h"
#include "sim-main.h"
#include "sim-syscall.h"
@@ -44,39 +43,6 @@ msp430_pc_store (SIM_CPU *cpu, sim_cia newpc)
cpu->state.regs[0] = newpc;
}
-static long
-lookup_symbol (SIM_DESC sd, const char *name)
-{
- struct bfd *abfd = STATE_PROG_BFD (sd);
- asymbol **symbol_table = STATE_SYMBOL_TABLE (sd);
- long number_of_symbols = STATE_NUM_SYMBOLS (sd);
- long i;
-
- if (abfd == NULL)
- return -1;
-
- if (symbol_table == NULL)
- {
- long storage_needed;
-
- storage_needed = bfd_get_symtab_upper_bound (abfd);
- if (storage_needed <= 0)
- return -1;
-
- STATE_SYMBOL_TABLE (sd) = symbol_table = xmalloc (storage_needed);
- STATE_NUM_SYMBOLS (sd) = number_of_symbols =
- bfd_canonicalize_symtab (abfd, symbol_table);
- }
-
- for (i = 0; i < number_of_symbols; i++)
- if (strcmp (symbol_table[i]->name, name) == 0)
- {
- long val = symbol_table[i]->section->vma + symbol_table[i]->value;
- return val;
- }
- return -1;
-}
-
static int
msp430_reg_fetch (SIM_CPU *cpu, int regno, unsigned char *buf, int len)
{
@@ -207,20 +173,14 @@ sim_open (SIM_OPEN_KIND kind,
assert (MAX_NR_PROCESSORS == 1);
msp430_initialize_cpu (sd, MSP430_CPU (sd));
- MSP430_CPU (sd)->state.cio_breakpoint = lookup_symbol (sd, "C$$IO$$");
- MSP430_CPU (sd)->state.cio_buffer = lookup_symbol (sd, "__CIOBUF__");
+ MSP430_CPU (sd)->state.cio_breakpoint = trace_sym_value (sd, "C$$IO$$");
+ MSP430_CPU (sd)->state.cio_buffer = trace_sym_value (sd, "__CIOBUF__");
if (MSP430_CPU (sd)->state.cio_buffer == -1)
- MSP430_CPU (sd)->state.cio_buffer = lookup_symbol (sd, "_CIOBUF_");
+ MSP430_CPU (sd)->state.cio_buffer = trace_sym_value (sd, "_CIOBUF_");
return sd;
}
-void
-msp430_sim_close (SIM_DESC sd, int quitting)
-{
- free (STATE_SYMBOL_TABLE (sd));
-}
-
SIM_RC
sim_create_inferior (SIM_DESC sd,
struct bfd *abfd,
diff --git a/sim/msp430/sim-main.h b/sim/msp430/sim-main.h
index 4a2ab22..da48ec6 100644
--- a/sim/msp430/sim-main.h
+++ b/sim/msp430/sim-main.h
@@ -37,11 +37,6 @@ struct sim_state
{
sim_cpu *cpu[MAX_NR_PROCESSORS];
- asymbol **symbol_table;
- long number_of_symbols;
-#define STATE_SYMBOL_TABLE(sd) ((sd)->symbol_table)
-#define STATE_NUM_SYMBOLS(sd) ((sd)->number_of_symbols)
-
/* Simulator specific members. */
sim_state_base base;
};
@@ -54,7 +49,4 @@ struct sim_state
#include "sim-engine.h"
#include "sim-options.h"
-extern void msp430_sim_close (SIM_DESC sd, int quitting);
-#define SIM_CLOSE_HOOK(...) msp430_sim_close (__VA_ARGS__)
-
#endif /* _MSP430_MAIN_SIM_H_ */