Commit Graph

3999 Commits

Author SHA1 Message Date
Andrew Burgess
73d4725f21 sim/rx: mark some functions as static
Some functions that should be marked static.

sim/rx/ChangeLog:

	* fpu.c (check_exceptions): Make static.
	* gdb-if.c (handle_step): Likewise.
	* mem.c (mem_put_byte): Likewise.
2021-02-08 11:01:07 +00:00
Andrew Burgess
1c3e93a41f sim/rx: fill in missing 'void' for empty argument lists
Ensure we have 'void' inside empty argument lists.  This was causing
several warnings for the rx simulator.

sim/rx/ChangeLog:

	* cpu.h (trace_register_changes): Add void parameter type.
	* err.c (ee_overrides): Likewise.
	* mem.c (mem_usage_stats): Likewise.
	(e): Likewise.
	* reg.c (stack_heap_stats): Likewise.
	* rx.c (pop): Likewise.
	(poppc): Likewise.
	(decode_opcode): Likewise.
	* syscalls.c (arg): Likewise.
2021-02-08 11:01:07 +00:00
Andrew Burgess
93a01471f3 sim/rx: fix an issue where we try to modify a const string
While experimenting with switching on warnings for the rx simulator I
discovered this bug.  In sim_do_command we get passed a 'const char *'
argument.  We create a copy of this string to work with locally, but
then while processing this we accidentally switch back to reference
the original string.

sim/rx/ChangeLog:

	* gdb-if.c (sim_do_command): Work with a copy of the command.
2021-02-08 11:01:07 +00:00
Andrew Burgess
0309f9549d sim/rx: define sim_memory_map
The rx simulator doesn't define sim_memory_map and so fails to link
with GDB.  Define it now to return NULL, this can be extended later to
return an actual memory map if anyone wants this functionality.

sim/rx/ChangeLog:

	* gdb-if.c (sim_memory_map): New function.
2021-02-08 11:01:07 +00:00
Mike Frysinger
7a9bd3b4e2 sim: erc32/m32c/rl78: add sim_memory_map stub for gdb
These ports don't use the common sim core, so they weren't providing
a sim_memory_map for gdb, so they failed to link with the new memory
map logic added for the sim.  Add stubs to fix.
2021-02-06 12:15:34 -05:00
Mike Frysinger
4c0d76b9c4 sim: watchpoints: use common sim_pc_get
Few arches implement STATE_WATCHPOINTS()->pc while all of them implement
sim_pc_get.  Lets switch the sim-watch core for monitoring pc events to
the sim_pc_get API so this module works for all ports, and then we can
delete this old back channel of snooping in the port's cpu state -- the
code needs the pointer to the pc storage so that it can read out bytes
and compare them to the watchrange.

This also fixes the logic on multi-cpu sims by removing the limitation
of only being able to watch CPU0's state.
2021-02-06 12:12:51 -05:00
Mike Frysinger
cd89c53f6d sim: add ChangeLog entries for last commits 2021-02-06 12:07:08 -05:00
Mike Frysinger
8e25beb4af sim: igen: drop libiberty linkage
This dir doesn't use anything from libiberty, so drop the linkage.
2021-02-06 12:01:40 -05:00
Mike Frysinger
7a36eeea26 sim: common: switch AC_CONFIG_HEADERS
The AC_CONFIG_HEADER macro is long deprecated, so switch to the
newer form.  This also gets rid of the position limitation, and
drops support for an argument to SIM_AC_COMMON which we haven't
used anywhere.
2021-02-06 12:00:42 -05:00
Mike Frysinger
aa09469fc6 sim: drop use of bfd/configure.host
These settings might have made sense in darker compiler times, but I
think they're largely obsolete now.  Looking through the values that
get used in HDEFINES, it's quite limited, and configure itself should
handle them.  If we still need something, we can leverage standard
autoconf macros instead, after we get a clear user report.

TDEFINES was never set anywhere and was always empty, so prune that.
2021-02-06 10:56:11 -05:00
Mike Frysinger
04b4939b03 gdb: riscv: enable sim integration
Now the simulator can be loaded via gdb using "target sim".
2021-02-04 19:15:17 -05:00
Mike Frysinger
b9249c461c sim: riscv: new port
This is a hand-written implementation that should have fairly complete
coverage for the base integer instruction set ("i"), and for the atomic
("a") and integer multiplication+division ("m") extensions.  It also
covers 32-bit & 64-bit targets.

