Commit Graph

4260 Commits

Author SHA1 Message Date
Mike Frysinger
cd09ab7c74 sim: microblaze: hook up libgloss syscalls
When in the virtual environment, have brki 8 trigger libgloss syscalls
like other ports.  This also matches the ABI that Linux uses for its
syscalls (ignoring the syscall table differences).
2021-05-04 21:47:10 -04:00
Tom Tromey
be7547b077 Add missing stdlib.h includes to sim
This updates the various "mloop.in" files to emit an include of
stdlib.h, to avoid warnings about 'abort' being undeclared.

One such warning now remains, in mn10300.igen.  I don't know offhand
the best way to fix this one.

2021-05-04  Tom Tromey  <tromey@adacore.com>

	* mloop.in: Include <stdlib.h>.

sim/iq2000/ChangeLog
2021-05-04  Tom Tromey  <tromey@adacore.com>

	* mloop.in: Include <stdlib.h>.

sim/lm32/ChangeLog
2021-05-04  Tom Tromey  <tromey@adacore.com>

	* mloop.in: Include <stdlib.h>.

sim/m32r/ChangeLog
2021-05-04  Tom Tromey  <tromey@adacore.com>

	* mloop.in: Include <stdlib.h>.

sim/or1k/ChangeLog
2021-05-04  Tom Tromey  <tromey@adacore.com>

	* mloop.in: Include <stdlib.h>.
2021-05-04 13:19:33 -06:00
Tom Tromey
a0c4531a55 Fix igen build
The igen build fails for me like:

gcc  -g -O2 -c ../../binutils-gdb/sim/igen/igen.c -o igen/igen.o
In file included from ../../binutils-gdb/sim/igen/igen.c:26:
../../binutils-gdb/sim/igen/lf.h:22:10: fatal error: ansidecl.h: No such file or directory

This patch fixes the problem by arranging for igen to find the
libiberty includes.

This seems slightly hacky to me, because libiberty is not a "build"
library, so it can't be linked against.  However, since igen currently
only includes the header, it seems relatively safe.

2021-05-04  Tom Tromey  <tromey@adacore.com>

	* Makefile.in: Rebuild.
	* Makefile.am (AM_CPPFLAGS): New variable.
2021-05-04 13:19:33 -06:00
Tom Tromey
937a049c95 Add config.h to generated_files for sim
I noticed that config.h isn't in 'generated_files' in the sim
subdirectories.  This causes it to sometimes be rebuilt too late.

2021-05-04  Tom Tromey  <tromey@adacore.com>

	* Make-common.in (generated_files): Add config.h.
2021-05-04 13:19:33 -06:00
Mike Frysinger
aa0fca163e sim: add support for build-time ar & ranlib
This is needed when building for a target whose ar & ranlib are
incompatible with the current build system.  For example, building
for Windows on a Linux system.

Then manually import the automake rule for libigen.a, but tweak the
tool variables to use the FOR_BUILD variants.
2021-05-04 08:22:07 -04:00
Mike Frysinger
5ee0bc23a6 sim: clean up bfd_vma printing
A lot of this code predates the bfd_vma format define, so we have a
random mix of casts to known types so we can printf the value.  Use
the BFD_VMA_FMT that now exists to simplify and reliability output
across different build configs.
2021-05-04 08:13:45 -04:00
Simon Marchi
f08708cbf5 sim: add ATTRIBUTE_PRINTF / ATTRIBUTE_NULL_PRINTF where necessary
I finally got the all-targets sim building with Clang, these are all the
instances where an ATTRIBUTE_PRINTF or ATTRIBUTE_NULL_PRINTF attribute
needed to be added to avoid errors like:

    /home/simark/src/binutils-gdb/sim/aarch64/../common/sim-profile.c:464:19: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
        vfprintf (fp, fmt, ap);
                      ^~~
There are more fixes needed to get everything building, but adding these
attributes is trivial enough, so I send them all in a single patch.

Adding the format attributes introduces some format string errors when
building with GCC (because now format strings are checked), so
corresponding changes are needed to avoid breaking the build.  Other
than simple format string specified changes, there is this one:

    /home/simark/src/binutils-gdb/sim/aarch64/../common/hw-events.c: In function 'hw_event_queue_schedule':
    /home/simark/src/binutils-gdb/sim/aarch64/../common/hw-events.c:95:15: error: too many arguments for format [-Werror=format-extra-args]
       95 |         NULL, dummy);
          |               ^~~~~

We can fix it and avoid using a dummy variable by simply calling
hw_event_queue_schedule_tracef instead of
hw_event_queue_schedule_vtracef.

sim/arm/ChangeLog:

	* armdefs.h (ARMul_ConsolePrint): Use format attribute.
	* wrapper.c (op_printf): Likewise.

sim/bfin/ChangeLog:

	* interp.c (sim_open): Adjust format string specifier.

sim/common/ChangeLog:

	* hw-events.h (hw_event_queue_schedule_tracef): Use format attribute.
	(hw_event_queue_schedule_vtracef): Likewise.
	* hw-tree.h (hw_tree_vparse): Likewise.
	* sim-profile.c (profile_vprintf): Likewise.
	* sim-trace.c (dis_printf): Likewise.
	* sim-trace.h (trace_printf): Likewise.
	(trace_vprintf): Likewise.
	* sim-utils.h (sim_do_commandf): Likewise.
	* hw-events.c (hw_event_queue_schedule): Use
	hw_event_queue_schedule_tracef.

sim/rx/ChangeLog:

	* trace.c (op_printf): Likewise.

sim/v850/ChangeLog:

	* interp.c (sim_open): Adjust format string specifier.

Change-Id: I1445115ce57db15bb8e35dca93014555e7555794
2021-05-03 10:55:25 -04:00
Simon Marchi
72042732bc sim: add default cases to two switches in sim-options.c
This is the next compilation error I hit when I build all targets with
Clang:

    /home/simark/src/binutils-gdb/sim/aarch64/../common/sim-options.c:234:12: error: no case matching constant switch condition '0' [-Werror]                                                                    switch (WITH_ENVIRONMENT)
                      ^~~~~~~~~~~~~~~~                                                                                                                                                                 ./config.h:215:26: note: expanded from macro 'WITH_ENVIRONMENT'
    #define WITH_ENVIRONMENT ALL_ENVIRONMENT                                                                                                                                                                                    ^~~~~~~~~~~~~~~
    /home/simark/src/binutils-gdb/sim/aarch64/../common/sim-options.c:276:15: error: no case matching constant switch condition '0' [-Werror]                                                                switch (WITH_ALIGNMENT)
                  ^~~~~~~~~~~~~~                                                                                                                                                                       /home/simark/src/binutils-gdb/sim/aarch64/../common/sim-config.h:220:24: note: expanded from macro 'WITH_ALIGNMENT'
    #define WITH_ALIGNMENT 0
                           ^

This is a little bit special because these are switches on compile-time
value.  But regardless, the idea is that we logically can't reach the
switches if WITH_ENVIRONMENT == 0 or WITH_ALIGNMENT == 0, so the code is
correct.

In addition to getting rid of the compiler warning, adding default cases
to these switches ensure that if we do get in an unexpected situation,
it is caught.  In GDB, I'd use gdb_assert_not_reached, I don't know if
there is something similar in sim so I went with abort.

sim/common/ChangeLog:

	* sim-options.c (standard_option_handler): Add default cases to
	switches.

Change-Id: Ie237d67a201caa6b72de0d17cc815193417156b6
2021-05-02 11:04:58 -04:00
Mike Frysinger
f0c4dc40b2 sim: replace custom attributes with ansidecl.h
A lot of this code predates the common attributes.  We had already
started migrating over piece by piece, so just do a pass across all
the attributes and replace most of them.
2021-05-02 10:58:20 -04:00
Mike Frysinger
d89a87ba3c sim: bfin: move option inits to respective modules
Now that modules can self declare their own init funcs, change the mmu
and mach logic to use it.  We don't need to export the option symbols
or specifically call this logic from the sim_open function anymore.
2021-05-01 23:10:28 -04:00
Mike Frysinger
e4821e2f5f sim: options: fix --help output
The hash table rewrite broke --help output due to subtle behavior:
calling dup_arg_p(NULL) will create & clear the table, not just
create it.  The --help output relies on this to clear the table
before it shows things.
2021-05-01 23:06:54 -04:00
Mike Frysinger
328e805b5a sim: dv-sockser: localize init callback
Now that we don't need to hardcode the module init list in a single
place, move the dv-sockser logic to the place to the one file.
2021-05-01 22:46:46 -04:00
Mike Frysinger
adbaa7b838 sim: mips: mark local func static 2021-05-01 21:16:28 -04:00
Mike Frysinger
8e5f151657 sim: add framework for declaring init callbacks locally
To facilitate decentralized module initialization/registration with an
eye towards multi-target support, add a framework to detect init calls
declared in the source and automatically call them.  This is akin to
gdb's _initialize_xxx framework for letting modules autodiscover.
2021-05-01 20:47:14 -04:00
Mike Frysinger
fe34861780 sim: nrun: add local strsignal prototype
While libiberty provides a definition for this for systems that lack
the function (e.g. Windows), it doesn't provide a prototype.  So add
our own local copy in the one file that uses the func.
2021-05-01 16:37:39 -04:00
Mike Frysinger
2a83fd8f48 sim: rx: cast bfd_vma when printing
A bit of a hack, but it's what we've been doing so far when printing
bfd_vma's since bfd doesn't provide PRI helper types for us to use.
2021-05-01 16:29:15 -04:00
Mike Frysinger
bd12755bf4 sim: riscv: fix building on 32-bit hosts w/out int128
Check for __SIZEOF_INT128__ before trying to use the builtin type.
This fixes building on some 32-bit systems like x86.
2021-05-01 16:26:31 -04:00
Mike Frysinger
f1ca32150c sim: aarch64: use PRIx64 for formatting 64-bit types
We can't assume that %lx is big enough for 64-bit types as it isn't on
most 32-bit builds.  Use the standard format define for this instead.
2021-05-01 16:25:02 -04:00
Mike Frysinger
ce2248135a sim: aarch64: fix 64-bit immediate shifts
Trying to shift immediates 63 bits fails on 32-bit systems since UL
is only 32-bits, not 64-bits.  Switch to ULL to guarantee at least
64-bits here.
2021-05-01 16:23:10 -04:00
Mike Frysinger
163cb76122 sim: arm: move build logic to source files
This simplifies the build logic a bit by just having source file
inputs.  It also simplifies code that assumes there's a source
file for each object.
2021-05-01 12:55:18 -04:00
Mike Frysinger
ccf2e5927c sim: callback: inline wrap helper
This is annoying as it requires inlining boiler plate, but we don't
have much choice: the wrap helper assumes the return value is always
an int, but that's already not the case with some of the callbacks
which use long.  GCC has extensions to define macros-as-functions,
but we can't assume GCC.
2021-05-01 09:58:27 -04:00
Mike Frysinger
2045d9d17f sim: riscv: switch MIN/MAX to common min/max
The common sim-basics.h defines min/max already, so use them.
2021-04-26 23:29:01 -04:00
Mike Frysinger
bd0918c910 sim: nltvals: unify common syscall tables
Since libgloss provides a default syscall table for arches, use that
to provide the default syscall table for ports.  Only the exceptions
need to be enumerated now with the common logic as the default.
2021-04-26 22:39:55 -04:00
Mike Frysinger
66d055c754 sim: enable hardware support by default
Force this on for all ports.  We have a few common models that can
be used, so make them generally available.  If the port doesn't use
any hardware (the default), then behavior is unchanged.
2021-04-26 22:30:55 -04:00
Nick Clifton
f6b9562fd9 Fix a bug in the ARM emulator which would not allow 4 byte alignment for double word stores.
PR 22790
	* armemu.c (Handle_Store_Double): Allow 4 byte alignment when
	running in v6 mode.
