aboutsummaryrefslogtreecommitdiff
path: root/sim/common
AgeCommit message (Collapse)AuthorFilesLines
2021-03-13sim: rename BUILD_LDFLAGS to LDFLAGS_FOR_BUILDMike Frysinger2-1/+6
The rest of the binutils tree renamed this variable many years ago.
2021-03-13sim: introduce {COMPILE,LINK}_FOR_BUILDMike Frysinger2-2/+14
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-07sim: testsuite: merge into toplevel automakeMike Frysinger2-1/+4
This allows us to delete most of our custom test logic, and avoids a recursive make for minor speed up.
2021-02-28sim: delete unused SIM_EXTRA_LIBDEPSMike Frysinger2-4/+6
This was last used 15 years ago, so clearly not important enough to keep around. Punt it.
2021-02-27sim: delete redundant SIM_EXTRA_ALLMike Frysinger2-3/+6
We don't need a variable to add a dependency to the "all" target, and having one doesn't really add value. Switch to the target directly for the few ports that actually use this.
2021-02-21sim: common: split up acinclude.m4 into individual m4 filesMike Frysinger2-875/+4
This file is quite large and is getting unmanageable. Split it apart to follow aclocal best practices by putting one-macro-per-file. There shouldn't be any real functional changes here as can be seen in the configure script regens.
2021-02-13sim: switch to AC_CONFIG_MACRO_DIRSMike Frysinger2-14/+4
Rather than hand maintain m4 includes in various autotool files, use AC_CONFIG_MACRO_DIRS to declare the relevant search paths. This simplifies the code, makes it more robust, and cleans out unused logic from configure.
2021-02-13sim: common: delete unused aclocal.m4Mike Frysinger2-15/+4
This was missed when we deleted the common/configure build logic.
2021-02-06sim: watchpoints: use common sim_pc_getMike Frysinger5-10/+87
Few arches implement STATE_WATCHPOINTS()->pc while all of them implement sim_pc_get. Lets switch the sim-watch core for monitoring pc events to the sim_pc_get API so this module works for all ports, and then we can delete this old back channel of snooping in the port's cpu state -- the code needs the pointer to the pc storage so that it can read out bytes and compare them to the watchrange. This also fixes the logic on multi-cpu sims by removing the limitation of only being able to watch CPU0's state.
2021-02-06sim: add ChangeLog entries for last commitsMike Frysinger1-0/+5
2021-02-06sim: common: switch AC_CONFIG_HEADERSMike Frysinger1-2/+1
The AC_CONFIG_HEADER macro is long deprecated, so switch to the newer form. This also gets rid of the position limitation, and drops support for an argument to SIM_AC_COMMON which we haven't used anywhere.
2021-02-06sim: drop use of bfd/configure.hostMike Frysinger3-8/+8
These settings might have made sense in darker compiler times, but I think they're largely obsolete now. Looking through the values that get used in HDEFINES, it's quite limited, and configure itself should handle them. If we still need something, we can leverage standard autoconf macros instead, after we get a clear user report. TDEFINES was never set anywhere and was always empty, so prune that.
2021-02-04sim: riscv: new portMike Frysinger3-0/+56
This is a hand-written implementation that should have fairly complete coverage for the base integer instruction set ("i"), and for the atomic ("a") and integer multiplication+division ("m") extensions. It also covers 32-bit & 64-bit targets. The unittest coverage is a bit weak atm, but should get better.
2021-01-31sim: cgen-trace: tweak printf callMike Frysinger2-1/+5
GCC warns that we pass a non-string literal as the format string, so add an explicit "%s" to make it happy.
2021-01-31sim: cgen-accfp: Fix pointer sign warningsStafford Horne2-3/+9
When compiling we get the following warnings: common/cgen-accfp.c: In function 'fixsfsi': common/cgen-accfp.c:370:18: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign] sim_fpu_to32i (&res, &op1, sim_fpu_round_near); ^ common/cgen-accfp.c: In function 'fixdfsi': common/cgen-accfp.c:381:18: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign] sim_fpu_to32i (&res, &op1, sim_fpu_round_near); ^
2021-01-30sim: common: change gennltvals helper to PythonMike Frysinger4-239/+238
This tool is only run by developers and not in a release build, so rewrite it in Python to make it more maintainable.
2021-01-30sim: watchpoints: change sizeof_pc to sizeof(sim_cia)Mike Frysinger3-4/+9
Existing ports already have sizeof_pc set to the same size as sim_cia, so simply make that part of the core code. We already assume this in places by way of sim_pc_{get,set}, and this is how it's documented in the sim-base.h API. There is code to allow sims to pick different register word sizes from address sizes, but most ports use the defaults for both (32-bits), and the few that support multiple register sizes never change the address size (so address defaults to register). I can't think of any machine where the register hardware size would be larger than the address word size either. We have ABIs that behave that way (e.g. x32), but the hardware is still equivalent register sized.
2021-01-30sim: profile: fix bucketing with 64-bit targetsMike Frysinger2-2/+6
When the target's PC is 64-bits, this shift expands into a range of 8 * 8 - 1 which doesn't work with 32-bit constants. Force it to be a 64-bit value all the time and let the compiler truncate it.
2021-01-30sim: hw: replace fgets with getlineMike Frysinger2-30/+41
This avoids fixed sized buffers on the stack.
2021-01-30sim: common: sort nltvals.defMike Frysinger3-90/+95
This was largely already done, but I think people didn't quite notice.
2021-01-18sim: common: simplify version scriptMike Frysinger3-13/+15
We don't use the host & target aliases, so don't bother emitting them.
2021-01-18sim: common: delete configure & MakefileMike Frysinger4-3887/+4
This was mostly orphaned a while back, but left behind so people could still run `make headers`. Merge that one target to the top sim dir and delete all the build logic. This should avoid confusing people further.
2021-01-18sim: common: modernize gennltvals.shMike Frysinger4-167/+237
It's not 1996 anymore, so stop writing shell code like it is, and rewrite it with modern POSIX shell standards. This makes it much more user friendly. Then regenerate the file with latest newlib sources to verify.
2021-01-13sim: watch: add basic default handler that trapsMike Frysinger2-1/+18
The default watchpoint handler is NULL. That means any port that sets the STATE_WATCHPOINTS->pc field will crash if you try to use the --watch options but don't configure the interrupt handler. In the past, you had to setup STATE_WATCHPOINTS->pc if you wanted to support PC profiling, and while that was fixed a while ago, we have a lot of ports who still configure it. We already add a default set of interrupts (just "int") if the port doesn't define any. Let's also add a default handler that raises a SIGTRAP. When connected to gdb, this is a breakpoint which is what people would expect. When running standalone, it'll abort the sim, but it's unclear whether there's anything better to do there. This really is just to make the watchpoint module more usable out of the box for most ports with very little setup, at least inside of gdb.
2021-01-13sim: watch: fix range expression processingMike Frysinger2-1/+5
The code supports a <start>[,<end>] syntax, but the logic for handling the <end> check was broken: it would detect the first byte was ",", but then include that in the strtoul call meaning the result is always 0. Further, it (re)assigned to arg0 when it meant arg1 which means this code always processed a range expression as 0,0. Oops.
2021-01-13sim: watch: fix pc watchpoints on little endian host systemsMike Frysinger4-5/+14
My change 1ac72f0659d64d6a14da862242db0d841d2878d0 ("sim: convert to bfd_endian") subtly broke the watchpoint module on little endian host systems. The old code used 0 to mean "whatever the host endian is", and while that was changed to use BFD_ENDIAN_UNKNOWN, this caller was missed. Since its API used an int instead of an enum, the coercion from 0 to the BFD endian enum was silently missed, and 0 happens to be BFD_ENDIAN_BIG. Instead of restoring the old logic by passing in BFD_ENDIAN_UNKNOWN, we know the right host endian at compile time, so use that directly.
2021-01-12sim: common: use #error properlyMike Frysinger2-1/+5
2021-01-11sim: always call SIM_AC_OPTION_WARNINGSMike Frysinger2-1/+7
Now that all ports have opted in to this, we can require it in the core. It guarantees that new ports have them turned on, and defaults to -Werror in the hopes that new ports keep their code clean from the start. We do this as a sep commit to make it clear that there are no changes to existing ports as they've all explicitly called it already.
2021-01-11sim: common: fix printf formatsMike Frysinger2-1/+6
For 32-bit targets, %x happens to work for unsigned_word. But for 64-bit targets, it's too small, and gcc throws an error. Use the right printf format define for them.
2021-01-11sim: clean up C11 header includesMike Frysinger28-187/+16
Since we require C11 now, we can assume many headers exist, and clean up all of the conditional includes. It's not like any of this code actually accounted for the headers not existing, just whether we could include them. The strings.h cleanup is a little nuanced: it isn't in C11, but every use of it in the codebase will include strings.h only if string.h doesn't exist. Since we now assume the C11 string.h exists, we'll never include strings.h, so we can delete it.
2021-01-09sim: common: clean up asprintf includes a bitMike Frysinger4-5/+7
Delete stale prototypes that libiberty.h already provides, and add missing libiberty.h includes to files that use those functions.
2021-01-09sim: clean up stale AC_PREREQ refsMike Frysinger2-12/+5
This was purged from the tree when we upgraded to autoconf-2.69, but a few references in the sim tree were missed.
2021-01-09sim: enable -Werror by default for some archesMike Frysinger2-5/+11
We've had this off for a long time because the sim code was way too full of warnings for it to be feasible. However, I've cleaned things up significantly from when this was first merged, and we can start to turn this around. Change the macro to enable -Werror by default, and allow ports to opt out. New ports will get it automatically (and we can push back on them if they try to turn it off). Also turn it off for the few ports that still hit warnings for me. All the rest will get the new default, and we'll wait for feedback if/when new issues come up.
2021-01-09sim: hw: rework code to avoid gcc warningsMike Frysinger2-7/+8
Newer gcc thinks we might return a pointer to a stack buffer, but we don't -- we strdup it before returning. Rework the code to just malloc the buffer from the start and avoid the stack+strdup.
2021-01-09sim: common: add missing stdlib.h for abort()Mike Frysinger5-0/+9
2021-01-08sim: require a C11 compilerMike Frysinger3-1/+34
With GDB requiring a C++11 compiler now, this hopefully shouldn't be a big deal. It's been 10 years since C11 came out, so should be plenty of time to upgrade. This will allow us to start cleaning up random header logic and many of our non-standard custom types.
2021-01-07gdb/sim: add support for exporting memory mapMike Frysinger2-0/+61
This allows gdb to quickly dump & process the memory map that the sim knows about. This isn't fully accurate, but is largely limited by the gdb memory map format. While the sim supports RWX bits, gdb can only handle RW or RO regions.
2021-01-04sim: update bug URI to https://Mike Frysinger2-1/+6
2021-01-04sim: common: version: add build & homepage info when interactiveMike Frysinger2-0/+20
This mirrors gdb behavior of dumping extra info when being run in interactive mode. It also gives us an excuse to use the otherwise unused sim_print_config.
2021-01-04sim: common: use sim_config_print nameMike Frysinger3-3/+3
Meant to push this variant where naming preference is given to the module the code resides in rather than the operation it performs.
2021-01-04sim: common: add a version output helper w/copyright+license infoMike Frysinger3-1/+31
This mirrors the existing sim_print_help function, and the behavior of all other GNU tools with their --version.
2021-01-04sim: common: rename sim_print_configMike Frysinger3-2/+8
print_sim_config has never been used anywhere, so rename it to follow the sim_* naming style for all other symbols we export.
2021-01-02sim: common: add align_{up,down} to match gdbMike Frysinger2-13/+10
We have ALIGN_{8,16,PAGE} and FLOOR_PAGE macros (where PAGE is defined as 4k) which were imported from the ppc sim. But no other sim utilizes these and hardcoding the sizes in the name is a bit limiting. Let's delete these and import the two general macros that gdb uses: align_up(addr, bytes) align_down(addr, bytes) This in turn allows us to cut over the Blackfin code immediately.
2021-01-01Update copyright year range in all GDB filesJoel Brobecker114-114/+114
This commits the result of running gdb/copyright.py as per our Start of New Year procedure... gdb/ChangeLog Update copyright year range in copyright header of all GDB files.
2020-08-10[sim] Fix mbuild build breaker in sim-cpu.cTom de Vries2-0/+6
When running gdb/gdb_mbuild.sh, I run into: ... src/sim/aarch64/../common/sim-cpu.c: In function 'sim_cpu_free': src/sim/aarch64/../common/sim-cpu.c:64:3: error: implicit declaration of \ function 'free' [-Werror=implicit-function-declaration] free (cpu); ^~~~ src/sim/aarch64/../common/sim-cpu.c:64:3: error: incompatible implicit \ declaration of built-in function 'free' [-Werror] src/sim/aarch64/../common/sim-cpu.c:64:3: note: include '<stdlib.h>' or \ provide a declaration of 'free' ... Fix this by adding "#include <stdlib.h>". Tested by gdb/gdb_mbuild.sh -e aarch64-elf. sim/common/ChangeLog: 2020-08-10 Tom de Vries <tdevries@suse.de> * sim-cpu.c: Include stdlib.h for free.
2020-01-19sim: add some stdlib.h includesSimon Marchi7-2/+21
When trying to compile GDB with --target=avr, with gcc 9.2.0, I am getting a bunch of: /home/simark/src/binutils-gdb/sim/avr/../common/nrun.c:94:7: error: implicit declaration of function ‘abort’ [-Werror=implicit-function-declaration] 94 | abort (); | ^~~~~ /home/simark/src/binutils-gdb/sim/avr/../common/nrun.c:94:7: error: incompatible implicit declaration of built-in function ‘abort’ [-Werror] /home/simark/src/binutils-gdb/sim/avr/../common/nrun.c:94:7: note: include ‘<stdlib.h>’ or provide a declaration of ‘abort’ I did what the compiler told me and added the relevant includes in the problematic files. sim/common/ChangeLog: * nrun.c: Include stdlib.h. * sim-core.c: Likewise. * sim-engine.c: Likewise. * sim-io.c: Likewise. * sim-module.c: Likewise. * sim-reason.c: Likewise.
2020-01-01Update copyright year range in all GDB files.Joel Brobecker114-114/+114
gdb/ChangeLog: Update copyright year range in all GDB files.
2019-12-19Add install-strip to sim/Tom Tromey2-0/+6
PR build/24572 notes that "make install-strip" fails. For me, it works in every directory except "sim", so this patch adds install-strip targets to the Makefiles that appear there. sim/ChangeLog 2019-12-19 Tom Tromey <tromey@adacore.com> PR build/24572: * Makefile.in (install-strip): New target. sim/common/ChangeLog 2019-12-19 Tom Tromey <tromey@adacore.com> PR build/24572: * Makefile.in (install-strip): New target. sim/igen/ChangeLog 2019-12-19 Tom Tromey <tromey@adacore.com> PR build/24572: * Makefile.in (install-strip): New target. sim/ppc/ChangeLog 2019-12-19 Tom Tromey <tromey@adacore.com> PR build/24572: * Makefile.in (install-strip): New target. sim/testsuite/ChangeLog 2019-12-19 Tom Tromey <tromey@adacore.com> PR build/24572: * Makefile.in (install-strip): New target. Change-Id: I76613bc5c7e7812284f33826f8a5d914477fcdc5
2019-12-04sim-utils.c: prevent buffer overflow.Pavel I. Kryukov2-4/+8
Representation of max 32-bit integer is 10 chars. The potential issue is observed by GCC 7 targeted to AArch64. sim/common/ChangeLog: 2019-12-01 Pavel I. Kryukov <kryukov@frtk.ru> * sim-utils.c: Prevent buffer overflow.
2019-09-23sim: Add PRU simulator portDimitar Dimitrov3-0/+40
A simulator port for the TI PRU I/O processor. v1: https://sourceware.org/ml/gdb-patches/2016-12/msg00143.html v2: https://sourceware.org/ml/gdb-patches/2017-02/msg00397.html v3: https://sourceware.org/ml/gdb-patches/2017-02/msg00516.html v4: https://sourceware.org/ml/gdb-patches/2018-06/msg00484.html v5: https://sourceware.org/ml/gdb-patches/2019-08/msg00584.html v6: https://sourceware.org/ml/gdb-patches/2019-09/msg00036.html gdb/ChangeLog: * NEWS: Mention new simulator port for PRU. sim/ChangeLog: * MAINTAINERS: Add myself as PRU maintainer. * configure: Regenerated. * configure.tgt: Add PRU. sim/common/ChangeLog: * gennltvals.sh: Add PRU libgloss target. * nltvals.def: Regenerate from the latest libgloss sources. sim/pru/ChangeLog: * Makefile.in: New file. * aclocal.m4: Regenerated. * config.in: Regenerated. * configure: Regenerated. * configure.ac: New file. * interp.c: New file. * pru.h: New file. * pru.isa: New file. * sim-main.h: New file.