Commit Graph

4507 Commits

Author SHA1 Message Date
Mike Frysinger
fb2c495f94 sim: avoid installing headers when there is no sim
If we aren't building any sims, don't install the sim headers as they
won't be useful to anyone.
2021-11-18 19:45:54 -05:00
Mike Frysinger
c2aad00a74 sim: testsuite: add support for $pwd replacements
Extend the common test framework to support $pwd replacements in
settings.  This allows replacing the custom cris @exedir@ with it.
2021-11-16 20:21:59 -05:00
Mike Frysinger
927f25ebac sim: cris: replace @srcdir@ test extension with $srcdir/$subdir
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.
2021-11-16 20:16:18 -05:00
Mike Frysinger
b31ff1f79b sim: cris: drop custom "dynamic" test field
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.
2021-11-16 20:06:44 -05:00
Mike Frysinger
5ec501b574 sim: testsuite: add more silent build rules
site.exp is still verbose, but that comes from automake, so have
to get it fixed upstream.
2021-11-16 19:33:57 -05:00
Sergei Trofimovich
e97436b1b7 sim: cr16: fix build on gcc-12 (NULL comparison)
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'.
2021-11-16 23:32:00 +00:00
Mike Frysinger
3b2934856f sim: run: support concise env var settings
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.
2021-11-16 03:34:28 -05:00
Mike Frysinger
35818ade96 sim: nrun: add --env-{set,unset,clear} command line options
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.
2021-11-16 03:34:00 -05:00
Mike Frysinger
85588c9ab9 sim: syscall: hoist argc/argn/argnlen to common code
Now that the callback framework supports argv & envp, we can move
the Blackfin implementation of these syscalls to the common code.
2021-11-16 02:13:42 -05:00
Mike Frysinger
fab6939b01 sim: syscall: fix argvlen & argv implementation
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.
2021-11-16 02:09:46 -05:00
Mike Frysinger
8cfc9a1895 sim: callback: expose argv & environ
Pass the existing strings data to the callbacks so that common
libgloss syscalls can be implemented (which we'll do shortly).
2021-11-16 01:13:39 -05:00
Mike Frysinger
54f7a83a62 sim: keep track of program environment strings
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.
2021-11-16 00:58:41 -05:00
Mike Frysinger
38f9e52086 sim: iq2000: fix some missing prototypes warnings
Turns out some of these were hiding real bugs like not passing the
pc variable down.
2021-11-16 00:49:13 -05:00
Mike Frysinger
e6c46d0772 sim: cris: make error message test a little more flexible
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 [--].
2021-11-15 03:34:36 -05:00
Mike Frysinger
7770da9714 sim: run: fix crash in argc==0 error situation
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.
2021-11-15 03:32:26 -05:00
Mike Frysinger
145a603abc sim: cris: touch up rvdummy handling
Add quiet build support and make sure it's removed with `make clean`.
2021-11-15 03:00:05 -05:00
Mike Frysinger
565cbe4b91 sim: cris: replace custom "dest" test field with new --argv0
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.
2021-11-15 02:53:31 -05:00
Mike Frysinger
852016f921 sim: run: add --argv0 option to control argv[0]
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.
2021-11-15 02:53:31 -05:00
Mike Frysinger
e8f20a28b1 sim: split program path out of argv vector
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.
2021-11-15 02:53:29 -05:00
Mike Frysinger
7b2ec4e46f sim: bfin: fix mach/xfail usage in tests
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.
2021-11-15 01:35:49 -05:00
Mike Frysinger
35f7d33dd9 sim: sh: fix switch-bool warnings
This code triggers -Werror=switch-bool warnings with <=gcc-5 versions.
Rework it to use if statements instead as it also simplifies a bit.
2021-11-13 00:57:00 -05:00
Mike Frysinger
dc5a462160 sim: sh: rework carry checks to not rely on integer overflows
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.
2021-11-13 00:57:00 -05:00
Mike Frysinger
efe113047d sim: testsuite: drop sim_compile cover function
Most code isn't using this, and the only call site (in one cris file)
can use target_compile directly.  So switch it over to simplify.
2021-11-11 02:07:10 -05:00
Mike Frysinger
f0f2906ca0 sim: cris: stop testing a.out explicitly [ld/13900]
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.
2021-11-11 00:38:53 -05:00
Mike Frysinger
40f6466678 sim: io: tweak compiler workaround with error output
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.
2021-11-11 00:16:33 -05:00
Mike Frysinger
bebe33486c sim: testsuite: delete unused arm remote host logic
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.
2021-11-10 21:58:08 -05:00
Mike Frysinger
23ec4a527d sim: synacor: simplify test generation
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.
2021-11-10 21:45:43 -05:00
Mike Frysinger
1ee4d0e313 sim: frv: flip trapdump default back to off
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.
2021-11-10 05:19:03 -05:00
Mike Frysinger
024120b6ee sim: sh: simplify testsuite a bit
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.
2021-11-09 01:22:06 -05:00
Mike Frysinger
4e6e8ba7c5 sim: cris: clean up missing func prototype warnings
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.
2021-11-08 22:48:55 -05:00
Mike Frysinger
81817dacd6 sim: sh: fix conversion of PC to an integer
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.
2021-11-06 21:09:08 -04:00
Mike Frysinger
a11cd3ddb2 sim: sh: clean up time(NULL) call
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.
2021-11-06 21:06:47 -04:00
Mike Frysinger
4a0bb487b8 sim: sh: break utime logic out of _WIN32 check
Some _WIN32 targets provide utime (like mingw), so move the header
include out from _WIN32 and under the specific HAVE_UTIME_H check.
2021-11-06 21:03:01 -04:00
Mike Frysinger
73eef3fc38 sim: sh: drop errno extern
This isn't needed on any reasonable target nowadays, and no other
source does this, and breaks with some mingw targets, so punt the
extern entirely.
2021-11-06 20:59:17 -04:00
Mike Frysinger
697fa6fe67 sim: sh: fix isnan redefinition with mingw targets
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.
2021-11-06 20:57:32 -04:00
Mike Frysinger
fd0975b96b sim: arm/bfin/rx: undefine page size from system headers
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.
2021-11-06 20:40:20 -04:00
Mike Frysinger
b44c5d6e21 sim: ppc: switch to libiberty environ.h
Drop our compat code and assume environ exists to simplify.
We did this for all other targets already, but ppc was missed.
2021-11-06 20:35:52 -04:00
Mike Frysinger
e6af0f123a sim: sh: enable -Werror everywhere
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.
2021-11-06 20:32:31 -04:00
Mike Frysinger
524d770c9c sim: sh: fix uninitialized variable usage with pdmsb
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 ...
2021-11-06 20:32:31 -04:00
Mike Frysinger
ee7af46230 sim: sh: constify a few read-only lookup tables 2021-11-06 20:32:31 -04:00
Mike Frysinger
6b015f8977 sim: sh: fix various parentheses warnings
Add parentheses to a bunch of places where the compiler suggests we
do to avoid confusion to most readers.
2021-11-06 20:32:31 -04:00
Mike Frysinger
7256320b95 sim: sh: fix unused-value warnings
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.
2021-11-06 20:32:31 -04:00
Mike Frysinger
74bbe64132 sim: sh: rework register layout with anonymous unions & structs
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.
2021-11-06 20:32:31 -04:00
Tiezhu Yang
50a97903ce sim: mips: use sim_fpu_to{32,64}u to fix build warnings
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>
2021-11-06 12:19:58 -04:00
Mike Frysinger
fe7fdfda72 sim: clarify license text via COPYING file
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.
2021-11-06 01:44:06 -04:00
Mike Frysinger
e5c9e53c9b sim: mips: fix missing prototype in multi-run generation
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
2021-11-03 23:53:10 -04:00
Mike Frysinger
6ed0d0a080 sim: ppc: inline common sim-fpu.c logic
We will never bother building w/out a ../common/ sim directory,
so drop ancient logic supporting that method.
2021-11-03 15:14:55 -04:00
Mike Frysinger
d54c09b99e sim: ppc: switch to common builds for callback objects
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.
2021-11-03 15:14:55 -04:00
Mike Frysinger
3a27554104 sim: mloop: mark a few conditionally used funcs as unused
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.
2021-11-03 01:19:43 -04:00
Mike Frysinger
0a129eb19a sim: hoist cgen mloop rules up to common builds
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.
2021-11-02 22:59:07 -04:00
Mike Frysinger
d2a5dbc744 sim: hoist mn10300 & v850 igen rules up to common builds
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.
2021-11-02 22:59:07 -04:00
Mike Frysinger
70ab6bdd55 sim: hoist gencode & opc2c build rules up to common builds
These rules don't depend on the target compiler settings, so hoist
the build logic up to the common builds for better parallelization.
2021-11-02 22:59:07 -04:00
Andrew Burgess
bd25c6eef8 gdb/sim: update my email address
gdb:

	* MAINTAINERS (Global Maintainers): Update my address.
	(Responsible Maintainers): Likewise.
	(Write After Approval): Likewise.

sim:

	* MAINTAINERS (Global Maintainers): Update my address.
2021-11-02 09:20:24 +00:00
Mike Frysinger
94c9216c03 sim: iq2000: reduce -Wno-error scope
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.
2021-11-01 00:58:05 -04:00
Mike Frysinger
2871d4d7f3 sim: lm32: reduce -Wno-error scope
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.
2021-11-01 00:56:52 -04:00
Mike Frysinger
97ebc24886 sim: frv: reduce -Wno-error scope
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.
2021-11-01 00:56:35 -04:00
Mike Frysinger
5d2b3c53a5 sim: m32r: reduce -Wno-error scope
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.
2021-11-01 00:56:08 -04:00
Mike Frysinger
6391b286b1 sim: mips: reduce -Wno-error scope
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.
2021-11-01 00:55:27 -04:00
Mike Frysinger
d0d7f2a742 sim: erc32: reduce -Wno-error scope
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.
2021-11-01 00:55:02 -04:00
Mike Frysinger
c79eb8d991 sim: cris: reduce -Wno-error scope
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.
2021-11-01 00:54:36 -04:00
Mike Frysinger
cd37cffed6 sim: sh: reduce -Wno-error scope
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.
2021-11-01 00:53:38 -04:00
Mike Frysinger
5c15e06faf sim: or1k: build with -Werror
The only warnings left in this port are a few maybe-uninitialized,
but we don't abort the build for them, so turn on -Werror everywhere.
2021-11-01 00:52:52 -04:00
Mike Frysinger
0eecf48fd4 sim: igen: minor build output alignment fix
The custom echo was off by one space relative to all the others.
2021-11-01 00:27:49 -04:00
Mike Frysinger
8009a84cfd sim: ppc: fix the printf fix for 32-bit systems
The time delta is a 64-bit value too.
2021-11-01 00:25:13 -04:00
Mike Frysinger
06969ac449 sim: m68hc11: clean up pointer casts
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.
2021-11-01 00:07:15 -04:00
Mike Frysinger
6dc840d69d sim: d10v: clean up pointer casts
Use %p to print pointers instead of trying to cast them to longs.
2021-11-01 00:05:15 -04:00
Mike Frysinger
f0bef2e9a7 sim: bfin: cast pointers using uintptr_t
We can't assume that sizeof(long) == sizeof(void*), so change all
these casts over to uintptr_t.
2021-10-31 23:55:51 -04:00
Mike Frysinger
fad7f13ae1 sim: ppc: clean up printf format handling
Don't blindly cast every possible type to (long).  Change to the right
printf format specifier whether it be a 64-bit type or a pointer.
2021-10-31 23:49:13 -04:00
Mike Frysinger
7b83db6a74 sim: ppc: switch core types to stdint.h types
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.
2021-10-31 23:48:16 -04:00
Mike Frysinger
ad2511744f sim: mn10300: clean up pointer casts
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.
2021-10-31 23:21:36 -04:00
Mike Frysinger
c704d6e7ee sim: events: clean up trace casts
Don't blindly cast every possible type to (long).  Change to the right
printf format specifier whether it be a 64-bit type or a pointer.
2021-10-31 23:05:45 -04:00
Mike Frysinger
f098231806 sim: ppc: handle \r in igen inputs [PR sim/28476]
Make sure we consume & ignore \r bytes in inputs in case the file
encodings are from a non-LF systems (e.g. Windows).
2021-10-31 22:35:41 -04:00
Mike Frysinger
fc3579da2e sim: ppc: constify strings in igen tooling 2021-10-31 22:34:02 -04:00
Mike Frysinger
c26c6bc0a5 sim: ppc: use silent build rules here too
The ppc codebase is unique and doesn't leverage common/, so have to
add silent rules to it specifically.
2021-10-31 05:26:57 -04:00
Mike Frysinger
5231e3f242 sim: rl78: drop obsolete manual dependency rules
We have GNU make generate these for us automatically now, so there's
no need to manually specify any deps.
2021-10-31 05:09:09 -04:00
Mike Frysinger
f9bfc01578 sim: drop unused targ-vals.h includes
This is used in a few places where it's not needed.  Drop the include
to avoid the build-time generated header file as we move to drop it.
2021-10-31 04:53:22 -04:00
Mike Frysinger
cd3ee89d38 sim: unify callback.o building
Now that the use of TARGET_xxx defines have been removed, we can move
this to the common logic so we only build it once for multi-targets.
2021-10-31 04:51:44 -04:00
Mike Frysinger
670817b947 sim: nltvals: pull target open flags out into a dedicated source file
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.
2021-10-31 04:51:44 -04:00
Mike Frysinger
b868a2393b sim: nltvals: localize TARGET_<open> defines
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.
2021-10-31 04:50:44 -04:00
Mike Frysinger
88c8370b25 sim: nltvals: pull target signal out into a dedicated source file
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.
2021-10-31 04:39:13 -04:00
Mike Frysinger
a7e40a9931 sim: nltvals: pull target errno out into a dedicated source file
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.
2021-10-31 04:31:28 -04:00
Mike Frysinger
f9cd2be59c sim: erc32: use silent build rules with sis linkage 2021-10-31 04:19:41 -04:00
Mike Frysinger
5b3c2b9f3b sim: erc32: fix a few more build warnings
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).
2021-10-31 04:18:58 -04:00
Orgad Shaneh
4ab6404b1c sim: erc32: fix signedness compatibility and redefinition warnings 2021-10-31 04:11:38 -04:00
Mike Frysinger
65dcce8f79 sim: add arch-specific conditional logic
This will make it easy to include arch-specific logic (build files)
as we migrate ports to the common top level build.
2021-10-31 02:03:16 -04:00
Mike Frysinger
68c2129ae6 sim: v850: delete old gencode logic
The v850 port used to have a gencode helper, but it was deleted long
ago.  Clean up the settings that no longer make sense w/out it.
2021-10-31 01:49:17 -04:00
Mike Frysinger
2213e33dd2 sim: common: merge multiple clean commands
This provides a minor speedup when cleaning in a multi-target build.
2021-10-31 01:17:10 -04:00
Mike Frysinger
b46621118d sim: m32c: tighten up opc2c build output
Drop the single debugging line that repeats the command line option,
and use the silent build helpers to tighten up output.
2021-10-31 01:11:41 -04:00
Mike Frysinger
9709fa5bcb sim: tighten up build regen rules
Update the makefile & configure related rules to use the silent
build helpers.
2021-10-31 01:08:05 -04:00
Mike Frysinger
4837497a7f sim: tighten up gencode output
Update the gencode rules to use the silent build helpers.
2021-10-31 01:05:27 -04:00
Mike Frysinger
ac9b6df28f sim: igen: tighten up build output
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.
2021-10-31 00:55:50 -04:00
Mike Frysinger
65f42b88ff sim: tighten up stamp rules
Add a new ECHO_STAMP helper and convert existing stamp code over
to it.  This is mostly common rules and cgen mloop rules.
2021-10-31 00:49:39 -04:00
Mike Frysinger
b6143d3162 sim: silence stamp touch rules
We pretty much never care about these stamp touches, so silence them.
Also switch to using $@ when it makes sense.
2021-10-31 00:46:28 -04:00
Mike Frysinger
4f2b181ecb sim: standardize move-if-change rules
Use the srcroot path and make them all silent.
2021-10-31 00:39:40 -04:00
Mike Frysinger
bdcbd1b67f sim: mips/v850: remove redundant variable setup
The common/Make-common.in fragment already provides these variables.
2021-10-31 00:23:36 -04:00
Orgad Shaneh
1352aabb23 sim: fix compilation on mingw64 [PR sim/28476]
...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
2021-10-30 23:50:09 -04:00
Christian Biesinger
cf365c10d0 [sim] Include defs.h in ppc/hw_memory.c
To fix this error (seen on cygwin):
/../../sim/ppc/../common ../../../sim/ppc/hw_memory.c
In file included from ../../gnulib/import/stdlib.h:100,
                 from ../../../sim/ppc/hw_memory.c:28:
../../gnulib/import/unistd.h:663:3: error: #error "Please include config.h first."
  663 |  #error "Please include config.h first."
      |   ^~~~~
../../gnulib/import/unistd.h:665:24: error: expected ';' before 'extern'
  665 | _GL_INLINE_HEADER_BEGIN
      |                        ^
      |                        ;
../../gnulib/import/unistd.h:2806:22: error: expected ';' before 'extern'
 2806 | _GL_INLINE_HEADER_END
      |                      ^
      |                      ;
2021-10-28 15:09:00 -04:00
Mike Frysinger
adc82fdb71 sim: add --info-target for listing supported BFD targets
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.
2021-10-04 02:19:58 -04:00
Mike Frysinger
39d53d0435 sim: filter out SIGSTKSZ [PR sim/28302]
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
2021-10-03 12:02:53 -04:00
Mike Frysinger
46039d3632 sim: ppc: fallback when ln is not available [PR sim/18864]
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
2021-10-03 11:36:30 -04:00