Commit Graph

4471 Commits

Author SHA1 Message Date
Mike Frysinger
13b0d6e5a2 sim: callback: add missing cb_target_to_host_signal
There's been a prototype for this forever, but the implementation was
missing.  Probably because there weren't any callers, but we'll start
using it to implement the kill function.
2021-06-22 19:38:48 -04:00
Mike Frysinger
cc40b4f2a3 sim: callback: generate signal map
We've been generating the syscall/errno/open maps, but not the signal
map, even though we've been including them in the source constants.
2021-06-22 19:38:09 -04:00
Mike Frysinger
c45cffdbe1 sim: callback: add a getpid interface
Rather than hit the OS interface directly, use the existing callback
layer so the instantiator can decide behavior.
2021-06-22 19:36:28 -04:00
Mike Frysinger
e173c80fbb sim: rx: merge with common configure script
Move the unique configure flag to acinclude.m4 so the common code
can include it, then delete the rx configure logic entirely.
2021-06-22 19:29:28 -04:00
Mike Frysinger
36bb57e40c sim: drop configure scripts for simple ports
These ports only use the pieces that have been unified, so we can
merge them into the common configure script and get rid of their
unique one entirely.

We still compile & link separate run programs, and have dedicated
subdir Makefiles, but the configure script portion is merged.
2021-06-22 19:26:13 -04:00
Mike Frysinger
456ef1c1d4 sim: unify hardware settings
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-21 22:20:18 -04:00
Mike Frysinger
be0387eed0 sim: hw: rework configure option & device selection
The sim-hardware configure option allows builders to select a set of
device models to enable.  But this seems like unnecessary overkill:
the existence of individual device models doesn't affect performance
at all as they are only enabled at runtime if the config uses them,
and individually these are all <5KB a piece.  Stripping off a total
of ~50KB from a ~1MB binary doesn't seem useful, and it's extremely
unlikely anyone will ever bother.

So let's simplify the configure/make logic by turning sim-hardware
into a boolean option like many of the other sim options.  Any ports
that have unique device models will declare them in their Makefile
instead of at configure time.  This will allow us to (eventually)
unify the setting into the common dir.
2021-06-21 21:36:51 -04:00
Mike Frysinger
1b40d569a8 sim: cris: clean up printf & abort usage a bit
Inline the stats printf calls to avoid compiler warnings about
non-literal format strings.  This in turn highlights bad type
sizes being passed in, so fix the strings to use the right size
type.  This in turn highlights the rest of the func using casts
rather than the right type directly, so adjust all of those.

