Commit Graph

290 Commits

Author SHA1 Message Date
Orgad Shaneh
acaf48b921 sim/erc32: Rename EVENT_MAX -> MAX_EVENTS
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-03-21 10:46:23 -06:00
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
a4531a4010 sim: erc32: fix -Wshadow=local warnings
Rename shadowed vars with different types to avoid confusion.
2023-12-22 23:29:19 -05:00
Mike Frysinger
fcad8e6ba7 sim: erc32: fix -Wimplicit-fallthrough warnings
Add the attribute where it seems to make sense.
2023-12-21 01:59:22 -05:00
Mike Frysinger
c6ce030ba9 sim: erc32: fix -Wunused-variable warnings 2023-12-19 05:51:10 -05:00
Mike Frysinger
89d7fc2ab0 sim: erc32: fix -Wunused-but-set-variable warnings 2023-12-07 21:41:27 -07: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
109a0a7e90 sim: modules.c: fix generation after recent refactors
Add explicit arch-specific modules.c rules to keep the build from
generating an incorrect common/modules.c.  Otherwise the pattern
rules would cascade such that it'd look for $arch/modules.o which
turned into common/modules.c which triggered the gen rule.

My local testing of this code didn't catch this bug because of how
Automake manages .Po (dependency files) in incremental builds -- it
was adding extra rules that override the pattern rules which caused
the build to generate correct modules.c files.  But when building
from a cold cache, the pattern rules would force common/modules.c to
be used leading to crashes at runtime.
2023-01-15 20:55:48 -05:00
Mike Frysinger
72be276fff sim: common: move modules.c to source tracking
This makes sure the arch-specific modules.c wildcard is matched and
not the common/%.c so that we compile it correctly.  It also makes
sure each subdir has depdir logic enabled.
2023-01-14 20:53:13 -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
6baf06097b sim: build: drop subdir Makefile.in files
These aren't used anymore, so punt them all.
2023-01-11 22:49:28 -05:00
Mike Frysinger
b36a89d135 sim: move arch-specific file compilation of common/ files to top-level 2023-01-10 01:15:29 -05:00
Mike Frysinger
304195bcf8 sim: erc32: move arch-specific file compilation to top-level
The arch-specific flags are only used by the arch-specific modules,
not the common/ files, so we can delete them too.
2023-01-10 01:15:28 -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
3f6c63ac49 sim: erc32: 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:24 -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
2a1b3235f2 sim: erc32: drop -I$(srcroot)
Since the port doesn't actually use this include, drop it.
No other port is doing this either.
2023-01-01 17:43:25 -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
63fd5b5dda sim: switch sim_{read,write} APIs to 64-bit all the time [PR sim/7504]
We've been using SIM_ADDR which has always been 32-bit.  This means
the upper 32-bit address range in 64-bit sims is inaccessible.  Use
64-bit addresses all the time since we want the APIs to be stable
regardless of the active arch backend (which can be 32 or 64-bit).

The length is also 64-bit because it's completely feasible to have
a program that is larger than 4 GiB in size/image/runtime.  Forcing
the caller to manually chunk those accesses up into 4 GiB at a time
doesn't seem useful to anyone.

Bug: https://sourceware.org/PR7504
2022-12-22 19:29:24 -05:00
Mike Frysinger
93e0ec910a sim: build: respect AM_MAKEFLAGS when entering subdirs
This doesn't matter right now, but it will as we add more flags to
the recursive make step to pass state down.
2022-11-06 21:48:42 +07:00
Mike Frysinger
c95bd9111e sim: use libtool to install programs
Now that we use libtool to link, we have to use it to install instead
of keeping the manual logic so we don't install wrapper shell scripts.
2022-11-05 20:28:14 +07:00
Mike Frysinger
c0c25232da sim: run: move linking into top-level
Automake will run each subdir individually before moving on to the next
one.  This means that the linking phase, a single threaded process, will
not run in parallel with anything else.  When we have to link ~32 ports,
that's 32 link steps that don't take advantage of parallel systems.  On
my really old 4-core system, this cuts a multi-target build from ~60 sec
to ~30 sec.  We eventually want to move all compile+link steps to this
common dir anyways, so might as well move linking now for a nice speedup.

