Commit Graph

4324 Commits

Author SHA1 Message Date
Mike Frysinger
d394a6efed sim: callback: add a kill interface
This will make it easier to emulate the syscall.  If the kill target
is the sim itself, don't do anything.  This forces the higher layers
to make a decision as to how to handle this event: like halting the
overall engine process.
2021-06-23 20:05:14 -04:00
Mike Frysinger
b34084121a sim: switch common srcdir to abs_srcdir
We rewrite srcdir in subdir Makefiles that we generate from the common
parent dir since it points to the parent dir.  Since @srcdir@ can be a
variety of formats (relative & absolute), switch to @abs_srcdir@ which
is a lot easier to adjust.  Our use of srcdir in here should handle it.
2021-06-23 18:12:43 -04:00
Mike Frysinger
072d63a871 sim: cris: fix a few warnings
Include header for hw funcs called, adjust prototype to match the
args given to it, and adjust cast to match the function.
2021-06-22 19:41:00 -04:00
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