Finally, replace a few abort+sim_engine_halt calls with the
common sim_engine_abort.  This provides good output while still
aborting as we want.
2021-06-20 23:45:24 -04:00
Mike Frysinger
4488e43c49 sim: rx: scope the unique configure flag
This will make it possible to merge into the common configure by
making sure we never collide with other arches.
2021-06-20 01:13:14 -04:00
Mike Frysinger
3eda63f2e4 sim: delete SIM_AC_COMMON macro
Now that we've moved all content out to the common file, this is
empty and can be deleted it entirely.
2021-06-20 00:39:38 -04:00
Mike Frysinger
3a829bc50c sim: unify general maintainer settings
Move these options up to the common dir so we only test & export
them once across all ports.  This takes a page from the cgen maint
logic to make $(MAINT) work for non-automake Makefiles which will
allow us to merge it together.
2021-06-20 00:31:27 -04:00
Mike Frysinger
1bf5c34239 sim: unify cgen maintainer settings
Move these options up to the common dir so we only test & export
them once across all ports.  It makes it available to targets that
aren't cgen-based, but those will just ignore the settings, so it
shouldn't be an issue.
2021-06-20 00:25:13 -04:00
Mike Frysinger
4ca8baee00 sim: m68hc11: fix unused function warnings with -O0
Mark these functions as unused in case they don't get inlined when
building with -O0.
2021-06-20 00:17:08 -04:00
Mike Frysinger
d73f39ee43 sim: move sim-inline to the common code
This will allow us to build the common code with the same inline
settings as the arch subdirs, and only do the test once.
2021-06-20 00:12:11 -04:00
Simon Marchi
57a922a598 sim: move UNUSED before TYPE in SIM_ENDIAN_INLINE's definition
I get this when building with gcc 11:

      CC       common/common_libcommon_a-sim-load.o
    In file included from /home/simark/src/binutils-gdb/sim/common/sim-n-bits.h:27,
                     from /home/simark/src/binutils-gdb/sim/common/sim-bits.c:259,
                     from /home/simark/src/binutils-gdb/sim/common/sim-bits.h:599,
                     from /home/simark/src/binutils-gdb/sim/common/sim-basics.h:122,
                     from /home/simark/src/binutils-gdb/sim/common/sim-load.c:30:
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:27: error: 'offset_16' defined but not used [-Werror=unused-function]
       39 | #define offset_N XCONCAT2(offset_,N)
          |                           ^~~~~~~
    /home/simark/src/binutils-gdb/sim/../include/symcat.h:23:26: note: in definition of macro 'CONCAT2'
       23 | #define CONCAT2(a,b)     a##b
          |                          ^
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:18: note: in expansion of macro 'XCONCAT2'
       39 | #define offset_N XCONCAT2(offset_,N)
          |                  ^~~~~~~~
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:138:1: note: in expansion of macro 'offset_N'
      138 | offset_N (unsigned_N *x,
          | ^~~~~~~~

offset_N uses INLINE_SIM_ENDIAN, which uses UNUSED to put the "unused"
attribute.  However, it appears after the function's return type, which
seems to make it not apply to the function.  Moving it to before the
return type fixes the error.

Change all instances found in that file.

sim/common/ChangeLog:

	* sim-inline.h: Move UNUSED before TYPE.

Change-Id: Ide20106683ed7a9ebf35d484dabf70b309cb1ba6
2021-06-19 22:49:52 -04:00
Mike Frysinger
a979f2a07a sim: unify dtc tool checks
Only one arch uses this currently, but others could too.  By moving
it up to the common checks, it'll also let us simplify the moxie code
significantly.
2021-06-19 22:43:56 -04:00
Mike Frysinger
54c47dfb68 sim: ppc: rename inline defines to match common code
Use the same basic names as the common sim inline logic so we can
merge the two.  We don't do that here, just prepare for it.

The common code seems to be based on the ppc version but with slightly
different names as it was cleaned up & generalized.  I *think* these
concepts are the same, so binding them together is OK, but maybe I'm
misreading them.  If so, can always tweak them later.
	REVEAL_MODULE  ->  H_REVEALS_MODULE
	INLINE_MODULE  ->  C_REVEALS_MODULE
2021-06-19 22:41:05 -04:00
Mike Frysinger
36842f65be sim: drop old BUILT_SRC_FROM_COMMON ref
The code that set & used this variable was deleted long ago,
but the clean target was missed.  Clean that up now.
2021-06-19 22:24:03 -04:00
Mike Frysinger
ce3ec98acd sim: unify gettext/intl probing logic
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-19 16:18:07 -04:00
Mike Frysinger
bc56166f66 sim: unify toolchain dependency logic
The common dir is already probing this info since it's using automake,
so pass it down to the subdirs so they don't have to probe it at all.
2021-06-19 16:07:31 -04:00
Mike Frysinger
d3562f83a7 sim: unify toolchain probing logic
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-19 16:01:37 -04:00
Mike Frysinger
b5689863bd sim: unify bfd library dependency testing logic
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-19 01:08:39 -04:00
Mike Frysinger
17a5da800d sim: mips: drop unused AC_PATH_X call
We don't use anything from X, so no sense in probing the env.
2021-06-19 01:03:20 -04:00
Mike Frysinger
07490bf81d sim: unify various library testing logic
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-19 01:01:21 -04:00
Mike Frysinger
47ce766a8b sim: unify -Werror build settings
Move these options up to the common dir so we only test & export
them once across all ports.  It also enables -Werror usage on the
common files we've been pulling out of arch subdirs.
2021-06-18 10:25:04 -04:00
Mike Frysinger
982c3a65ca sim: move -Werror disabling to Makefile
For the ports that still don't build with -Werror, rather than disable
the flag at configure time, do it at make time.  This will allow us to
unify these tests in the common sim configure script.
2021-06-18 10:15:15 -04:00
Mike Frysinger
3f8414df7a sim: create a makefile fragment to pass common settings down
As we merge settings from subdirs into the common configure, we
sometimes need to keep the settings working in both dirs.  Create
a makefile fragment to pass them down so we don't have to run the
checks twice.  For now, the file is empty, but we'll start moving
logic in shortly.
2021-06-18 10:11:58 -04:00
Mike Frysinger
1fef66b0dc sim: split sim-signal.h include out
The sim-basics.h is too big and includes too many things.  This leads
to some arch's sim-main.h having circular loop issues with defs, and
makes it hard to separate out common objects from arch-specific defs.
By splitting up sim-basics.h and killing off sim-main.h, it'll make
it easier to separate out the two.
2021-06-18 00:50:14 -04:00
Mike Frysinger
7039b29160 sim: drop core libiberty.h include
This doesn't need to be included for every sim file, so drop it.
Every C file that needs it seems to already include it.
2021-06-18 00:39:32 -04:00
Mike Frysinger
f9a4d54332 sim: overhaul & unify endian settings management
The m4 macro has 2 args: the "wire" settings (which represents the
hardwired port behavior), and the default settings (which are used
if nothing else is specified).  If none are specified, the arch is
expected to support both, and the value will be probed based on the
user runtime options or the input program.

Only two arches today set the default value (bpf & mips).  We can
probably let this go as it only shows up in one scenario: the sim
is invoked, but with no inputs, and no user endian selection.  This
means bpf will not behave like the other arches: an error is shown
and forces the user to make a choice.  If an input program is used
though, we'll still switch the default to that.  This allows us to
remove the WITH_DEFAULT_TARGET_BYTE_ORDER setting.

For the ports that set a "wire" endian, move it to the runtime init
of the respective sim_open calls.  This allows us to change the
WITH_TARGET_BYTE_ORDER to purely a user-selected configure setting
if they want to force a specific endianness.

With all the endian logic moved to runtime selection, we can move
the configure call up to the common dir so we only process it once
across all ports.

The ppc arch was picking the wire endian based on the target used,
but since we weren't doing that for other biendian arches, we can
let this go too.  We'll rely on the input selecting the endian, or
make the user decide.
2021-06-17 23:20:13 -04:00
Mike Frysinger
a49dd19e81 sim: ppc: avoid "PAGE_SIZE" name
This define is used for a particular target and depends on the
simulated CPU hardware.  It has no relation to the host CPU that
the sim is running on.  So rename the common "PAGE_SIZE" here to
better reflect its usage and avoid conflicts with system headers.
2021-06-17 19:05:59 -04:00
Mike Frysinger
209f108f73 sim: mn10300: tweak static inlines
Use INLINE2 instead of INLINE to fix builds when -O0 are used -- the
latter define is omitted at -O0 levels while the former is always
set to inline.  These helper funcs are used by defines in here but
the defines aren't always called.
2021-06-17 00:14:02 -04:00
Mike Frysinger
ef5058ae87 sim: split sim/callback.h include out
The sim-basics.h is too big and includes too many things.  This leads
to some arch's sim-main.h having circular loop issues with defs, and
makes it hard to separate out common objects from arch-specific defs.
By splitting up sim-basics.h and killing off sim-main.h, it'll make
it easier to separate out the two.

Start with splitting out sim/callback.h.
2021-06-17 00:11:48 -04:00
Simon Marchi
7daf500de2 sim: make some rules silent by default in Make-common.in
Use GDB's silent-rules.mk to make some rules silent by default.  These
rules cover most of what is built in sim/.

gdb/ChangeLog:

	* silent-rules.mk (ECHO_CCLD, ECHO_AR, ECHO_RANLIB): New.

sim/ChangeLog:

	* common/Make-common.in (COMPILE, libsim.a, run$(EXEEXT),
	gentmap.o, gentmap): Make rules silent.

Change-Id: Idf9ba5beaee10c7c614859ace5fbdcd1de0287db
2021-06-16 11:56:28 -04:00
Mike Frysinger
b80d447580 sim: mips: add printf attribute to trace func
This helps catch format errors in code, although they're all clean
at this point already.
2021-06-16 01:56:22 -04:00
Mike Frysinger
6828a30253 sim: mips: rework dynamic printf logic to avoid compiler warnings
The compiler doesn't like passing non-constant strings to printf
functions, so tweak the code to always pass one in.  This code is
a little more verbose, but it's probably the same performance.

The macro usage is a bit ugly, but maybe less than copying &
pasting the extended conditional format logic.
2021-06-16 01:55:31 -04:00
Mike Frysinger
df32b446c3 sim: mips: tweak buffer sign
This model uses unsigned char buffers, but this temporary pointer is
declared as signed.  Switch it to unsigned since it's just a temporary
variable to hold the new pointer.
2021-06-16 01:53:09 -04:00
Mike Frysinger
7b2298cbd8 sim: mips: fix uninitialized register use
In the default case, this code will read from this variable before
it is initialized as a dummy access.  Set it to 0 to fix the compiler
warning.
2021-06-16 01:51:32 -04:00
Mike Frysinger
a8a3d90792 sim: drop obsolete AC_EXEEXT call
The current autoconf 2.69 defines this to nothing because the logic
in AC_PROG_CC takes care of it all the time now.  Delete the call.
2021-06-16 01:29:41 -04:00
Mike Frysinger
46f0c0c6cc sim: ppc: use common sim-assert setting
The common sim code already sets this up for us, so no need to
duplicate the logic.
2021-06-16 01:24:20 -04:00
Mike Frysinger
956f0babcd sim: ppc: convert to bfd_endian
Rather than re-invent endian defines, as well as maintain our own list
of OS & arch-specific includes, punt all that logic in favor of the bfd
ones already set up and maintained elsewhere.  We already rely on the
bfd library, so leveraging the endian aspect should be fine.

This was done for all the other ports years ago, so catch ppc up.
2021-06-16 01:22:50 -04:00
Mike Frysinger
1b828ebe53 sim: ppc: replace local __attribute__ fallback
The common ansidecl.h provides fallbacks for these so we don't need to.
2021-06-16 01:14:53 -04:00
Mike Frysinger
69ff2dac7a sim: ppc: use common ATTRIBUTE_PRINTF macros
Use the common ansidecl.h macros to replace our ad-hoc printf attributes.
2021-06-16 01:14:05 -04:00
Mike Frysinger
3547f99a30 sim: ppc: use common ATTRIBUTE_PACKED macro
Drop local packed attribute with the common ansidecl.h define.
2021-06-16 01:11:08 -04:00
Mike Frysinger
6e57d02532 sim: ppc: replace local NORETURN macros with common one
Drop local NORETURN macro with the common ansidecl.h ATTRIBUTE_NORETURN define.
2021-06-16 01:10:11 -04:00
Mike Frysinger
f6428ce423 sim: ppc: replace local UNUSED macros with common one
Drop local UNUSED macro with the common ansidecl.h ATTRIBUTE_UNUSED define.
2021-06-16 01:08:43 -04:00
Mike Frysinger
b778e6b079 sim: ppc: replace local CONCAT macros with common ones
Drop local copies of CONCAT macros that the common ansidecl.h provides.
2021-06-16 01:06:28 -04:00
Mike Frysinger
5976569641 sim: ppc: change bool variable name to boolean
This is a reserved type with stdbool.h.
2021-06-16 01:05:10 -04:00
Mike Frysinger
430456e347 sim: ppc: drop host endian configure option
The --enable-sim-hostendian flag was purely so people had an escape route
for when cross-compiling.  This is because historically, AC_C_BIGENDIAN
did not work in those cases.  That was fixed a while ago though, so we can
require that macro everywhere now and simplify a good bit of code.

This was done for all the other ports years ago, so catch ppc up.
2021-06-16 01:03:54 -04:00
Mike Frysinger
dae666c968 sim: mips: fix format warnings when setting up memory
The majority of these inputs are not long's, so don't use %lx.
This fixes compiler warnings about type mismatches.
2021-06-16 00:50:56 -04:00
Mike Frysinger
52d37d2c91 sim: drop arch-specific config.h
All of the settings in here are handled by the common top-level
config.h, so drop the individual arch-config.h files entirely.

This will also help guarantee that we don't add any new arch
specific defines that would affect common code which will help
with the effort of unifying them.
2021-06-16 00:22:53 -04:00
Mike Frysinger
bcaa61f7c8 sim: move dv-sockser define to CPPFLAGS
This is the only define left in m4/ that is not in the common config.h,
so move it to sim_hw_cflags so we can drop the arch-specific config.h.
2021-06-15 23:27:14 -04:00
Mike Frysinger
015f7b7462 sim: switch modules.c & version.c to stamp files
This fixes remaking of these files and avoids unnecessary rebuilds.

Also add both to `make clean` to match other stamp files.
2021-06-15 17:06:46 -04:00
Mike Frysinger
79afa8caab sim: mn10300: enable -Werror
Now that all warnings are fixed in this port, enable -Werror by default.
2021-06-14 23:47:01 -04:00
Mike Frysinger
aa077c0d18 sim: mn10300: switch abort to sim_engine_abort
This allows the caller to catch engine aborts if they want, and fixes
the warning about missing stdlib.h include by not using abort().
2021-06-14 23:46:41 -04:00
Mike Frysinger
757b3c2fea sim: erc32: fix build w/out F_{G,S}ETFL
Add conditional logic around fcntl.h F_{G,S}ETFL usage to fix builds
on systems that don't have it (e.g. Windows).  The code is only used
to save & restore limited terminal stdin state.
2021-06-14 23:30:17 -04:00
Mike Frysinger
4df5cdbd3a sim: erc32: fix build w/out termios.h
Add conditional logic around termios.h usage to fix builds on systems
that don't have it (e.g. Windows).
2021-06-14 23:29:11 -04:00
Mike Frysinger
82e6d6bf90 sim: drop redundant SIM_AC_OPTION_WARNINGS
The common code already calls this, so no need to do so in arch dirs.
We leave the calls that disable -Werror.  This will help unify the
configure scripts.
2021-06-14 23:19:52 -04:00
Mike Frysinger
fbe8d1cf5b sim: enable silent rules in common builds
We only do the common code as automake simplifies the logic.
2021-06-14 20:04:44 -04:00
Mike Frysinger
483ab96a1b gnulib: define the path to gnulib's parent dir
The current setting assumes that gnulib is only used by dirs
immediately under the source root.  Trying to build it two or
more levels deep fails.  Switch GNULIB_BUILDDIR to a relative
GNULIB_PARENT_DIR so that it can be used to construct both the
build & source paths.
2021-06-14 18:01:20 -04:00
Mike Frysinger
92a3f61363 sim: ppc: use common version.o too
The common version.o we're building can be used for the ppc subdir,
so switch it over too.
2021-06-13 23:04:22 -04:00
Mike Frysinger
0f318b8478 sim: rx: move cycle-accurate settings to CPPFLAGS
This is the last unique setting that rx has in its config.h, so by
moving this to CPPFLAGS, we can drop its config.h entirely.
2021-06-13 20:33:35 -04:00
Mike Frysinger
ad9cc20970 sim: start unifying portability shims
There are some functions that gnulib does not yet provide fallbacks
for, so start a common file of our own for holding existing stubs.
2021-06-12 23:51:35 -04:00
Mike Frysinger
dd8e16ea7b sim: unify sim-load.o building
Since this file does not rely on any port-specific settings, move it
up to building as part of the common step so we only do it once in a
multibuild.
2021-06-12 23:49:41 -04:00
Mike Frysinger
a687671327 sim: rx: replace cycle-stats with common profile settings
The common sim-profile option controls whether to keep track of
runtime execution (like cycle count), so switch the rx-specific
cycle-stats option over to that.
2021-06-12 22:29:26 -04:00
Mike Frysinger
2726bbc339 sim: assume sys/select.h always exists
Now that gnulib provides this, assume it exists.
2021-06-12 22:19:30 -04:00
Mike Frysinger
a80249d0a9 sim: erc32: replace caddr_t with void*
This BSDism was never accepted into standards, so replace it with the
portable void* type instead.
2021-06-12 21:58:17 -04:00
Mike Frysinger
4218a6dc8b sim: erc32/ppc: fix handling of $EXEEXT 2021-06-12 21:35:23 -04:00
Mike Frysinger
ba307cddcf sim: overhaul alignment settings management
Currently, the sim-config module will abort if alignment settings
haven't been specified by the port's configure.ac.  This is a bit
weird when we've allowed SIM_AC_OPTION_ALIGNMENT to seem like it's
optional to use.  Thus everyone invokes it.

There are 4 alignment settings, but really only 2 matters: strict
and nonstrict.  The "mixed" setting is just the default ("unset"),
and "forced" isn't used directly by anyone (it's available as a
runtime option for some ports).

