From 132fdcb974ba05bdb2338292e9bbabce9c48a973 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Fri, 12 Apr 1996 22:42:03 +0000 Subject: [PATCH] * compile.c (sim_load): Re-allocate memory for the simulator here. HMSE. --- sim/h8300/ChangeLog | 5 +++++ sim/h8300/compile.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/sim/h8300/ChangeLog b/sim/h8300/ChangeLog index 04d56242e3c..b20fc31e60c 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 cf1e9bcec83..b7e1c2948c2 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; } -- 2.30.2