2021-04-26 17:17:34 +01:00
Tom Tromey
b22138f32f Add engv32.h to SIM_EXTRA_DEPS in sim/cris
A rebuild showed that an earlier change of mine missed a built header
file -- cris/engv32.h.  This patch fixes the problem.

sim/cris/ChangeLog
2021-04-25  Tom Tromey  <tom@tromey.com>

	* Makefile.in (SIM_EXTRA_DEPS): Add engv32.h.
2021-04-25 07:30:03 -06:00
Tom Tromey
4478c33127 Use htab_t in sim-options.c
This changes sim-options.c to use the libiberty hash table, rather
than its own custom hash table.

sim/common/ChangeLog
2021-04-25  Tom Tromey  <tom@tromey.com>

	* sim-options.c (compare_strings): New function.
	(ARG_HASH_SIZE, ARG_HASH): Remove.
	(dup_arg_p): Use htab_t.
	(sim_parse_args): Remove assert.
2021-04-25 07:02:20 -06:00
Mike Frysinger
3886790f13 sim: dv-cfi: fix printf format
Use the existing PRI constants to select the right format rather than
assume signed_cell is always %u.  Fixes building for riscv64.
2021-04-24 00:18:48 -04:00
Mike Frysinger
837b53fd08 sim: options: increase max option count
As we turn on more modules by default for all ports, the number of
options has been increasing.  The sim-options module has a limit on
the number of options it can support, and if it's exceeded, it likes
to go into an infinite loop.  Increase the ceiling and add an assert
so we abort right away instead of hanging.

This will be needed to turn on hw support for v850 as it will then
exceed the current limit.
2021-04-24 00:17:35 -04:00
Mike Frysinger
9d90335212 sim: simplify hardware m4 macro
Every port using this sets the 1st arg to yes and the 2nd arg to "".
These are the defaults we probably want anyways in order to unify the
codebase, so move them to the macro and only allow ports to declare
extra hardware models.
2021-04-23 21:58:21 -04:00
Tom Tromey
19f6a43c6c Do not check for sys/time.h or sys/times.h
This updates the sim so that it unconditionally uses sys/time.h.  This
is in agreement with existing code, and a recent change to BFD.

I also think that sys/times.h is never needed by the sim, so this
patch removes the check and the one spot that was conditionally
including it.

sim/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* m4/sim_ac_common.m4 (SIM_AC_COMMON): Don't check for sys/time.h
	or sys/times.h.

sim/aarch64/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/arm/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/avr/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/bfin/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/bpf/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/common/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* sim-utils.c: Update includes.

sim/cr16/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* simops.c: Update includes.
	* configure, config.in: Rebuild.

sim/cris/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* rvdummy.c: Update includes.
	* dv-rv.c: Update includes.
	* configure, config.in: Rebuild.

sim/d10v/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/erc32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/example-synacor/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/frv/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/ft32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/h8300/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/iq2000/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/lm32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/m32c/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/m32r/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/m68hc11/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/mcore/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/microblaze/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/mips/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/mn10300/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/moxie/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/msp430/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/or1k/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/ppc/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* mon.c: Update includes.
	* emul_unix.c: Update includes.
	(do_unix_gettimeofday): Update condition.

sim/pru/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/riscv/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/rl78/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/rx/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/sh/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* interp.c: Update includes.
	* configure, config.in: Rebuild.

sim/v850/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.
2021-04-22 19:51:55 -06:00
Tom Tromey
51de628a22 Remove LIBS from two sim Makefiles
A couple of sim Makefiles define LIBS, but don't use it.  This removes
these.

sim/m32c/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (LIBS): Remove

sim/rx/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (LIBS): Remove.
2021-04-22 19:51:55 -06:00
Tom Tromey
d6581fcd69 Remove INCLUDE variable from some sim Makefiles
Some Makefiles in sim define INCLUDE but don't use it.  This removes
these instances.

sim/bfin/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (INCLUDE): Remove.

sim/m68hc11/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (INCLUDE): Remove.

sim/mn10300/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (INCLUDE): Remove.

sim/v850/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (INCLUDE): Remove.
2021-04-22 19:51:55 -06:00
Tom Tromey
e7d8f1da71 Remove and modernize dependencies in sim
Some spots in the sim build used manual dependencies, and some spots
did a compilation by hand but did not use the automatic dependency
tracking code.  This patch fixes these spots.

I didn't touch ppc, because it doesn't use the common Makefile code.
I also didn't touch objects that are for the build machine, because
automatic dependencies don't work for those.

sim/arm/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (armemu26.o, armemu32.o): Use COMPILE and
	POSTCOMPILE.

sim/bpf/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (arch.o, cpu.o, sim-if.o, traps.o): Remove.
	(mloop-le.o, mloop-be.o, decode-le.o, decode-be.o, sim-le.o)
	(sim-be.o): Use COMPILE and POSTCOMPILE.
	(SIM_EXTRA_DEPS): Add eng-le.h, eng-be.h.

sim/cr16/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (SIM_EXTRA_DEPS): New variable.
	(simops.o): Remove.

sim/cris/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (sim-if.o, dv-cris.o, dv-rv.o, arch.o, traps.o)
	(devices.o, crisv10f.o, mloopv10f.o, cpuv10.o, decodev10.o)
	(modelv10.o, crisv32f.o, mloopv32f.o, cpuv32.o, decodev32.o)
	(modelv32.o): Remove.
	(SIM_EXTRA_DEPS): Add engv10.h.

sim/d10v/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (SIM_EXTRA_DEPS): New variable.
	(simops.o): Remove.

sim/frv/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (arch.o, devices.o, frv.o, traps.o, pipeline.o)
	(interrupts.o, memory.o, cache.o, options.o, reset.o)
	(registers.o, profile.o, profile-fr400.o, profile-fr450.o)
	(profile-fr500.o, profile-fr550.o, sim-if.o, mloop.o, cpu.o)
	(decode.o, sem.o, model.o): Remove.
	(SIM_EXTRA_DEPS): Add eng.h.

sim/iq2000/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (sim-if.o): Remove.
	(arch.o): Use COMPILE and POSTCOMPILE.
	(devices.o, iq2000.o, mloop.o, cpu.o, decode.o, sem.o, model.o):
	Remove.
	(SIM_EXTRA_DEPS): Add eng.h.

sim/lm32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (arch.o, traps.o, sim-if.o, lm32.o, mloop.o)
	(cpu.o, decode.o, sem.o, model.o): Remove.
	(SIM_EXTRA_DEPS): Add eng.h.

sim/m32r/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (sim-if.o, arch.o, traps.o, traps-linux.o)
	(devices.o, m32r.o, mloop.o, cpu.o, decode.o, sem.o, model.o)
	(m32rx.o, mloopx.o, cpux.o, decodex.o, semx.o, modelx.o)
	(m32r2.o, mloop2.o, cpu2.o, decode2.o, sem2.o, model2.o): Remove.
	(SIM_EXTRA_DEPS): Add eng.h, engx.h, eng2.h.

sim/m68hc11/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (interp.o): Remove.

sim/mips/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (interp.o, m16run.o, micromipsrun.o, multi-run.o):
	Remove.
	(SIM_EXTRA_DEPS): New variable.

sim/mn10300/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (interp.o): Remove.
	(idecode.o op_utils.o semantics.o): Remove.

sim/or1k/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (mloop.o, arch.o, cpu.o, decode.o, sem.o)
	(sem-switch.o, model.o): Remove.

sim/rl78/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (err.o, fpu.o, gdb-if.o, load.o, main.o, mem.o)
	(reg.o, rl78.o): Remove.

sim/rx/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (err.o, fpu.o, gdb-if.o, load.o, main.o, mem.o)
	(misc.o, reg.o, rx.o, syscalls.o, trace.o): Remove.

sim/sh/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (SIM_EXTRA_DEPS): New variable.
	(interp.o): Remove.

sim/v850/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (interp.o, simops.o, semantics.o): Remove.
2021-04-22 19:51:55 -06:00
Tom Tromey
efd82ac7cb Require GNU make
GDB has required GNU make for quite some time, and this patch applies
this approach to the sim as well.  Requiring GNU make means that
automatic dependency tracking can be simple and reliable, and it also
makes other refactorings simpler.

sim/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* m4/sim_ac_common.m4 (SIM_AC_COMMON): Don't check for make.

sim/aarch64/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/arm/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/avr/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/bfin/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/common/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Make-common.in: Require GNU make.

sim/cr16/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/cris/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/d10v/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/erc32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/example-synacor/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/frv/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/ft32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/h8300/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/iq2000/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/lm32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/m32c/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/m32r/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/m68hc11/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/mcore/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/microblaze/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/mips/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/mn10300/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/moxie/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/msp430/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/or1k/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/pru/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/riscv/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/rl78/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/rx/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/sh/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/v850/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
2021-04-22 19:51:54 -06:00
Tom Tromey
06a84ea384 Add stamp files for generated files in sim/ppc
This changes the sim/ppc Makefile to use the stamp file idiom for a
couple of generated files, avoiding extra rebuilds.

sim/ppc/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (stamp-vals, stamp-map): New targets.
	(targ-vals.h, targ-map.c): Update.
	(clean): Remove files.
2021-04-22 19:51:54 -06:00
Tom Tromey
b396d3a16e Introduce stamp file for hw-config.h
This adds a stamp file for hw-config.h, to avoid unnecessary rebuilds.
It also arranges to remove hw-config.h in "mostlyclean", because the
file is created by "make".

sim/common/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Make-common.in (stamp-hw): New target.
	(hw-config.h): Depend on stamp-hw.
	(mostlyclean): Remove stamp-hw and hw-config.h.
2021-04-22 19:51:54 -06:00
Tom Tromey
be866656a0 Make mostlyclean an alias for clean
I found out by accident that "mostlyclean" in a sim subdir removes all
the configure artifacts.  The usual rule is:

* If the maintainer built it, maintainer-clean should remove it;
* If configure built it, distclean should remove it;
* If make built it, "clean" should remove it;
* If there is a handy subset of "clean" that is "easy" to rebuild,
  "mostlyclean" should remove it; otherwise mostlyclean should be an
  alias for clean

This patch makes mostlyclean an alias for clean.

sim/common/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Make-common.in (mostlyclean): Now an alias for clean, not
	distclean.
2021-04-22 19:51:54 -06:00
Tom Tromey
dbc0e7ce65 Fix sim build failure
On x86-64 Fedora 32, the sim was failing to build.
sim_events_schedule was passing a 'dummy' argument to
sim_events_schedule_vtracef, which caused an error because the format
parameter was NULL.  However, removing this dummy argument caused an
error because too few arguments were being passed -- catch 22.

This patch fixes the build problem by using sim_events_schedule_tracef
instead.

sim/common/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* sim-events.c (sim_events_schedule): Use
	sim_events_schedule_tracef.