The m4 macro has 2 args: the "wire" settings (which represents the
hardwired port behavior), and the default settings (which are used
if nothing else is specified).  If none are specified, then the
build won't work (see above as if SIM_AC_OPTION_ALIGNMENT wasn't
called).  If default settings are provided, then that is used, but
we allow the user to override at runtime.  Otherwise, the "wire"
settings are used and user runtime options to change are ignored.

Most ports specify a default, or set the "wire" to nonstrict.  A
few set "wire" to strict, but it's not clear that's necessary as
it doesn't make the code behavior, by default, any different.  It
might make things a little faster, but we should provide the user
the choice of the compromises to make: force a specific mode at
compile time for faster runtime, or allow the choice at runtime.
More likely it seems like an oversight when these ports were
initially created, and/or copied & pasted from existing ports.

With all that backstory, let's get to what this commit does.

First kill off the idea of a compile-time default alignment and
set it to nonstrict in the common code.  For any ports that want
strict alignment by default, that code is moved to sim_open while
initializing the sim.  That means WITH_DEFAULT_ALIGNMENT can be
completely removed.

Moving the default alignment to the runtime also allows removal
of setting the "wire" settings at configure time.  Which allows
removing of all arguments to SIM_AC_OPTION_ALIGNMENT and moving
that call to common code.

