diff options
author | Mike Frysinger <vapier@gentoo.org> | 2022-12-25 00:53:25 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2022-12-25 02:10:46 -0500 |
commit | 883be197745c9a9ea626cf0671e8bb0109d21a36 (patch) | |
tree | 0c19d5fa5fb39952a439f495c29c32e5ea777738 | |
parent | fc9b04458287e58365b1de8eaf6b626ac11743c2 (diff) | |
download | gdb-883be197745c9a9ea626cf0671e8bb0109d21a36.zip gdb-883be197745c9a9ea626cf0671e8bb0109d21a36.tar.gz gdb-883be197745c9a9ea626cf0671e8bb0109d21a36.tar.bz2 |
sim: cpu: change default init to handle all cpus
All the runtimes were only initializing a single CPU. When SMP is
enabled, things quickly crash as none of the other CPU structs are
setup. Change the default from 0 to the compile time value.
-rw-r--r-- | sim/aarch64/interp.c | 2 | ||||
-rw-r--r-- | sim/arm/wrapper.c | 2 | ||||
-rw-r--r-- | sim/avr/interp.c | 2 | ||||
-rw-r--r-- | sim/bfin/interp.c | 2 | ||||
-rw-r--r-- | sim/bpf/sim-if.c | 2 | ||||
-rw-r--r-- | sim/common/sim-cpu.c | 5 | ||||
-rw-r--r-- | sim/cr16/interp.c | 2 | ||||
-rw-r--r-- | sim/cris/sim-if.c | 2 | ||||
-rw-r--r-- | sim/d10v/interp.c | 2 | ||||
-rw-r--r-- | sim/example-synacor/interp.c | 2 | ||||
-rw-r--r-- | sim/frv/sim-if.c | 2 | ||||
-rw-r--r-- | sim/ft32/interp.c | 2 | ||||
-rw-r--r-- | sim/h8300/compile.c | 2 | ||||
-rw-r--r-- | sim/iq2000/sim-if.c | 2 | ||||
-rw-r--r-- | sim/lm32/sim-if.c | 2 | ||||
-rw-r--r-- | sim/m32r/sim-if.c | 2 | ||||
-rw-r--r-- | sim/m68hc11/interp.c | 2 | ||||
-rw-r--r-- | sim/mcore/interp.c | 2 | ||||
-rw-r--r-- | sim/microblaze/interp.c | 2 | ||||
-rw-r--r-- | sim/mips/interp.c | 2 | ||||
-rw-r--r-- | sim/mn10300/interp.c | 2 | ||||
-rw-r--r-- | sim/moxie/interp.c | 2 | ||||
-rw-r--r-- | sim/msp430/msp430-sim.c | 2 | ||||
-rw-r--r-- | sim/or1k/sim-if.c | 2 | ||||
-rw-r--r-- | sim/pru/interp.c | 2 | ||||
-rw-r--r-- | sim/riscv/interp.c | 2 | ||||
-rw-r--r-- | sim/sh/interp.c | 2 | ||||
-rw-r--r-- | sim/v850/interp.c | 2 |
28 files changed, 32 insertions, 27 deletions
diff --git a/sim/aarch64/interp.c b/sim/aarch64/interp.c index 234d978..03efb42 100644 --- a/sim/aarch64/interp.c +++ b/sim/aarch64/interp.c @@ -348,7 +348,7 @@ sim_open (SIM_OPEN_KIND kind, current_alignment = NONSTRICT_ALIGNMENT; /* Perform the initialization steps one by one. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct aarch64_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct aarch64_sim_cpu)) != SIM_RC_OK || sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK || sim_parse_args (sd, argv) != SIM_RC_OK diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c index 5eb61df..4e80078 100644 --- a/sim/arm/wrapper.c +++ b/sim/arm/wrapper.c @@ -822,7 +822,7 @@ sim_open (SIM_OPEN_KIND kind, current_alignment = STRICT_ALIGNMENT; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK) + if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK) { free_state (sd); return 0; diff --git a/sim/avr/interp.c b/sim/avr/interp.c index ddd9e1f..27834f1 100644 --- a/sim/avr/interp.c +++ b/sim/avr/interp.c @@ -1703,7 +1703,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, current_target_byte_order = BFD_ENDIAN_LITTLE; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct avr_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct avr_sim_cpu)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c index 04c1773..e904506 100644 --- a/sim/bfin/interp.c +++ b/sim/bfin/interp.c @@ -675,7 +675,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, current_target_byte_order = BFD_ENDIAN_LITTLE; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct bfin_cpu_state)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct bfin_cpu_state)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/bpf/sim-if.c b/sim/bpf/sim-if.c index b29300f..4c9aa83 100644 --- a/sim/bpf/sim-if.c +++ b/sim/bpf/sim-if.c @@ -132,7 +132,7 @@ sim_open (SIM_OPEN_KIND kind, STATE_MACHS (sd) = bpf_sim_machs; STATE_MODEL_NAME (sd) = "bpf-def"; - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct bpf_sim_cpu)) != SIM_RC_OK) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct bpf_sim_cpu)) != SIM_RC_OK) goto error; if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK) diff --git a/sim/common/sim-cpu.c b/sim/common/sim-cpu.c index 024bd05..9f64d9d 100644 --- a/sim/common/sim-cpu.c +++ b/sim/common/sim-cpu.c @@ -35,8 +35,13 @@ sim_cpu_alloc_all_extra (SIM_DESC sd, int ncpus, size_t extra_bytes) { int c; + /* TODO: This should be a command line option for users to control. */ + if (ncpus == 0) + ncpus = MAX_NR_PROCESSORS; + for (c = 0; c < ncpus; ++c) STATE_CPU (sd, c) = sim_cpu_alloc_extra (sd, extra_bytes); + return SIM_RC_OK; } diff --git a/sim/cr16/interp.c b/sim/cr16/interp.c index 1830e34..fe1e24b 100644 --- a/sim/cr16/interp.c +++ b/sim/cr16/interp.c @@ -407,7 +407,7 @@ sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *cb, cb->syscall_map = cb_cr16_syscall_map; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK) + if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK) { free_state (sd); return 0; diff --git a/sim/cris/sim-if.c b/sim/cris/sim-if.c index 47862ed..d939854 100644 --- a/sim/cris/sim-if.c +++ b/sim/cris/sim-if.c @@ -670,7 +670,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, current_target_byte_order = BFD_ENDIAN_LITTLE; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct cris_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct cris_sim_cpu)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c index 9beedf8..aebd98a 100644 --- a/sim/d10v/interp.c +++ b/sim/d10v/interp.c @@ -765,7 +765,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, cb->syscall_map = cb_d10v_syscall_map; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK) + if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK) { free_state (sd); return 0; diff --git a/sim/example-synacor/interp.c b/sim/example-synacor/interp.c index 20ae057..25e519d 100644 --- a/sim/example-synacor/interp.c +++ b/sim/example-synacor/interp.c @@ -90,7 +90,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, current_target_byte_order = BFD_ENDIAN_LITTLE; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct example_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct example_sim_cpu)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/frv/sim-if.c b/sim/frv/sim-if.c index 6e0f1bb..ad94423 100644 --- a/sim/frv/sim-if.c +++ b/sim/frv/sim-if.c @@ -65,7 +65,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, bfd *abfd, current_target_byte_order = BFD_ENDIAN_BIG; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct frv_sim_cpu)) != SIM_RC_OK) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct frv_sim_cpu)) != SIM_RC_OK) { free_state (sd); return 0; diff --git a/sim/ft32/interp.c b/sim/ft32/interp.c index dfea472..1eda9a7 100644 --- a/sim/ft32/interp.c +++ b/sim/ft32/interp.c @@ -823,7 +823,7 @@ sim_open (SIM_OPEN_KIND kind, current_target_byte_order = BFD_ENDIAN_LITTLE; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct ft32_cpu_state)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct ft32_cpu_state)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c index cc8b52c..467eeaf 100644 --- a/sim/h8300/compile.c +++ b/sim/h8300/compile.c @@ -4631,7 +4631,7 @@ sim_open (SIM_OPEN_KIND kind, current_target_byte_order = BFD_ENDIAN_BIG; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct h8300_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct h8300_sim_cpu)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/iq2000/sim-if.c b/sim/iq2000/sim-if.c index e9b66b6..e02a413 100644 --- a/sim/iq2000/sim-if.c +++ b/sim/iq2000/sim-if.c @@ -70,7 +70,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, current_target_byte_order = BFD_ENDIAN_BIG; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct iq2000_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct iq2000_sim_cpu)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/lm32/sim-if.c b/sim/lm32/sim-if.c index 82f2e11..b510280 100644 --- a/sim/lm32/sim-if.c +++ b/sim/lm32/sim-if.c @@ -101,7 +101,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, current_target_byte_order = BFD_ENDIAN_BIG; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct lm32_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct lm32_sim_cpu)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/m32r/sim-if.c b/sim/m32r/sim-if.c index 7fe6b42..1305ea6 100644 --- a/sim/m32r/sim-if.c +++ b/sim/m32r/sim-if.c @@ -68,7 +68,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, current_target_byte_order = BFD_ENDIAN_BIG; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct m32r_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct m32r_sim_cpu)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/m68hc11/interp.c b/sim/m68hc11/interp.c index b80f5cb..8215521 100644 --- a/sim/m68hc11/interp.c +++ b/sim/m68hc11/interp.c @@ -422,7 +422,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, current_target_byte_order = BFD_ENDIAN_BIG; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct m68hc11_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct m68hc11_sim_cpu)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c index 84b243f..ae554c7 100644 --- a/sim/mcore/interp.c +++ b/sim/mcore/interp.c @@ -1370,7 +1370,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, cb->syscall_map = cb_mcore_syscall_map; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct mcore_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct mcore_sim_cpu)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/microblaze/interp.c b/sim/microblaze/interp.c index 8a8cb9f..df7f41f 100644 --- a/sim/microblaze/interp.c +++ b/sim/microblaze/interp.c @@ -410,7 +410,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct microblaze_regset)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct microblaze_regset)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/mips/interp.c b/sim/mips/interp.c index fa192d3..d44c474a 100644 --- a/sim/mips/interp.c +++ b/sim/mips/interp.c @@ -351,7 +351,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct mips_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct mips_sim_cpu)) != SIM_RC_OK) return 0; diff --git a/sim/mn10300/interp.c b/sim/mn10300/interp.c index 8467070..2915551 100644 --- a/sim/mn10300/interp.c +++ b/sim/mn10300/interp.c @@ -97,7 +97,7 @@ sim_open (SIM_OPEN_KIND kind, current_target_byte_order = BFD_ENDIAN_LITTLE; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK) + if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK) return 0; /* for compatibility */ diff --git a/sim/moxie/interp.c b/sim/moxie/interp.c index 144d83c..2bc241d 100644 --- a/sim/moxie/interp.c +++ b/sim/moxie/interp.c @@ -1202,7 +1202,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, current_target_byte_order = BFD_ENDIAN_BIG; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct moxie_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct moxie_sim_cpu)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c index e7b58ba..c02e7ca 100644 --- a/sim/msp430/msp430-sim.c +++ b/sim/msp430/msp430-sim.c @@ -123,7 +123,7 @@ sim_open (SIM_OPEN_KIND kind, /* Set default options before parsing user options. */ current_target_byte_order = BFD_ENDIAN_LITTLE; - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct msp430_cpu_state)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct msp430_cpu_state)) != SIM_RC_OK) { sim_state_free (sd); diff --git a/sim/or1k/sim-if.c b/sim/or1k/sim-if.c index 799812b..3bbf4f0 100644 --- a/sim/or1k/sim-if.c +++ b/sim/or1k/sim-if.c @@ -168,7 +168,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, current_target_byte_order = BFD_ENDIAN_BIG; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct or1k_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct or1k_sim_cpu)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/pru/interp.c b/sim/pru/interp.c index 250a32a..0e1874c 100644 --- a/sim/pru/interp.c +++ b/sim/pru/interp.c @@ -774,7 +774,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, current_target_byte_order = BFD_ENDIAN_LITTLE; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct pru_regset)) != SIM_RC_OK) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct pru_regset)) != SIM_RC_OK) { free_state (sd); return 0; diff --git a/sim/riscv/interp.c b/sim/riscv/interp.c index a49ad04..601753e 100644 --- a/sim/riscv/interp.c +++ b/sim/riscv/interp.c @@ -77,7 +77,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, callback->syscall_map = cb_riscv_syscall_map; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct riscv_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct riscv_sim_cpu)) != SIM_RC_OK) { free_state (sd); diff --git a/sim/sh/interp.c b/sim/sh/interp.c index b2d30e3..5a90cd2 100644 --- a/sim/sh/interp.c +++ b/sim/sh/interp.c @@ -2350,7 +2350,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, cb->syscall_map = cb_sh_syscall_map; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK) + if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK) { free_state (sd); return 0; diff --git a/sim/v850/interp.c b/sim/v850/interp.c index efe35c6..948b724 100644 --- a/sim/v850/interp.c +++ b/sim/v850/interp.c @@ -206,7 +206,7 @@ sim_open (SIM_OPEN_KIND kind, cb->syscall_map = cb_v850_syscall_map; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct v850_sim_cpu)) + if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct v850_sim_cpu)) != SIM_RC_OK) return 0; |