aboutsummaryrefslogtreecommitdiff
path: root/sim/common/cgen-run.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-06-05 10:21:46 -0400
committerMike Frysinger <vapier@gentoo.org>2021-06-09 18:21:28 -0400
commit906192d7859f9e768fc73f330e10d3b3a4ddaba3 (patch)
treef55e6c1aad3a8083932ffd01027856078a0d6a28 /sim/common/cgen-run.c
parentc70fdc45f60845852f98eae3b8035de1a2df78de (diff)
downloadgdb-906192d7859f9e768fc73f330e10d3b3a4ddaba3.zip
gdb-906192d7859f9e768fc73f330e10d3b3a4ddaba3.tar.gz
gdb-906192d7859f9e768fc73f330e10d3b3a4ddaba3.tar.bz2
sim: cgen: inline cgen_init logic
This function has done only one thing: post-process command line settings to see if profiling or tracing has been enabled, and if so, set the run_fast_p flag in the simulator state. That flag is only used in one place: to select the fast or slow cgen engine. By inlining the run_fast_p logic to the one place it's used, we can delete a good amount of logic specific to cgen ports: both the call to cgen_init and the conditional simulator state. This in turn allows us to have a single simulator state struct across all ports so we can share objects more between them, and makes the sim_open calls look more consistent.
Diffstat (limited to 'sim/common/cgen-run.c')
-rw-r--r--sim/common/cgen-run.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/sim/common/cgen-run.c b/sim/common/cgen-run.c
index 443b62a..9420942 100644
--- a/sim/common/cgen-run.c
+++ b/sim/common/cgen-run.c
@@ -51,6 +51,24 @@ static void prime_cpu (SIM_CPU *, int);
static void engine_run_1 (SIM_DESC, int, int);
static void engine_run_n (SIM_DESC, int, int, int, int);
+/* If no profiling or tracing has been enabled, run in fast mode. */
+static int
+cgen_get_fast_p (SIM_DESC sd)
+{
+ int i, c;
+ int run_fast_p = 1;
+
+ for (c = 0; c < MAX_NR_PROCESSORS; ++c)
+ {
+ SIM_CPU *cpu = STATE_CPU (sd, c);
+
+ if (PROFILE_ANY_P (cpu) || TRACE_ANY_P (cpu))
+ return 0;
+ }
+
+ return 1;
+}
+
/* sim_resume for cgen */
void
@@ -59,9 +77,13 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
sim_engine *engine = STATE_ENGINE (sd);
jmp_buf buf;
int jmpval;
+ static int fast_p = -1;
ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
+ if (fast_p == -1)
+ fast_p = cgen_get_fast_p (sd);
+
/* we only want to be single stepping the simulator once */
if (engine->stepper != NULL)
{
@@ -102,7 +124,6 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
&& STATE_OPEN_KIND (sd) == SIM_OPEN_STANDALONE)
? 0
: 8); /*FIXME: magic number*/
- int fast_p = STATE_RUN_FAST_P (sd);
sim_events_preprocess (sd, last_cpu_nr >= nr_cpus, next_cpu_nr >= nr_cpus);
if (next_cpu_nr >= nr_cpus)