The unittest coverage is a bit weak atm, but should get better.
2021-02-04 19:02:19 -05:00
Mike Frysinger
6451541244 sim: cgen-trace: tweak printf call
GCC warns that we pass a non-string literal as the format string,
so add an explicit "%s" to make it happy.
2021-01-31 17:31:44 -05:00
Mike Frysinger
bccec180ce sim: bpf: fix mainloop extract call
The extract function takes the argbuf, not the scache.
2021-01-31 17:19:38 -05:00
Mike Frysinger
ba2f0de216 sim: bpf/or1k: fix CGEN_TRACE_EXTRACT name
We renamed these years ago, but it looks like the cgen core missed the
TRACE_EXTRACT function, so these new ports still used the incompatible
common name.  Fix those ports to use the right func.
2021-01-31 17:08:49 -05:00
Stafford Horne
5bc4f5ca15 sim: cgen-accfp: Fix pointer sign warnings
When compiling we get the following warnings:

  common/cgen-accfp.c: In function 'fixsfsi':
  common/cgen-accfp.c:370:18: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign]
     sim_fpu_to32i (&res, &op1, sim_fpu_round_near);
                    ^
  common/cgen-accfp.c: In function 'fixdfsi':
  common/cgen-accfp.c:381:18: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign]
     sim_fpu_to32i (&res, &op1, sim_fpu_round_near);
                    ^
2021-01-31 15:26:58 -05:00
Mike Frysinger
5f05936d9b sim: v850: cleanup build warnings
This port only had one minor warning left in it, so fix it and then
enable -Werror behavior by deleting the macro call.  We'll use the
common default now (which is -Werror).
2021-01-31 15:19:16 -05:00
Mike Frysinger
44b30b7f0e sim: v850: fix handling of SYS_times
My recent rewrite of the nltvals generator fixed a bug where SYS_times
was not being exported for v850.  But that in turn uncovered this bug
where the SYS_times codepath had a compile error.
2021-01-31 15:15:33 -05:00
Mike Frysinger
3c811346e9 sim: moxie: cleanup build warnings
This port only had one minor warning left in it, so fix it and then
enable -Werror behavior by deleting the macro call.  We'll use the
common default now (which is -Werror).
2021-01-31 12:06:29 -05:00
Mike Frysinger
9a7ba4aa0e sim: common: change gennltvals helper to Python
This tool is only run by developers and not in a release build,
so rewrite it in Python to make it more maintainable.
2021-01-30 20:17:46 -05:00
Mike Frysinger
683b8d961e sim: m68hc11: fix printf size warnings
GCC complains %llu is wrong for signed64, so switch to PRIi64.
2021-01-30 10:40:26 -05:00
Mike Frysinger
b9e016f517 sim: m68hc11: localize a few functions
These are only used in this file and lack prototypes, so gcc
complains about it.  Add static everywhere to clean that up.
2021-01-30 10:28:38 -05:00
Mike Frysinger
fb8d4e59af sim: m68hc11: tweak printf-style funcs
GCC complains that we past non-string literals to a printf style func,
so put a %s in here to keep it quiet.
2021-01-30 10:25:04 -05:00
Mike Frysinger
ee64caae5b sim: m68hc11: include stdlib.h for prototypes
These files use abort() & strtod(), so include stdlib.h for them.
2021-01-30 10:21:15 -05:00
Mike Frysinger
d4e3adda12 sim: watchpoints: change sizeof_pc to sizeof(sim_cia)
Existing ports already have sizeof_pc set to the same size as sim_cia,
so simply make that part of the core code.  We already assume this in
places by way of sim_pc_{get,set}, and this is how it's documented in
the sim-base.h API.

