Commit Graph

573 Commits

Author SHA1 Message Date
Alan Modra
93f83dcc94 sim: no rule to make sim/ppc/Makefile.in
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-24 11:52:10 +10:30
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
Mike Frysinger
48157d30b6 sim: ppc: implement 128-bit register read/writes with sim-endian APIs
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-18 01:49:56 -05:00
Mike Frysinger
dcc6c863ed sim: ppc: switch register read/writes to union to avoid aliasing issues
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-18 01:46:27 -05: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
20617191e4 sim: ppc: return register error when unhandled
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-11 00:49:56 -05:00
Mike Frysinger
0846ae35a1 sim: ppc: rework defines.h to handle HAVE symbols defined to 0
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-10 19:53:10 -05:00
Mike Frysinger
92bdeb2888 sim: ppc: workaround uninitialized variable compiler warnings
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-08 20:13:22 -05:00
Mike Frysinger
086d7dbb2e sim: ppc: unify igen filter modules
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-03 03:37:13 -05:00
Mike Frysinger
7811c75893 sim: ppc: unify igen line number output modules
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-03 03:32:08 -05:00
Mike Frysinger
b37a470842 sim: ppc: switch to common endian code
The common sim-endian is a forked & updated version of the ppc code.
Fortunately, they didn't diverge from the basic APIs, so they are
still compatible, which means we can just delete the ppc version now
that the build env is merged at the top-level.
2024-01-03 02:17:16 -05:00
Mike Frysinger
9c81c318f6 sim: ppc: rename local ALU SIGNED64 macros
The common/ code has macros with the same name but different behavior:
it's for declaring integer constants as 64-bit, not for casting them.
Rename ppc's local variant since it's only used in this file in order
to avoid conflicts.
2024-01-03 02:13:55 -05:00
Mike Frysinger
34cacf7d97 sim: ppc: sync WITH_TARGET_{ADDRESS,CELL}_BITSIZE with common/
This will make it easier to share common/ code that rely on these
additional defines.
2024-01-03 02:10:52 -05:00
Mike Frysinger
2c3bcf2537 sim: ppc: hoist compilation up to top-level
This removes all recursive makes from the ppc port.
2024-01-03 01:21:48 -05:00
Mike Frysinger
01c2a7aa69 sim: ppc: 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.  It adds some overhead, so it's not great, but it shouldn't
be a big deal.  This will go away once compilation is hoisted up.
2024-01-03 01:21:48 -05:00
Mike Frysinger
e0e9cd645f sim: ppc: move main.o compilation to top-level 2024-01-03 01:21:48 -05:00
Mike Frysinger
b22ee0e49b sim: ppc: hoist pk.h creation to top-level 2024-01-02 02:22:07 -05:00
Mike Frysinger
10f554512f sim: ppc: hoist hw.[ch] creation to top-level 2024-01-02 02:19:50 -05:00
Mike Frysinger
431d8a2ca4 sim: ppc: hoist igen execution to top-level
Invoke ppc's igen from the top-level like we do for all other ports.
2024-01-02 02:19:50 -05:00
Mike Frysinger
5f7e03a6bb sim: ppc: merge configure logic into top-level
Now that the ppc configure script is just namespaced options, we can
move it to ppc/acinclude.m4 and include it directly in the top-level
configure script and kill off the last subdir configure script.
2024-01-02 01:41:55 -05:00
Mike Frysinger
cc92657346 sim: ppc: scope configure options to --enable-sim-ppc-xxx
To prepare for moving these into the top-level configure, namespace
then with the port name like we do with all other ports.
2024-01-02 01:41:55 -05:00
Mike Frysinger
08e88f27c7 sim: ppc: standardize configure option processing
Switch from ad-hoc $silent checks & echo calls to standard
AC_MSG_CHECKING & AC_MSG_RESULT calls.  Also delete pointless
variable setting after calling AC_MSG_ERROR.
2024-01-02 01:41:55 -05:00
Mike Frysinger
0c53b9d697 sim: ppc: switch to AS_HELP_STRING for automatic formatting 2024-01-02 01:41:55 -05:00
Mike Frysinger
5b6d72c9a5 sim: ppc: drop now unused config.in 2024-01-02 01:41:55 -05:00
Mike Frysinger
93c0f1cf94 sim: ppc: move defines.h generation to the top-level
Since we rely on the top-level config.h now, the defines.h generation
step should live here too.
2024-01-02 00:35:59 -05:00
Mike Frysinger
82931068f4 sim: ppc: drop configure compiler checks
Now that the ppc script only checks configure options and sets up
variables in the Makefile from those, delete all the compile related
logic to greatly simplify the configure script.
2024-01-02 00:35:45 -05:00
Mike Frysinger
2c7cc02f96 sim: ppc: drop custom config.h header
Now that everything has moved to the top-level, we can drop the
custom ppc config.h and reuse the common one.
2024-01-02 00:34:55 -05:00
Mike Frysinger
0b5415c13c sim: ppc: stop including headers from gdb/
The common sim code doesn't snoop in gdb/, and the ppc code doesn't
need to either.  Any common code we pull from gnulib/ now only.
2024-01-02 00:34:34 -05:00
Mike Frysinger
6bf212a8ac sim: ppc: move termios probes to top-level
This is the last compile-time logic in the ppc subdir.
2024-01-02 00:34:15 -05:00
Mike Frysinger
0168f1aedf sim: ppc: switch to AC_CACHE_CHECK
This macro replaces the AC_MSG_CHECKING+AC_CACHE_VAL+AC_MSG_RESULT
which reduces the boilerplate in here a little bit.
2024-01-02 00:32:48 -05:00
Mike Frysinger
1a9f6039fb sim: ppc: switch struct member checks to AC_CHECK_MEMBER
This covers a lot of the AC_MSG_CHECKING+AC_TRY_COMPILE+AC_MSG_RESULT
boilerplate and matches what we do in the top-level platform checks.
2024-01-02 00:32:29 -05:00
Mike Frysinger
e04ab9b01a sim: ppc: move termio defines to config.h
Move the defines from explicit -D options to config.h defines to simplify
the build and make it easier to move to the top-level configure.
2024-01-02 00:31:55 -05:00
Mike Frysinger
d43207b057 sim: ppc: move struct statfs to top-level 2024-01-02 00:31:40 -05:00
Mike Frysinger
568432432a sim: ppc: move long long test to top-level
While the sim code doesn't utilize HAVE_LONG_LONG itself, other code
(like libiberty) seem to, so check for it in the top-level for all
ports to leverage.
2024-01-02 00:31:08 -05:00
Mike Frysinger
d472066471 sim: ppc: hoist sysv tests to top-level
Now that the sysv tests turn into config.h defines and everything
checks that, we can move the tests to the top-level and out of the
ppc subdir.
2024-01-02 00:29:29 -05:00
Mike Frysinger
bc756034ee sim: ppc: always compile in the sysv sem & shm device files
Move the stub logic to the device files themselves.  This makes the
configure & build logic more static which will make it easier to move
to the top-level build, and matches what we did with the common/ hw
tree already.