The macro logic can be reworked to not pass WITH_ALIGNMENT as -D
CPPFLAG and instead move it to config.h.

All of these taken together mean we can hoist the macro up to the
top level and share it among all sims so behavior is consistent
among all the ports.
2021-06-12 21:14:50 -04:00
Mike Frysinger
6dd65fc048 sim: unify bug & package settings
Move these options up to the common dir so we only test & export
them once across all ports.  The AC_INIT macro does a lot of the
heavy lifting already which allows further simplification.
2021-06-12 20:24:08 -04:00
Mike Frysinger
04381273a9 sim: unify debug/stdio/trace/profile build settings
Move these options up to the common dir so we only test & export
them once across all ports.

The ppc code needs a little extra care with its trace settings as
it's not exactly the same API as the common code.  The other knobs
are the same though.
2021-06-12 20:07:57 -04:00
Mike Frysinger
497a20bd3b sim: split debug/stdio/trace/profile options into dedicated m4 files
This follows existing organizational structure with one configure option
per m4 file, and will make it easier to move to the common configure dir.
2021-06-12 20:07:57 -04:00
Mike Frysinger
a48ff3efda sim: ppc: unify header & function & type tests too
Since ppc now shares a config.h with the top-level, move all of its
relevant settings up a level.  The ppc port tests a lot more funcs,
but that's because its syscall emulation is a lot more complete.
We'll probably utilize some of these in the common code too.
2021-06-12 14:39:44 -04:00
Mike Frysinger
5629cf2b98 sim: ppc: unify env settings too
The ppc port doesn't share a lot of the common logic, but there are
a few bits that bleed across.  Have it use the common configure for
environment settings too to avoid duplicate define errors after the
recent unification with the other ports.
2021-06-12 12:58:54 -04:00
Mike Frysinger
5ea4547402 sim: unify environment build settings
Move the --sim-enable-environment option up to the common dir so we
only test & export it once across all ports.
2021-06-12 11:01:57 -04:00
Mike Frysinger
dba333c1e4 sim: unify assert build settings
Move the --sim-enable-assert option up to the common dir so we only
test & export it once across all ports.
2021-06-12 10:58:22 -04:00
Mike Frysinger
b15c5d7a51 sim: unify platform function & header tests
Move the various platform tests up a level to avoid duplication
across the ports.  When building multiple versions, this speeds
things up a bit.

For now we move the obvious stuff up a level, but we don't turn
own the config.h entirely just yet -- we still have some tests
related to libraries that need consideration.
2021-06-12 10:45:36 -04:00
Mike Frysinger
943f9baa37 sim: cleanup obsolete NULL fallback
We require C11 which defines NULL, so drop the inconsistent set of
fallback defines in the codebase.
2021-06-09 19:07:09 -04:00
Mike Frysinger
dc3de083d5 sim: mn10300: tweak engine halt hook
The hook is a void func, so defining it to 0 triggers warnings,
and isn't really needed.
2021-06-09 19:06:20 -04:00
Mike Frysinger
cfc6061bd8 sim: nrun: tweak init of callback endian
Allow ports to initialize the callback endian if they want.  This will
allow delegation of the logic out of common code in the future.

Also switch from the CURRENT_TARGET_BYTE_ORDER macro to the underlying
current_target_byte_order storage since the latter has been setup by
the sim-config module based on the same macros.  This will allow the
nrun module to be moved to common building for sharing.
2021-06-09 18:24:59 -04:00
Mike Frysinger
eee649922f sim: bpf: use CURRENT_TARGET_BYTE_ORDER
Code should be going through this macro rather than accessing the
underlying value directly.
2021-06-09 18:23:48 -04:00
Mike Frysinger
906192d785 sim: cgen: inline cgen_init logic
This function has done only one thing: post-process command line
settings to see if profiling or tracing has been enabled, and if
so, set the run_fast_p flag in the simulator state.  That flag is
only used in one place: to select the fast or slow cgen engine.
By inlining the run_fast_p logic to the one place it's used, we
can delete a good amount of logic specific to cgen ports: both
the call to cgen_init and the conditional simulator state.  This
in turn allows us to have a single simulator state struct across
all ports so we can share objects more between them, and makes
the sim_open calls look more consistent.
2021-06-09 18:21:28 -04:00
Mike Frysinger
a55b92be28 sim: igen: harmonize tool variables
Separate the name of the igen program from the options used to run it.
This allows us to avoid duplicating ../igen/igen in Makefiles and reuse
the existing setting in the common Makefile.  This also allows us to
easily harmonize the use of EXEEXT between igen/local.mk and the common
makefiles when cross-compiling for e.g. Windows.
2021-06-08 00:57:58 -04:00
Mike Frysinger
c469a50252 sim: v850: assume chown is available
Now that gnulib provides a wrapper, assume it always exists.
2021-06-08 00:15:56 -04:00
Mike Frysinger
5bea0c3276 sim: common: start dedicated local.mk
This provides a space to generate things that we only need to build
once per-arch.  Some day that will be all of common/, but for now,
we move the version.c management in.
2021-06-05 10:09:27 -04:00
John Baldwin
ea6197bf5f sim m32c: Include defs.h in m32c.opc and r8c.opc.
gnulib can override stdio.h and/or stdlib.h in which case the gnulib
headers require config.h to be included first.