There is code to allow sims to pick different register word sizes from
address sizes, but most ports use the defaults for both (32-bits), and
the few that support multiple register sizes never change the address
size (so address defaults to register).  I can't think of any machine
where the register hardware size would be larger than the address word
size either.  We have ABIs that behave that way (e.g. x32), but the
hardware is still equivalent register sized.
2021-01-30 10:14:21 -05:00
Mike Frysinger
18d4b488f4 sim: profile: fix bucketing with 64-bit targets
When the target's PC is 64-bits, this shift expands into a range of
8 * 8 - 1 which doesn't work with 32-bit constants.  Force it to be
a 64-bit value all the time and let the compiler truncate it.
2021-01-30 01:15:04 -05:00
Mike Frysinger
88f68ee277 sim: m68hc11: stop making hardware conditional
This port doesn't build if these hardware modules are omitted, and
there's no reason we need to make it conditional at build time, so
always enable it.  The hardware devices only get turned on if the
user requests it at runtime via hardware settings.
2021-01-30 01:09:38 -05:00
Mike Frysinger
f4dd74915b sim: hw: replace fgets with getline
This avoids fixed sized buffers on the stack.
2021-01-30 01:07:58 -05:00
Mike Frysinger
481fac96bd sim: common: sort nltvals.def
This was largely already done, but I think people didn't quite notice.
2021-01-30 01:00:07 -05:00
Mike Frysinger
008a02e36d sim: readd myself as a maintainer 2021-01-29 22:11:45 -05:00
Maciej W. Rozycki
c651f0a614 MAINTAINERS: Update my e-mail address
binutils/
	* MAINTAINERS: Update my e-mail address.

	gdb/
	* MAINTAINERS: Update my e-mail address.

	sim/
	* MAINTAINERS: Update my e-mail address.
2021-01-22 00:10:39 +00:00
Mike Frysinger
c65ca138c4 sim: ppc: update version script usage
This matches the changes in the common code.
2021-01-19 10:54:06 -05:00
Mike Frysinger
0e7620dcdc sim: bfin: delete accidental ADI copyright
This wasn't supposed to be in here when it was first merged as we
had specifically disabled it for all the tests (and ADI has papers
in place w/the FSF).  Clean up this one.
2021-01-18 21:30:12 -05:00
Mike Frysinger
f89f33e57c sim: common: simplify version script
We don't use the host & target aliases, so don't bother emitting them.
2021-01-18 12:25:57 -05:00
Mike Frysinger
5e25901fcc sim: common: delete configure & Makefile
This was mostly orphaned a while back, but left behind so people could
still run `make headers`.  Merge that one target to the top sim dir and
delete all the build logic.  This should avoid confusing people further.
2021-01-18 12:23:18 -05:00
Mike Frysinger
4cfcd3b333 sim: common: modernize gennltvals.sh
It's not 1996 anymore, so stop writing shell code like it is, and
rewrite it with modern POSIX shell standards.  This makes it much
more user friendly.

