diff options
author | Andrew Cagney <cagney@redhat.com> | 1997-09-01 03:26:31 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 1997-09-01 03:26:31 +0000 |
commit | 4b2a6aed8413d6e7d7b25d918896ae637266d9d5 (patch) | |
tree | fc0f49b0104f94778be3465dc74f0f206afef7aa | |
parent | 9f3f3525396695352bffc5f9cda3ae542e3b83f7 (diff) | |
download | gdb-4b2a6aed8413d6e7d7b25d918896ae637266d9d5.zip gdb-4b2a6aed8413d6e7d7b25d918896ae637266d9d5.tar.gz gdb-4b2a6aed8413d6e7d7b25d918896ae637266d9d5.tar.bz2 |
Use sim_state_alloc to create common sim object.
-rw-r--r-- | sim/common/ChangeLog | 10 | ||||
-rw-r--r-- | sim/common/sim-base.h | 19 | ||||
-rw-r--r-- | sim/common/sim-utils.c | 15 | ||||
-rw-r--r-- | sim/tic80/ChangeLog | 5 | ||||
-rw-r--r-- | sim/tic80/sim-calls.c | 10 |
5 files changed, 37 insertions, 22 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index db34e86..237905d 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,13 @@ +Mon Sep 1 10:50:11 1997 Andrew Cagney <cagney@b1.cygnus.com> + + * sim-utils.c (sim_state_alloc): Set CPU backlinks, callback and + kind. + + * sim-base.h (sim_state_alloc): Add callback and kind arguments. + + * sim-base.h (INVALID_INSTRUCTION_ADDRESS): Add default + definition. + Sat Aug 30 09:47:21 1997 Andrew Cagney <cagney@b1.cygnus.com> * sim-fpu.c (DP_GARDMSB, ...): Make unsigned. diff --git a/sim/common/sim-base.h b/sim/common/sim-base.h index b21c397..12e1a25 100644 --- a/sim/common/sim-base.h +++ b/sim/common/sim-base.h @@ -21,25 +21,23 @@ with this program; if not, write to the Free Software Foundation, Inc., /* Simulator state pseudo baseclass. - Each simulator is required to have a sim-main.h file that includes - sim-basics.h, defines the base type sim_cia (the data type that - contains the complete current instruction address information), and - then sim-base.h: + Each simulator is required to have the file ``sim-main.h''. That + file includes ``sim-basics.h'', defines the base type ``sim_cia'' + (the data type that contains complete current instruction address + information), include ``sim-base.h'': #include "sim-basics.h" typedef address_word sim_cia; #include "sim-base.h" - and defines two key simulator structures. Firstly, struct - _sim_cpu: + finally, two data types ``struct _sim_cpu' and ``struct sim_state' + are defined: struct _sim_cpu { ... simulator specific members ... sim_cpu_base base; }; - and secondly, struct sim_state (which uses the sim_cpu structure): - struct sim_state { sim_cpu cpu[MAX_NR_PROCESSORS]; #if (WITH_SMP) @@ -64,6 +62,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef NULL_CIA #define NULL_CIA ((sim_cia) 0) #endif +#ifndef INVALID_INSTRUCTION_ADDRESS +#define INVALID_INSTRUCTION_ADDRESS ((address_word)0 - 1) +#endif typedef struct _sim_cpu sim_cpu; #include "sim-module.h" @@ -258,7 +259,7 @@ typedef struct { /* Functions for allocating/freeing a sim_state. */ -SIM_DESC sim_state_alloc PARAMS ((void)); +SIM_DESC sim_state_alloc PARAMS ((SIM_OPEN_KIND kind, host_callback *callback)); void sim_state_free PARAMS ((SIM_DESC)); diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c index 9bcfffc..c72a1ab 100644 --- a/sim/common/sim-utils.c +++ b/sim/common/sim-utils.c @@ -53,7 +53,8 @@ with this program; if not, write to the Free Software Foundation, Inc., Set by sim_resume. */ struct sim_state *current_state; -/* Allocate zero filled memory with xmalloc. */ +/* Allocate zero filled memory with xmalloc - xmalloc aborts of the + allocation fails. */ void * zalloc (unsigned long size) @@ -72,10 +73,16 @@ zfree (void *data) /* Allocate a sim_state struct. */ SIM_DESC -sim_state_alloc (void) +sim_state_alloc (SIM_OPEN_KIND kind, + host_callback *callback) { - SIM_DESC sd = zalloc (sizeof (struct sim_state)); - sd->base.magic = SIM_MAGIC_NUMBER; + int cpu_nr; + SIM_DESC sd = ZALLOC (struct sim_state); + STATE_MAGIC (sd) = SIM_MAGIC_NUMBER; + STATE_CALLBACK (sd) = callback; + STATE_OPEN_KIND (sd) = kind; + for (cpu_nr = 0; cpu_nr < MAX_NR_PROCESSORS; cpu_nr++) + CPU_STATE (STATE_CPU (sd, cpu_nr)) = sd; return sd; } diff --git a/sim/tic80/ChangeLog b/sim/tic80/ChangeLog index ea81861..0ac08b2 100644 --- a/sim/tic80/ChangeLog +++ b/sim/tic80/ChangeLog @@ -1,3 +1,8 @@ +Mon Sep 1 11:06:30 1997 Andrew Cagney <cagney@b1.cygnus.com> + + * sim-calls.c (sim_open): Use sim_state_alloc + (simulation): Delete. + Sat Aug 30 09:40:47 1997 Andrew Cagney <cagney@b1.cygnus.com> * insns (do_trap): Unsigned `i' for unsigned iterator. diff --git a/sim/tic80/sim-calls.c b/sim/tic80/sim-calls.c index 095ddf1..32da79b 100644 --- a/sim/tic80/sim-calls.c +++ b/sim/tic80/sim-calls.c @@ -44,21 +44,13 @@ #define SIM_ADDR unsigned -/* Structures used by the simulator, for gdb just have static structures */ - -struct sim_state simulation = { 0 }; - - SIM_DESC sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct _bfd *abfd, char **argv) { - SIM_DESC sd = &simulation; - STATE_OPEN_KIND (sd) = kind; - STATE_MAGIC (sd) = SIM_MAGIC_NUMBER; - STATE_CALLBACK (&simulation) = callback; + SIM_DESC sd = sim_state_alloc (kind, callback); if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK) return 0; |