Commit Graph

1252 Commits

Author SHA1 Message Date
Mark Wielaard
cbbcd7fd10 sim: Fix -Werror=shadow=local by changing mem to addr in sim_{read,write}
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-22 14:22:30 +01:00
Andrew Burgess
1d506c26d9 Update copyright year range in header of all files managed by GDB
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-12 15:49:57 +00:00
Mike Frysinger
b2ea48df92 sim: cgen: rework DI macros to avoid signed left shifts
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-08 20:01:05 -05:00
Mike Frysinger
d4edfa1e2e sim: common: include sim-types.h in the endian header directly
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-03 02:15:54 -05:00
Tom Tromey
cbbb73f4f9 sim: fix pervasive typo
I noticed a typo in a sim constant.  This patch fixes it.
	permenant -> permanent
2024-01-01 10:44:13 -05:00
Mike Frysinger
a70dcdebbd sim: common: pull in newlib extensions for Linux compatibility
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-26 22:53:31 -05:00
Mike Frysinger
9e6855c7cb sim: cgen: mark cgen_rtx_error noreturn
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-24 05:09:28 -05:00
Mike Frysinger
ef382e84b7 sim: common: fix -Wshadow=local warnings
Rename shadowed vars with different types, and delete redundant decls.
2023-12-22 23:29:19 -05:00
Mike Frysinger
6003fe166d sim: mloop: add #line pragmas everywhere
This will make compiler diagnostics much better with generated code
so people can understand the original source file.
2023-12-21 20:16:26 -05:00
Mike Frysinger
c0e97c8525 sim: common: add $LINENO rewriting support to genmloop scripts
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-21 20:16:26 -05:00
Mike Frysinger
9362022e95 sim: common: fix -Wimplicit-fallthrough warnings
Replace some fall through comments with the attribute.
2023-12-21 01:59:22 -05:00
Mike Frysinger
29f1ffea25 sim: add ATTRIBUTE_FALLTHROUGH for local code
We'll replace various /* fall through */ comments so compilers can
actually understand what the code is doing.
2023-12-21 01:59:22 -05:00
Mike Frysinger
d137b254d9 sim: signal: mark signal callback funcs as noreturn since they don't return
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-21 01:59:22 -05:00
Mike Frysinger
c5190830db sim: common: mark engine restart as noreturn
This helps the compiler with optimization and fixes fallthru warnings.
2023-12-21 01:23:00 -05:00
Mike Frysinger
a4de6c88c9 sim: common: delete unused scache in some mloop paths
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-20 22:13:28 -05:00
Mike Frysinger
09d4e6bb2f sim: cgen: unify the genmloop logic a bit
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-20 21:24:40 -05:00
Mike Frysinger
e875d98ee5 sim: common: delete unused argbuf in generated mloop code
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-19 06:54:56 -05:00
Mike Frysinger
715dd70c29 sim: common: fix -Wunused-variable warnings 2023-12-19 05:51:09 -05:00
Mike Frysinger
3762437ead sim: common: fix -Wunused-but-set-variable warnings 2023-12-07 22:31:21 -07:00
Tom Tromey
fd669f71ea Simplify definition of GUILE
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-08-26 13:09:38 -06:00
Mike Frysinger
cc67f780ec sim: info: convert verbose field to a bool
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-18 20:47:55 -05:00
Mike Frysinger
7fd14d6f58 sim: unify sim-signal.o building
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-18 19:26:58 -05:00
Mike Frysinger
da8c966399 sim: assume sys/stat.h always exists (via gnulib)
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-16 04:42:47 -05:00
Mike Frysinger
4cd7de783b sim: formally assume unistd.h always exists (via gnulib)
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-16 04:35:48 -05:00
Mike Frysinger
1b907fc09f sim: common: simplify modules.c deps
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-14 21:01:33 -05:00
Mike Frysinger
4df7470704 sim: common: move libcommon.a dep to ppc code
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-14 20:51:53 -05:00
Mike Frysinger
eac2fbdc4b sim: common: move libcommon.a objects to sources
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-14 20:48:49 -05:00
Mike Frysinger
49444feaef sim: common: simplify hw-config.h deps
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-14 20:44:40 -05:00
Mike Frysinger
068b723abc sim: build: drop AM_MAKEFLAGS settings
We don't have any recursive builds anymore, so we can drop this logic.
2023-01-14 20:41:24 -05:00
Mike Frysinger
fe0adb538f sim: build: delete Make-common.in logic
Now that all (other than ppc) build in the top-level, this logic is
unused, so punt it all.
2023-01-13 17:34:53 -05:00
Mike Frysinger
b014c9b087 sim: common: move test-hw-events to top-level build
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-10 01:15:29 -05:00
Mike Frysinger
bc438b3e59 sim: build: add basic framework for compiling arch objects in top-level
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-10 01:15:26 -05:00
Mike Frysinger
54e26255ca sim: modules.c: move generation to top-level
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-10 01:15:26 -05:00
Mike Frysinger
e732fe9b4f sim: build: drop support for creating libsim.a in subdirs
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-10 01:15:26 -05:00
Mike Frysinger
c58353b786 sim: aarch64: move libsim.a creation to top-level
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-10 01:15:23 -05:00
Mike Frysinger
7a1e1f9463 sim: build: drop support for subdir extra deps
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-10 01:15:23 -05:00
Mike Frysinger
437eeee95c sim: modules: trigger generation from top-level
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-10 01:15:23 -05:00
Mike Frysinger
127d167a98 sim: common: drop libcommon.a linkage
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-02 22:21:01 -05:00
Mike Frysinger
3b89a7b8ce sim: cgen: drop common subdir build rules
Now that everything has been hoisted to the top-level, we can delete
this unused logic.
2023-01-02 20:31:56 -05:00
Mike Frysinger
93b937c903 sim: cgen: hoist rules to the top-level build
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-02 20:26:27 -05:00
Mike Frysinger
c217e3d54e sim: replace -I$srcroot/bfd include with -I$srcroot
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-01 23:17:07 -05:00
Mike Frysinger
60a1031181 sim: replace -I$srcroot/opcodes include with -I$srcroot
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-01 23:14:19 -05:00
Mike Frysinger
33383d1674 sim: build: drop unused SIM_EXTRA_LIBS
Now that all run binaries are linked in the topdir, this subdir libs
variable isn't used anywhere, so punt it.
2023-01-01 17:46:15 -05:00
Mike Frysinger
0d9d77e506 sim: refresh copyright dates a bit
Update a few files that were missed, and revert the generated Automake
output that uses dates from Automake itself.
2023-01-01 15:09:19 -05:00
Joel Brobecker
213516ef31 Update copyright year range in header of all files managed by GDB
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.
2023-01-01 17:01:16 +04:00
Mike Frysinger
b19d96d139 sim: build: clean up unused codegen logic
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-27 00:31:34 -05:00
Mike Frysinger
2a005e97c9 sim: build: drop support for subdir distclean
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-25 14:24:05 -05:00
Mike Frysinger
111b1cf97e sim: smp: plumb igen flag down to all users
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-25 02:13:32 -05:00
Mike Frysinger
883be19774 sim: cpu: change default init to handle all cpus
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-25 02:10:46 -05:00
Mike Frysinger
fb74976044 sim: cpu: fix SMP msg prefix helper
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.
2022-12-25 02:09:17 -05:00