Then regenerate the file with latest newlib sources to verify.
2021-01-18 12:19:19 -05:00
Mike Frysinger
1368b914e9 sim: testsuite: flatten tree
Now that all port tests live under testsuite/sim/*/, and none live
in testsuite/ directly, flatten the structure by moving all of the
dirs under testsuite/sim/ to testsuite/ directly.

We need to stop passing --tool to dejagnu so that it searches all
dirs and not just ones that start with "sim".  Since we have no
other dirs in this tree, and no plans to add any, should be fine.
2021-01-15 19:18:34 -05:00
Mike Frysinger
bb3eddb5bd sim: testsuite: delete configure script
Now that we've moved all ports to dejagnu & testsuite/sim/, the only
thing the testsuite/configure script has been doing is filling in the
sim_arch field in the testsuite/Makefile.  We can simply let the top
sim/configure script do that for us now.  This simplifies & speeds up
the build a bit by killing an entire configure script.
2021-01-15 01:51:11 -05:00
Mike Frysinger
29fd199ed8 sim: d10v: relocate tests & clean up test harness
This is the only target using a dir directly under testsuite/.  All
others use sim/<arch>/ instead.  Relocate it so all targets look the
same, and so we can leverage the common test harness.

We drop loop.s in the process because it was never referenced and
was just 2 lines of code.

All other test files are moved & have directives added to the top so
that the test harness can invoke them correctly.
2021-01-15 01:49:23 -05:00
Mike Frysinger
137d6efd8a sim: mips: delete empty stub test dir
No tests were ever added in here in the ~22 years since it was first
created.  Seems unlikely any tests will be added at this rate, and
the sim/mips/ testdir already has some (light) coverage for this
target.  So punt the tree.
2021-01-15 01:46:51 -05:00
Mike Frysinger
89bfc2a429 sim: frv: clean up redundant test coverage
The frv-elf subdir contained five tests:
* cache: A cache test of some sort.
* exit47: A program to test exit status of 47 from sim.
* grloop: Some basic limited loop test program.
* hello: Standard "hello world" output program.
* loop: An infinite loop program.

The loop.s test is never referenced anywhere, and is all of 2 lines.
Anyone who really needs a while(1); test case and re-implement it
themselves locally.

The cache.s code isn't referenced anywhere because it requires some
custom args to the run program, and when this testcase was added, we
didn't have any support for that.  We do now, so we can add a header
to enable that.  Turns out the code crashes even with those, so turn
around and mark it xfail.  Maybe someone someday will care.

That leaves the small exit47, grloop, and hello tests.  Now that the
sim test harness supports testing for custom exit status, we can move
them all to sim/frv/ to maintain test coverage.

The remaining differences between frv-elf & sim/frv are:
* frv-elf/ runs for frv-*-elf while sim/frv/ runs for frv*-*-*.
* frv-elf/ runs "*.s" files while sim/frv/ only has .cgs and such.

On closer inspection, these are also meaningless distinctions:
* There is nothing specific to the tests that require an *-elf
  target.  Normally that would mean newlib+libgloss type stuff,
  but there's no such requirement in frv-elf/.
* The ".s" suffix is the standard "this is an assembly file" suffix.
  Since FRV is a CGEN target, we can reuse the existing convention of
  ".ms" to mean "miscellaneous .s" as in "this is an assembly file,
  and run/bucket its test results in the miscellaneous category".

So moving frv-elf/{cache,exit47,grloop,hello}.s to sim/frv/*.ms makes
sense and simplifies things quite a bit for the target while also
slightly increasing the coverage for some tuples.
2021-01-15 01:43:47 -05:00
Mike Frysinger
7cf91a2481 sim: m32r: clean up redundant test coverage
The m32r-elf subdir contained three tests:
* exit47: A program to test exit status of 47 from sim.
* hello: Standard "hello world" output program.
* loop: An infinite loop program.

There's already a sim/m32r/hello.ms test that does exactly the same
thing as m32r-elf/hello.s, so we can delete that.

The loop.s test is never referenced anywhere, and is all of 2 lines.
Anyone who really needs a while(1); test case and re-implement it
themselves locally.

That leaves the single exit47 test.  Now that the sim test harness
supports testing for custom exit status, we can easily move that to
sim/m32r/exit47.ms to maintain test coverage.

The remaining differences between m32r-elf & sim/m32r are:
* m32r-elf/ runs for m32r-*-elf while sim/m32r/ runs for m32r*-*-*.
* m32r-elf/ runs "*.s" files while sim/m32r/ runs "*.ms" files.

On closer inspection, these are also meaningless distinctions:
* There is nothing specific to the tests that require an *-elf
  target.  Normally that would mean newlib+libgloss type stuff,
  but there's no such requirement in m32r-elf/.
* The ".s" suffix is the standard "this is an assembly file"
  suffix.  Turns out ".ms" is just how sim/m32r/ (and a few other
  CGEN based targets) categorize/bucket test cases.  It simply
  means "miscellaneous .s" as in "this is an assembly file, and
  run/bucket its test results in the miscellaneous category".

So moving m32r-elf/exit47.s to sim/m32r/exit47.ms makes sense and
simplifies things quite a bit for the target while also slightly
increasing the coverage for some tuples.
2021-01-15 01:34:57 -05:00
Mike Frysinger
37a9c3a53e sim: testsuite: allow tests to declare expected exit status
Some tests want to verify they can control the exit status, and
allowing any non-zero value would allow tests to silently fail:
if it crashed & exited 1, or forced all non-zero to 1, then we
wouldn't be able to differentiate with a test exiting with a
status like 47.

Extend the test harness to allow tests to declare their expected
exit status that would be defined as a "pass".  This requires a
small tweak to the sim_run API to return the status directly, but
that shouldn't be a big deal as it's only used by sim code.
2021-01-15 01:33:35 -05:00
Mike Frysinger
54780889e9 sim: h8300: drop separate eightbit memory buffer
The h8300 sim has its own implementation for memory handling that I'd
like to replace with the common sim memory code.  However, it's got a
weird bit of code it calls "eightbit mem" that makes this not as easy
as it would otherwise be.  The code has this comment:
/* These define the size of main memory for the simulator.

   Note the size of main memory for the H8/300H is only 256k.  Keeping it
   small makes the simulator run much faster and consume less memory.

   The linker knows about the limited size of the simulator's main memory
   on the H8/300H (via the h8300h.sc linker script).  So if you change
   H8300H_MSIZE, be sure to fix the linker script too.

   Also note that there's a separate "eightbit" area aside from main
   memory.  For simplicity, the simulator assumes any data memory reference
   outside of main memory refers to the eightbit area (in theory, this
   can only happen when simulating H8/300H programs).  We make no attempt
   to catch overlapping addresses, wrapped addresses, etc etc.  */

