aboutsummaryrefslogtreecommitdiff
path: root/sim/common/sim-utils.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>1998-02-27 18:39:22 +0000
committerDoug Evans <dje@google.com>1998-02-27 18:39:22 +0000
commit966df5804d7586c1a30853ffb4aa0663c942c337 (patch)
tree3451ce3db2f4deec7d55670a701f507c024b6d72 /sim/common/sim-utils.c
parent2e7236783eccbd1d0bed7f49aac81e447be5e314 (diff)
downloadgdb-966df5804d7586c1a30853ffb4aa0663c942c337.zip
gdb-966df5804d7586c1a30853ffb4aa0663c942c337.tar.gz
gdb-966df5804d7586c1a30853ffb4aa0663c942c337.tar.bz2
* sim-base.h (sim_cpu_base): New members name, options.
(sim_cpu_lookup): Add prototype. * sim-module.c (sim_pre_argv_init): Provide default names for cpus. * sim-options.h (DECLARE_OPTION_HANDLER): New argument `cpu'. (sim_add_option_table): Update prototype. * sim-options.c (sim_add_option_table): New argument `cpu'. (standard_option_handler,standard_install): Update. (sim_parse_args): Handle cpu specific options. (print_help): New static function. (sim_print_help): Call it. Print cpu specific options. (find_match): New static function. (sim_args_command): Call it. Handle cpu specific options. * sim-utils.c (sim_cpu_lookup): New function. * sim-memopt.c (memory_option_handler): Update. (sim_memopt_install): Update. * sim-model.c (model_option_handler): Update. (model_install): Update. * sim-profile.c (profile_option_handler): Update. (profile_install): Update. * sim-trace.c (trace_option_handler): Update. (trace_install): Update. * sim-watch.c (watchpoint_option_handler): Update. (sim_watchpoint_install): Update. * cgen-scache.c (scache_option_handler): Update. (scache_install): Update.
Diffstat (limited to 'sim/common/sim-utils.c')
-rw-r--r--sim/common/sim-utils.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c
index aee2ed9..8327c5e 100644
--- a/sim/common/sim-utils.c
+++ b/sim/common/sim-utils.c
@@ -1,5 +1,5 @@
/* Miscellaneous simulator utilities.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
Contributed by Cygnus Support.
This file is part of GDB, the GNU debugger.
@@ -76,7 +76,6 @@ SIM_DESC
sim_state_alloc (SIM_OPEN_KIND kind,
host_callback *callback)
{
- int cpu_nr;
SIM_DESC sd = ZALLOC (struct sim_state);
STATE_MAGIC (sd) = SIM_MAGIC_NUMBER;
@@ -84,15 +83,19 @@ sim_state_alloc (SIM_OPEN_KIND kind,
STATE_OPEN_KIND (sd) = kind;
#if 0
- /* Initialize the back link from the cpu struct to the state struct. */
- /* ??? I can envision a design where the state struct contains an array
- of pointers to cpu structs, rather than an array of structs themselves.
- Implementing this is trickier as one may not know what to allocate until
- one has parsed the args. Parsing the args twice wouldn't be unreasonable,
- IMHO. If the state struct ever does contain an array of pointers then we
- can't do this here. */
- for (cpu_nr = 0; cpu_nr < MAX_NR_PROCESSORS; cpu_nr++)
- CPU_STATE (STATE_CPU (sd, cpu_nr)) = sd;
+ {
+ int cpu_nr;
+
+ /* Initialize the back link from the cpu struct to the state struct. */
+ /* ??? I can envision a design where the state struct contains an array
+ of pointers to cpu structs, rather than an array of structs themselves.
+ Implementing this is trickier as one may not know what to allocate until
+ one has parsed the args. Parsing the args twice wouldn't be unreasonable,
+ IMHO. If the state struct ever does contain an array of pointers then we
+ can't do this here. */
+ for (cpu_nr = 0; cpu_nr < MAX_NR_PROCESSORS; cpu_nr++)
+ CPU_STATE (STATE_CPU (sd, cpu_nr)) = sd;
+ }
#endif
#ifdef SIM_STATE_INIT
@@ -116,6 +119,19 @@ sim_state_free (SIM_DESC sd)
zfree (sd);
}
+/* Return a pointer to the cpu data for CPU_NAME, or NULL if not found. */
+
+sim_cpu *
+sim_cpu_lookup (SIM_DESC sd, const char *cpu_name)
+{
+ int i;
+
+ for (i = 0; i < MAX_NR_PROCESSORS; ++i)
+ if (strcmp (cpu_name, CPU_NAME (STATE_CPU (sd, i))) == 0)
+ return STATE_CPU (sd, i);
+ return NULL;
+}
+
/* Turn VALUE into a string with commas. */
char *