aboutsummaryrefslogtreecommitdiff
path: root/sim
AgeCommit message (Collapse)AuthorFilesLines
2024-06-10regen sim/frv files for copyright updateAlan Modra4-4/+4
2024-06-10autoupdate: replace obsolete macros AC_HELP_STRINGMatthieu Longo1-1/+1
- AC_HELP_STRING by AS_HELP_STRING https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/autoconf.html#index-AC_005fHELP_005fSTRING-1 Except for the ifdef in lib-prefix.m4, make the defun of AC_LIB_ARG_WITH unconditional.
2024-05-09sim: riscv: Fix build issue due to recent binutils commitBernd Edlinger1-1/+2
The commit c144f6383379 removed INSN_CLASS_A and added INSN_CLASS_ZAAMO and INSN_CLASS_ZALRSC instead, which broke the build of the sim for riscv targets. Fix that by using the new INSN_CLASS types. Fixes: c144f6383379 ("RISC-V: Support B, Zaamo and Zalrsc extensions.") Approved-By: Tom Tromey <tom@tromey.com>
2024-04-15sim: riscv: Fix confusion with c.jal vs. c.addiwBernd Edlinger1-4/+4
There was apparently a confusion which cpu model uses compressed JAL and which ADDIW. Fixed that in execute_c, case MATCH_C_JAL | MATCH_C_ADDIW. Fixes 3224e32fb84f ("sim: riscv: Add support for compressed integer instructions") Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-04-15sim: riscv: Make stack 16-byte alignedBernd Edlinger1-0/+2
Various gcc test cases fail due to the stack alignment of 16 bytes is expected by gcc, causing issues mostly with vararg functions, e.g. FAIL: gcc.c-torture/execute/nest-align-1.c -O0 execution test FAIL: gcc.c-torture/execute/nest-stdar-1.c -O0 execution test FAIL: gcc.c-torture/execute/va-arg-12.c -O0 execution test FAIL: gcc.c-torture/execute/va-arg-15.c -O0 execution test FAIL: gcc.c-torture/execute/va-arg-16.c -O0 execution test FAIL: gcc.c-torture/execute/va-arg-17.c -O0 execution test FAIL: gcc.c-torture/execute/va-arg-20.c -O0 execution test FAIL: gcc.c-torture/execute/va-arg-26.c -O0 execution test ... Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-04-15sim: riscv: Fix PC at gdb breakpointsBernd Edlinger1-3/+1
The uncompressed EBREAK instruction does not work correctly this way, and the comment saying that GDB expects us to step over EBREAK is just wrong. The PC was always 4 bytes too high, which skips one instruction at break and step over commands, and causes complete chaos. The compressed EBREAK was already implemented correctly. Tested by using gdb's "target sim" and single-stepping. Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-03-21sim/erc32: Rename EVENT_MAX -> MAX_EVENTSOrgad Shaneh2-4/+4
EVENT_MAX is defined as 0x7FFFFFFF (INT_MAX) in winuser.h, so when building on Windows, the value is overridden and compilation fails because the array size of evbuf is too large. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28476 Approved-By: Tom Tromey <tom@tromey.com>
2024-02-24sim: no rule to make sim/ppc/Makefile.inAlan Modra2-2/+2
Seen with --enable-maintainer-mode. make[3]: *** No rule to make target '.../sim/ppc/Makefile.in', needed by 'ppc/stamp-pk'. Stop. * sim/ppc/local.mk (stamp-pk): Depend on local.mk not Makefile.in. * Makefile.in: Regenerate. Approved-By: Tom Tromey <tom@tromey.com>
2024-02-13sim: riscv: Add support for compressed integer instructionsJaydeep Patil7-8/+437
Added support for simulation of compressed integer instruction set ("c"). Added test file sim/testsuite/riscv/c-ext.s to test compressed instructions. The compressed instructions are available for models implementing C extension. Such as RV32IC, RV64IC, RV32GC, RV64GC etc. Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-01-29sim: bpf: remove support for ldinddw and ldabsdw instructionsJose E. Marchesi2-28/+0
This patch removes support for the two instructions above from the GNU simulator, including the corresponding tests. These instructions do not really exist in BPF and are not recognized as such by the kernel verifier. This has now been pointed out during the standardization of the BPF ISA. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
2024-01-23sim: sh: fix nested braces in struct initMike Frysinger3-1558/+2223
The op struct includes an array of strings, but doesn't use braces around that array when initializing. This causes a ton of warnings when using -Wmissing-braces. Add them to fix. The code this tool generates is the same before & after.
2024-01-22sim: riscv: Fix crash during instruction decodingJaydeep Patil1-1/+1
The match_never() function has been removed and thus step_once() crashes during instruction decoding. Fixed it by checking for null pointer before invoking function attached to match_func member of riscv_opcode structure
2024-01-22sim: frv: fix -Wincompatible-function-pointer-types warnings [PR sim/29752]Mike Frysinger6-63/+59
Some compilers warn in the frv code: sem.c:24343:41: error: incompatible function pointer types passing 'void (SIM_CPU *, UINT, UDI)' (aka 'void (struct _sim_cpu *, unsigned int, unsigned long)') to parameter of type 'void (*)(SIM_CPU *, UINT, DI)' (aka 'void (*)(struct _sim_cpu *, unsigned int, long)') [-Wincompatible-function-pointer-types] This is due to frvbf_h_acc40U_set using UDI for setting the new value, but using the common sim_queue_fn_di_write API which uses DI. The same size, but different sign. We could change frvbf_h_acc40U_set to take a DI without changing behavior in practice: the UDI is already passed via the queue function which accepts a DI, and frvbf_h_acc40U_set already casts the input to UDI before running any operations on it. However, these files are all generated, so manual changes here would be reverted. Seems like we can only change the register type for all APIs in the cpu definition. This builds cleanly, and passes sim unittests. Not sure if it's 100% the answer, but seems to be the best we have currently. Bug: https://sourceware.org/PR29752
2024-01-22sim: Fix -Werror=shadow=local by changing mem to addr in sim_{read,write}Mark Wielaard6-40/+40
m32c/cpu.h defines mem as enum value, which causes GCC 14 to emit sim/m32c/gdb-if.c: In function ‘sim_read’: sim/m32c/gdb-if.c:162:33: error: declaration of ‘mem’ shadows a previous local [-Werror=shadow=local] 162 | sim_read (SIM_DESC sd, uint64_t mem, void *buf, uint64_t length) | ~~~~~~~~~^~~ In file included from ../../binutils-gdb/sim/m32c/gdb-if.c:38: sim/m32c/cpu.h:83:3: note: shadowed declaration is here 83 | mem, | ^~~ Fix this by renaming mem to addr in all sim_read and sim_write functions. Most already used addr instead of mem. In one file, sim/rx/gdb-if.c, this also meant renaming the local addr variable to vma.
2024-01-22sim: Fix some -Werror=shadow=compatible-local issues in aarch64/simulator.cMark Wielaard1-34/+34
With GCC 14 -Werror=shadow=compatible-local flags the reuse of single capital letters used in aarch64/cpustate.h enums 88 | expand_logical_immediate (uint32_t S, uint32_t R, uint32_t N) | ~~~~~~~~~^ In file included from ../../binutils-gdb/sim/aarch64/aarch64-sim.h:27, from ../../binutils-gdb/sim/aarch64/simulator.c:33: 217 | N = 1 << N_IDX | ^ sim/aarch64/simulator.c: In function ‘expand_logical_immediate’: sim/aarch64/simulator.c:88:60: error: declaration of ‘N’ shadows a previous local [-Werror=shadow=compatible-local] sim/aarch64/cpustate.h:217:3: note: shadowed declaration is here
2024-01-22sim: Fix cc -Werror=shadow=local in cr16/simops.cMark Wielaard1-8/+8
include/opcode/cr16.h defines cc as an enum value, which causes GCC 14 to warn sim/cr16/simops.c: In function ‘cond_stat’: sim/cr16/simops.c:138:26: error: declaration of ‘cc’ shadows a previous local [-Werror=shadow=local] 138 | static int cond_stat(int cc) | ~~~~^~ In file included from ../../binutils-gdb/sim/cr16/cr16-sim.h:26, from ../../binutils-gdb/sim/cr16/simops.c:39: sim/../include/opcode/cr16.h:149:3: note: shadowed declaration is here 149 | cc, | ^~ Fix this by renaming cc in cr16/simops.c to cond.
2024-01-18sim: ppc: implement 128-bit register read/writes with sim-endian APIsMike Frysinger1-26/+8
We have APIs in sim-endian for working with 128-bit values like this code is already doing for 8/16/32/64-bit values. Switch over to that to make it a bit simpler, and drop the WITH_ALTIVEC check. The code probably is only used when altivec is enabled, but it doesn't add much to always compile it in, and avoids #ifdef rot by not actually compiling it.
2024-01-18sim: ppc: switch register read/writes to union to avoid aliasing issuesMike Frysinger1-50/+75
This code creates a small buffer on the stack w/alloca, then proceeds to write to it with a cast to a pointer type based on the register type, then reads from it with a cast to a pointer type based on the register size. gcc will flags only one of these lines as "maybe used uninitialized", but it seems to track back to this memory abuse. Create a large union with all the possible types that this code will read or write as, and then use those. It's a bit ugly, but is probably better than using raw memcpy's everywhere.
2024-01-15Regenerate two Makefile.in files to update Copyright headersMark Wielaard1-2/+2
commit 1d506c26d9772bcd84e1a7b3a8c8c5bc602dbf61 Update copyright year range in header of all files managed by GDB updated gnulib/Makefile.am but didn't regenerate gnulib/Makefile.in also sim/Makefile.in was updated, but the Copyright hunks/years were off. The first hunk comes from automake 1.15.1 header-vars.am and so should have 2017 as last year, the second hunk does come from sim/Makefile.am and so should have 2024 as last year. * gnulib/Makefile.in: Regenerate. * sim/Makefile.in: Likewise.
2024-01-12sim: Fix compile errorsDimitar Dimitrov3-12/+12
The following change broke simulator testsuite with host GCC 13: commit 435ad222b3de93fa647fba7221eece36b1b395eb sim: warnings: compile build tools with -Werror too Host GCC13 complains about missing function prototypes: binutils/sim/testsuite/common/bits-gen.c:26:1: error: no previous prototype for ‘gen_struct’ [-Werror=missing-prototypes] 26 | gen_struct (void) | ^~~~~~~~~~ Fix by making the functions static, which instructs the compiler that there is no need for a prototype. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2024-01-12Update copyright year range in header of all files managed by GDBAndrew Burgess671-673/+673
This commit is the result of the following actions: - Running gdb/copyright.py to update all of the copyright headers to include 2024, - Manually updating a few files the copyright.py script told me to update, these files had copyright headers embedded within the file, - Regenerating gdbsupport/Makefile.in to refresh it's copyright date, - Using grep to find other files that still mentioned 2023. If these files were updated last year from 2022 to 2023 then I've updated them this year to 2024. I'm sure I've probably missed some dates. Feel free to fix them up as you spot them.
2024-01-11sim: ppc: return register error when unhandledMike Frysinger1-4/+2
We don't want to fallthru and use cooked_buf when we haven't initialized it to anything. Returning 0 indicates the register wasn't recognized.
2024-01-10sim: m32r: enable warnings in traps.cMike Frysinger2-4/+0
File should be clean now!
2024-01-10sim: m32r: fixup some of the int<->pointer castsMike Frysinger4-31/+94
The m32r trap code was written for a 32-bit Linux host (and really, one whose Linux ABI matched pretty exactly). This has lead to conversions between integers and pointers which breaks down hard on 64-bit hosts. Clean up some of the functions where possible to avoid unnecessary conversions, use uintptr_t to cast 32-bit target pointers to host pointers in some places, and just stub out a few functions that can't easily be salvaged currently when sizeof(void*) is not 32-bits. This is a bit ugly, but lets us enable warnings for the whole file.
2024-01-10sim: m32r: fix missing break statementMike Frysinger1-0/+1
The ftime syscall should not fallthrough to the sync syscall. Clearly the code was missing a break statement.
2024-01-10sim: m32r: migrate ftime() to clock_gettime()Mike Frysinger1-5/+8
The ftime() function has been deprecated since POSIX-1-2004, and removed in POSIX.1-2008. It's also been deprecated/removed in glibc since 2.33. POSIX has always said the function is not portable, and its return value, timezone, and dstflag fields are unspecified. Even if Linux/glibc & m32r had defined behavior, those aren't the host for the sim runtime. So let's stop using the function and switch to clock_gettime. gnulib already has detection support for it, and it's been around since at least POSIX-1-2004.
2024-01-10sim: m32r: cleanup unused variablesMike Frysinger1-3/+1
We've been building this file with -Wno-error, so clean up unused variable warnings.
2024-01-10sim: igen: add printf attributes to the prototypes tooMike Frysinger1-4/+4
While gcc propagates the printf attribute via the typedef, clang doesn't seem to, so add it to the prototypes themselves too. We still keep it on the prototype for cases where it's used as a variable.
2024-01-10gdbsupport: tighten up libiberty code a bit with dnlMike Frysinger1-4/+1
No functional change here, just touch up generated output slightly. Approved-By: Tom Tromey <tom@tromey.com>
2024-01-10sim: build: switch to gdbsupport/libiberty.m4Mike Frysinger5-13/+411
Leverage this common logic to find all the libiberty settings rather than duplicate it ourselves.
2024-01-10sim: ppc: rework defines.h to handle HAVE symbols defined to 0Mike Frysinger2-2/+2
The HAVE_DECL_xxx defines are always defined to 0 or 1. The current defines.h logic assumes every HAVE_xxx symbol is only defined iff it's defined to 1 which causes this to break. Tweak the sed logic to only match defines of 1.
2024-01-08sim: warnings: compile build tools with -Werror tooMike Frysinger4-5/+100
Add support for compiling build tools with various -Werror settings. Since the tools don't compile cleanly with the same set of flags as the rest of the sim code, we need to maintain & test a separate list. Only bother when not cross-compiling so we don't have to test all the flags against the build compiler. This should be good enough for our actual development flows.
2024-01-08sim: igen: fix format-zero-length warningsMike Frysinger1-3/+7
Fix warnings from calling printf functions with "" which normally is useless.
2024-01-08sim: m68hc11: gencode: add printf markingsMike Frysinger1-0/+2
2024-01-08sim: m32c: fix declaration-after-statement warningsMike Frysinger1-2/+3
2024-01-08sim: warnings: fix unused variable warningsMike Frysinger3-76/+7
Leave the igen code in place as it's meant to be used with newer (to-be-written) code ported from the ppc version. The sh code isn't really necessary as the opcodes enums have been maintained independently from here, and the lists are out-of-sync already.
2024-01-08sim: warnings: mark local funcs/vars as staticMike Frysinger2-49/+35
These are only used in the respective files, so mark them as static. This fixes missing prototype warnings at build time.
2024-01-08sim: build: clean more generated outputsMike Frysinger10-125/+147
2024-01-08sim: mips: drop old clean workaroundMike Frysinger2-4/+1
This logic dates back to the original import, and seems to be for handling systems where `rm -f` (i.e. no files) would error out. None of that is relevant for us with current automake, so drop it.
2024-01-08sim: ppc: workaround uninitialized variable compiler warningsMike Frysinger1-2/+2
Some compilers don't understand the semctl API and think it's an input argument even when it's used as an output, and then complains that it is being used uninitialized. Zero it out explicitly to workaround it. This adds some runtime overhead, but should be fairly minor as it's a small stack buffer, and shouldn't be that relevant relative to all the other logic in these functions.
2024-01-08sim: warnings: enable -Wshift-negative-valueMike Frysinger2-0/+2
Now that all the relevant sources are fixed, enable the warning.
2024-01-08sim: sh: avoid left shifting negative valuesMike Frysinger1-2/+2
We just want to create a bitmask here, so cast the mask to unsigned to avoid left shifting a negative value which is undefined behavior.
2024-01-08sim: bfin: avoid left shifting negative valuesMike Frysinger1-2/+2
We just want to create a bitmask here, so cast the mask to unsigned to avoid left shifting a negative value which is undefined behavior.
2024-01-08sim: cgen: rework DI macros to avoid signed left shiftsMike Frysinger1-3/+3
The cgen code uses DI as int64_t and UDI as uint64_t. The DI macros are used to construct 64-bit values from 32-bit values (for the low and high parts). The MAKEDI macro casts the high 32-bit value to a signed 32-bit value before shifting. If this created a negative value, this would be undefined behavior according to the C standard. All we care about is shifting the 32-bits as they are to the high 32-bits, not caring about sign extension (since there's nothing left to shift into), and the low 32-bits being empty. This is what we get from shifting an unsigned value, so cast it to unsigned 32-bit to avoid undefined behavior. While we're here, change the SETLODI macro to truncate the lower value to 32-bits before we set it. If it was passing in a 64-bit value, those high bits would get included too, and that's not what we want. Similarly, tweak the SETHIDI macro to cast the value to an unsigned 64-bit instead of a signed 64-bit. If the value was only 32-bits, the behavior would be the same. If it happened to be signed 64-bit, it would trigger the undefined behavior too.
2024-01-06sim: warnings: enable -Wshadow=localMike Frysinger2-1/+2
This brings us in sync with current set of gdb warnings (for C).
2024-01-06sim: cris: change temp var name slightly to avoid shadowingMike Frysinger2-48/+48
Rename the temp var to avoid shadowing another one: .../sim/cris/semcrisv10f-switch.c:11032:22: error: declaration of ‘tmp_tmpb’ shadows a previous local [-Werror=shadow=compatible-local] 11032 | tmp_tmpb = ({ SI tmp_tmpb; | ^~~~~~~~ .../sim/cris/semcrisv10f-switch.c:11031:24: note: shadowed declaration is here 11031 | tmp_tmpres = ({ SI tmp_tmpb; | ^~~~~~~~
2024-01-06sim: cris: add error fallbacks when decoding condition & swap codesMike Frysinger2-0/+24
The condition & swap code decoder only checks known bits and sets based on that. If the variable is out of range, it ends up returning uninitialized data. Turn that case into a hard error. This fixes build warnings like: sim/cris/semcrisv10f-switch.c:13115:11: error: variable 'tmp_condres' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
2024-01-03sim: ppc: unify igen filter modulesMike Frysinger11-190/+67
The common igen code was forked from the ppc long ago. The filter module is still pretty similar in API, so we can unfork them with a little bit of effort. The filter.c module is still here because of the unique it_is API. The common igen code doesn't seem to have an equiv API as this only operates on two strings and not an actual filter object, and it's easy enough to leave behind to unfork the rest.
2024-01-03sim: ppc: unify igen line number output modulesMike Frysinger13-670/+154
The common igen code was forked from the ppc long ago. The lf module is still pretty similar in API, so we can unfork them with a little bit of effort. Some of the generated ppc code is now slightly different, but that's because of fixes the common igen code has gained, but not the ppc igen code (e.g. fixing of #line numbers). The ppc code retains lf_print__c_code because the common igen code rewrote the logic to a new table.c API. Let's delay that in the ppc code to at least unfork all this code.
2024-01-03sim: igen: clean up headers a bitMike Frysinger17-8/+73
Add standard multiple inclusion protection, and add a few missing local includes when one header uses another. This isn't complete, but fixes some short comings seen when merging the ppc igen.