aboutsummaryrefslogtreecommitdiff
path: root/sim
AgeCommit message (Collapse)AuthorFilesLines
2021-05-16sim: switch config.h usage to defs.hMike Frysinger302-169/+923
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-16sim: riscv: move __int128 check to configureMike Frysinger96-63/+596
2021-05-15sim: ppc: clean up various warningsMike Frysinger22-54/+122
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-15sim: switch to libiberty environ.hMike Frysinger4-24/+18
Drop our compat code and assume environ exists to simplify.
2021-05-14sim: callback: convert FS interfaces to 64-bitMike Frysinger4-8/+16
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-14sim: callback: convert time interface to 64-bitMike Frysinger9-21/+35
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-14sim: callback: inline PTR defineMike Frysinger3-3/+8
We require C11 now, so no need for these pre-ANSI C hacks. PTR is simply void*, so use that directly.
2021-05-14sim: create header namespaceMike Frysinger70-74/+190
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-12sim: clean up explicit environment build callsMike Frysinger8-48/+16
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-12Fix build failure in d10v simLuis Machado2-2/+11
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-08sim: h8300: clean up various warningsMike Frysinger4-8/+21
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-08sim: touch modules targetMike Frysinger2-0/+5
If there are no updates to the file, touch the result so we don't keep trying to regenerate it.
2021-05-08sim: cgen: tweak trace formatMike Frysinger2-1/+5
Fixes build warnings when the address size isn't an integer.
2021-05-08sim: cgen: namespace mode_names a bitMike Frysinger3-3/+11
These are exported in the library linkage, so add a cgen_ prefix.
2021-05-08sim: cgen: tweak cgen_rtx_error to fix warningsMike Frysinger3-1/+8
The function was missing a prototype, and passing a constant string as the format string instead of going through a %s format.
2021-05-08sim: cgen: tweak initializers to avoid warningsMike Frysinger2-6/+10
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-08sim: add html & pdf stubsMike Frysinger2-0/+13
We stub out the info targets already since we don't provide any.
2021-05-08sim: use htab_eq_stringTom Tromey2-9/+6
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-07sim: m68hc11: fix up cycle buffer printingMike Frysinger2-5/+8
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-07sim: Add bfd include path for common testsuite toolsDimitar Dimitrov4-2/+12
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-07sim: m32c: clean up various warningsMike Frysinger5-21/+41
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-07sim: m32c: fix warnings about mixing code & declsMike Frysinger3-1/+31
Add scope braces to a bunch of the generated sections to avoid compiler warnings about mixing code & variable declarations.
2021-05-07sim: m32c: switch from custom fgets to getlineMike Frysinger5-105/+17
No need to implement this ourselves when POSIX has a nice API.
2021-05-06sim: m68hc11: fix up last warningsMike Frysinger4-105/+113
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-06sim: m68hc11: warn when emul_write failsMike Frysinger2-2/+10
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-06sim: h8300 special case testYoshinori Sato4-2/+37
In "mov. [bwl] reg, @ -reg", added a special case test using the same register.
2021-05-05sim: m32c/rl78/rx: fix command parsingMike Frysinger6-80/+59
Use buildargv to avoid writing to const memory and freeing invalid pointers, and to avoid doing any string parsing ourselves.
2021-05-04sim: rl78: clean up various warningsMike Frysinger9-17/+34
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-04sim: m68hc11: tweak types to fix warningsMike Frysinger3-2/+7
The hw attach API wants unsigned addresses. The write API wants signed chars.
2021-05-04sim: mips: include stdlib.h for memory prototypesMike Frysinger2-0/+5
This file uses free() and friends, so include it to fix missing prototype warnings.
2021-05-04sim: mips: always enable device modelsMike Frysinger3-18/+8
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-04sim: mips: delete unused constant variablesMike Frysinger4-29/+10
Since these never change, inline and delete them.
2021-05-04sim: mcore: fix build time warningsMike Frysinger4-3/+11
Once we fix a minor const warning we can enable -Werror in here.
2021-05-04sim: remove sys/times.h in most placesMike Frysinger6-3/+12
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-04sim: mips: fix qh_acc tableMike Frysinger2-1/+5
The AccAddLQH func was unused, and looking at this table, it looks like it's due to a typo.
2021-05-04sim: hw: localize init callbackMike Frysinger4-14/+13
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-04sim: microblaze: enable some basic trace pointsMike Frysinger3-0/+9
This isn't super complete, but it's useful enough as-is.
2021-05-04sim: microblaze: hook up libgloss syscallsMike Frysinger6-4/+54
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-04Add missing stdlib.h includes to simTom Tromey10-0/+26
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-04Fix igen buildTom Tromey3-0/+8
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-04Add config.h to generated_files for simTom Tromey2-0/+5
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-04sim: add support for build-time ar & ranlibMike Frysinger68-66/+476
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-04sim: clean up bfd_vma printingMike Frysinger18-42/+79
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-03sim: add ATTRIBUTE_PRINTF / ATTRIBUTE_NULL_PRINTF where necessarySimon Marchi17-21/+50
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-02sim: add default cases to two switches in sim-options.cSimon Marchi2-0/+7
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-02sim: replace custom attributes with ansidecl.hMike Frysinger20-63/+79
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-01sim: bfin: move option inits to respective modulesMike Frysinger4-13/+30
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-01sim: options: fix --help outputMike Frysinger2-0/+5
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-01sim: dv-sockser: localize init callbackMike Frysinger4-12/+12
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-01sim: mips: mark local func staticMike Frysinger2-1/+5