2021-04-22 19:44:12 -06:00
Simon Marchi
2f63213381 sim: sprinkle some ATTRIBUTE_PRINTF
Add some ATTRIBUTE_PRINTF attributes to functions that take a format
string, to fix a few -Wformat-nonliteral warnings.  Use the
ATTRIBUTE_PRINTF macro like we use in GDB, instead of spelling out
__attribute__((format...)).  Use ATTRIBUTE_NULL_PRINTF at one place,
because callers expect to be able to pass NULL.

sim/common/ChangeLog:

	* callback.c (os_printf_filtered, os_vprintf_filtered,
	os_evprintf_filtered, os_error): Use ATTRIBUTE_PRINTF.
	* sim-engine.h (sim_engine_abort, sim_engine_vabort): Likewise.
	* sim-events.h (sim_events_schedule_tracef,
	sim_events_schedule_vtracef): Use ATTRIBUTE_NULL_PRINTF.

Change-Id: Icd206f7b2c325e8b144f72eb129fb2a6b5af2fa3
2021-04-22 12:07:14 -04:00
Mike Frysinger
2662c237a9 sim: regen against sim/m4/
My scripts weren't updated to use new -I../m4 as the first arg.
2021-04-21 20:40:51 -04:00
Simon Marchi
1f195bc327 sim: use -Werror when probing for supported warning flags
When building with clang, we get:

    error: unknown warning option '-Wmissing-parameter-type' [-Werror,-Wunknown-warning-option]

This is because clang only warns by default when encountering an unknown
warning option, and the probe for supported warning flags is done
without -Werror.  All flags are therefore accepted by configure, but
then it breaks when actually compiling a source file with -Werror.

This is equivalent to this commit in gdb:

    3e019bdc20
    gdb: Use -Werror when checking for (un)supported warning flags

We then see some other compilation errors when building with clang and
-Werror, they can be dealt with later.
2021-04-21 19:48:35 -04:00
Mike Frysinger
d549b029d6 sim: rl78/rx: drop unnecessary getopt.h probing
Since getopt.h is provided by libiberty, there's no need to probe for
a system version of it.  Plus we already assume it exists in other
parts of the sim.
2021-04-20 09:23:56 -04:00
Mike Frysinger
2c2645d7a8 sim: switch to AC_CHECK_HEADERS_ONCE
This avoids duplicate tests for headers between common m4, arches,
and any other sources that would trigger header tests.
2021-04-18 23:53:01 -04:00
Mike Frysinger
41e166b43b sim: msp430: delete unused getopt.h probe
This port doesn't include it anywhere, so drop the test.
2021-04-18 23:34:16 -04:00
Mike Frysinger
f3d25569f1 sim: moxie: switch syscalls to common nltvals
Rather than hand duplicate the syscall constants, switch to the
common nltvals framework.  I made sure the constants have the
same values before & after too :).
2021-04-18 23:03:38 -04:00
Mike Frysinger
b7c5246bbf sim: sh: switch syscalls to common nltvals
Rather than hand duplicate the syscall table, switch to the common
nltvals framework.  We have to tweak the constant names, but we get
everything else for free.  I made sure the constants have the same
values before & after too :).
2021-04-18 23:03:08 -04:00
Mike Frysinger
b3d4da0f12 sim: rx: switch syscalls to common nltvals
Rather than hand duplicate the syscall table, switch to the common
nltvals framework.  We have to tweak the constant names, but we get
everything else for free.  I made sure the constants have the same
values before & after too :).
2021-04-18 23:02:15 -04:00
Mike Frysinger
f956ecde56 sim: m32c: switch syscalls to common nltvals
Rather than hand duplicate the syscall table, switch to the common
nltvals framework.  We have to tweak the constant names, but we get
everything else for free.  I made sure the constants have the same
values before & after too :).
2021-04-18 23:01:08 -04:00
Mike Frysinger
2390d77943 sim: iq2000: switch syscalls to common nltvals
Rather than hand duplicate the syscall table, switch to the common
nltvals framework.  We have to tweak the constant names, but we get
everything else for free.  I made sure the constants have the same
values before & after too :).
2021-04-18 23:00:58 -04:00
Mike Frysinger
37e9f18266 sim: switch to AC_CHECK_FUNCS_ONCE & merge a little
This avoids duplicate tests for functions between common m4, arches,
and any other sources that would trigger func tests.

Also manually delete known duplicate function tests between the m4,
bfin, and v850 ports.
2021-04-18 21:55:17 -04:00
Mike Frysinger
3e91feb948 sim: mn10300: delete unused func & header tests
These appear to have been blindly copied from the v850 port many years
ago as the code has never been used.  Just delete it all and be done.
2021-04-18 21:33:07 -04:00
Mike Frysinger
7da5cf78fb sim: syscall: add getpid support
Hoist the Blackfin implementation up to the common one.
2021-04-18 21:22:31 -04:00
Mike Frysinger
d3b0ab8b36 sim: d10v: fix build warnings
The printf fix uses our PRIxTA for our sim address type.

Then cast away the const (since the underlying code safely treats it
as such) even if it's ugly.

Finally touch up the argv iterator pointer to match the new func arg.

With this tidied up, we can delete the SIM_AC_OPTION_WARNINGS(no) call
to get the default common behavior where -Werror is enabled.
2021-04-18 21:16:03 -04:00
Mike Frysinger
3912a8db68 sim: cr16: fix build warnings
The printf fix is obvious enough, but the hash one is a real bug:
cr16/interp.c: In function 'sim_open':
cr16/interp.c:560:17: error: 'h' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  560 |               h = h->next;
      |               ~~^~~~~~~~~

It happens to not cause a problem currently because the first entry in
the generated table that this loop operates matches a codepath where h
is initialized.  Then when later entries don't match, the previous value
is pointing at the end of a valid hash table already, and the rest of
the code does nothing.

With this tidied up, we can delete the SIM_AC_OPTION_WARNINGS(no) call
to get the default common behavior where -Werror is enabled.
2021-04-18 21:07:25 -04:00
John Baldwin
2694bce941 sim erc32: Add include path for readline.
Add a READLINE_CFLAGS variable which adds the include path to the
in-tree readline when using the in-tree readline library.

sim/erc32/ChangeLog:

	* Makefile.in (READLINE_SRC, READLINE_CFLAGS): Add.
	(SIM_EXTRA_CFLAGS): Add READLINE_CFLAGS.
	* configure: Rebuild.
	* configure.ac (READLINE_CFLAGS): Add.
2021-04-15 16:07:46 -07:00
John Baldwin
32b14776a0 sim mn10300: Fix igen generation.
Only pass the top-level instruction decode table (mn10300.igen) to
igen via -i.  The additional files passed previously caused igen to
exit its getopt loop in main and exit silently without generating any
output.  In addition, when am33-2.igen was added, it was not included
from mn10300.igen, so was never used.

sim/mn10300/ChangeLog:

	* Makefile.in: (tmp-igen) Only pass mn10300.igen to igen.
	* mn10300.igen: Include am33-2.igen.
2021-04-15 16:06:39 -07:00
John Baldwin
599a6ff01e sim lm32: Use a known-good shell with genmloop.sh.
Explicitly use a known-good shell found by autoconf for executing
additional scripts in genmloop.sh rather than the building user's
shell.

sim/lm32/ChangeLog:

	* Makefile.in: Pass -shell to genmloop.sh.
2021-04-15 16:06:10 -07:00
John Baldwin
f00b50d057 sim frv: Add a missing return value for frvbf_check_acc_range.
Claim that the accumulator indices are out of range without raising an
exception if the CPU doesn't support media instructions.

sim/frv/ChangeLog:

	* traps.c (frvbf_check_acc_range): Add missing return value.
2021-04-15 16:05:41 -07:00
John Baldwin
10737236a0 sim: Add SIM_EXTRA_CFLAGS after CSEARCH.
The bfin sim adds include paths for the SDL libraries.  These include
paths might include headers for different version of binutils.  Move
SIM_EXTRA_CFLAGS after CSEARCH to ensure local includes are always
preferred to external includes.

sim/common/ChangeLog:

	* Make-common.in (CONFIG_CFLAGS): Remove SIM_EXTRA_CFLAGS.
	(ALL_CLAGS, COMMON_DEP_CFLAGS): Add SIM_EXTRA_CFLAGS after
	CSEARCH.
2021-04-15 16:04:55 -07:00
Mike Frysinger
d5a71b1131 sim: cgen: move cgen_cpu_max_extra_bytes logic into the common code
Every arch handles this the same way, so move it to the common code.
This will also make unifying the sim_cpu structure easier.
2021-04-12 00:14:32 -04:00
Luis Machado
3a3fa80109 Add missing ChangeLog entry for sim/rx change. 2021-04-09 11:39:00 -03:00
Luis Machado
ed29efbd17 [sim,rx] Silence warning that turns into a build error
On a 32-bit build, I ran into the following:

sim/rx/fpu.c:789:6: error: "*((void *)&a+8)" may be used uninitialized in this function [-Werror=maybe-uninitialized]
rv = fp_implode (&a);

To silence this, just initialize the struct with 0's.

sim/rx/ChangeLog:

2021-04-09  Luis Machado  <luis.machado@linaro.org>

	* fpu.c (rxfp_itof): Initialize structure.
2021-04-09 09:17:32 -03:00
Tom Tromey
06a88b3b39 Avoid sequence point warning in h8300 sim
GCC gives a -Wsequence-point warning for this code in the h8300 sim.
The bug is that memory_size is both assigned and used in the same
expression.  The fix is to assign after the print.

sim/h8300/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* compile.c (init_pointers): Fix sequence point warning.
2021-04-08 15:15:59 -06:00
Tom Tromey
32a046ab0d Add system includes in sim
This updates various parts of the sim to include missing system
headers.  I made the includes unconditional, because other parts of
the tree are already doing this.

2021-04-08  Tom Tromey  <tom@tromey.com>

	* traps.c: Include stdlib.h.
	* cris-tmpl.c: Include stdlib.h.

sim/erc32/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* func.c: Include sys/time.h.

sim/frv/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* traps.c: Include stdlib.h.
	* registers.c: Include stdlib.h.
	* profile.c: Include stdlib.h.
	* memory.c: Include stdlib.h.
	* interrupts.c: Include stdlib.h.
	* frv.c: Include stdlib.h.
	* cache.c: Include stdlib.h.

sim/iq2000/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* iq2000.c: Include stdlib.h.

sim/m32r/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* traps.c: Include stdlib.h.
	* m32r.c: Include stdlib.h.

sim/ppc/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* emul_unix.c: Include time.h.
2021-04-08 14:34:42 -06:00
Tom Tromey
81e6e8ae40 Do not use old-style definitions in sim
This changes all the non-generated (hand-written) code in sim to use
"new" (post-K&R) style function definitions.

2021-04-08  Tom Tromey  <tom@tromey.com>

	* bpf.c (bpf_def_model_init): Use new-style declaration.

sim/common/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* cgen-utils.c (RORQI, ROLQI, RORHI, ROLHI, RORSI, ROLSI): Use
	new-style declaration.

