aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>1996-04-12 22:42:03 +0000
committerJeff Law <law@redhat.com>1996-04-12 22:42:03 +0000
commit132fdcb974ba05bdb2338292e9bbabce9c48a973 (patch)
treedf78674e8a04ddfa5e68f9a977a52d82833587da /sim
parentc6fbd98bed167d79e49c0d4a38b5432853f11799 (diff)
downloadgdb-132fdcb974ba05bdb2338292e9bbabce9c48a973.zip
gdb-132fdcb974ba05bdb2338292e9bbabce9c48a973.tar.gz
gdb-132fdcb974ba05bdb2338292e9bbabce9c48a973.tar.bz2
* compile.c (sim_load): Re-allocate memory for the simulator
here. HMSE.
Diffstat (limited to 'sim')
-rw-r--r--sim/h8300/ChangeLog5
-rw-r--r--sim/h8300/compile.c33
2 files changed, 38 insertions, 0 deletions
diff --git a/sim/h8300/ChangeLog b/sim/h8300/ChangeLog
index 04d5624..b20fc31 100644
--- a/sim/h8300/ChangeLog
+++ b/sim/h8300/ChangeLog
@@ -1,3 +1,8 @@
+Fri Apr 12 16:44:10 1996 Jeffrey A Law (law@cygnus.com)
+
+ * compile.c (sim_load): Re-allocate memory for the simulator
+ here.
+
Fri Apr 12 09:39:56 1996 Jeffrey A Law (law@cygnus.com)
* compile.c (sim_resume): Fix and simplify overflow and carry
diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c
index cf1e9bc..b7e1c29 100644
--- a/sim/h8300/compile.c
+++ b/sim/h8300/compile.c
@@ -1875,6 +1875,39 @@ sim_load (prog, from_tty)
bfd_close (abfd);
}
+ /* If we're using gdb attached to the simulator, then we have to
+ reallocate memory for the simulator.
+
+ When gdb first starts, it calls fetch_registers (among other
+ functions), which in turn calls init_pointers, which allocates
+ simulator memory.
+
+ The problem is when we do that, we don't know whether we're
+ debugging an h8/300 or h8/300h program.
+
+ This is the first point at which we can make that determination,
+ so we just reallocate memory now; this will also allow us to handle
+ switching between h8/300 and h8/300h programs without exiting
+ gdb. */
+ if (h8300hmode)
+ memory_size = H8300H_MSIZE;
+ else
+ memory_size = H8300_MSIZE;
+
+ if (cpu.memory)
+ free (cpu.memory);
+ if (cpu.cache_idx)
+ free (cpu.cache_idx);
+
+ cpu.memory = (unsigned char *) calloc (sizeof (char), memory_size);
+ cpu.cache_idx = (unsigned short *) calloc (sizeof (short), memory_size);
+ cpu.eightbit = (unsigned char *) calloc (sizeof (char), 256);
+
+ /* `msize' must be a power of two */
+ if ((memory_size & (memory_size - 1)) != 0)
+ abort ();
+ cpu.mask = memory_size - 1;
+
/* Return non-zero so gdb will handle it. */
return 1;
}