gdb/sim/m32c/ChangeLog:

	* m32c.opc: Include defs.h.
	* r8c.opc: Likewise.
2021-06-02 08:48:09 -07:00
Mike Frysinger
c5b349e1c5 sim: ppc: enable -Wno-format for mingw targets
This mirrors what we do for other builds already.
2021-05-29 18:09:02 -04:00
Mike Frysinger
952170707b sim: ppc: avoid shadowing errno
If the OS headers define the "errno" symbol, it breaks some of these
funcs that were using "int errno" itself.  Rename local vars to "err"
to avoid that, and delete the old "extern int errno".
2021-05-29 18:05:20 -04:00
Mike Frysinger
1f8ef36f75 sim: v850: add pointer casts for execv on Windows
The execv prototypes on Windows via mingw64 include extra const
markings on the argv/envp pointers than what POSIX specifies.
Cast them to void* as a hack to get it working on all platforms.
2021-05-29 15:32:59 -04:00
Mike Frysinger
fc23e71a17 sim: mn10300: add SIGTRAP fallback
This is a bit of a hack, but it matches the hack we use in other
places in the sim currently.  This fixes building for e.g. Windows.
The signal fallback logic needs a bit of love in general at some
point across all sim code.
2021-05-29 15:32:00 -04:00
Mike Frysinger
b25370aa9f sim: pull in extra gnulib libs too
Some modules might require extra linking depending on the platform
(e.g. Windows might need -lws2_32), so include the existing extra
gnulib libs setting.
2021-05-29 15:31:12 -04:00
Mike Frysinger
8ea881d9e3 sim: mips: fix build w/out dv-sockser
Make sure we don't fail to build when dv-socker is unavailable.
2021-05-29 15:29:54 -04:00
Mike Frysinger
67514280fc sim: frv: fix up a bunch of prototype warnings
Some were missing, some were unused, and some were partially renamed.
2021-05-29 13:10:42 -04:00
Mike Frysinger
fc12ae4215 sim: frv: fix compiler parentheses suggestions warnings
Newer gcc warns when writing statements like (a && b || c && d),
so add more parentheses to make it (and the reader) happy.
2021-05-29 13:07:34 -04:00
Mike Frysinger
cd7caae651 sim: sh: fix a few compiler warnings 2021-05-29 13:06:26 -04:00
Mike Frysinger
80e61ea097 sim: m32c: rename open symbol to avoid collisions
If the header files define open(), make sure our local open var
doesn't shadow it.
2021-05-29 12:03:27 -04:00
Mike Frysinger
5c9e84c2d8 sim: leverage gnulib
We use getline, so leverage gnulib to provide fallback implementation.
2021-05-29 11:56:43 -04:00
Mike Frysinger
f006d9e205 sim: bfin: fix the otp fix fix
Need to shift the upper 32-bits and not just combine directly with
the lower 32-bits.
2021-05-28 23:31:24 -04:00
Yoshinori Sato
9d7c4ba5e5 sim: h8300 add special case test.
* addb.s: Add special case reg,<@reg+ / @reg- / @+reg / @-reg>.
* andb.s: Likewise.
* cmpb.s: Likewise.
* orb.s: Likewise.
* subb.s: Likewise.
* xorb.s: Likewise.
* movb.s: Add special case reg,<@reg+ / @reg- / @+reg / @-reg>
          @reg+,@reg+ / @-reg,@-reg.
* movw.s: Likewise.
* movl.s: Likewise.
2021-05-28 21:14:24 +09:00
Yoshinori Sato
0ef4c3f83b sim: h8300 Fixed different behavior in preinc/predec.
* sim-main.h (h8_typecodes): Add operand type OP_REG_DEC, OP_REG_INC.
* compile.c (decode): Rewrite oprand type for specific case.
(fetch_1): Add handling OP_REG_DEC and OP_REG_INC.
(step_once): Fix operand fetch order.
2021-05-28 21:14:24 +09:00
Mike Frysinger
5471128011 opcodes: cris: move desc & opc files from sim/
All other cgen ports keep their generated desc & opc files under
opcodes/, so move the cris files over too.  The cris-opc.c file,
while not generated, is already here to complement.
2021-05-24 18:42:34 -04:00
Mike Frysinger
d16ce6e4d5 sim: cris: fix memory setup typos
The cleanup to use BFD_VMA_FMT also adjusted this line, but used the
incorrect format: while BFD_VMA_FMT needs an explicit "x", PRIx32 does
not, so the spurious "x" here confused the parser and broke execution.
2021-05-23 23:43:37 -04:00
Mike Frysinger
d699be882b sim: bfin: fix the otp fix
I misread the code and thought data0/... were bu64 when they were
actually bu32.  Fix the call to assemble the 2 64-bit values instead
of passing the 2 halves of the first 64-bit value.
2021-05-23 22:16:13 -04:00
Mike Frysinger
3cc4ee83ad sim: bfin: fix build warnings w/newer gcc
The bfin_otp_write_page_val func wants a pointer to an bu64[2] array,
but this code passes it a pointer to a single bu64.  It's in a struct
with a known compatible layout:
	bu64 data0, data1, data2, data3;