sim/erc32/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sis.c (run_sim, main): Use new-style declaration.
	* interf.c (run_sim, sim_open, sim_close, sim_load)
	(sim_create_inferior, sim_store_register, sim_fetch_register)
	(sim_info, sim_stop_reason, flush_windows, sim_do_command): Use
	new-style declaration.
	* help.c (usage, gen_help): Use new-style declaration.
	* func.c (batch, set_regi, set_rega, disp_reg, limcalc)
	(reset_stat, show_stat, init_bpt, int_handler, init_signals)
	(disp_fpu, disp_regs, disp_ctrl, disp_mem, dis_mem, event)
	(init_event, set_int, advance_time, now, wait_for_irq, check_bpt)
	(reset_all, sys_reset, sys_halt): Use new-style declaration.
	* float.c (get_accex, clear_accex, set_fsr): Use new-style
	declaration.
	* exec.c (sub_cc, add_cc, log_cc, dispatch_instruction, fpexec)
	(chk_asi, execute_trap, check_interrupts, init_regs): Use
	new-style declaration.
	* erc32.c (init_sim, reset, decode_ersr, mecparerror)
	(error_mode, decode_memcfg, decode_wcr, decode_mcr, sim_halt)
	(close_port, exit_sim, mec_reset, mec_intack, chk_irq, mec_irq)
	(set_sfsr, mec_read, mec_write, init_stdio, restore_stdio)
	(port_init, read_uart, write_uart, flush_uart, uarta_tx)
	(uartb_tx, uart_rx, uart_intr, uart_irq_start, wdog_intr)
	(wdog_start, rtc_intr, rtc_start, rtc_counter_read)
	(rtc_scaler_set, rtc_reload_set, gpt_intr, gpt_start)
	(gpt_counter_read, gpt_scaler_set, gpt_reload_set, timer_ctrl)
	(memory_read, memory_write, get_mem_ptr, sis_memory_write)
	(sis_memory_read): Use new-style declaration.

sim/frv/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sim-if.c (sim_open, frv_sim_close, sim_create_inferior): Use
	new-style declaration.

sim/h8300/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* compile.c (cmdline_location): Use new-style declaration.

sim/iq2000/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sim-if.c (sim_open, sim_create_inferior): Use new-style
	declaration.
	* iq2000.c (fetch_str): Use new-style declaration.

sim/lm32/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sim-if.c (sim_open, sim_create_inferior): Use new-style
	declaration.

sim/m32r/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sim-if.c (sim_open, sim_create_inferior): Use new-style
	declaration.
2021-04-08 14:34:42 -06:00
Luis Machado
b7f507caf0 Fix DTB generation mechanism and build failure
I ran into a build failure with --enable-targets=all due to the fact that
the moxie sim expects to be able to use the dtc tool.  If it isn't available,
the builds fails.

The following patch adds a prebuilt dtb file to the tree. That file is the one
that is used for installations.

The patch also enables (re-)generation of the dtb file through maintainer
mode, if it needs to be updated due to a change in the dts file.

Tested on aarch64-linux/x86_64-linux.

sim/moxie/ChangeLog:

2021-04-08  Luis Machado  <luis.machado@linaro.org>

	* Makefile.in (moxie-gdb.dtb): Add maintainer mode dependency.
	(install-dtb): Install prebuilt dtb file.
	* moxie-gdb.dtb: New prebuilt file.
2021-04-08 15:02:14 -03:00
Simon Marchi
2b8d134be4 sim: set ASAN_OPTIONS=detect_leaks=0 when running igen and opc2c
The igen/dgen and opc2c tools leak their heap-allocated memory (on
purpose) at program exit, which makes AddressSanitizer fail the tool
execution.  This breaks the build, as it makes the tool return a
non-zero exit code.

Fix that by disabling leak detection through the setting of that
environment variable.

I also changed the opc2c rules for m32c to go through a temporary file.
What happened is that the failing opc2c would produce an incomplete file
(probably because ASan exits the process before stdout is flushed).
This meant that further make attempts didn't try to re-create the file,
as it already existed.  A "clean" was therefore necessary.  This can
also happen in regular builds if the user interrupts the build (^C) in
the middle of the opc2c execution and tries to resume it.  Going to a
temporary file avoids this issue.

sim/m32c/ChangeLog:

	* Makefile.in: Set ASAN_OPTIONS when running opc2c.

sim/mips/ChangeLog:

	* Makefile.in: Set ASAN_OPTIONS when running igen.

sim/mn10300/ChangeLog:

	* Makefile.in: Set ASAN_OPTIONS when running igen.

sim/ppc/ChangeLog:

	* Makefile.in: Set ASAN_OPTIONS when running igen.

sim/v850/ChangeLog:

	* Makefile.in: Set ASAN_OPTIONS when running igen.

Change-Id: I00f21d4dc1aff0ef73471925d41ce7c23e83e082
2021-04-08 09:49:30 -04:00
Mike Frysinger
05385fc777 sim: testsuite: support exit 77 for unsupported tests
Exit status 77 is common (including the autotools world) to indicate
"skip this test".  Add support for mapping that to "unsupported" as
that's the closest in the dejagnu world.
2021-04-08 00:48:54 -04:00
Mike Frysinger
1bcee7fd87 sim: testsuite: skip tests when the port is disabled
If the port hasn't been enabled, don't try to run its tests.  Making
this dynamic simplifies the test harnesses and avoids duplicating a
bunch of target tuple checks.
2021-04-08 00:47:49 -04:00
Mike Frysinger
23cb7bac66 sim: testsuite: calculate $arch from $subdir
Since we require ports to use a matching subdir name in the testsuite
tree, we can use that to calculate the $arch value.
2021-04-08 00:45:07 -04:00
Jim Wilson
0592e80bcf Aarch64 sim fix for gcc-10 miscompilation.
This fixes a problem that occurs when compiled by gcc-10, as the code
is relying on undefined overflow behavior.  This is fixed by replacing
compares between 32-bit and 64-bit results with compares that just use
the 64-bit results with a cast.

	PR sim/27483
	* simulator.c (set_flags_for_add32): Compare uresult against
	itself.  Compare sresult against itself.
2021-04-07 18:51:52 -07:00
Simon Marchi
efd86e5b0f sim: m32c: opc2c: remove unused vlist variable
When building with AddressSanitizer, sim/m32c fails with:

./opc2c -l r8c.out /home/simark/src/binutils-gdb/sim/m32c/r8c.opc > r8c.c
sim_log: r8c.out

=================================================================
==3919390==ERROR: LeakSanitizer: detected memory leaks

    Direct leak of 4 byte(s) in 1 object(s) allocated from:
        #0 0x7ffff7677459 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145
        #1 0x55555555b3df in main /home/simark/src/binutils-gdb/sim/m32c/opc2c.c:658
        #2 0x7ffff741fb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

Fix the leak in main by removing the vlist variable, which seems unused.
2021-04-07 07:41:33 -04:00
Tom Tromey
53e123a578 Adjust location of readline in sim/erc32
sim/erc32 uses an obsolete path to the in-tree build of readline.
readline was moved into a subdirectory some time ago.  This patch
fixes the problem.  Tested by rebuilding.

sim/erc32/ChangeLog
2021-04-05  Tom Tromey  <tromey@adacore.com>

	* configure: Rebuild.
	* configure.ac (READLINE): Adjust in-tree value.
2021-04-05 06:53:35 -06:00
Faraz Shahbazker
5c6f091ae0 sim: mips: Add handlers to simulator monitor for unlink, lseek and stat
sim/mips/ChangeLog
	* interp.c (sim_monitor): Add switch entries for unlink (13),
	lseek (14), and stat (15).

Derived from patch authored by Steve Ellcey <sellcey@mips.com>
2021-04-04 16:44:21 +05:30
Mike Frysinger
26da232cbd sim: example-synacor: a simple implementation for reference
Provide a simple example simulator for people porting to new targets
to use as a reference.  This one has the advantage of being used by
people and having a fun program available for it.

It doesn't require a special target -- the example simulators can be
built for any existing port.
2021-04-03 16:19:16 -04:00
Mike Frysinger
a389375f5b sim: testsuite: integrate common tests into build
Now that we have the common automake build with support for build-time
programs working, we can integrate the common tests into the default
`make check` flow.
2021-04-03 15:34:13 -04:00
Mike Frysinger
a0e674c1ce sim: add preliminary support for --enable-targets
This doesn't actually create one `run` program like other projects,
but creates multiple `run-$arch` targets.  While it might not seem
that useful initially, this has some nice properties:
- Allows us to quickly build all sim targets in a single tree.
- Positions us better for converting targets over to a proper
  multitarget build+install.

We don't have the ability to actually run tests against them, but
that's due to a limitation in gas: it doesn't support multitarget.
If that ever changes, we should be able to turn on our tests too.
We can improve the test framework to fallback to a system toolchain
if available to help mitigate that.
2021-04-03 14:49:50 -04:00
Mike Frysinger
b6b1c79084 sim: igen: merge build into top level
This simplifies the build a bit (especially for deps in port subdirs),
and avoids recursive make.  This in turn speeds up the build, and sets
us up for multi-target.
2021-04-02 23:35:47 -04:00
Mike Frysinger
c2783492b6 sim: unify toolchain settings
The toplevel, common, and igen dirs all have their own code for
setting up toolchain settings.  Unify all of that in a new macro.
2021-04-02 23:31:14 -04:00
Martin Liska
caaf412e98 Fix microblaze sim build error
I see the following error for --target=microblaze-elf:

