diff options
Diffstat (limited to 'sim')
-rw-r--r-- | sim/d10v/ChangeLog | 19 | ||||
-rw-r--r-- | sim/d10v/d10v_sim.h | 6 | ||||
-rw-r--r-- | sim/d10v/interp.c | 35 | ||||
-rw-r--r-- | sim/d10v/simops.c | 23 |
4 files changed, 57 insertions, 26 deletions
diff --git a/sim/d10v/ChangeLog b/sim/d10v/ChangeLog index aafc8777006..2d640f51e35 100644 --- a/sim/d10v/ChangeLog +++ b/sim/d10v/ChangeLog @@ -1,3 +1,22 @@ +Wed Oct 30 17:35:14 1996 Michael Meissner <meissner@tiktok.cygnus.com> + + * interp.c (bfd.h) Don't include it here any more. + (text{,_start,_end}): Move here from simops.c and make extern. + (decode_pc): New function to return the PC as an address that the + debugger can use. + (dmem_addr): Print decoded PC in error message. + (pc_addr): Ditto. + + * simops.c (bfd.h) Don't include it here any more. + (text{,_start,_end}): Move to simops.c. + (trace_input_func): Move decoding of PC, and looking up .text + start to decode_pc. + + * d10v_sim.h (bfd.h): Include it here. + (text{,_start,_end}): Add external declarations. + (exec_bfd): Ditto. + (decode_pc): Ditto. + Tue Oct 29 12:13:52 1996 Martin M. Hunt <hunt@pizza.cygnus.com> * interp.c (sim_size): Now allocates unified memory for imap segments diff --git a/sim/d10v/d10v_sim.h b/sim/d10v/d10v_sim.h index e6d9c4bac86..49b3edcfff4 100644 --- a/sim/d10v/d10v_sim.h +++ b/sim/d10v/d10v_sim.h @@ -4,6 +4,7 @@ #include "ansidecl.h" #include "callback.h" #include "opcode/d10v.h" +#include "bfd.h" #define DEBUG_TRACE 0x00000001 #define DEBUG_VALUES 0x00000002 @@ -128,6 +129,10 @@ struct _state extern host_callback *d10v_callback; extern uint16 OP[4]; extern struct simops Simops[]; +extern asection *text; +extern bfd_vma text_start; +extern bfd_vma text_end; +extern bfd *exec_bfd; #define PC (State.cregs[2]) #define PSW (State.cregs[0]) @@ -174,6 +179,7 @@ extern struct simops Simops[]; #define INC_ADDR(x,i) x = ((State.MD && x == MOD_E) ? MOD_S : (x)+(i)) extern uint8 *dmem_addr PARAMS ((uint32)); +extern bfd_vma decode_pc PARAMS ((void)); #define RB(x) (*(dmem_addr(x))) #define SB(addr,data) ( RB(addr) = (data & 0xff)) diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c index 3d663697380..e617eac49ae 100644 --- a/sim/d10v/interp.c +++ b/sim/d10v/interp.c @@ -1,6 +1,5 @@ #include <signal.h> #include "sysdep.h" -#include "bfd.h" #include "remote-sim.h" #include "d10v_sim.h" @@ -17,6 +16,11 @@ unsigned long ins_type_counters[ (int)INS_MAX ]; uint16 OP[4]; +static int init_text_p = 0; +asection *text; +bfd_vma text_start; +bfd_vma text_end; + static long hash PARAMS ((long insn, int format)); static struct hash_entry *lookup_hash PARAMS ((uint32 ins, int size)); static void get_operands PARAMS ((struct simops *s, uint32 ins)); @@ -111,6 +115,26 @@ get_operands (struct simops *s, uint32 ins) } } +bfd_vma +decode_pc () +{ + asection *s; + if (!init_text_p) + { + init_text_p = 1; + for (s = exec_bfd->sections; s; s = s->next) + if (strcmp (bfd_get_section_name (exec_bfd, s), ".text") == 0) + { + text = s; + text_start = bfd_get_section_vma (exec_bfd, s); + text_end = text_start + bfd_section_size (exec_bfd, s); + break; + } + } + + return (PC << 2) + text_start; +} + static void do_long (ins) uint32 ins; @@ -507,7 +531,8 @@ dmem_addr( addr ) if (addr > 0xbfff) { if ( (addr & 0xfff0) != 0xff00) - (*d10v_callback->printf_filtered) (d10v_callback, "Data address %x is in I/O space.\n",addr); + (*d10v_callback->printf_filtered) (d10v_callback, "Data address 0x%lx is in I/O space, pc = 0x%lx.\n", + (long)addr, (long)decode_pc ()); return State.dmem + addr; } @@ -524,7 +549,8 @@ dmem_addr( addr ) seg = (DMAP & 0x3ff) >> 2; if (State.umem[seg] == NULL) { - (*d10v_callback->printf_filtered) (d10v_callback, "ERROR: unified memory region %d unmapped\n", seg); + (*d10v_callback->printf_filtered) (d10v_callback, "ERROR: unified memory region %d unmapped, pc = 0x%lx\n", + seg, (long)decode_pc ()); exit(1); } return State.umem[seg] + (DMAP & 3) * 0x4000; @@ -550,7 +576,8 @@ pc_addr() if (State.umem[imap & 0xff] == NULL) { - (*d10v_callback->printf_filtered) (d10v_callback, "ERROR: unified memory region %d unmapped\n", imap & 0xff); + (*d10v_callback->printf_filtered) (d10v_callback, "ERROR: unified memory region %d unmapped, pc = 0x%lx\n", + imap & 0xff, (long)PC); State.exception = SIGILL; return 0; } diff --git a/sim/d10v/simops.c b/sim/d10v/simops.c index a7da24f66b3..ff59b0de243 100644 --- a/sim/d10v/simops.c +++ b/sim/d10v/simops.c @@ -7,7 +7,6 @@ #include "d10v_sim.h" #include "simops.h" #include "sys/syscall.h" -#include "bfd.h" extern char *strrchr (); @@ -52,12 +51,6 @@ static void trace_output_func PARAMS ((enum op_types result)); #define trace_output(result) do { if (d10v_debug) trace_output_func (result); } while (0) -static int init_text_p = 0; -static asection *text; -static bfd_vma text_start; -static bfd_vma text_end; -extern bfd *exec_bfd; - #ifndef SIZE_INSTRUCTION #define SIZE_INSTRUCTION 8 #endif @@ -96,7 +89,6 @@ trace_input_func (name, in1, in2, in3) char *p; long tmp; char *type; - asection *s; const char *filename; const char *functionname; unsigned int linenumber; @@ -129,21 +121,8 @@ trace_input_func (name, in1, in2, in3) else { - if (!init_text_p) - { - init_text_p = 1; - for (s = exec_bfd->sections; s; s = s->next) - if (strcmp (bfd_get_section_name (exec_bfd, s), ".text") == 0) - { - text = s; - text_start = bfd_get_section_vma (exec_bfd, s); - text_end = text_start + bfd_section_size (exec_bfd, s); - break; - } - } - buf[0] = '\0'; - byte_pc = (bfd_vma)PC << 2; + byte_pc = decode_pc (); if (text && byte_pc >= text_start && byte_pc < text_end) { filename = (const char *)0; |