aboutsummaryrefslogtreecommitdiff
path: root/sim/common
AgeCommit message (Collapse)AuthorFilesLines
2021-11-11sim: io: tweak compiler workaround with error outputMike Frysinger1-3/+3
Outputting an extra space broke a cris test. Change the workaround to use %s with an empty string to avoid the compiler warning but not output an extra space.
2021-11-03sim: mloop: mark a few conditionally used funcs as unusedMike Frysinger1-2/+2
These are marked inline, so building w/gcc at higher optimization levels will automatically discard them. But building with -O0 will trigger unused function warnings, so fix that. The common before/after cover functions in the common mloop generator are not used by all architecture ports. Doesn't seem to be a hard requirement, so marking them optional (i.e. unused) is fine. The cris execute function is conditionally used depending on the fast-build mode settings, so mark it unused too.
2021-11-02sim: hoist cgen mloop rules up to common buildsMike Frysinger1-6/+9
These rules don't depend on the target compiler settings, so hoist the build logic up to the common builds for better parallelization. We have to extend the genmloop.sh logic a bit to allow outputting to a subdir since it always assumed cwd was the right place. We leave the cgen maintainer rules in the subdirs for now as they aren't normally run, and they rely on cgen logic that has not yet been generalized.
2021-11-01sim: igen: minor build output alignment fixMike Frysinger1-1/+1
The custom echo was off by one space relative to all the others.
2021-10-31sim: events: clean up trace castsMike Frysinger1-72/+83
Don't blindly cast every possible type to (long). Change to the right printf format specifier whether it be a 64-bit type or a pointer.
2021-10-31sim: drop unused targ-vals.h includesMike Frysinger3-3/+0
This is used in a few places where it's not needed. Drop the include to avoid the build-time generated header file as we move to drop it.
2021-10-31sim: unify callback.o buildingMike Frysinger2-1/+3
Now that the use of TARGET_xxx defines have been removed, we can move this to the common logic so we only build it once for multi-targets.
2021-10-31sim: nltvals: pull target open flags out into a dedicated source fileMike Frysinger5-45/+87
Like we just did for pulling out the errno & signal maps, pull out the open flag map into a dedicated common file. All newlib ports are using the same map which makes it easy.
2021-10-31sim: nltvals: localize TARGET_<open> definesMike Frysinger2-19/+29
Code should not be using these directly, instead they should be resolving these dynamically via the open_map. Rework the common callback code that was using the defines to use symbolic names instead, and localize some of the defines in the ARM code (since it's a bit unclear how many different APIs it supports currently), then remove the defines out of the header so no new code can rely on them.
2021-10-31sim: nltvals: pull target signal out into a dedicated source fileMike Frysinger5-65/+138
Like we just did for pulling out the errno map, pull out the signal map into a dedicated common file. All newlib ports are using the same signal map which makes it easy.
2021-10-31sim: nltvals: pull target errno out into a dedicated source fileMike Frysinger6-147/+365
The current system maintains a list of target errno constants in the nltvals.def file, then runs a build-time tool to turn that into a C file. This list of errno values is the same for all arches, so we don't need the arch-specific flexibility. Further, these are only for newlib/libgloss environments, which makes it confusing to support other userland runtimes (like Linux). Let's simplify to make this easier to understand & build. We don't namespace the variables yet, but sets up the framework for it. Create a new target-newlib-errno.c template file. The template file is hand written, but the inline map is still automatically generated. This allows us to move it to the common set of objects so it's only built once in a multi-target build. Now we can remove the output from the gentmap build-time tool since it's checked into the tree. Then we stop including the errno lists in nltvals.def since nothing uses it.
2021-10-31sim: common: merge multiple clean commandsMike Frysinger1-6/+6
This provides a minor speedup when cleaning in a multi-target build.
2021-10-31sim: tighten up build regen rulesMike Frysinger1-4/+4
Update the makefile & configure related rules to use the silent build helpers.
2021-10-31sim: igen: tighten up build outputMike Frysinger1-0/+1
Add a new stamp helper for quiet builds, and don't dump the command line options when it runs. That isn't standard tool behavior, and doesn't really seem necessary in any way.
2021-10-31sim: tighten up stamp rulesMike Frysinger1-20/+24
Add a new ECHO_STAMP helper and convert existing stamp code over to it. This is mostly common rules and cgen mloop rules.
2021-10-31sim: silence stamp touch rulesMike Frysinger1-3/+3
We pretty much never care about these stamp touches, so silence them. Also switch to using $@ when it makes sense.
2021-10-31sim: standardize move-if-change rulesMike Frysinger1-4/+4
Use the srcroot path and make them all silent.
2021-10-30sim: fix compilation on mingw64 [PR sim/28476]Orgad Shaneh1-3/+2
...by reordering includes. 1. sim-utils.c sim/mips/sim-main.h defines UserMode, while there is a struct in winnt.h which has UserMode as a member. So if sim-main.h is included before winnt.h, compilation fails. 2. ppc registers.h defines CR, which is used as a member in winnt.h. winsock2.h is included by sys/time.h, so sys/time.h has to be included before registers.h. Bug: https://sourceware.org/PR28476
2021-10-04sim: add --info-target for listing supported BFD targetsMike Frysinger1-0/+19
It can be difficult to guess the exact bfd name, so add an option to list all the targets that the current build supports. This aligns with other simulator options like --info-architecture.
2021-10-03sim: filter out SIGSTKSZ [PR sim/28302]Mike Frysinger2-3/+4
We map target signals to host signals so we can propagate signals between the host & simulated worlds. That means we need to know the symbolic names & values of all signals that might be sent. The tools that generate that list use signal.h and include all symbols that start with "SIG" so as to automatically include any new symbols that the C library might add. Unfortunately, this also picks up "SIGSTKSZ" which is not actually a signal itself, but a signal related setting -- it's the size of the stack when a signal is handled. By itself this doesn't super matter as we will never see a signal with that same value (since the range of valid signals tend to be way less than 1024, and the size of the default signal stack will never be that small). But with recent glibc changes that make this into a dynamic value instead of a compile-time constant, some users see build failures when building the sim. As suggested by Adam Sampson, update our scripts to ignore this symbol to simplify everything and avoid the build failure. Bug: https://sourceware.org/PR28302
2021-09-28sim: drop weak func attrs on module initsMike Frysinger1-1/+1
When I first wrote this, I was thinking we'd scan all source files that existed and generate a complete init list. That means for any particular build, we'd probably have a few functions that didn't exist, so weak attributes was necessary. What I ended up scanning though was only the source files that went into a particular build. There was another concern too: a source file might be included, but the build settings would cause all of its contents to be skipped (via CPP defines). So scanning via naive grep would pick up names not actually available. A check of the source tree shows that we never do this, and it's pretty easy to institute a policy that we don't start (by at the very least including a stub init func). The use of weak symbols ends up causing a problem in practice: for a few modules (like profiling), nothing else pulls it in, so the linker omits it entirely, which leads to the profiling module never being available. So drop the weak markings since we know all these funcs will be available.
2021-09-11sim: run: change help short option to -hMike Frysinger1-1/+1
It's unclear why -H was picked over the more standard -h, but since -h is still not used, just change -H to -h to match pretty much every other tool in the sourceware tree.
2021-09-09sim: accept -EB/-EL short optionsMike Frysinger1-3/+3
Many GNU tools accept -EB/-EL as short options for selecting big & little endian modes. While the sim has an -E option, it requires spelling out "big" and "little". Adding support for -EB & -EL is thus quite trivial, so lets round it out to be less annoying.
2021-09-09sim: drop old O_NDELAY & FNBLOCK supportMike Frysinger2-22/+4
We use these older names inconsistently in the sim codebase, and time has moved on long ago, so drop support for these non-standard names. POSIX provides O_NONBLOCK for us, so use it everywhere.
2021-09-09sim: dv-sockser: enable for mingw targets tooMike Frysinger1-4/+4
We have enough functionality from gnulib now to build sockser on all platforms. Non-blocking I/O is supported when F_GETFL/F_SETFL are unavailable, but we can address that in a follow up commit. This mirrors what is done in other places in the sim already.
2021-09-09sim: cgen: workaround Windows VOID defineMike Frysinger1-0/+2
The cgen framework provides a "VOID" type for code to use, but this defines ends up conflicting with the standard Windows VOID define. Since they actually define to the same thing ("void"), undef it here to fix the Windows build. We might want to reconsider the need for "VOID" in cgen, but that will take larger discussion & coordination with the cgen project.
2021-09-09sim: dv-sockser: move sim-main.h include after system includesMike Frysinger1-2/+1
The sim-main.h header is a bit of a dumping ground. Every arch can (and many do) define all sorts of weird & common names that end up conflicting with system headers. So including it before the system headers sets us up for pain. v850 is a good example of this -- when building for mingw, we see weird failures: $ i686-w64-mingw32-gcc ... -c -o dv-sockser.o ../../../../sim/v850/../common/dv-sockser.c In file included from ../../../../sim/v850/sim-main.h:11, from ../../../../sim/v850/../common/dv-sockser.c:24: ../../../../sim/v850/../common/sim-base.h:97:32: error: expected ')' before '->' token 97 | # define STATE_CPU(sd, n) ((sd)->cpu[0]) | ^~ While gcc is unhelpful at first, running it through the preprocessor by hand shows more details: $ i686-w64-mingw32-gcc ... -E -dD -o dv-sockser.i ../../../../sim/v850/../common/dv-sockser.c $ i686-w64-mingw32-gcc -c dv-sockser.i In file included from /usr/i686-w64-mingw32/usr/include/minwindef.h:163, from /usr/i686-w64-mingw32/usr/include/windef.h:9, from /usr/i686-w64-mingw32/usr/include/windows.h:69, from /usr/i686-w64-mingw32/usr/include/winsock2.h:23, from ../../gnulib/import/sys/socket.h:684, from ../../gnulib/import/netinet/in.h:43, from ../../../../sim/v850/../common/dv-sockser.c:39: /usr/i686-w64-mingw32/usr/include/winnt.h:4803:25: error: expected ')' before '->' token 4803 | DWORD State; | ^ | ) This is because v850 sets up this common name: All of this needs cleaning up someday, but since the dv-sockser code definitely should be fixed in this way, lets do that now and unblock the v850 code.
2021-08-19sim: nltvals: switch output mode to a directoryMike Frysinger1-5/+8
In preparation for this script generating more files, change the output argument to specify a directory. This drops the stdout behavior, but since no one really runs this tool directly, it's not a big deal.
2021-08-17sim: nltvals: localize TARGET_<ERRNO> definesMike Frysinger1-5/+1
Code should not be using these directly, instead they should be resolving these dynamically via cb_host_to_target_errno maps. Fix the Blackfin code and remove the defines out of the header so no new code can rely on them.
2021-08-17sim: rename ChangeLog files to ChangeLog-2021Mike Frysinger1-0/+0
Now that ChangeLog entries are no longer used for sim patches, this commit renames all relevant sim ChangeLog to ChangeLog-2021, similar to what we would do in the context of the "Start of New Year" procedure. The purpose of this change is to avoid people merging ChangeLog entries by mistake when applying existing commits that they are currently working on. Also throw in a .gitignore entry to keep people from adding new ChangeLog files anywhere in the sim tree.
2021-07-01sim: unify reserved instruction bits settingsMike Frysinger2-2/+4
Move these options up to the common dir so we only test & export them once across all ports. The setting only affects igen based ports, and they were turning this on by default, so keep the default in place.
2021-07-01cgen: split GUILE setting outMike Frysinger2-1/+7
This makes it easier to override to point to an older version of guile. The current cgen code doesn't work with guile-2, so need to point to an older guile-1.8.
2021-06-30sim: unify scache settingsMike Frysinger4-8/+8
The cgen scache module is enabled by every cgen port, and with the same default value of 16k (which matches the common default value). Let's pull this option out of the individual ports (via CPPFLAGS) and into the common code (via config.h). The object itself is compiled only for cgen ports atm, so that part doesn't change. The scache code is initialized dynamically via the modules.c logic. That's why the profile code needs an additional CGEN_ARCH check. This will allow us to collapse arch configure files more. Merging the source files will require more future work, but integrating the cgen & non-cgen worlds itself will take a lot.
2021-06-30sim: move scache init to dynamic modules.cMike Frysinger4-7/+12
Use the new modules.c framework to find & initialize this module.
2021-06-30sim: move profile init to dynamic modules.cMike Frysinger4-8/+11
Use the new modules.c framework to find & initialize this module.
2021-06-30sim: move trace init to dynamic modules.cMike Frysinger4-8/+11
Use the new modules.c framework to find & initialize this module.
2021-06-30sim: move engine init to dynamic modules.cMike Frysinger4-6/+10
Use the new modules.c framework to find & initialize this module.
2021-06-30sim: delete unused model settingsMike Frysinger2-23/+6
These were never fully migrated from the psim to common code, and since we've finished moving the logic into the runtime sim state, we won't ever need these. So punt them.
2021-06-30sim: move default model to the runtime sim stateMike Frysinger5-16/+21
This kills off another compile-time option by moving the setting to the individual arch runtimes. This will allow dynamic selection by the arch when doing a single build with multiple arches. The sim_model_init rework is a little funky. In the past it was disabled entirely if no default model was set. We maintain the spirit of the logic by gating the fallback logic on whether the port has defined any models.
2021-06-30sim: namespace sim_machsMike Frysinger7-37/+67
We want to do a single build with all arches in one binary which means we need to namespace sim_machs on a per-arch basis. Move it from a global variable to the sim description structure so it can be setup at runtime. Changing the SIM_MODEL->num from an enum to an int is unfortunate, but we specifically don't want to maintain a centralized list anymore, and this was never used directly in common code, just passed to per-arch callbacks.
2021-06-29sim: fix arch Makefile regen when unifiedMike Frysinger2-1/+7
The $(arch) variable is only setup for cgen ports, so calculate this value dynamically. We also need to generate multiple inputs in order to properly recreate the subdir Makefile, so list them all.
2021-06-29sim: callback: add check for HAVE_KILLMike Frysinger2-0/+9
Fix building on systems w/out a kill function (e.g. Windows).
2021-06-29sim: model: constify sim_machs storageMike Frysinger3-6/+15
The array of pointers is never modified, so mark it const so it ends up in the read-only data section.
2021-06-29sim: io: add printf attributes to vprintf funcs tooMike Frysinger2-2/+9
The compiler can still do basic format checks with vprintf style funcs, so add the printf attribute to these.
2021-06-29sim: callback: add printf attributesMike Frysinger2-1/+7
This helps these funcs get printf format checking coverage. The sim-io.c hack as a result is a bit unfortunate, but the compiler throws warnings when printing with empty strings. In this one case, we actually want that due to the side-effect of the callback halting execution for us.
2021-06-29sim: callback: drop unused printf helpersMike Frysinger3-66/+8
These cover functions aren't used anywhere, so drop them. There was one caller, but it's old DOS code that most likely hasn't been tested in years, so just delete that too.
2021-06-29sim: cgen: require long long supportMike Frysinger3-29/+6
We require C11 now, so we can assume & require long long exists. Drop this old code that hasn't been used for a long long time.
2021-06-27sim: cgen: suppress trace non-literal printf warningMike Frysinger2-0/+10
The cgen trace macros are a bit ugly in that they specify a series of format strings & arguments in a single call. This means we pass a non-literal string to printf and the compiler warns about it. Use the diagnostic macros to suppress that in this one place.
2021-06-27sim: cgen: add asserts to fix unused engine warningsMike Frysinger2-1/+8
If the user passed in values outside the range of [0, MAX_NR_PROCESSORS), it would cause the code to access out-of-bind engine function pointers. Add some asserts to catch that and to fix the related compiler warnings.
2021-06-27sim: cgen: add printf attributes in a few more callsMike Frysinger2-2/+7
This helps the compiler process calls to these functions and emit warnings about mismatched format arguments.