../../../sim/microblaze/interp.c: In function 'sim_engine_run':
../../../sim/microblaze/interp.c:147:39: error: passing argument 2 of 'get_insn_microblaze' from incompatible pointer type [-Werror=incompatible-pointer-types]
  147 |       op = get_insn_microblaze (inst, &imm_unsigned, &insn_type,
      |                                       ^~~~~~~~~~~~~
      |                                       |
      |                                       int *
In file included from ../../bfd/bfd.h:45,
                 from ../../../sim/microblaze/interp.c:24:
../../../sim/microblaze/../../opcodes/microblaze-dis.h:34:57: note: expected '_Bool *' but argument is of type 'int *'
   34 | extern enum microblaze_instr get_insn_microblaze (long, bool *,
      |                                                         ^

sim/microblaze/ChangeLog:

	* interp.c (sim_engine_run): Use bool instead of int.
2021-04-01 15:53:11 +02:00
Mike Frysinger
e7d9022ba8 sim: rename BUILD_LDFLAGS to LDFLAGS_FOR_BUILD
The rest of the binutils tree renamed this variable many years ago.
2021-03-13 11:21:13 -05:00
Mike Frysinger
c6c7769d9d sim: introduce {COMPILE,LINK}_FOR_BUILD
These use the same pattern as seen in the opcodes/ dir and in automake
in general (ish).  This helps simplify the boilerplate for building and
linking build-time code, and fixes some inconsistency in flag usage.

For rules that were compiling+linking in a single step, split them into
separate steps so we can apply the correct set of options.  This matches
automake behavior too.
2021-03-13 11:15:46 -05:00
Tom Tromey
8c379db285 Enable maintainer mode for sim
The sim's recently switch to using Automake caused a build failure for
me, because I didn't have the correct auto* tools in my path.
However, the rule in the tree is that this is not needed in general.
This patch adds a call to AM_MAINTAINER_MODE, to align the sim with
the way the rest of the tree works here.

sim/ChangeLog
2021-03-08  Tom Tromey  <tromey@adacore.com>

	* aclocal.m4, configure, Makefile.in: Rebuild.
	* configure.ac: Use AM_MAINTAINER_MODE.
2021-03-08 07:53:53 -07:00
Mike Frysinger
8c9b6e7689 sim: delete unused BUILD_LIBS setting
This hasn't been initialized anywhere for years.  It used to be for
passing in the path to libiberty, but that stopped happening long ago.
Delete it to simplify the build logic.
2021-03-08 00:54:37 -05:00
Mike Frysinger
2916e3e18f sim: igen: update options API
This local macro doesn't take any args, so adjust the API to match.
No one really noticed as this is behind code that is not normally
built, only when a dev specifically tries to compile it.
2021-03-07 22:03:00 -05:00
Jeff Law
f4df849f1d Regenerated 2021-03-07 16:03:49 -07:00
Mike Frysinger
6c57b87fc4 sim: testsuite: merge into toplevel automake
This allows us to delete most of our custom test logic,
and avoids a recursive make for minor speed up.
2021-03-07 15:54:53 -05:00
Mike Frysinger
6bddc3e8b4 sim: switch top level to automake
This doesn't gain us much by itself, but it sets us up for using more
features as we try to unify ports and avoid recursive make.
2021-03-07 13:41:45 -05:00
Mike Frysinger
9f34b60a43 sim: igen: drop config.h & header checking
While the configure script was checking for a bunch of headers, only
one of them was conditionally included in the source (unistd.h).  The
rest were always included.  Based on those usage this whole time, we
can reasonably assume that the build also has unistd.h.

All the other files including config.h never actually used any defines
from the header.
2021-02-28 03:32:47 -05:00
Mike Frysinger
88d7273afd sim: igen: delete more unused toolchain settings
This package doesn't build any archives or install programs.
2021-02-28 03:26:24 -05:00
Mike Frysinger
9ea3e81ca0 sim: igen: delete unused FOR_BUILD vars 2021-02-28 03:21:36 -05:00
Mike Frysinger
c25ea03dd6 sim: set up build-time compiler settings
Some sim dirs were already setting up CFLAGS_FOR_BUILD in inconsistent
ways.  Move it to a common place for reuse.
2021-02-28 03:14:59 -05:00
Mike Frysinger
a3e2cc64a6 sim: use AC_CHECK_TOOL to find ar
Rather than require $AR be set and then default to `ar`, use the
standard AC_CHECK_TOOL helper to find a good prefixed tool.  In
practice this shouldn't change much as we seem to have macros in
the tree that were already setting it up, but we shouldn't rely
on that implicitly.
2021-02-28 03:03:44 -05:00
Mike Frysinger
ebe9564b99 sim: require AC_PROG_CPP explicitly
All the scripts were using this implicitly already, so there's no real
change for them, but we want to call it explicitly as the CPP tool is
used to generate nltvals.def.
2021-02-28 02:19:51 -05:00
Mike Frysinger
ed30adf750 sim: delete unused SIM_EXTRA_LIBDEPS
This was last used 15 years ago, so clearly not important enough to
keep around.  Punt it.
2021-02-28 01:39:02 -05:00
Mike Frysinger
f8069d55c1 sim: delete redundant SIM_EXTRA_ALL
We don't need a variable to add a dependency to the "all" target, and
having one doesn't really add value.  Switch to the target directly for
the few ports that actually use this.
2021-02-27 23:50:52 -05:00
Mike Frysinger
760b3e8bc9 sim: common: split up acinclude.m4 into individual m4 files
This file is quite large and is getting unmanageable.  Split it apart
to follow aclocal best practices by putting one-macro-per-file.  There
shouldn't be any real functional changes here as can be seen in the
configure script regens.
2021-02-21 02:20:19 -05:00
Mike Frysinger
3e8bb3e934 sim: merge configure.tgt into configure.ac
One fewer file to worry about & manage.
2021-02-20 10:35:27 -05:00
Nelson Chu
5a9f5403c7 RISC-V: PR27158, fixed UJ/SB types and added CSS/CL/CS types for .insn.
* Renamed obsolete UJ/SB types and RVC types, also added CSS/CL(CS) types,

[VALID/EXTRACT/ENCODE macros]
BTYPE_IMM:            Renamed from SBTYPE_IMM.
JTYPE_IMM:            Renamed from UJTYPE_IMM.
CITYPE_IMM:           Renamed from RVC_IMM.
CITYPE_LUI_IMM:       Renamed from RVC_LUI_IMM.
CITYPE_ADDI16SP_IMM:  Renamed from RVC_ADDI16SP_IMM.
CITYPE_LWSP_IMM:      Renamed from RVC_LWSP_IMM.
CITYPE_LDSP_IMM:      Renamed from RVC_LDSP_IMM.
CIWTYPE_IMM:          Renamed from RVC_UIMM8.
CIWTYPE_ADDI4SPN_IMM: Renamed from RVC_ADDI4SPN_IMM.
CSSTYPE_IMM:          Added for .insn without special encoding.
CSSTYPE_SWSP_IMM:     Renamed from RVC_SWSP_IMM.
CSSTYPE_SDSP_IMM:     Renamed from RVC_SDSP_IMM.
CLTYPE_IMM:           Added for .insn without special encoding.
CLTYPE_LW_IMM:        Renamed from RVC_LW_IMM.
CLTYPE_LD_IMM:        Renamed from RVC_LD_IMM.
RVC_SIMM3:            Unused and removed.
CBTYPE_IMM:           Renamed from RVC_B_IMM.
CJTYPE_IMM:           Renamed from RVC_J_IMM.

* Added new operands and removed the unused ones,

C5: Unsigned CL(CS) immediate, added for .insn directive.
C6: Unsigned CSS immediate, added for .insn directive.
Ci: Unused and removed.
C<: Unused and removed.

bfd/
    PR 27158
    * elfnn-riscv.c (perform_relocation): Updated encoding macros.
    (_bfd_riscv_relax_call): Likewise.
    (_bfd_riscv_relax_lui): Likewise.
    * elfxx-riscv.c (howto_table): Likewise.
gas/
    PR 27158
    * config/tc-riscv.c (riscv_ip): Updated encoding macros.
    (md_apply_fix): Likewise.
    (md_convert_frag_branch): Likewise.
    (validate_riscv_insn): Likewise.  Also arranged operands, including
    added C5 and C6 operands, and removed unused Ci and C< operands.
    * doc/c-riscv.texi: Updated and added CSS/CL/CS types.
    * testsuite/gas/riscv/insn.d: Added CSS/CL/CS instructions.
    * testsuite/gas/riscv/insn.s: Likewise.
gdb/
    PR 27158
    * riscv-tdep.c (decode_ci_type_insn): Updated encoding macros.
    (decode_j_type_insn): Likewise.
    (decode_cj_type_insn): Likewise.
    (decode_b_type_insn): Likewise.
    (decode): Likewise.
include/
    PR 27158
    * opcode/riscv.h: Updated encoding macros.
opcodes/
    PR 27158
    * riscv-dis.c (print_insn_args): Updated encoding macros.
    * riscv-opc.c (MASK_RVC_IMM): defined to ENCODE_CITYPE_IMM.
    (match_c_addi16sp): Updated encoding macros.
    (match_c_lui): Likewise.
    (match_c_lui_with_hint): Likewise.
    (match_c_addi4spn): Likewise.
    (match_c_slli): Likewise.
    (match_slli_as_c_slli): Likewise.
    (match_c_slli64): Likewise.
    (match_srxi_as_c_srxi): Likewise.
    (riscv_insn_types): Added .insn css/cl/cs.
sim/
    PR 27158
    * riscv/sim-main.c (execute_i): Updated encoding macros.
2021-02-19 11:44:49 +08:00
Mike Frysinger
b0dcd7d832 sim: testsuite: push $arch out to targets
This is needed to move to automake & its dejagnu-provided logic,
and eventually by the unified sim logic.  The $arch is used only
to figure out which `run` program to use when running tests, and
as we move to a single top-level build, we can delete this and
use sim/run directly.
2021-02-13 12:14:25 -05:00
Mike Frysinger
9ee455572d sim: rx: mitigate fread warning
Current toolchains warn about unused result from fread, so mitigate
the edge case if fread returns short data.  It's not great, but it
gets things building again.
2021-02-13 02:44:36 -05:00
Mike Frysinger
136da8cd9c sim: switch to AC_CONFIG_MACRO_DIRS
Rather than hand maintain m4 includes in various autotool files,
use AC_CONFIG_MACRO_DIRS to declare the relevant search paths.
This simplifies the code, makes it more robust, and cleans out
unused logic from configure.
2021-02-13 00:24:20 -05:00
Mike Frysinger
652f80e07b sim: common: delete unused aclocal.m4
This was missed when we deleted the common/configure build logic.
2021-02-13 00:17:45 -05:00
Andrew Burgess
6bf99988c6 sim/rx: enable build with warnings
The rx simulator now has no build warnings.  Delete the call to
SIM_AC_OPTION_WARNINGS in configure.ac, the default yes will be
provided by SIM_AC_OUTPUT.

sim/rx/ChangeLog:

	* configure: Regenerate.
	* configure.ac (SIM_AC_OPTION_WARNINGS): Delete call.
2021-02-08 11:01:07 +00:00
Andrew Burgess
da9ecd6085 sim/rx: avoid pointer arithmetic on void * pointers
Pointer arithmetic on void * pointers results in a GCC warning.  Avoid
the warning by casting the pointer to its actual type earlier in the
function.

sim/rx/ChangeLog:

	* mem.c (mem_put_blk): Rename parameter, add cast from parameter
	type to local type.  Remove cast later in the function.
	(mem_get_blk): Likewise.
	* mem.h (mem_put_blk): Rename parameter to match definition.
	(mem_get_blk): Likewise.
2021-02-08 11:01:07 +00:00
Andrew Burgess
fab2b376e3 sim/rx: add some missing includes
In load.c there's some GCC warnings about undefined
functions (bfd_get_elf_phdr_upper_bound and bfd_get_elf_phdrs).  To
get the declarations of these functions include 'elf-bfd.h'.  This
headers also pulls in other elf related headers, like 'elf/internal.h'
and 'elf/common.h', so these no longer need to be explicitly included
from load.c.

In trace.c and include for trace.h is missing, again this results in
GCC warnings for missing function declarations.

sim/rx/ChangeLog:

	* load.c: Replace 'elf/internal.h' and 'elf/common.h' includes
	with 'elf-bfd.h' include.
	* trace.c: Add 'trace.h' include.
2021-02-08 11:01:07 +00:00
Andrew Burgess
ae41b4ce9f sim/rx: use PRIx64 in printf format string
Silence a GCC compiler warning by using PRIx64 in printf format string
instead of hard coded "llx".

sim/rx/ChangeLog:

	* reg.c (trace_register_changes): Use PRIx64 in printf format
	string.
2021-02-08 11:01:07 +00:00
Andrew Burgess
783a7b12d3 sim/rx: move some variable declarations to the start of the block
For sim code variables still need to be declared at the start of the
enclosing block.  This silences a few GCC warnings.

sim/rx/ChangeLog:

	* syscalls.c (rx_syscall): Move declaration of some variables to
	the start of the enclosing block.
	* trace.c (load_file_and_line): Likewise.
2021-02-08 11:01:07 +00:00
Andrew Burgess
b9fe995797 sim/rx: provide a format string for printf
Calling printf with the format being a non constant string results in
a GCC warning:

  warning: format not a string literal and no format arguments [-Wformat-nonliteral]

Provide a constant format string to printf in the few places this
warning is triggered.

sim/rx/ChangeLog:

	* reg.c (fpsw2str): Provide a format string to printf.
	(trace_register_changes): Likewise.
2021-02-08 11:01:07 +00:00
Andrew Burgess
4b42639636 sim/rx: delete an unused function
This function is not used.

sim/rx/ChangeLog:

	* err.c (execution_error_exit_all): Delete.
2021-02-08 11:01:07 +00:00
Andrew Burgess
73d4725f21 sim/rx: mark some functions as static
Some functions that should be marked static.

sim/rx/ChangeLog:

	* fpu.c (check_exceptions): Make static.
	* gdb-if.c (handle_step): Likewise.
	* mem.c (mem_put_byte): Likewise.
2021-02-08 11:01:07 +00:00
Andrew Burgess
1c3e93a41f sim/rx: fill in missing 'void' for empty argument lists
Ensure we have 'void' inside empty argument lists.  This was causing
several warnings for the rx simulator.

sim/rx/ChangeLog:

	* cpu.h (trace_register_changes): Add void parameter type.
	* err.c (ee_overrides): Likewise.
	* mem.c (mem_usage_stats): Likewise.
	(e): Likewise.
	* reg.c (stack_heap_stats): Likewise.
	* rx.c (pop): Likewise.
	(poppc): Likewise.
	(decode_opcode): Likewise.
	* syscalls.c (arg): Likewise.
2021-02-08 11:01:07 +00:00
Andrew Burgess
93a01471f3 sim/rx: fix an issue where we try to modify a const string
While experimenting with switching on warnings for the rx simulator I
discovered this bug.  In sim_do_command we get passed a 'const char *'
argument.  We create a copy of this string to work with locally, but
then while processing this we accidentally switch back to reference
the original string.

sim/rx/ChangeLog:

	* gdb-if.c (sim_do_command): Work with a copy of the command.
2021-02-08 11:01:07 +00:00
Andrew Burgess
0309f9549d sim/rx: define sim_memory_map
The rx simulator doesn't define sim_memory_map and so fails to link
with GDB.  Define it now to return NULL, this can be extended later to
return an actual memory map if anyone wants this functionality.

sim/rx/ChangeLog:

	* gdb-if.c (sim_memory_map): New function.
2021-02-08 11:01:07 +00:00
Mike Frysinger
7a9bd3b4e2 sim: erc32/m32c/rl78: add sim_memory_map stub for gdb
These ports don't use the common sim core, so they weren't providing
a sim_memory_map for gdb, so they failed to link with the new memory
map logic added for the sim.  Add stubs to fix.
2021-02-06 12:15:34 -05:00
Mike Frysinger
4c0d76b9c4 sim: watchpoints: use common sim_pc_get
Few arches implement STATE_WATCHPOINTS()->pc while all of them implement
sim_pc_get.  Lets switch the sim-watch core for monitoring pc events to
the sim_pc_get API so this module works for all ports, and then we can
delete this old back channel of snooping in the port's cpu state -- the
code needs the pointer to the pc storage so that it can read out bytes
and compare them to the watchrange.

This also fixes the logic on multi-cpu sims by removing the limitation
of only being able to watch CPU0's state.
2021-02-06 12:12:51 -05:00
Mike Frysinger
cd89c53f6d sim: add ChangeLog entries for last commits 2021-02-06 12:07:08 -05:00
Mike Frysinger
8e25beb4af sim: igen: drop libiberty linkage
This dir doesn't use anything from libiberty, so drop the linkage.
2021-02-06 12:01:40 -05:00
Mike Frysinger
7a36eeea26 sim: common: switch AC_CONFIG_HEADERS
The AC_CONFIG_HEADER macro is long deprecated, so switch to the
newer form.  This also gets rid of the position limitation, and
drops support for an argument to SIM_AC_COMMON which we haven't
used anywhere.
2021-02-06 12:00:42 -05:00
Mike Frysinger
aa09469fc6 sim: drop use of bfd/configure.host
These settings might have made sense in darker compiler times, but I
think they're largely obsolete now.  Looking through the values that
get used in HDEFINES, it's quite limited, and configure itself should
handle them.  If we still need something, we can leverage standard
autoconf macros instead, after we get a clear user report.

TDEFINES was never set anywhere and was always empty, so prune that.
2021-02-06 10:56:11 -05:00
Mike Frysinger
04b4939b03 gdb: riscv: enable sim integration
Now the simulator can be loaded via gdb using "target sim".
2021-02-04 19:15:17 -05:00
Mike Frysinger
b9249c461c sim: riscv: new port
This is a hand-written implementation that should have fairly complete
coverage for the base integer instruction set ("i"), and for the atomic
("a") and integer multiplication+division ("m") extensions.  It also
covers 32-bit & 64-bit targets.

The unittest coverage is a bit weak atm, but should get better.
2021-02-04 19:02:19 -05:00
Mike Frysinger
6451541244 sim: cgen-trace: tweak printf call
GCC warns that we pass a non-string literal as the format string,
so add an explicit "%s" to make it happy.
2021-01-31 17:31:44 -05:00
Mike Frysinger
bccec180ce sim: bpf: fix mainloop extract call
The extract function takes the argbuf, not the scache.
2021-01-31 17:19:38 -05:00
Mike Frysinger
ba2f0de216 sim: bpf/or1k: fix CGEN_TRACE_EXTRACT name
We renamed these years ago, but it looks like the cgen core missed the
TRACE_EXTRACT function, so these new ports still used the incompatible
common name.  Fix those ports to use the right func.
2021-01-31 17:08:49 -05:00
Stafford Horne
5bc4f5ca15 sim: cgen-accfp: Fix pointer sign warnings
When compiling we get the following warnings:

  common/cgen-accfp.c: In function 'fixsfsi':
  common/cgen-accfp.c:370:18: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign]
     sim_fpu_to32i (&res, &op1, sim_fpu_round_near);
                    ^
  common/cgen-accfp.c: In function 'fixdfsi':
  common/cgen-accfp.c:381:18: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign]
     sim_fpu_to32i (&res, &op1, sim_fpu_round_near);
                    ^