But gcc doesn't allow these kinds of tricks anymore.  Use the more
verbose form to make the compiler happy since this is not performance
sensitive code.
2021-05-23 21:37:31 -04:00
Mike Frysinger
9a28444faa sim: rl78: rename open symbol to avoid collisions
If the header files define open(), make sure our local open var
doesn't shadow it.
2021-05-23 17:40:32 -04:00
Mike Frysinger
e82a36be9a sim: cris: add unistd.h for environ decl
We include environ.h for the fallback, but we still need to include
unistd.h in case it provides it as gnulib will detect.
2021-05-23 17:39:16 -04:00
Mike Frysinger
01d3ae40df sim: bfin: add strings.h for ffs() 2021-05-23 17:36:29 -04:00
Faraz Shahbazker
168671c14c sim: mips: Add shadow mappings for 32-bit memory address space
32-bit MIPS programs run on the 64-bit simulator model in 64-bit
sign-extended space. The mapping from 64-bit sign-extended addresses to
32-bit addresses was removed by commit
26f8bf63bf, breaking the 64-bit simulator
model. Add shadow mappings from 64-bit sign extended address space to
32-bit address spaces, in lieu of the AddressTranslation function.

2021-05-04  Faraz Shahbazker  <fshahbazker@wavecomp.com>

sim/mips/ChangeLog:
	* interp.c (sim_open): Add shadow mappings from 32-bit
	address space to 64-bit sign-extended address space.
2021-05-22 11:32:35 +05:30
Faraz Shahbazker
b312488f10 sim: mips: Only truncate sign extension bits for 32-bit target models
64-bit BFD for MIPS applies a standard sign extension on all addresses
assuming 64-bit target.  These bits are required for 64-bit and can only
be safely truncated for 32-bit target models. This partially reverts commit
b36d953bce