I've read the H8/300 Programming Manual and the H8/300H Software Manual
and can't find documentation on it.  The closest I can find is the bits
about the exception vectors, but that sounds like a convention where the
first 256 bytes of memory are used for a special purpose.  The sim will
actually allocate a sep memory buffer of 256 bytes and you address it by
accessing anywhere outside of main memory.  e.g. I would expect code to
access it like:
	uint32_t *data = (void *)0;
	data[0] = reset_exception_vector;
not like the sim expects like:
	uint8_t *data = (void *)0x1000000;
	data[0] = ...;

The gcc manual has an "eightbit_data" attribute:
	Use this attribute on the H8/300, H8/300H, and H8S to indicate that
	the specified variable should be placed into the eight-bit data
	section. The compiler generates more efficient code for certain
	operations on data in the eight-bit data area. Note the eight-bit
	data area is limited to 256 bytes of data.

And the gcc code implies that it's accessed via special addressing:
   eightbit_data: This variable lives in the 8-bit data area and can
   be referenced with 8-bit absolute memory addresses.

I'm fairly certain these are referring to the 8-bit addressing modes
that allow access to 0xff00 - 0xffff with only an 8-bit immediate.
They aren't completely separate address spaces which this eightbit
memory buffer occupies.

But the sim doesn't access its eightbit memory based on specific insns,
it does it purely on the addresses requested.

Unfortunately, much of this code was authored by Michael Snyder, so I
can't ask him :(.  I asked Renesas support and they didn't know:
https://renesasrulz.com/the_vault/f/archive-forum/6952/question-about-eightbit-memory

So I've come to the conclusion that this was a little sim-specific hack
done for <some convenience> and has no relation to real hardware.  And
as such, let's drop it until someone notices and can provide a reason
for why we need to support it.
2021-01-13 21:54:00 -05:00
Mike Frysinger
d9b1deff13 sim: watch: add basic default handler that traps
The default watchpoint handler is NULL.  That means any port that
sets the STATE_WATCHPOINTS->pc field will crash if you try to use
the --watch options but don't configure the interrupt handler.  In
the past, you had to setup STATE_WATCHPOINTS->pc if you wanted to
support PC profiling, and while that was fixed a while ago, we have
a lot of ports who still configure it.

We already add a default set of interrupts (just "int") if the port
doesn't define any.  Let's also add a default handler that raises a
SIGTRAP.  When connected to gdb, this is a breakpoint which is what
people would expect.  When running standalone, it'll abort the sim,
but it's unclear whether there's anything better to do there.  This
really is just to make the watchpoint module more usable out of the
box for most ports with very little setup, at least inside of gdb.
2021-01-13 21:53:11 -05:00
Mike Frysinger
c54f3efdc2 sim: watch: fix range expression processing
The code supports a <start>[,<end>] syntax, but the logic for handling
the <end> check was broken: it would detect the first byte was ",", but
then include that in the strtoul call meaning the result is always 0.
Further, it (re)assigned to arg0 when it meant arg1 which means this
code always processed a range expression as 0,0.  Oops.
2021-01-13 05:52:51 -05:00
Mike Frysinger
62fe7512a7 sim: watch: fix pc watchpoints on little endian host systems
My change 1ac72f0659 ("sim: convert to
bfd_endian") subtly broke the watchpoint module on little endian host
systems.  The old code used 0 to mean "whatever the host endian is",
and while that was changed to use BFD_ENDIAN_UNKNOWN, this caller was
missed.  Since its API used an int instead of an enum, the coercion
from 0 to the BFD endian enum was silently missed, and 0 happens to
be BFD_ENDIAN_BIG.

Instead of restoring the old logic by passing in BFD_ENDIAN_UNKNOWN,
we know the right host endian at compile time, so use that directly.
2021-01-13 05:52:51 -05:00
Mike Frysinger
e998918e98 sim: or1k: fix mixing of code & decl warning
Use the correct style of declaring variables at top of scope.
This fixes a few compiler warnings in the process.
2021-01-12 04:15:28 -05:00
Mike Frysinger
5e9e2f41eb sim: or1k: clean up stale build entries
This logic was migrated to the common code long ago so ports don't
need to declare them themselves.
2021-01-12 04:13:13 -05:00
Mike Frysinger
68895f7d7e sim: README-HACKING: clean up stale run references
The run.c interface was deleted long ago and everyone moved to nrun.c
(which is also the default), so no one needs to declare this anymore.
2021-01-12 04:13:11 -05:00