2021-01-31 15:26:58 -05:00
Mike Frysinger
5f05936d9b sim: v850: cleanup build warnings
This port only had one minor warning left in it, so fix it and then
enable -Werror behavior by deleting the macro call.  We'll use the
common default now (which is -Werror).
2021-01-31 15:19:16 -05:00
Mike Frysinger
44b30b7f0e sim: v850: fix handling of SYS_times
My recent rewrite of the nltvals generator fixed a bug where SYS_times
was not being exported for v850.  But that in turn uncovered this bug
where the SYS_times codepath had a compile error.
2021-01-31 15:15:33 -05:00
Mike Frysinger
3c811346e9 sim: moxie: cleanup build warnings
This port only had one minor warning left in it, so fix it and then
enable -Werror behavior by deleting the macro call.  We'll use the
common default now (which is -Werror).
2021-01-31 12:06:29 -05:00
Mike Frysinger
9a7ba4aa0e sim: common: change gennltvals helper to Python
This tool is only run by developers and not in a release build,
so rewrite it in Python to make it more maintainable.
2021-01-30 20:17:46 -05:00
Mike Frysinger
683b8d961e sim: m68hc11: fix printf size warnings
GCC complains %llu is wrong for signed64, so switch to PRIi64.
2021-01-30 10:40:26 -05:00
Mike Frysinger
b9e016f517 sim: m68hc11: localize a few functions
These are only used in this file and lack prototypes, so gcc
complains about it.  Add static everywhere to clean that up.
2021-01-30 10:28:38 -05:00
Mike Frysinger
fb8d4e59af sim: m68hc11: tweak printf-style funcs
GCC complains that we past non-string literals to a printf style func,
so put a %s in here to keep it quiet.
2021-01-30 10:25:04 -05:00
Mike Frysinger
ee64caae5b sim: m68hc11: include stdlib.h for prototypes
These files use abort() & strtod(), so include stdlib.h for them.
2021-01-30 10:21:15 -05:00
Mike Frysinger
d4e3adda12 sim: watchpoints: change sizeof_pc to sizeof(sim_cia)
Existing ports already have sizeof_pc set to the same size as sim_cia,
so simply make that part of the core code.  We already assume this in
places by way of sim_pc_{get,set}, and this is how it's documented in
the sim-base.h API.

There is code to allow sims to pick different register word sizes from
address sizes, but most ports use the defaults for both (32-bits), and
the few that support multiple register sizes never change the address
size (so address defaults to register).  I can't think of any machine
where the register hardware size would be larger than the address word
size either.  We have ABIs that behave that way (e.g. x32), but the
hardware is still equivalent register sized.
2021-01-30 10:14:21 -05:00
Mike Frysinger
18d4b488f4 sim: profile: fix bucketing with 64-bit targets
When the target's PC is 64-bits, this shift expands into a range of
8 * 8 - 1 which doesn't work with 32-bit constants.  Force it to be
a 64-bit value all the time and let the compiler truncate it.
2021-01-30 01:15:04 -05:00
Mike Frysinger
88f68ee277 sim: m68hc11: stop making hardware conditional
This port doesn't build if these hardware modules are omitted, and
there's no reason we need to make it conditional at build time, so
always enable it.  The hardware devices only get turned on if the
user requests it at runtime via hardware settings.
2021-01-30 01:09:38 -05:00
Mike Frysinger
f4dd74915b sim: hw: replace fgets with getline
This avoids fixed sized buffers on the stack.
2021-01-30 01:07:58 -05:00
Mike Frysinger
481fac96bd sim: common: sort nltvals.def
This was largely already done, but I think people didn't quite notice.
2021-01-30 01:00:07 -05:00
Mike Frysinger
008a02e36d sim: readd myself as a maintainer 2021-01-29 22:11:45 -05:00
Maciej W. Rozycki
c651f0a614 MAINTAINERS: Update my e-mail address
binutils/
	* MAINTAINERS: Update my e-mail address.

	gdb/
	* MAINTAINERS: Update my e-mail address.

	sim/
	* MAINTAINERS: Update my e-mail address.
2021-01-22 00:10:39 +00:00
Mike Frysinger
c65ca138c4 sim: ppc: update version script usage
This matches the changes in the common code.
2021-01-19 10:54:06 -05:00
Mike Frysinger
0e7620dcdc sim: bfin: delete accidental ADI copyright
This wasn't supposed to be in here when it was first merged as we
had specifically disabled it for all the tests (and ADI has papers
in place w/the FSF).  Clean up this one.
2021-01-18 21:30:12 -05:00
Mike Frysinger
f89f33e57c sim: common: simplify version script
We don't use the host & target aliases, so don't bother emitting them.
2021-01-18 12:25:57 -05:00
Mike Frysinger
5e25901fcc sim: common: delete configure & Makefile
This was mostly orphaned a while back, but left behind so people could
still run `make headers`.  Merge that one target to the top sim dir and
delete all the build logic.  This should avoid confusing people further.
2021-01-18 12:23:18 -05:00
Mike Frysinger
4cfcd3b333 sim: common: modernize gennltvals.sh
It's not 1996 anymore, so stop writing shell code like it is, and
rewrite it with modern POSIX shell standards.  This makes it much
more user friendly.

