The common framework supports $srcdir & $subdir replacements already,
so replace the custom @srcdir@ logic with those. Since the replace
happens in slurp_options that cris already uses, we don't have any
logic to port over there. We have to duplicate that into the cris
slurp_rv helper though.
This tag is used to force tests to be built dynamically (i.e. without
-static linking). This is because cris-sim.exp in dejagnu turns on
static linking in ldflags.
The default configs and runtest flags shouldn't load these boards.
If these settings are still needed, we should figure out a different
way of suppressing the stock settings wholesale. We want these to
all pass out of the box with little to no configuration so that they
can run in a multitarget build.
With dropping "dynamic", it'll be easier to merge the custom cris
test logic with the common sim test logic.
On gcc-12 build fails as:
sim/cr16/interp.c: In function 'lookup_hash':
sim/cr16/interp.c:89:25: error:
the comparison will always evaluate as 'true'
for the address of 'mnimonic' will never be NULL [-Werror=address]
89 | if ((h->ops->mnimonic != NULL) &&
| ^~
'mnimonic' is a sharr array within ops. It can never be NULL.
While at it renamed 'mnimonic' to 'mnemonic'.
Support the same syntax as other common utilities where env vars can
be specified before the program to be run without an explicit option.
This behavior can be suppressed by using the -- marker.
Provide explicit control over the program's environment with the
basic set/unset/clear options. These are a bit clunky to use,
but they're functional.
The env set operation is split out into a separate function as it'll
be used in the next commit.
With these in place, we can adjust the custom cris testsuite to use
the now standard options and not its one-off hack.
Now that we have access to the argv & envp strings, finish implementing
these syscalls. Delete unused variables, fix tbuf by incrementing the
pointer instead of setting to the length, and make sure we don't write
more data than the bufsize says is available.
We've been passing the environment strings to sim_create_inferior,
but most ports don't do anything with them. A few will use ad-hoc
logic to stuff the stack for user-mode programs, but that's it.
Let's formalize this across the board by storing the strings in the
normal sim state. This will allow (in future commits) supporting
more functionality in the run interface, and to unify some of the
libgloss syscalls.
The point of this test is to just make sure the usage text is shown,
not the exact details of the usage text. So shorten the output test
to match the beginning. This fixes breakage when the output changed
slightly to include [--].
The new argv processing code assumed that we were always passed a
command line. If we weren't, make sure we don't crash before we
get a chance to output an error message about incorrect usage.
The #dest field used in the cris testsuite is a bit of hack to set the
argv[0] for the tests to read out later on. Now that the sim has an
option to set argv[0] explicitly, we don't need this custom field, so
let's drop it to harmonize the testsuites a little.
We default argv[0] to the program we run which is a standard *NIX
convention, but sometimes we want to be able to control the argv[0]
setting independently (especially for programs that inspect argv[0]
to change their behavior or output). Add an option to control it.
We use the program argv to both find the program to run (argv[0]) and
to hold the arguments to the program. Most of the time this is fine,
but if we want to let programs specify argv[0] independently (which is
possible in standard *NIX programs), this double duty doesn't work.
So let's split the path to the program to run out into a separate
field by itself. This simplifies the various sim_open funcs too.
By itself, this code is more of a logical cleanup than something that
is super useful. But it will open up customization of argv[0] in a
follow up commit. Split the changes to make it easier to review.
Set the mach to the right value all the time, and update xfail to
say the test fails on all targets. WIth multitarget testing, the
idea of target here doesn't make much sense.
In <=gcc-7 versions, -fstrict-overflow is enabled by default, and that
triggers warnings in this code that relies on integer overflows to test
for carries. Change the logic to test against the limit directly.
Since gcc dropped support for a.out starting with 4.4.0 in 2009, it's
been impossible to verify this code actually still works. Since it
crashes in ld, and it uses a config option that no other tests uses
and we want to remove, drop the test to avoid all the trouble.
Outputting an extra space broke a cris test. Change the workaround
to use %s with an empty string to avoid the compiler warning but not
output an extra space.
There's no need to sync testutils.inc with remote hosts. The one
we have in the source tree is all we need and only thing we test.
Delete it to simplify.
Objcopy was used to create a binary file of just the executable code
since the environment requires code to based at address 0. We can
accomplish the same thing with the -Ttext=0 flag, so switch to that
to get rid of custom logic.
When I refactored this by scoping it to sim-frv-xxx in commit
e7954ef5e5 ("sim: frv: scope the
unique configure flag"), I changed the default from off to on.
While the feature is nice for developers, it breaks a bunch of
tests which aren't expecting this extra output. So flip it back
to off by default.
Switch from the centralized list in the exp file to each test declaring
its own requirements which they're already (mostly) doing. This will
increase coverage slightly by running more tests in more configurations
since the hardcoded exp list was a little out of date.
We have to mark the psh* tests as shdsp only (to match what the exp
file was doing), mark the fsca & fsrra tests as failing (since they
weren't even being run by the exp file), and to fix the expected
output & status of the fail test.
Move some unused funcs under existing #if 0 protection, mark a few
local funcs as static, and add missing prototypes for the rest which
are used from other files. This fixes all the fatal warnings in the
mloop files so we can turn -Werror on here fully.
On LLP64 targets where sizeof(long) != sizeof(void*), this code fails:
sim/sh/interp.c:704:24: error: cast from pointer to integer of different size -Werror=pointer-to-int-cast]
704 | do { memstalls += ((((long) PC & 3) != 0) ? (n) : ((n) - 1)); } while (0)
| ^
Since this code simply needs to check alignment, cast it using uintptr_t
which is the right type for this.
Casting 0 to a pointer via (long *) doesn't work on LLP64 targets:
error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
It's also unnecessary here. We can simply pass NULL like every other
bit of code does.
The code assumes that all _WIN32 targets are the same and can
define isnan to _isnan. For mingw targets, they provide an isnan
define already, so no need for the fallback here.
Some targets (like cygwin) will export page size defines that clash
with our local usage here. Undefine the system one to fix building
for these targets.
With most of the warnings fixed in interp.c, we can enable -Werror
here too now. There are some -Wmaybe-uninitialized warnings still
lurking that look legitimate, but we don't flag those are fatal,
and I don't have the expertise to dive into each opcode to figure
out the right way to clean them up.
This block of code relies on i to control which bits to test and how
many times to run through the loop, but it never actually initialized
it. There is another chunk of code that handles the pdmsb instruction
that sets i to 16, so use that here too assuming it's correct. The
programming manual suggests this is the right value too, but I am by
no means a SuperH DSP expert. The tests are still passing though ...
These macro expansions are deliberate in not using the computed value
so that they trigger side-effects (possible invalid memory accesses)
but while otherwise being noops. Add a (void) cast so the compiler
knows these are intentional.
Now that we require C11, we can leverage anonymous unions & structs
to fix a long standing issue with the SH register layout. The use
of sregs.i for sh-dsp has generated a lot of compiler warnings about
the access being out of bounds -- it only has 7 elements declared,
but code goes beyond that to reach into the fregs that follow. But
now that we have anonymous unions, we can reduce the nested names
and have sregs cover all of these registers.
Since the first argument type is unsigned32 or unsigned64, just use
sim_fpu_to{32,64}u instead of sim_fpu_to{32,64}i to fix the following
build warnings:
CC cp1.o
.../sim/mips/cp1.c: In function 'convert':
.../sim/mips/cp1.c:1425:32: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign]
status |= sim_fpu_to32i (&result32, &wop, round);
^~~~~~~~~
In file included from .../sim/mips/sim-main.h:67,
from .../sim/mips/cp1.c:46:
.../sim/mips/../common/sim-fpu.h:270:22: note: expected 'signed32 *' {aka 'int *'} but argument is of type 'unsigned32 *' {aka 'unsigned int *'}
INLINE_SIM_FPU (int) sim_fpu_to32i (signed32 *i, const sim_fpu *f,
^~~~~~~~~~~~~
.../sim/mips/cp1.c:1429:32: warning: pointer targets in passing argument 1 of 'sim_fpu_to64i' differ in signedness [-Wpointer-sign]
status |= sim_fpu_to64i (&result64, &wop, round);
^~~~~~~~~
In file included from .../sim/mips/sim-main.h:67,
from .../sim/mips/cp1.c:46:
.../sim/mips/../common/sim-fpu.h:274:22: note: expected 'signed64 *' {aka 'long int *'} but argument is of type 'unsigned64 *' {aka 'long unsigned int *'}
INLINE_SIM_FPU (int) sim_fpu_to64i (signed64 *i, const sim_fpu *f,
^~~~~~~~~~~~~
.../sim/mips/cp1.c: In function 'convert_ps':
.../sim/mips/cp1.c:1528:34: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign]
status_u |= sim_fpu_to32i (&res_u, &wop_u, round);
^~~~~~
In file included from .../sim/mips/sim-main.h:67,
from .../sim/mips/cp1.c:46:
.../sim/mips/../common/sim-fpu.h:270:22: note: expected 'signed32 *' {aka 'int *'} but argument is of type 'unsigned32 *' {aka 'unsigned int *'}
INLINE_SIM_FPU (int) sim_fpu_to32i (signed32 *i, const sim_fpu *f,
^~~~~~~~~~~~~
.../sim/mips/cp1.c:1529:34: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign]
status_l |= sim_fpu_to32i (&res_l, &wop_l, round);
^~~~~~
In file included from .../sim/mips/sim-main.h:67,
from .../sim/mips/cp1.c:46:
.../sim/mips/../common/sim-fpu.h:270:22: note: expected 'signed32 *' {aka 'int *'} but argument is of type 'unsigned32 *' {aka 'unsigned int *'}
INLINE_SIM_FPU (int) sim_fpu_to32i (signed32 *i, const sim_fpu *f,
^~~~~~~~~~~~~
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
The project has been using GPL v3 for a while now in the source files,
and the arm & ppc ports have carried a copy of the COPYING file. Lets
move those up to the top sim dir like other projects to make it clear.
Also drop the ppc/COPYING.LIB as it's not really referenced by any
source as everything is GPL v3.
The multi-run logic for mips involves a bit of codegen and rewriting
of files to include per-architecture prefixes. That can result in
files with missing prototypes which cause compiler errors. In the
case of mips-sde-elf targets, we have:
$srcdir/m16run.c -> $builddir/m16mips64r2_run.c
sim_engine_run -> m16mips64r2_engine_run
$srcdir/micromipsrun.c -> micromipsmicromips_run.c
sim_engine_run -> micromips64micromips_engine_run
micromipsmicromips_run.c:80:1: error: no previous prototype for 'micromips64micromips_engine_run' [-Werror=missing-prototypes]
80 | micromips64micromips_engine_run (SIM_DESC sd, int next_cpu_nr, int nr_cpus,
We generate headers for those prototypes in the configure script,
but only include them in the generated multi-run.c file. Update the
rewrite logic to turn the sim-engine.h include into the relevant
generated engine include so these files also have their prototypes.
$srcdir/m16run.c -> $builddir/m16mips64r2_run.c
sim-engine.h -> m16mips64r2_engine.h
$srcdir/micromipsrun.c -> micromipsmicromips_run.c
sim-engine.h -> micromips64micromips_engine.h
We don't need to build this anymore ourselves since the common build
includes it and produces the same object code. We also need to pull
in the split constant modules after the refactoring and pulling them
out of nltvals.def & targ-map.o. This doesn't matter for the sim
directly, but does for gdb and other users of libsim.
We also delete some conditional source tree logic since we already
require this be the "new" combined tree with a ../common/ dir. This
has been the case for decades at this point.
These are marked inline, so building w/gcc at higher optimization
levels will automatically discard them. But building with -O0 will
trigger unused function warnings, so fix that.
The common before/after cover functions in the common mloop generator
are not used by all architecture ports. Doesn't seem to be a hard
requirement, so marking them optional (i.e. unused) is fine.
The cris execute function is conditionally used depending on the
fast-build mode settings, so mark it unused too.
These rules don't depend on the target compiler settings, so hoist
the build logic up to the common builds for better parallelization.
We have to extend the genmloop.sh logic a bit to allow outputting
to a subdir since it always assumed cwd was the right place.
We leave the cgen maintainer rules in the subdirs for now as they
aren't normally run, and they rely on cgen logic that has not yet
been generalized.
These rules don't depend on the target compiler settings, so hoist
the build logic up to the common builds for better parallelization.
We leave the mips rules in place as they depend on complicated
arch-specific configure logic that needs to be untangled first.
Clean up the warnings in sim-if, then reduce the -Werror disable to
the files that still aren't clean that now that we require GNU make
and can set variables on a per-object basis.
Clean up some warnings in dv-lm32cpu, and all in sim-if, then reduce
the -Werror disable to the files that still aren't clean that now that
we require GNU make and can set variables on a per-object basis.
Only two files in here still generates warnings, so reduce the -Werror
disable to that now that we require GNU make and can set variables on
a per-object basis.
Only two files in here still generates warnings, so reduce the -Werror
disable to that now that we require GNU make and can set variables on
a per-object basis.
Fix a few printf warnings in sim-main.c, and then we're left with only
one file in here still generating warnings, so reduce the -Werror
disable to that alone now that we require GNU make and can set variables
on a per-object basis.
Only one file in here still generates warnings, so reduce the -Werror
disable to that alone now that we require GNU make and can set variables
on a per-object basis.
Only two files in here still generates warnings, so reduce the -Werror
disable to that now that we require GNU make and can set variables on
a per-object basis.
Only one file in here still generates warnings, so reduce the -Werror
disable to that alone now that we require GNU make and can set variables
on a per-object basis.
The void *data field is used to past arbitrary data between event
handlers, and these are using it to pass an integer. Fix up the
casts to avoid using (long) to cast to/from pointers since there
is no guarantee that's the right size.
There's no need to define these ourselves anymore, so switch to the
stdint.h types. This will be important when we start using PRI*
defines with printf formats.
The void *data field is used to past arbitrary data between event
handlers, and these are using it to pass an enum. Fix up the casts
to avoid using (long) to cast to/from pointers since there is no
guarantee that's the right size.
Like we just did for pulling out the errno & signal maps, pull out the
open flag map into a dedicated common file. All newlib ports are using
the same map which makes it easy.
Code should not be using these directly, instead they should be
resolving these dynamically via the open_map. Rework the common
callback code that was using the defines to use symbolic names
instead, and localize some of the defines in the ARM code (since
it's a bit unclear how many different APIs it supports currently),
then remove the defines out of the header so no new code can rely on
them.
Like we just did for pulling out the errno map, pull out the signal
map into a dedicated common file. All newlib ports are using the
same signal map which makes it easy.
The current system maintains a list of target errno constants in the
nltvals.def file, then runs a build-time tool to turn that into a C
file. This list of errno values is the same for all arches, so we
don't need the arch-specific flexibility. Further, these are only
for newlib/libgloss environments, which makes it confusing to support
other userland runtimes (like Linux). Let's simplify to make this
easier to understand & build. We don't namespace the variables yet,
but sets up the framework for it.
Create a new target-newlib-errno.c template file. The template file
is hand written, but the inline map is still automatically generated.
This allows us to move it to the common set of objects so it's only
built once in a multi-target build.
Now we can remove the output from the gentmap build-time tool since
it's checked into the tree.
Then we stop including the errno lists in nltvals.def since nothing
uses it.
Tweak the if indentation & brace style to avoid ambiguous warnings.
Add ATTRIBUTE_UNUSED to UART functions that aren't used when FAST_UART
is defined (which is the default).
Add a new stamp helper for quiet builds, and don't dump the command
line options when it runs. That isn't standard tool behavior, and
doesn't really seem necessary in any way.
...by reordering includes.
1. sim-utils.c
sim/mips/sim-main.h defines UserMode, while there is a struct in winnt.h
which has UserMode as a member. So if sim-main.h is included before winnt.h,
compilation fails.
2. ppc
registers.h defines CR, which is used as a member in winnt.h.
winsock2.h is included by sys/time.h, so sys/time.h has to be included
before registers.h.
Bug: https://sourceware.org/PR28476
It can be difficult to guess the exact bfd name, so add an option to
list all the targets that the current build supports. This aligns with
other simulator options like --info-architecture.
We map target signals to host signals so we can propagate signals
between the host & simulated worlds. That means we need to know
the symbolic names & values of all signals that might be sent.
The tools that generate that list use signal.h and include all
symbols that start with "SIG" so as to automatically include any
new symbols that the C library might add. Unfortunately, this
also picks up "SIGSTKSZ" which is not actually a signal itself,
but a signal related setting -- it's the size of the stack when
a signal is handled.
By itself this doesn't super matter as we will never see a signal
with that same value (since the range of valid signals tend to be
way less than 1024, and the size of the default signal stack will
never be that small). But with recent glibc changes that make this
into a dynamic value instead of a compile-time constant, some users
see build failures when building the sim.
As suggested by Adam Sampson, update our scripts to ignore this
symbol to simplify everything and avoid the build failure.
Bug: https://sourceware.org/PR28302
Not all systems have easy access to hard links or symlinks, so add
fallback logic to the run->psim build code to handle those.
Bug: https://sourceware.org/PR18864