This also decouples the logic from the two -- in the past, you needed
both sem & shm in order to enable the device models, but now each one
is tied to its own independent knob.  Practically speaking, this will
probably not make a difference, but it simplifies the build a bit.
2024-01-02 00:29:28 -05:00
Mike Frysinger
d961049a26 sim: ppc: change SysV sem & shm tests to compile-time
Instead of executing code to see if SysV semaphores & shared memory
are available, switch to just a compile-time test.  The system used
to compile might not match the system used to run the code wrt the
current kernel & OS settings, but the library APIs should.  So move
the failures from compile-time to runtime so the program is more
portable, and works correctly even when cross-compiling.
2024-01-02 00:29:28 -05:00
Mike Frysinger
d237a93af3 sim: ppc: merge System V semaphores checks
Compile tests can use earlier defines, so hoist the HAVE_UNION_SEMUN
define to before the semaphore check, and use it in the test so that
we can merge the 2 versions into one.

This also defines HAVE_UNION_SEMUN even when ac_cv_sysv_sem is not
set, but that's OK as this define is only about a type existing, not
about whether the overall code is usable.
2024-01-02 00:29:28 -05:00
Mike Frysinger
4d4952a63d sim: ppc: fix bad AC_CACHE_CHECK call with semun
The first arg is the cache var name, and this one was typoed relative
to what the call actually set.  We also don't need the manual call to
AC_MSG_RESULT as the AC_CACHE_CHECK takes care of it for us.
2024-01-02 00:29:28 -05:00
Mike Frysinger
d264d78607 sim: ppc: delete unused build compile & link settings
These should have been removed as part of the ppc/igen merging into the
top-level, but they were missed.  Clean up now.
2024-01-02 00:27:12 -05:00
Mike Frysinger
1b89e2b720 sim: ppc: merge misc igen APIs
The common igen code provides the same misc APIs as the ppc version,
so delete the ppc code and pull in the common one.  There is one
minor difference: the ppc code has a unique dumpf function.  The
common code switched to lf_printf for the same functionality, but
since that requires changes throughout the igen codebase, delay that
cleanup for now so we can merge the rest.
2024-01-01 18:16:38 -05:00
Mike Frysinger
9ddac092a8 sim: ppc: rework igen error to match common
Switch to an ERROR macro and tweak the error signature to match the
common igen version in preparation for merging the two implementations.
2024-01-01 17:39:09 -05:00
Mike Frysinger
9b6e0cb3ba sim: ppc: rename igen max_insn_bit_size
We want to avoid conflicts with the common igen enums.  This should
get migrated over to the common parsing logic, but for now, switch
the name to avoid redefinition.
2024-01-01 17:30:53 -05:00
Mike Frysinger
0a4d338dd0 sim: ppc: unify igen filter_filename implementations
Now that both igen implementations are in the top-level, we can unify
the filter_filename implementation between them since they're the same
(literally the same code).
2024-01-01 17:06:50 -05:00
Mike Frysinger
a243f0a5a1 sim: ppc: replace filter_filename with lbasename
The lbasename function from libiberty provides the same API as this
custom function.  The common/ code already made the switch, so make
the same change to the ppc code to avoid target duplication.
2024-01-01 16:32:48 -05:00
Mike Frysinger
5817b1f52f sim: ppc: hoist igen compilation into top-level
This simplifies the build a bit (especially for deps in port subdirs),
and avoids recursive make.  This in turn speeds up the build, and lets
us reuse existing build-time vs host-time logic from Makefile.am.
2024-01-01 16:12:16 -05:00
Mike Frysinger
179bd7a89d sim: ppc: drop build-config.h usage
This header is only used by the igen tool, and none of the igen code
depends on the configure-time checks.  Delete the logic to simplify
to prepare for moving it to the local.mk code.
2024-01-01 15:59:11 -05:00
Mike Frysinger
a295b6b0cd sim: ppc: simplify filter_host.c logic
Switch this from a build-time generation to a static include.  This
makes the build rules a bit simpler, especially as we move them to
Automake from hand-written makefiles.
2024-01-01 15:59:06 -05:00
Mike Frysinger
22a09a1a33 sim: ppc: drop unused host bitsize settings
This is never set anywhere, so it's always empty.  Scrub it.
2024-01-01 14:52:16 -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