Then regenerate the file with latest newlib sources to verify.
2021-01-18 12:19:19 -05:00
Mike Frysinger
1368b914e9 sim: testsuite: flatten tree
Now that all port tests live under testsuite/sim/*/, and none live
in testsuite/ directly, flatten the structure by moving all of the
dirs under testsuite/sim/ to testsuite/ directly.

We need to stop passing --tool to dejagnu so that it searches all
dirs and not just ones that start with "sim".  Since we have no
other dirs in this tree, and no plans to add any, should be fine.
2021-01-15 19:18:34 -05:00
Mike Frysinger
bb3eddb5bd sim: testsuite: delete configure script
Now that we've moved all ports to dejagnu & testsuite/sim/, the only
thing the testsuite/configure script has been doing is filling in the
sim_arch field in the testsuite/Makefile.  We can simply let the top
sim/configure script do that for us now.  This simplifies & speeds up
the build a bit by killing an entire configure script.
2021-01-15 01:51:11 -05:00
Mike Frysinger
29fd199ed8 sim: d10v: relocate tests & clean up test harness
This is the only target using a dir directly under testsuite/.  All
others use sim/<arch>/ instead.  Relocate it so all targets look the
same, and so we can leverage the common test harness.

We drop loop.s in the process because it was never referenced and
was just 2 lines of code.

All other test files are moved & have directives added to the top so
that the test harness can invoke them correctly.
2021-01-15 01:49:23 -05:00
Mike Frysinger
137d6efd8a sim: mips: delete empty stub test dir
No tests were ever added in here in the ~22 years since it was first
created.  Seems unlikely any tests will be added at this rate, and
the sim/mips/ testdir already has some (light) coverage for this
target.  So punt the tree.
2021-01-15 01:46:51 -05:00
Mike Frysinger
89bfc2a429 sim: frv: clean up redundant test coverage
The frv-elf subdir contained five tests:
* cache: A cache test of some sort.
* exit47: A program to test exit status of 47 from sim.
* grloop: Some basic limited loop test program.
* hello: Standard "hello world" output program.
* loop: An infinite loop program.

The loop.s test is never referenced anywhere, and is all of 2 lines.
Anyone who really needs a while(1); test case and re-implement it
themselves locally.

The cache.s code isn't referenced anywhere because it requires some
custom args to the run program, and when this testcase was added, we
didn't have any support for that.  We do now, so we can add a header
to enable that.  Turns out the code crashes even with those, so turn
around and mark it xfail.  Maybe someone someday will care.

That leaves the small exit47, grloop, and hello tests.  Now that the
sim test harness supports testing for custom exit status, we can move
them all to sim/frv/ to maintain test coverage.

The remaining differences between frv-elf & sim/frv are:
* frv-elf/ runs for frv-*-elf while sim/frv/ runs for frv*-*-*.
* frv-elf/ runs "*.s" files while sim/frv/ only has .cgs and such.

On closer inspection, these are also meaningless distinctions:
* There is nothing specific to the tests that require an *-elf
  target.  Normally that would mean newlib+libgloss type stuff,
  but there's no such requirement in frv-elf/.
* The ".s" suffix is the standard "this is an assembly file" suffix.
  Since FRV is a CGEN target, we can reuse the existing convention of
  ".ms" to mean "miscellaneous .s" as in "this is an assembly file,
  and run/bucket its test results in the miscellaneous category".

So moving frv-elf/{cache,exit47,grloop,hello}.s to sim/frv/*.ms makes
sense and simplifies things quite a bit for the target while also
slightly increasing the coverage for some tuples.
2021-01-15 01:43:47 -05:00
Mike Frysinger
7cf91a2481 sim: m32r: clean up redundant test coverage
The m32r-elf subdir contained three tests:
* exit47: A program to test exit status of 47 from sim.
* hello: Standard "hello world" output program.
* loop: An infinite loop program.

There's already a sim/m32r/hello.ms test that does exactly the same
thing as m32r-elf/hello.s, so we can delete that.

The loop.s test is never referenced anywhere, and is all of 2 lines.
Anyone who really needs a while(1); test case and re-implement it
themselves locally.

That leaves the single exit47 test.  Now that the sim test harness
supports testing for custom exit status, we can easily move that to
sim/m32r/exit47.ms to maintain test coverage.

The remaining differences between m32r-elf & sim/m32r are:
* m32r-elf/ runs for m32r-*-elf while sim/m32r/ runs for m32r*-*-*.
* m32r-elf/ runs "*.s" files while sim/m32r/ runs "*.ms" files.

On closer inspection, these are also meaningless distinctions:
* There is nothing specific to the tests that require an *-elf
  target.  Normally that would mean newlib+libgloss type stuff,
  but there's no such requirement in m32r-elf/.
* The ".s" suffix is the standard "this is an assembly file"
  suffix.  Turns out ".ms" is just how sim/m32r/ (and a few other
  CGEN based targets) categorize/bucket test cases.  It simply
  means "miscellaneous .s" as in "this is an assembly file, and
  run/bucket its test results in the miscellaneous category".

So moving m32r-elf/exit47.s to sim/m32r/exit47.ms makes sense and
simplifies things quite a bit for the target while also slightly
increasing the coverage for some tuples.
2021-01-15 01:34:57 -05:00
Mike Frysinger
37a9c3a53e sim: testsuite: allow tests to declare expected exit status
Some tests want to verify they can control the exit status, and
allowing any non-zero value would allow tests to silently fail:
if it crashed & exited 1, or forced all non-zero to 1, then we
wouldn't be able to differentiate with a test exiting with a
status like 47.

Extend the test harness to allow tests to declare their expected
exit status that would be defined as a "pass".  This requires a
small tweak to the sim_run API to return the status directly, but
that shouldn't be a big deal as it's only used by sim code.
2021-01-15 01:33:35 -05:00
Mike Frysinger
54780889e9 sim: h8300: drop separate eightbit memory buffer
The h8300 sim has its own implementation for memory handling that I'd
like to replace with the common sim memory code.  However, it's got a
weird bit of code it calls "eightbit mem" that makes this not as easy
as it would otherwise be.  The code has this comment:
/* These define the size of main memory for the simulator.

   Note the size of main memory for the H8/300H is only 256k.  Keeping it
   small makes the simulator run much faster and consume less memory.

   The linker knows about the limited size of the simulator's main memory
   on the H8/300H (via the h8300h.sc linker script).  So if you change
   H8300H_MSIZE, be sure to fix the linker script too.

   Also note that there's a separate "eightbit" area aside from main
   memory.  For simplicity, the simulator assumes any data memory reference
   outside of main memory refers to the eightbit area (in theory, this
   can only happen when simulating H8/300H programs).  We make no attempt
   to catch overlapping addresses, wrapped addresses, etc etc.  */

I've read the H8/300 Programming Manual and the H8/300H Software Manual
and can't find documentation on it.  The closest I can find is the bits
about the exception vectors, but that sounds like a convention where the
first 256 bytes of memory are used for a special purpose.  The sim will
actually allocate a sep memory buffer of 256 bytes and you address it by
accessing anywhere outside of main memory.  e.g. I would expect code to
access it like:
	uint32_t *data = (void *)0;
	data[0] = reset_exception_vector;
not like the sim expects like:
	uint8_t *data = (void *)0x1000000;
	data[0] = ...;

The gcc manual has an "eightbit_data" attribute:
	Use this attribute on the H8/300, H8/300H, and H8S to indicate that
	the specified variable should be placed into the eight-bit data
	section. The compiler generates more efficient code for certain
	operations on data in the eight-bit data area. Note the eight-bit
	data area is limited to 256 bytes of data.

And the gcc code implies that it's accessed via special addressing:
   eightbit_data: This variable lives in the 8-bit data area and can
   be referenced with 8-bit absolute memory addresses.

I'm fairly certain these are referring to the 8-bit addressing modes
that allow access to 0xff00 - 0xffff with only an 8-bit immediate.
They aren't completely separate address spaces which this eightbit
memory buffer occupies.

But the sim doesn't access its eightbit memory based on specific insns,
it does it purely on the addresses requested.

Unfortunately, much of this code was authored by Michael Snyder, so I
can't ask him :(.  I asked Renesas support and they didn't know:
https://renesasrulz.com/the_vault/f/archive-forum/6952/question-about-eightbit-memory

So I've come to the conclusion that this was a little sim-specific hack
done for <some convenience> and has no relation to real hardware.  And
as such, let's drop it until someone notices and can provide a reason
for why we need to support it.
2021-01-13 21:54:00 -05:00
Mike Frysinger
d9b1deff13 sim: watch: add basic default handler that traps
The default watchpoint handler is NULL.  That means any port that
sets the STATE_WATCHPOINTS->pc field will crash if you try to use
the --watch options but don't configure the interrupt handler.  In
the past, you had to setup STATE_WATCHPOINTS->pc if you wanted to
support PC profiling, and while that was fixed a while ago, we have
a lot of ports who still configure it.