The sign-extension logic modeled by BFD is an integral part of the
MIPS64 architecture spec. It appears in the virtual address map, where
sign extension allows for 32-bit compatibility segments [1] with 64-bit
addressing. Truncating these addresses prematurely (commit
models (-DWITH_TARGET_WORD_BITSIZE=64).

In the ISA itself, direct addressing (Load-Upper-Immediate) and indirect
addressing (Load-Word) both automatically sign-extend their results. These
instructions regenerate the sign-extended addresses even if we don't start
with one (see pr gdb/19447).

Moreover, some instructions like ADD*/SUB* have unpredictable behaviour when
an operand is not correctly sign extended [3]. This affects PC-relative
addressing in particular, so arithmetic on the link-address generated in the
return address register by a jump-and-link is no longer possible, neither is
the use of the PC-relative addressing instructions provided by MIPSR6.

[1] "MIPS64 Architecture for Programmers Volume III: The MIPS64
    Privileged Resource Architecture", Document Number: MD00091,
    Revision 6.02, December 10, 2015, Section 4.3 "Virtual Address
    Spaces", pp. 29-31
https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00091-2B-MIPS64PRA-AFP-06.03.pdf

[2] "MIPS64 Architecture for Programmers Volume II-A: The MIPS64
    Instruction Set Reference Manual", Document Number: MD00087,
    Revision 6.06, December 15, 2016, Section 3.2 "Alphabetical
    List of Instructions", pp. 321
https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00087-2B-MIPS64BIS-AFP-6.06.pdf

[3] "MIPS64 Architecture for Programmers Volume II-A: The MIPS64
    Instruction Set Reference Manual", Document Number: MD00087,
    Revision 6.06, December 15, 2016, Section 3.2 "Alphabetical
    List of Instructions", pp. 56
https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00087-2B-MIPS64BIS-AFP-6.06.pdf

2021-04-23  Faraz Shahbazker  <fshahbazker@wavecomp.com>

sim/mips/ChangeLog:
	* interp.c (sim_create_inferior): Only truncate sign extension
	bits for 32-bit target models
.
2021-05-22 11:30:57 +05:30
John Baldwin
39549caef4 sim/d10v: Use offsetof in a static assertion about structure layout.
clang 11 fails to compile the static assertion as it cannot compute
the pointer value at a compile time:

gdb/sim/d10v/interp.c:1149:37: error: static_assert expression is not an integral constant expression
  static_assert ((uintptr_t) &State == (uintptr_t) &State.regs,
                 ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Instead, assert that the offset of State.regs is 0.

sim/d10v/ChangeLog:

	* interp.c (sim_create_inferior): Use offsetof in static
	assertion.
2021-05-21 17:27:05 -07:00
Tom de Vries
8baee38bfe sim: ppc: fix Wpointer-sign warning
When compiling with --enable-werror and CFLAGS="-O0 -g -Wall", we run into:
...
src/sim/ppc/hw_memory.c: In function 'hw_memory_init_address':
src/sim/ppc/hw_memory.c:194:75: error: pointer targets in passing \
  argument 4 of 'device_find_integer_array_property' differ in signedness \
  [-Werror=pointer-sign]
     int nr_cells
       = device_find_integer_array_property(me, "available", 0, &dummy);
                                                                ^
...

Fix this by changing the type of dummy.
2021-05-20 13:58:35 +02:00
Tom de Vries
17bb1d80f5 sim: ppc: fix some Wenum-compare warnings
When compiling with --enable-werror and CFLAGS="-O0 -g -Wall", we run into:
...
src/sim/ppc/hw_phb.c: In function 'hw_phb_attach_address':
src/sim/ppc/hw_phb.c:315:12: error: comparison between \
  'attach_type {aka enum _attach_type}' and \
  'enum <anonymous>' [-Werror=enum-compare]
   if (type != hw_phb_normal_decode
            ^~
...

Fix this by casting type to hw_phb_decode.
2021-05-19 19:08:53 +02:00
Tom de Vries
bfff0efb3d sim: ppc: fix Wnonnull warning
When compiling with --enable-werror and CFLAGS="-O0 -g -Wall", we run into:
...
src/sim/ppc/emul_netbsd.c: In function 'do_gettimeofday':
src/sim/ppc/emul_netbsd.c:770:16: error: null argument where non-null \
  required (argument 1) [-Werror=nonnull]
   int status = gettimeofday((t_addr != 0 ? &t : NULL),
                ^~~~~~~~~~~~
...

Fix this by unconditionally passing &t as first argument.
2021-05-19 18:42:59 +02:00
Tom de Vries
4156e38676 sim: ppc: fix some more Wunused-function warnings
When compiling with --enable-werror and CFLAGS="-O0 -g -Wall", we run into:
...
In file included from src/sim/ppc/cpu.h:26:0,
                 from src/sim/ppc/mon.c:25,
                 from src/sim/ppc/inline.c:64,
                 from idecode.c:26:
src/sim/ppc/device.h:788:8: error: 'device_event_queue_deschedule' \
  declared 'static' but never defined [-Werror=unused-function]
 (void) device_event_queue_deschedule
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

This seems to be caused by the fact that the function is declared using
INLINE_EVENT instead of INLINE_DEVICE.

Fix this and a similar error in the same file.
2021-05-19 17:46:24 +02:00
Tom de Vries
8f09aa5ba8 sim: ppc: fix some Wunused-function warnings
When compiling with --enable-werror and CFLAGS="-O0 -g -Wall", we run into:
...
In file included from src/sim/ppc/cpu.h:251:0,
                 from src/sim/ppc/emul_generic.h:24,
                 from src/sim/ppc/emul_generic.c:24:
src/sim/ppc/cpu.c:76:1: error: 'cpu_create' defined but not used \
  [-Werror=unused-function]
 cpu_create(psim *system,
 ^~~~~~~~~~
...

The function is defined as:
...
INLINE_CPU\
(cpu *)
cpu_create(psim *system,
...
which expands to:
...
static cpu * __attribute__((__unused__))
cpu_create(psim *system,
...

The problem is that gcc does not associate the attribute to the function.
I've filed a PR about this ( PR gcc/100670 ), which may or may not be valid.

Work around/fix this by modifying the INLINE_* definitions in inline.h to move
UNUSED to the start such that we have:
...
__attribute__((__unused__)) static cpu *
cpu_create(psim *system,
...
2021-05-19 17:46:24 +02:00
Mike Frysinger
f4fdd84587 sim: fully merge sim_state_base into sim_state
Now that all ports have migrated to the new framework, drop support
for the old sim_state_base layout.
2021-05-17 01:05:08 -04:00
Mike Frysinger
10c23a2c6f sim: riscv: invert sim_state storage 2021-05-17 01:02:09 -04:00
Mike Frysinger
2ad10cb222 sim: h8300: invert sim_state storage 2021-05-17 01:01:08 -04:00
Mike Frysinger
8ea7241cf3 sim: mips: invert sim_state storage 2021-05-17 01:00:08 -04:00
Mike Frysinger
937af0fde5 sim: avr: invert sim_state storage 2021-05-17 00:58:32 -04:00
Mike Frysinger
e106fc358c sim: cgen: invert sim_state storage for cgen ports 2021-05-17 00:46:32 -04:00
Mike Frysinger
85d93de3d8 sim: bfin: invert sim_state storage 2021-05-17 00:43:45 -04:00
Mike Frysinger
383861bd08 sim: invert sim_state storage
Currently all ports have to declare sim_state themselves in their
sim-main.h and then embed the common sim_state_base & sim_cpu in it.
This dynamic makes it impossible to share common object code among
multiple ports because the core data structure is always different.

Let's invert this relationship: common code declares sim_state, and
if the port actually needs state on a per-instance basis, it can use
the new arch_data field for it.  Most ports don't actually use it,
so they don't need to declare anything at all.

This is the first in a series of changes: it adds a define to select
between the old & new layouts, then converts all the ports that don't
need custom state over to the new layout.
2021-05-17 00:42:55 -04:00
Mike Frysinger
92bc001e1f sim: install library header files
We install libsim.a for people to link against, but haven't been
installing the header files to for its API.  Export them!
2021-05-16 22:42:02 -04:00
Mike Frysinger
6df01ab8ab sim: switch config.h usage to defs.h
The defs.h header will take care of including the various config.h
headers.  For now, it's just config.h, but we'll add more when we
integrate gnulib in.

This header should be used instead of config.h, and should be the
first include in every .c file.  We won't rely on the old behavior
where we expected files to include the port's sim-main.h which then
includes the common sim-basics.h which then includes config.h.  We
have a ton of code that includes things before sim-main.h, and it
sometimes needs to be that way.  Creating a dedicated header avoids
the ordering mess and implicit inclusion that shows up otherwise.
2021-05-16 22:38:41 -04:00
Mike Frysinger
79633c125e sim: riscv: move __int128 check to configure 2021-05-16 00:04:17 -04:00
Mike Frysinger
be2bc30f9c sim: ppc: clean up various warnings
A random grab bag of minor fixes to enable -Werror for this port.

Cast address vars to long when the format was using %l.
Use %zu with sizeof operations.
Add const to a bunch of strings.
Trim unused variables.
Fix sizeof call to calculate target storage and not the pointer itself.
2021-05-15 11:00:00 -04:00
Mike Frysinger
c5a2e0123b sim: switch to libiberty environ.h
Drop our compat code and assume environ exists to simplify.
2021-05-15 10:59:19 -04:00
Mike Frysinger
2fbe9507bf sim: callback: convert FS interfaces to 64-bit
Rather than rely on off_t being the right size between the host &
target, have the interface always be 64-bit.  We can figure out if
we need to truncate when actually outputting it to the right target.
2021-05-14 21:16:40 -04:00
Mike Frysinger
00330cd18a sim: callback: convert time interface to 64-bit
PR sim/27705
Rather than rely on time_t being the right size between the host &
target, have the interface always be 64-bit.  We can figure out if
we need to truncate when actually outputting it to the right target.
2021-05-14 21:05:36 -04:00
Mike Frysinger
64654371d6 sim: callback: inline PTR define
We require C11 now, so no need for these pre-ANSI C hacks.
PTR is simply void*, so use that directly.
2021-05-14 01:23:06 -04:00
Mike Frysinger
df68e12b3b sim: create header namespace
The gdb/callback.h & gdb/remote-sim.h headers have nothing to do with
gdb and are really definitions for the libsim API under the sim/ tree.
While gdb uses those headers as a client, it's not specific to it.  So
create a new sim/ namespace and move the headers there.
2021-05-14 00:41:05 -04:00
Mike Frysinger
425b0b1a98 sim: clean up explicit environment build calls
This was enabled by default for all targets, but a few ports still
include an explicit call.  Clean that up, and update the docs.
2021-05-12 00:47:49 -04:00
Luis Machado
e7e40cedbb Fix build failure in d10v sim
While building all targets on Ubuntu 20.04/aarch64, I ran into the following
build error:

In file included from /usr/include/string.h:495,
                 from ../../bfd/bfd.h:48,
                 from ../../../../repos/binutils-gdb/sim/d10v/interp.c:4:
In function memset,
    inlined from sim_create_inferior at ../../../../repos/binutils-gdb/sim/d10v/interp.c:1146:3:
/usr/include/aarch64-linux-gnu/bits/string_fortified.h:71:10: error: __builtin_memset offset [33, 616] from the object at State is out of the bounds of referenced subobject regs with type reg_t[16] {aka short unsigned int[16]} at offset 0 [-Werror=array-bounds]
   71 |   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [Makefile:558: interp.o] Error 1

The following patch fixes this.

sim/ChangeLog:

2021-05-12  Luis Machado  <luis.machado@linaro.org>

	* d10v/interp.c (sim_create_inferior): Fix memset call.
2021-05-12 00:57:46 -03:00
Mike Frysinger
bb608f811b sim: h8300: clean up various warnings
A random grab bag of minor fixes to enable -Werror for this port.

Disable h8_set_macS for now as it's unused.
Initialize trace & intMask before using them.
Mark local set_h8300h function static.
2021-05-08 12:43:06 -04:00
Mike Frysinger
b50a658ac1 sim: touch modules target
If there are no updates to the file, touch the result so we don't
keep trying to regenerate it.
2021-05-08 12:35:08 -04:00
Mike Frysinger
532497fe6f sim: cgen: tweak trace format
Fixes build warnings when the address size isn't an integer.
2021-05-08 12:33:08 -04:00
Mike Frysinger
1227922933 sim: cgen: namespace mode_names a bit
These are exported in the library linkage, so add a cgen_ prefix.
2021-05-08 12:29:00 -04:00
Mike Frysinger
6ae9091ab0 sim: cgen: tweak cgen_rtx_error to fix warnings
The function was missing a prototype, and passing a constant string
as the format string instead of going through a %s format.
2021-05-08 12:27:45 -04:00
Mike Frysinger
aac7ce3c87 sim: cgen: tweak initializers to avoid warnings
Use {} instead of {0} to avoid warnings:

common/cgen-utils.c:59:1: warning: missing braces around initializer [-Wmissing-braces]
   59 | {
      | ^
   60 |   {
   61 |     VIRTUAL_INSN_X_INVALID, "--invalid--", NULL, 0, { V, { 0 } }
      |                                                            {{}}

Generated code should be the same.
2021-05-08 12:10:27 -04:00
Mike Frysinger
0d0878d72e sim: add html & pdf stubs
We stub out the info targets already since we don't provide any.
2021-05-08 11:55:22 -04:00
Tom Tromey
65a9835b29 sim: use htab_eq_string
This changes the sim to use htab_eq_string from libiberty.

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

	* sim-options.c (compare_strings): Remove.
	(dup_arg_p): Use htab_eq_string.
2021-05-08 07:50:47 -06:00
Mike Frysinger
8a16cc4b93 sim: m68hc11: fix up cycle buffer printing
Make sure the local static buffer is large enough, and simplify the
sprintf for merging the fields all into one.  This fixes compiler
warnings from buf possibly being overflowed.
2021-05-07 21:55:27 -04:00
Dimitar Dimitrov
0d315c88a7 sim: Add bfd include path for common testsuite tools
On a host without installed libbfd, this patch fixes the following
"make check-sim" errors for both pru cross target, and native x86_64:

In file included from ../../../binutils/sim/common/sim-basics.h:131,
                 from testsuite/common/bits32m0.c:13:../../../binutils/sim/../include/gdb/callback.h:55:10: fatal error: bfd.h: No such file or directory
   55 | #include "bfd.h"
      |          ^~~~~~~

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2021-05-07 21:02:34 +03:00
Mike Frysinger
44056b7ce4 sim: m32c: clean up various warnings
A random grab bag of minor fixes to enable -Werror for this port.

Check the return values of read & write calls and issue warnings when
they fail.
Fixup funky pointer math as the compiler doesn't like ++ on void*.
Handle short reads with fread().
2021-05-07 00:36:26 -04:00
Mike Frysinger
0ae995e2df sim: m32c: fix warnings about mixing code & decls
Add scope braces to a bunch of the generated sections to avoid compiler
warnings about mixing code & variable declarations.
2021-05-07 00:34:25 -04:00
Mike Frysinger
a588403597 sim: m32c: switch from custom fgets to getline
No need to implement this ourselves when POSIX has a nice API.
2021-05-07 00:34:03 -04:00
Mike Frysinger
8e78e9b995 sim: m68hc11: fix up last warnings
Change the printf formats a little to fix the last build warnings in
here, and then turn on -Werror by default for the arch port.
2021-05-06 23:54:23 -04:00
Mike Frysinger
8852d02874 sim: m68hc11: warn when emul_write fails
Not sure what we should do here when this fails, so just emit a warning
for now to satisfy unused result compiler warnings.  We can see if any
users actually notice here.
2021-05-06 23:53:30 -04:00
Yoshinori Sato
15091ded14 sim: h8300 special case test
In "mov. [bwl] reg, @ -reg", added a special case test
using the same register.
2021-05-06 17:11:49 +09:00
Mike Frysinger
75070a4ede sim: m32c/rl78/rx: fix command parsing
Use buildargv to avoid writing to const memory and freeing invalid
pointers, and to avoid doing any string parsing ourselves.
2021-05-05 23:33:16 -04:00
Mike Frysinger
5318ba65f8 sim: rl78: clean up various warnings
A random grab bag of minor fixes to enable -Werror for this port.

Fix local prototypes for a bunch of functions (e.g. adding static).
Add missing includes for missing prototypes.
Move local variable decls from the middle of functions to the top
of the scope.
Fix a logic error when processing commands where p was reassigned
to cmd and then has its leading whitespace scanned a 2nd time.
Handle short reads with fread().
2021-05-04 23:05:02 -04:00
Mike Frysinger
bf06b2a2f9 sim: m68hc11: tweak types to fix warnings
The hw attach API wants unsigned addresses.
The write API wants signed chars.
2021-05-04 22:06:23 -04:00
Mike Frysinger
77c0fdb7ff sim: mips: include stdlib.h for memory prototypes
This file uses free() and friends, so include it to fix missing
prototype warnings.
2021-05-04 22:04:01 -04:00
Mike Frysinger
9b1af85c78 sim: mips: always enable device models
There's no need to restrict these to only specific targets as the user
can select them at runtime if they want them.  Always build them so we
can improve build coverage too.
2021-05-04 22:02:37 -04:00
Mike Frysinger
d97ba9c60c sim: mips: delete unused constant variables
Since these never change, inline and delete them.
2021-05-04 22:00:46 -04:00
Mike Frysinger
91eea12156 sim: mcore: fix build time warnings
Once we fix a minor const warning we can enable -Werror in here.
2021-05-04 21:57:49 -04:00
Mike Frysinger
a147f3ff8c sim: remove sys/times.h in most places
The v850 port used this, and then it got copied to other ports even
though it wasn't needed.  Clean it up to avoid portability issues on
platforms not providing this (e.g. mingw64 for Windows).
2021-05-04 21:56:38 -04:00
Mike Frysinger
4df817de57 sim: mips: fix qh_acc table
The AccAddLQH func was unused, and looking at this table, it looks
like it's due to a typo.
2021-05-04 21:54:36 -04:00
Mike Frysinger
2849d28d96 sim: hw: localize init callback
Now that we don't need to hardcode the module init list in a single
place, move the hw init logic out to the sim-hw file.
2021-05-04 21:52:38 -04:00
Mike Frysinger
4d47dcfcf1 sim: microblaze: enable some basic trace points
This isn't super complete, but it's useful enough as-is.
2021-05-04 21:49:11 -04:00
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