We use noinst_PROGRAMS instead of bin_PROGRAMS because we're taking care
of the install ourselves rather than letting automake process it.
2022-11-05 20:00:56 +07:00
Mike Frysinger
59d8576e4f sim: build: add uninstall support
This never worked before, but adding it to the common top-level dir
is pretty easy to do now that we're unified.
2022-11-05 16:26:15 +07:00
Mike Frysinger
63bf33ff90 sim: build: move install steps to the top-level
We still have to maintain custom install rules due to how we rename
arch-specific files with an arch prefix in their name, but we can at
least unify the logic in the common dir.
2022-11-05 16:26:08 +07:00
Mike Frysinger
0dea8b8d9f sim: drop -lm from SIM_EXTRA_LIBS
We have configure tests for this in the top-level configure script
to link this when necessary, so we don't need to explicitly list it
for specific ports.
2022-11-04 07:42:31 +07:00
Mike Frysinger
fa71c76d47 sim: erc32: link sis to run program
The erc32 sim does a lot itself, including handling of the CLI.  It
used to provide a run-compatible interface in the pre-nrun days, but
it was dropped when the old run interface was punted.  Since the old
commit 465fb143c8 ("sim: make nrun the
default run program"), the erc32 run & sis programs have been the
same, and erc32 hasn't provide a real run-compatible interface.

Simplify this by linking the two programs via ln/cp instead of running
the linking phase twice to produce the same result.  If/when we fix up
the erc32 port to have a proper run interface, it should be easy to
split these back apart into real programs.

Note: the interf.o reference in here is a bit of a misdirect.  Since
that object is placed into libsim.a, it's never been linked into the
programs since the linker ignores objects that aren't referenced, and
only gdb uses those symbols.
2022-11-04 01:37:07 +07:00
Mike Frysinger
ee1cffd388 sim: common: change sim_{fetch,store}_register helpers to use void* buffers
When reading/writing arbitrary data to the system's memory, the unsigned
char pointer type doesn't make that much sense.  Switch it to void so we
align a bit with standard C library read/write functions, and to avoid
having to sprinkle casts everywhere.
2022-11-02 20:31:10 +05:45
Mike Frysinger
5bab16fdf1 sim: reg: constify store helper
These functions only read from memory, so mark the pointer as const.
2022-10-31 21:24:39 +05:45
Mike Frysinger
5b94c38081 sim: common: change sim_read & sim_write to use void* buffers
When reading/writing arbitrary data to the system's memory, the unsigned
char pointer type doesn't make that much sense.  Switch it to void so we
align a bit with standard C library read/write functions, and to avoid
having to sprinkle casts everywhere.
2022-10-31 21:24:39 +05:45
Tsukasa OI
57e3eee069 sim/erc32: Use int32_t as IRQ callback argument
Clang generates a warning if an argument is passed to a function without
prototype (zero arguments, even without (void)).  Such calls are deprecated
forms of indefinite arguments passing ("-Wdeprecated-non-prototype").
On the default configuration, it (somehow) doesn't cause a build failure but
a warning is generated.

But because the cause is the same as the issue the author fixed in
"sim/erc32: Use int32_t as event callback argument", it would be better to
fix it now to prevent problems in the future.

To fix the issue, this commit makes struct irqcall to use int32_t as a
callback (callback) argument of an IRQ.
2022-10-29 08:13:15 +00:00
Tsukasa OI
e47530f72f sim/erc32: Use int32_t as event callback argument
Clang generates a warning if an argument is passed to a function without
prototype (zero arguments, even without (void)).  Such calls are deprecated
forms of indefinite arguments passing ("-Wdeprecated-non-prototype").
On the default configuration, it causes a build failure (unless
"--disable-werror" is specified).

To fix that, this commit makes struct evcell to use int32_t as a callback
(cfunc) argument of an event.  int32_t is chosen because "event" function
accepts "int32_t arg".
2022-10-29 08:13:15 +00:00
Tsukasa OI
dc4e697f2f sim/erc32: Insert void parameter
Clang generates a warning if there is a function declaration/definition
with zero arguments.  Such declarations/definitions without a prototype (an
argument list) are deprecated forms of indefinite arguments
("-Wdeprecated-non-prototype").  On the default configuration, it causes a
build failure (unless "--disable-werror" is specified).

This commit replaces () with (void) to avoid this warning.
2022-10-29 08:13:15 +00:00
Andrew Burgess
d0a7ca87ab sim/erc32: avoid dereferencing type-punned pointer warnings
When building the erc32 simulator I get a few warnings like this:

  /tmp/build/sim/../../src/sim/erc32/exec.c:1377:21: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   1377 |   sregs->fs[rd] = *((float32 *) & ddata[0]);
        |                    ~^~~~~~~~~~~~~~~~~~~~~~~

The type of '& ddata[0]' will be 'uint32_t *', which is what triggers
the warning.

This commit makes use of memcpy when performing the type-punning,
which resolves the above warnings.

With this change, I now see no warnings when compiling exec.c, which
means that the line in Makefile.in that disables -Werror can be
removed.

There should be no change in behaviour after this commit.
2022-10-19 14:32:22 +01:00
Tsukasa OI
682389d557 sim/erc32: Add ATTRIBUTE_PRINTF
Clang generates a warning if the format string of a printf-like function is
not a literal ("-Wformat-nonliteral").  On the default configuration, it
causes a build failure (unless "--disable-werror" is specified).

To avoid warnings on the printf-like wrapper, it requires proper
__attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason.

This commit adds ATTRIBUTE_PRINTF to the printf-like functions.
2022-10-11 15:18:14 +01:00
Andrew Burgess
a411a714f3 sim/erc32: fix gdb with simulator build
In commit:

  commit 7b01c1cc1d
  Date:   Mon Apr 4 22:38:04 2022 +0100

      sim: fixes for libopcodes styled disassembler

changes were made to the simulator source to handle the new libopcodes
disassembler styling API.

Unfortunately, these changes broke building GDB with the erc32 (sparc)
simulator, like this:

  ../src/configure --target=sparc-linux
  make all-gdb
  ....
  /usr/bin/ld: ../sim/erc32/libsim.a(interf.o): in function `sim_open':
  /tmp/build/sim/../../src/sim/erc32/interf.c:247: undefined reference to `fprintf_styled'
  collect2: error: ld returned 1 exit status

The problem is that in commit 7b01c1cc1d the fprintf_styled function
was added into sis.c.  This file is only used when building the 'run'
binary, that is, the standalone simulator, and is not included in the
libsim.a library.

Now, the obvious fix would be to move fprintf_styled into libsim.a,
however, that turns out to be tricky.

The erc32 simulator currently has two copies of the function run_sim,
one in sis.c, and one in interf.c, both of these copies are global.

Currently, the 'run' binary links fine, though I suspect this might be
pure luck.  When I tried moving fprintf_styled into interf.c, I ran
into multiple-definition (of run_sim) errors.  I suspect that by
requiring the linker to pull in fprintf_styled from libsim.a I was
changing the order in which symbols were loaded, and the linker was
now seeing both copies of run_sim, while currently we only see one
copy.

The ideal solution of course, would be to merge the two similar, but
slightly different copies of run_sim, and just use the one copy.  Then
we could safely move fprintf_styled into interf.c too, and all would
be good.

But I don't have time right now to start debugging the erc32
simulator, so I wanted a solution that fixes the build without
introducing multiple definition errors.

The easiest solution I think is to just have two copies of
fprintf_styled, one in sis.c, and one in interf.c.  Unlike run_sim,
these two copies are both static, so we will not run into multiple
definition issues with this function.  The functions themselves are
not very big, so it's not a huge amount of duplicate code.

I am very aware that this is not an ideal solution, and I would
welcome anyone who wants to take on fixing the run_sim problem
properly, and then cleanup the fprintf_styled duplication.
2022-09-04 18:02:15 +01:00
Alan Modra
29136be7df Don't use BFD_VMA_FMT in gdb and sim
Like commit b82817674f, this replaces BFD_VMA_FMT "x" in sim/ with
PRIx64 and casts to promote bfd_vma to uint64_t.  The one file using
BFD_VMA_FMT in gdb/ instead now uses hex_string, and a typo in the
warning message is fixed.
2022-08-06 08:03:16 +09:30
Andrew Burgess
7b01c1cc1d sim: fixes for libopcodes styled disassembler
In commit:

  commit 60a3da00bd
  Date:   Sat Jan 22 11:38:18 2022 +0000

      objdump/opcodes: add syntax highlighting to disassembler output

I broke several sim/ targets by forgetting to update their uses of the
libopcodes disassembler to take account of the new styled printing.

These should all be fixed by this commit.

I've not tried to add actual styled output to the simulator traces,
instead, the styled print routines just ignore the style and print the
output unstyled.
2022-04-04 22:41:24 +01:00
Mike Frysinger
4a92dedc59 sim: erc32: migrate to standard uintXX_t types
This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.
2022-01-06 01:17:38 -05:00
Joel Brobecker
4a94e36819 Automatic Copyright Year update after running gdb/copyright.py
This commit brings all the changes made by running gdb/copyright.py
as per GDB's Start of New Year Procedure.

For the avoidance of doubt, all changes in this commits were
performed by the script.
2022-01-01 19:13:23 +04:00
Mike Frysinger
de8a2781a5 sim: use ## for automake comments
The ## marker tells automake to not include the comment in its
generated output, so use that in most places where the comment
only makes sense in the inputs.
2021-12-09 01:40:28 -05:00
Mike Frysinger
23bd26ecf6 sim: erc32: drop old configure target
There is no configure script in here anymore to regenerate.
2021-12-04 13:45:16 -05:00
Mike Frysinger
ed939535e2 sim: install various doc files 2021-11-19 03:36:45 -05:00
Mike Frysinger
d0d7f2a742 sim: erc32: reduce -Wno-error scope
Only one file in here still generates warnings, so reduce the -Werror
disable to that alone now that we require GNU make and can set variables
on a per-object basis.
2021-11-01 00:55:02 -04:00
Mike Frysinger
f9cd2be59c sim: erc32: use silent build rules with sis linkage 2021-10-31 04:19:41 -04:00
Mike Frysinger
5b3c2b9f3b sim: erc32: fix a few more build warnings
Tweak the if indentation & brace style to avoid ambiguous warnings.

Add ATTRIBUTE_UNUSED to UART functions that aren't used when FAST_UART
is defined (which is the default).
2021-10-31 04:18:58 -04:00
Orgad Shaneh
4ab6404b1c sim: erc32: fix signedness compatibility and redefinition warnings 2021-10-31 04:11:38 -04:00
Mike Frysinger
9335d9f823 sim: rename ChangeLog files to ChangeLog-2021
Now that ChangeLog entries are no longer used for sim patches,
this commit renames all relevant sim ChangeLog to ChangeLog-2021,
similar to what we would do in the context of the "Start of New
Year" procedure.

The purpose of this change is to avoid people merging ChangeLog
entries by mistake when applying existing commits that they are
currently working on.

Also throw in a .gitignore entry to keep people from adding new
ChangeLog files anywhere in the sim tree.
2021-08-17 20:27:36 -04:00
Mike Frysinger
c8d4ff8a3a sim: erc32: use libsim.a for common objects
We're starting to move more objects to the common build that sis did
not need before, so linking them is causing problems (when common
objects end up needing symbols from non-common objects).  Switch it
to the libsim.a archive which will allow the link to pull out only
what it needs.
2021-07-08 02:30:37 -04:00
Mike Frysinger
5d0b3088f7 sim: erc32: merge with common configure script
Move the unique library tests to the common code so we can delete
the erc32 configure logic entirely.
2021-06-27 01:21:47 -04:00