We already add a default set of interrupts (just "int") if the port
doesn't define any.  Let's also add a default handler that raises a
SIGTRAP.  When connected to gdb, this is a breakpoint which is what
people would expect.  When running standalone, it'll abort the sim,
but it's unclear whether there's anything better to do there.  This
really is just to make the watchpoint module more usable out of the
box for most ports with very little setup, at least inside of gdb.
2021-01-13 21:53:11 -05:00
Mike Frysinger
c54f3efdc2 sim: watch: fix range expression processing
The code supports a <start>[,<end>] syntax, but the logic for handling
the <end> check was broken: it would detect the first byte was ",", but
then include that in the strtoul call meaning the result is always 0.
Further, it (re)assigned to arg0 when it meant arg1 which means this
code always processed a range expression as 0,0.  Oops.
2021-01-13 05:52:51 -05:00
Mike Frysinger
62fe7512a7 sim: watch: fix pc watchpoints on little endian host systems
My change 1ac72f0659 ("sim: convert to
bfd_endian") subtly broke the watchpoint module on little endian host
systems.  The old code used 0 to mean "whatever the host endian is",
and while that was changed to use BFD_ENDIAN_UNKNOWN, this caller was
missed.  Since its API used an int instead of an enum, the coercion
from 0 to the BFD endian enum was silently missed, and 0 happens to
be BFD_ENDIAN_BIG.

Instead of restoring the old logic by passing in BFD_ENDIAN_UNKNOWN,
we know the right host endian at compile time, so use that directly.
2021-01-13 05:52:51 -05:00
Mike Frysinger
e998918e98 sim: or1k: fix mixing of code & decl warning
Use the correct style of declaring variables at top of scope.
This fixes a few compiler warnings in the process.
2021-01-12 04:15:28 -05:00
Mike Frysinger
5e9e2f41eb sim: or1k: clean up stale build entries
This logic was migrated to the common code long ago so ports don't
need to declare them themselves.
2021-01-12 04:13:13 -05:00
Mike Frysinger
68895f7d7e sim: README-HACKING: clean up stale run references
The run.c interface was deleted long ago and everyone moved to nrun.c
(which is also the default), so no one needs to declare this anymore.
2021-01-12 04:13:11 -05:00
Mike Frysinger
f220ef633c sim: common: use #error properly 2021-01-12 03:51:44 -05:00
Mike Frysinger
f631b79abe sim: or1k: delete redundant SIM_AC_OPTION_INLINE call
This was merged into the common code a long time ago, so ports
shouldn't be calling this themselves.
2021-01-12 03:36:08 -05:00
Mike Frysinger
254c3783fe sim: tests: get common tests working again
These were written with 32-bit host assumptions baked into it.
Simplify the printf formats to use ll length modifier as it's
in C11 rather than trying to manually break it up into two,
and cleanup some of the casts to stop assuming sizeof(long) is
the same as sizeof(int).

We also have to add a few more includes for the various funcs
used in here.

The tests aren't compiled automatically still.  We can figure
that out later with more work.
2021-01-11 18:30:06 -05:00
Mike Frysinger
9c70334dee sim: always call SIM_AC_OPTION_WARNINGS
Now that all ports have opted in to this, we can require it in the
core.  It guarantees that new ports have them turned on, and defaults
to -Werror in the hopes that new ports keep their code clean from the
start.  We do this as a sep commit to make it clear that there are no
changes to existing ports as they've all explicitly called it already.
2021-01-11 09:18:27 -05:00
Mike Frysinger
5c1008a41f sim: call SIM_AC_OPTION_WARNINGS(no) in remaining ports
We want all ports to opt into extra warnings as the default compiler
settings lets a lot slide.  Opt all the ports that haven't already in
to the warning system.  None of them build with -Werror, so disable
that by default.  Hopefully someone finds these important enough to
start fixing at some point.
2021-01-11 09:13:11 -05:00
Mike Frysinger
a0c38f0d70 sim: or1k: fix include ordering with sim-main.h
Make sure config.h is included before C library headers otherwise the
later libiberty.h include gets confused about asprintf state leading
to warnings like:
common/sim-utils.c:330:9:
	warning: implicit declaration of function 'vasprintf';
	did you mean 'xvasprintf'? [-Wimplicit-function-declaration]
2021-01-11 08:29:18 -05:00
Mike Frysinger
90e123dd60 sim: common: fix printf formats
For 32-bit targets, %x happens to work for unsigned_word.  But for
64-bit targets, it's too small, and gcc throws an error.  Use the
right printf format define for them.
2021-01-11 08:27:40 -05:00
Mike Frysinger
933306703a sim: rl78: move storage out of header
This port declares its pc variable in a header and then includes
it multiple times.  This causes linker errors with newer gcc due
to the change in -fno-common behavior.  Move the storage to a C
file so we only have one instance of it in the final program.
2021-01-11 08:25:34 -05:00
Mike Frysinger
68ed285428 sim: clean up C11 header includes
Since we require C11 now, we can assume many headers exist, and
clean up all of the conditional includes.  It's not like any of
this code actually accounted for the headers not existing, just
whether we could include them.

The strings.h cleanup is a little nuanced: it isn't in C11, but
every use of it in the codebase will include strings.h only if
string.h doesn't exist.  Since we now assume the C11 string.h
exists, we'll never include strings.h, so we can delete it.
2021-01-11 08:05:54 -05:00
Mike Frysinger
a9fd212a24 sim: replace rindex with strrchr 2021-01-09 09:40:59 -05:00
Mike Frysinger
7eb99e5e27 sim: cr16/d10v: move storage out of header
These ports declare their State variable in a header and then include
multiple times.  This causes linker errors with newer gcc due to the
change in -fno-common behavior.  Move the storage to a C file so we
only have one instance of it in the final program.
2021-01-09 09:39:17 -05:00
Mike Frysinger
f074c07d8d sim: common: clean up asprintf includes a bit
Delete stale prototypes that libiberty.h already provides, and add
missing libiberty.h includes to files that use those functions.
2021-01-09 09:32:34 -05:00
Mike Frysinger
f8cab0b995 sim: sh64: delete port
Support for sh64 was dropped from bfd et al in 2018.  Without
that, the sim port is useless.  So clean up this code too.
2021-01-09 09:29:17 -05:00
Mike Frysinger
50df264dae sim: clean up stale AC_PREREQ refs
This was purged from the tree when we upgraded to autoconf-2.69,
but a few references in the sim tree were missed.
2021-01-09 09:27:29 -05:00
Mike Frysinger
bf470982f9 sim: enable -Werror by default for some arches
We've had this off for a long time because the sim code was way too
full of warnings for it to be feasible.  However, I've cleaned things
up significantly from when this was first merged, and we can start to
turn this around.

Change the macro to enable -Werror by default, and allow ports to opt
out.  New ports will get it automatically (and we can push back on
them if they try to turn it off).

Also turn it off for the few ports that still hit warnings for me.
All the rest will get the new default, and we'll wait for feedback
if/when new issues come up.
2021-01-09 09:19:37 -05:00
Mike Frysinger
f41464416a sim: pru: fix include ordering with sim-main.h
Make sure config.h is included before C library headers otherwise the
later libiberty.h include gets confused about asprintf state leading
to warnings like:
common/sim-utils.c:330:9:
	warning: implicit declaration of function 'vasprintf';
	did you mean 'xvasprintf'? [-Wimplicit-function-declaration]
2021-01-09 08:43:48 -05:00
Mike Frysinger
b5a4a01af4 sim: hw: rework code to avoid gcc warnings
Newer gcc thinks we might return a pointer to a stack buffer, but
we don't -- we strdup it before returning.  Rework the code to just
malloc the buffer from the start and avoid the stack+strdup.
2021-01-09 08:40:07 -05:00
Mike Frysinger
ce0be4070f sim: common: add missing stdlib.h for abort() 2021-01-09 02:45:14 -05:00
Mike Frysinger
46f900c065 sim: require a C11 compiler
With GDB requiring a C++11 compiler now, this hopefully shouldn't
be a big deal.  It's been 10 years since C11 came out, so should
be plenty of time to upgrade.

This will allow us to start cleaning up random header logic and
many of our non-standard custom types.
2021-01-08 15:45:42 -05:00
Mike Frysinger
f4cfa91741 sim: ppc: stub out sim_memory_map
Not clear how to implement this in the ppc-specific sim, so just
stub it out.  This is as good as it was previously.
2021-01-08 01:03:10 -05:00
Mike Frysinger
0f8e278da2 sim: ChangeLog: move arch-specific entries into the arch dir
We don't want arch-specific entries in the common ChangeLog files.
Most arches do this already, so clean up the recent additions, and
move some older entries down to help avoid confusing newcomers.
2021-01-07 12:22:33 -05:00
Mike Frysinger
e6c1dbbfe8 sim: cris: disable test that crashes the linker
PR ld/13900
Linking this test crashes the linker, so disable it.  The crash
was reported about 9 years ago but haven't made progress, so lets
avoid the failures in test runs.
2021-01-07 12:22:14 -05:00
Mike Frysinger
a39487c668 sim: cris: use -sim with C tests for cris-elf targets
Building the C tests with a cris-elf toolchain (gcc-10.2 &
newlib-4.1.0) currently fail due to warnings it emits:
cris-elf-ld: libc.a(lib_a-closer.o): in function `_close_r':
newlib/libc/reent/closer.c:47: warning: _close is not implemented and will always fail

This is because the default target for cris-elf is bare metal, not
the simulator.  For that, we need -sim.  So add it for elf targets.

We don't add it for all targets as the simulator (and testsuite)
run both libgloss programs as well as Linux userspace programs.
2021-01-07 12:21:48 -05:00
Mike Frysinger
bfc7d04afb sim: h8300: delete opcode caching
This is in preparation for converting h8300 over to the common memory
framework.  It's not clear how much of a speed gain this was providing
in the first place -- a naive test of ~400k insns (using shlr.s) shows
that this code actually slowed things down a bit.

If anyone really cares about h8300 anymore, they can migrate to the
common insn caching logic.
2021-01-07 12:21:12 -05:00
Mike Frysinger
e904f56d02 gdb/sim: add support for exporting memory map
This allows gdb to quickly dump & process the memory map that the sim
knows about.  This isn't fully accurate, but is largely limited by the
gdb memory map format.  While the sim supports RWX bits, gdb can only
handle RW or RO regions.
2021-01-07 12:18:59 -05:00
Mike Frysinger
9446bcf6be fix paths in ChangeLog 2021-01-07 01:27:06 -05:00
Mike Frysinger
1861f7cfbf sim: cris: fix C tests with newer toolchains
Make sure we include unistd.h for getpid prototypes to fix build
warnings/errors with newer compilers & C libraries.

Doing that for close in openpf highlights these were using the
wrong function -- need to use fclose on FILE*, not close.

These tests pass again with a cris-elf toolchain.
2021-01-07 01:19:49 -05:00
Mike Frysinger
865288236d sim: fr30: delete unused testsuite
Looking through the history, it doesn't seem like the fr30 port was
ever merged.  There used to be a testsuite/fr30-elf/ dir, but that
was punted back in 2005 as being dead too.  Since there's no refs
and the dir hasn't been touched since 1999, lets assume no one will
ever notice or care.
2021-01-05 19:29:46 -05:00
Mike Frysinger
c004e77f7d sim: testsuite: delete unused Make-common.in file
This seems like it was meant to unify arch test Makefiles, but
that never happened, and we've instead unified using dejagnu.
2021-01-05 19:29:11 -05:00
Mike Frysinger
a2f8e947a8 sim: h8300: fix test mach markers
These tests all fail to assemble when targeting the h8300 or h8300h
cpu variants with errors like:
rotl.s:242: Warning: Opcode `rotl.b' with these operand types not available in H8/300H mode
rotl.s:242: Error: invalid operands

It's been this way for years and no one seems to care, so disable
them for those targets since the assembler thinks it's impossible.
2021-01-05 19:26:33 -05:00
Mike Frysinger
0c7f5bd08c sim: h8300: simplify testsuite runner
We don't need to manually enumerate every test.  Use a glob function
like every other port and rely on the (already existing) #mach headers
in each file to filter out targets we don't care about.
2021-01-05 19:26:17 -05:00
Mike Frysinger
3d52735bab sim: include stdlib.h for atoi()
Make sure the files using atoi() include stdlib.h for its prototype.
These files were relying on it being included implicitly by others
which isn't guaranteed, and newer toolchains produce warnings.
2021-01-04 20:17:37 -05:00
Mike Frysinger
9416af6e7d sim: stdlib.h for abs()
Make sure the files using abs() include stdlib.h for its prototype.
These files were relying on it being included implicitly by others
which isn't guaranteed, and newer toolchains produce warnings.
2021-01-04 20:13:10 -05:00
Mike Frysinger
dfb856ba26 sim: update bug URI to https:// 2021-01-04 18:14:37 -05:00
Mike Frysinger
babd2ee15d sim: common: version: add build & homepage info when interactive
This mirrors gdb behavior of dumping extra info when being run in
interactive mode.  It also gives us an excuse to use the otherwise
unused sim_print_config.
2021-01-04 18:10:40 -05:00
Mike Frysinger
2b667e3297 sim: common: use sim_config_print name
Meant to push this variant where naming preference is given to the
module the code resides in rather than the operation it performs.
2021-01-04 18:10:40 -05:00
Mike Frysinger
19b1c38562 sim: common: add a version output helper w/copyright+license info
This mirrors the existing sim_print_help function, and the behavior
of all other GNU tools with their --version.
2021-01-04 17:41:23 -05:00
Mike Frysinger
dbed468bcb sim: common: rename sim_print_config
print_sim_config has never been used anywhere, so rename it to follow
the sim_* naming style for all other symbols we export.
2021-01-04 17:35:20 -05:00
Mike Frysinger
0ede24f2c4 sim: common: add align_{up,down} to match gdb
We have ALIGN_{8,16,PAGE} and FLOOR_PAGE macros (where PAGE is defined as
4k) which were imported from the ppc sim.  But no other sim utilizes these
and hardcoding the sizes in the name is a bit limiting.

Let's delete these and import the two general macros that gdb uses:
	align_up(addr, bytes)
	align_down(addr, bytes)

This in turn allows us to cut over the Blackfin code immediately.
2021-01-02 20:55:21 -05:00