aboutsummaryrefslogtreecommitdiff
path: root/sim/common
AgeCommit message (Collapse)AuthorFilesLines
2024-01-22sim: Fix -Werror=shadow=local by changing mem to addr in sim_{read,write}Mark Wielaard1-4/+4
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-12Update copyright year range in header of all files managed by GDBAndrew Burgess123-124/+124
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-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-03sim: common: include sim-types.h in the endian header directlyMike Frysinger1-0/+2
This is a bit redundant for most ports as they go through sim-basics.h which always includes sim-types.h before including sim-endian.h, but in order to unify ppc's sim-endian code, we need this include here. Plus, it's the directly we generally want to go to get away from one header that defines all APIs and causes hard to untangle dependencies.
2024-01-01sim: fix pervasive typoTom Tromey5-21/+21
I noticed a typo in a sim constant. This patch fixes it. permenant -> permanent
2023-12-26sim: common: pull in newlib extensions for Linux compatibilityMike Frysinger2-1/+122
Since newlib allows people to opt-in to extra errno names, pull them into our table too. The values don't conflict with each other -- the newlib names & values are distinct from newlib's Linux compatibility.
2023-12-24sim: cgen: mark cgen_rtx_error noreturnMike Frysinger1-1/+1
Since this function never returns, mark it as such to fix some unused variable warnings in error code paths. For example, cris triggers: sim/cris/semcrisv10f-switch.c:3558:11: error: variable 'tmp_newval' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] Even though it has an "else" path that calls this error function.
2023-12-22sim: common: fix -Wshadow=local warningsMike Frysinger2-3/+3
Rename shadowed vars with different types, and delete redundant decls.
2023-12-21sim: mloop: add #line pragmas everywhereMike Frysinger1-0/+32
This will make compiler diagnostics much better with generated code so people can understand the original source file.
2023-12-21sim: common: add $LINENO rewriting support to genmloop scriptsMike Frysinger3-20/+79
The generated mloop files can trigger compile time warnings. It can be difficult to see/understand where the original code is coming from as all the diagnostics point to the generated output. Using #line pragmas, we can point people to the original source files. Unfortunately, this code is written in POSIX shell, and that lacks support for line number tracking. The $LINENO variable, even when available, can just be plain wrong. For example, when using dash and subshells, $LINENO can end up having negative values. Add a wrapper script that will uses awk to rewrite the $LINENO variable to the right value to avoid all that. Basically lineno.sh takes an input script, rewrites all uses of $LINENO into the actual line number (and $0 into the original file name), and then executes the temporary script. This commit doesn't actually add #line pragmas to any files. That comes next.
2023-12-21sim: common: fix -Wimplicit-fallthrough warningsMike Frysinger3-5/+7
Replace some fall through comments with the attribute.
2023-12-21sim: add ATTRIBUTE_FALLTHROUGH for local codeMike Frysinger1-0/+3
We'll replace various /* fall through */ comments so compilers can actually understand what the code is doing.
2023-12-21sim: signal: mark signal callback funcs as noreturn since they don't returnMike Frysinger1-1/+1
All funcs already call other funcs that don't return. The mips port is the only exception because its generic exception handler can return in the case of normal exceptions. So while the exceptions its signal handler triggers doesn't return, we can't express that conditional logic. So add some useless abort calls to make the compiler happy.
2023-12-21sim: common: mark engine restart as noreturnMike Frysinger1-1/+1
This helps the compiler with optimization and fixes fallthru warnings.
2023-12-20sim: common: delete unused scache in some mloop pathsMike Frysinger1-4/+0
The scache vars aren't used by ports in the pbb & fast codepaths, nor are they documented as inputs to the callbacks, so delete them to avoid unused variable compiler warnings.
2023-12-20sim: cgen: unify the genmloop logic a bitMike Frysinger1-0/+5
Pull out the common parts of the genmloop invocation into the common code. This will make it easier to add more, and make the per-port differences a little more obvious.
2023-12-19sim: common: delete unused argbuf in generated mloop codeMike Frysinger1-2/+0
This function only uses prev_abuf, not abuf, and doesn't inline code from the various ports on the fly, so abuf will never be used.
2023-12-19sim: common: fix -Wunused-variable warningsMike Frysinger6-14/+10
2023-12-07sim: common: fix -Wunused-but-set-variable warningsMike Frysinger1-2/+0
2023-08-26Simplify definition of GUILETom Tromey2-5/+1
This patch sets GUILE to just plain 'guile'. In the distant ("devo") past, the top-level build did support building Guile in-tree. However, I don't think this really works any more. For one thing, there are no build dependencies on it, so there's no guarantee it would actually be built before the uses. This patch also removes the use of "-s" as an option to cgen scheme scripts. With my latest patch upstream, this is no longer needed. After the upstream changes, either Guile 2 or Guile 3 will work, with or without the compiler enabled. 2023-08-24 Tom Tromey <tom@tromey.com> * cgen.sh: Don't pass "-s" to cgen. * Makefile.in: Rebuild. * Makefile.am (GUILE): Simplify.
2023-01-18sim: info: convert verbose field to a boolMike Frysinger7-13/+13
The verbose argument has always been an int treated as a bool, so convert it to an explicit bool. Further, update the API docs to match the reality that the verbose value is actually used by some of the internal modules.
2023-01-18sim: unify sim-signal.o buildingMike Frysinger2-2/+3
Now that sim-main.h has been reduced significantly, we can remove it from sim-signal.c and unify it across all boards since it compiles to the same code.
2023-01-16sim: assume sys/stat.h always exists (via gnulib)Mike Frysinger1-2/+0
We have many uses of sys/stat.h that are unprotected by HAVE_SYS_STAT_H, so this is more formalizing the reality that we require this header. Since we switched to gnulib, it guarantees that a sys/stat.h exists for us to include, so we're doubly OK.
2023-01-16sim: formally assume unistd.h always exists (via gnulib)Mike Frysinger7-14/+0
We have many uses of unistd.h that are unprotected by HAVE_UNISTD_H, so this is more formalizing the reality that we require this header. Since we switched to gnulib, it guarantees that a unistd.h exists for us to include, so we're doubly OK.
2023-01-14sim: common: simplify modules.c depsMike Frysinger1-4/+1
Now that all ports (other than ppc) build in the top-level, we don't need to expand all the modules.c targets as a recursive dep. Each port depends on their respective file now, and the ppc port doesn't use it at all.
2023-01-14sim: common: move libcommon.a dep to ppc codeMike Frysinger1-5/+0
Rather than force this to be built ahead of time for all targets, move the dep to the ppc code since it's the only user of it now.
2023-01-14sim: common: move libcommon.a objects to sourcesMike Frysinger1-0/+1
This simplifies the build logic and avoids an Automake bug where the common_libcommon_a_OBJECTS variable isn't set in the arch libsim.a DEPENDENCIES for targets that, alphabetically, come before "common". We aren't affected by that bug with the current code, but as we move things out of SIM_ALL_RECURSIVE_DEPS and rely on finer dependencies, we will trip over it.
2023-01-14sim: common: simplify hw-config.h depsMike Frysinger1-3/+1
Now that all ports (other than ppc) build in the top-level, we don't need to expand all the hw-config.h targets as a recursive dep. Each port depends on their respective header now, and the ppc port doesn't use it at all.
2023-01-14sim: build: drop AM_MAKEFLAGS settingsMike Frysinger1-4/+0
We don't have any recursive builds anymore, so we can drop this logic.
2023-01-13sim: build: delete Make-common.in logicMike Frysinger2-211/+0
Now that all (other than ppc) build in the top-level, this logic is unused, so punt it all.
2023-01-10sim: common: move test-hw-events to top-level buildMike Frysinger3-5/+11
This is an internal developer target that isn't normally compiled, but it can still be occasionally useful. Move it to the top-level build so we can kill off common/Make-common.in.
2023-01-10sim: build: add basic framework for compiling arch objects in top-levelMike Frysinger2-2/+3
The code so far has been assuming that we only compile common/ objects. Now that we're ready to compile arch-specific objects, refactor some of the flags & checks a bit to support both.
2023-01-10sim: modules.c: move generation to top-levelMike Frysinger2-28/+25
Now that all arches create libsim.a from the top-level, we have full access to their inputs, and can move the actual generation from the subdir up to the top-level. This avoids recursive makes and will help simplify state passing between the two.
2023-01-10sim: build: drop support for creating libsim.a in subdirsMike Frysinger1-37/+3
Now that all ports have moved to creating libsim.a in the top-level, drop all the support code to create it in a subdir.
2023-01-10sim: aarch64: move libsim.a creation to top-levelMike Frysinger1-1/+2
The objects are still compiled in the subdir, but the creation of the archive itself is in the top-level. This is a required step before we can move compilation itself up, and makes it easier to review. The downside is that each object compile is a recursive make instead of a single one. On my 4 core system, it adds ~100msec to the build per port, so it's not great, but it shouldn't be a big deal. This will go away of course once the top-level compiles objects.
2023-01-10sim: build: drop support for subdir extra depsMike Frysinger1-14/+0
Nothing uses this hook anymore, so punt it. It was largely used to track generated files (which we do in the top-level now) and extra header files (which we use automake depgen for now).
2023-01-10sim: modules: trigger generation from top-levelMike Frysinger2-3/+18
Add rules for tracking generated subdir modules.c files. This doesn't actually generate the file from the top-level, but allows us to add rules that need to be ordered wrt it. Once those changes land, we can rework this to actually generate from the top-level. This currently builds off of the objects that go into the libsim.a as we don't build those from the top-level either. Once we migrate that up, we can switch this to the source files directly. It's a bit hacky overall, but makes it easier to migrate things in smaller chunks, and we aren't going to keep this logic long term.
2023-01-02sim: common: drop libcommon.a linkageMike Frysinger1-3/+1
All of these objects should be in libsim.a already, so don't link to it too. In practice it never gets used, but no point in listing it.
2023-01-02sim: cgen: drop common subdir build rulesMike Frysinger1-68/+0
Now that everything has been hoisted to the top-level, we can delete this unused logic.
2023-01-02sim: cgen: hoist rules to the top-level buildMike Frysinger1-0/+60
The rules seem to generate the same output as existing subdir cgen rules with cgen ports, so hopefully this should be correct. These are the last set of codegen rules that we run in subdirs, so this will help unblock killing off subdir builds entirely.
2023-01-01sim: replace -I$srcroot/bfd include with -I$srcrootMike Frysinger1-1/+1
Clean up includes a bit by making ports include bfd/ headers explicitly. This matches other projects, and makes it more clear where these headers are coming from.
2023-01-01sim: replace -I$srcroot/opcodes include with -I$srcrootMike Frysinger1-1/+1
Clean up includes a bit by making ports include opcodes/ headers explicitly. This matches other projects, and makes it more clear where these headers are coming from.
2023-01-01sim: build: drop unused SIM_EXTRA_LIBSMike Frysinger1-3/+1
Now that all run binaries are linked in the topdir, this subdir libs variable isn't used anywhere, so punt it.
2023-01-01sim: refresh copyright dates a bitMike Frysinger1-1/+1
Update a few files that were missed, and revert the generated Automake output that uses dates from Automake itself.
2023-01-01Update copyright year range in header of all files managed by GDBJoel Brobecker123-123/+123
This commit is the result of running the gdb/copyright.py script, which automated the update of the copyright year range for all source files managed by the GDB project to be updated to include year 2023.
2022-12-27sim: build: clean up unused codegen logicMike Frysinger1-8/+1
Now that all igen ports are in the top-level makefile, we don't need this logic in any subdirs anymore, so clean it up.
2022-12-25sim: build: drop support for subdir distcleanMike Frysinger1-5/+2
All ports that need to clean things up at distclean time have moved to the top-level build, so we can drop support for this hook.
2022-12-25sim: smp: plumb igen flag down to all usersMike Frysinger1-1/+1
While mips has respected sim_igen_smp at configure time (which was always empty since it defaulted smp to off), no other igen port did. Move this to a makefile variable and plumb it through the common IGEN_RUN variable instead so everyone gets it by default. We also clean up some redundant -N0 setting with multirun mips.
2022-12-25sim: cpu: change default init to handle all cpusMike Frysinger1-0/+5
All the runtimes were only initializing a single CPU. When SMP is enabled, things quickly crash as none of the other CPU structs are setup. Change the default from 0 to the compile time value.
2022-12-25sim: cpu: fix SMP msg prefix helperMike Frysinger1-4/+7
This code fails to compile when SMP is enabled due to some obvious errors. Fix those and change the logic to avoid CPP to prevent any future rot from creeping back in.