Commit Graph

3886 Commits

Author SHA1 Message Date
Nick Clifton 4eb70007f1 Add myself as the maintainer for the AArch64. 2016-01-05 16:49:26 +00:00
Nick Clifton 296ebfbb91 Fix the execution of the MSP430 simulator testsuite.
ld	* emulparams/msp430elf.sh (RAM_START): Move to 0x500 - above the
	MSP430 hardware multiply address range.
	* scripttempl/elf32msp430.sc (__romdatastart): Define.
	(__romdatacopysize): Define.
	* scripttempl/elf32msp430_3.sc: Likewise.

tests	* testutils.inc (__pass): Use the LMA addresses of the _passmsg
	symbol.
	(__fail): Likewise.
2016-01-05 16:43:58 +00:00
Mike Frysinger 44ddb0c66a sim: use STATE_MAGIC helper 2016-01-04 23:01:14 -05:00
Mike Frysinger bc273e1751 sim: unify min/max macros
Import defines from gdb/defs.h to the sim core so we can delete the
various copies that already exist.
2016-01-04 22:24:03 -05:00
Tristan Gingold ac8eefeb24 sim: aarch64: drop syscall.h include to fix build
The simulator is including syscall.h which is not standard and apparently
not required (builds correctly without it on my machine).
2016-01-04 20:09:24 -05:00
Mike Frysinger 8d7d784e23 sim: parse_args: polish getopt error message
The cris sim hit a few failures after the recent getopt logic, and the
expected output showed a few ways we can improve things to better match
other utils.
2016-01-04 05:08:26 -05:00
Mike Frysinger 9bbf6f91c6 sim: punt x86-specific bswap logic
The compiler/C library should produce reasonable code for htonl/ntohl,
and at least glibc tries pretty hard to always produce good code for
them.  This logic only had support for 32-bit x86 systems anymore, and
it's unlikely people were even opting into this, so drop it all.
2016-01-04 05:04:30 -05:00
Mike Frysinger 13adda68c5 sim: d10v: gut endian logic
The compiler should produce reasonable code here in general, so punt the
various arch checks and bswap defines.  This code will eventually go away
entirely when we convert it to the common memory code.
2016-01-04 05:04:04 -05:00
Mike Frysinger 77cf2ef5dc sim: parse_args: display getopt error ourselves
Fix a long standing todo where we let getopt write directly to stderr
when an invalid option is passed.  Use the sim io funcs instead as they
go through the filtered callbacks that gdb wants.
2016-01-03 22:07:39 -05:00
Mike Frysinger 3726f72c65 sim: TODO: move to wiki
We're maintaining development docs in the wiki now:
	https://sourceware.org/gdb/wiki/Sim/TODO
2016-01-03 19:54:25 -05:00
Mike Frysinger 61971b86bb sim: clean up some more device detritus
Clean up some more remains of WITH_DEVICES that escaped notice.

We also clean up GETTWI/SETTWI defines in a few ports where they
were copied & pasted and are unused as they happen to be near the
device code.
2016-01-03 04:23:10 -05:00
Mike Frysinger 34fed69938 sim: use libiberty countargv in more places
A bunch of places open code the countargv implementation, or outright
duplicate it (as count_argc).  Replace all of those w/countargv.
2016-01-03 04:08:56 -05:00
Mike Frysinger aba6f46b23 sim: nrun: use lbasename 2016-01-03 03:50:08 -05:00
Mike Frysinger 0cb8d8513c sim: drop host endian configure option
The --enable-sim-hostendian flag was purely so people had an escape route
for when cross-compiling.  This is because historically, AC_C_BIGENDIAN
did not work in those cases.  That was fixed a while ago though, so we can
require that macro everywhere now and simplify a good bit of code.
2016-01-03 00:52:51 -05:00
Mike Frysinger 1ac72f0659 sim: convert to bfd_endian
Rather than re-invent endian defines, as well as maintain our own list
of OS & arch-specific includes, punt all that logic in favor of the bfd
ones already set up and maintained elsewhere.  We already rely on the
bfd library, so leveraging the endian aspect should be fine.
2016-01-03 00:18:07 -05:00
Mike Frysinger b3fbb288af sim: cris: use standard output helpers
The sim-io module provides output helpers, so no need to define local
ones anymore.
2016-01-02 14:00:48 -05:00
Mike Frysinger 027e73b217 sim: iq2000/m32r/lm32/sh64: delete dead option code
The iq2000/m32r/sh64 option parsing logic appears to have always been
dead.  At least iq2000/sh64 are simply copy & paste rot from m32r.

The lm32 option parsing hack here hasn't been needed for a while -- this
was fixed back in commit 11409fac6b in the
common code.
2016-01-02 10:39:13 -05:00
Mike Frysinger d47f5b30d8 sim: delete dead current_state globals
The global current_state handle to the current simulator state is a
design idea that was half implemented, but never really cleaned up.
The point was to have a global variable pointing to the state so that
funcs could more quickly & easily access the state anywhere.  We've
instead moved in the direction of passing state around everywhere and
don't have any intention of moving back.

I also can't find any references to gdb using this variable, or to
cgen related "dump_regs" functions, both of which were used in the
comments related to this code.
2016-01-02 10:27:56 -05:00
Mike Frysinger dea827fc5c sim: ppc: do not exit when parsing args w/gdb
When connecting to the simulator in gdb, we don't want it to exit on
us when we pass down unknown/invalid/help/etc... options.  Plumb down
the kind argument so we can handle both gdb & psim interfaces.
2016-01-02 03:38:29 -05:00
Joel Brobecker 618f726fcb GDB copyright headers update after running GDB's copyright.py script.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2016-01-01 08:43:22 +04:00
Mike Frysinger 8e26d677a2 sim: m68hc11: fix default endian
The previous commit here set the default to little instead of big.
A typo lost when reviewing the different targets in parallel.
2015-12-30 23:48:17 -05:00
Mike Frysinger eca4255a1a sim: cris/m68hc11: move default endian/alignment to configure 2015-12-30 21:01:58 -05:00
Mike Frysinger cec99e6b2c sim: h8300: inline sim_state_initialize
All the state is handled already by the common cpu allocation which
zeros out the entire state.
2015-12-30 06:05:02 -05:00
Mike Frysinger 2a2757ac7e sim: h8300: simplify h8300_reg_{fetch,store} funcs
We can leverage the cpu->regs array rather than going through the
function helpers to get nice compact code.

Further, fix up the return values: return -1 when we can't find a
register (and let the caller write out warnings), return 2/4 when
we actually write out that amount, and handle the zero reg.
2015-12-30 06:02:27 -05:00
Mike Frysinger 4ca9d09e82 sim: h8300: switch to common sim-resume 2015-12-30 05:27:18 -05:00
Mike Frysinger 5658c2571f sim: h8300: move default endian/alignment to configure 2015-12-30 05:20:41 -05:00
Mike Frysinger 9950eccba1 sim: simplify STATE_MY_NAME setup
No point in writing basename ourselves when libiberty provides one.
2015-12-30 03:35:12 -05:00
Mike Frysinger e1211e5506 sim: arm/d10v/h8300/m68hc11/microblaze/mips/mn10300/moxie/sh/v850: convert to common sim_{fetch,store}_register 2015-12-30 03:30:25 -05:00
Mike Frysinger c78dff2291 sim: h8300: move unused/buggy lregs array
This array isn't used anywhere, and the init phase actually corrupts
some memory because the array has 18 elements but tries to set the
19th (ZERO) position.
2015-12-30 03:30:23 -05:00
Mike Frysinger f2089a69c1 sim: h8300: drop unused inst.h
We can also drop the compile.o rule since the common dep generation
logic takes care of this for us.
2015-12-30 03:29:53 -05:00
Kevin Buettner 90d99f3270 sim: ppc: track closed state of file descriptors 0, 1, and 2.
This change tracks the "closed" state of file descriptors 0, 1, and 2,
introducing the function fdbad() to emul_netbsd.c and emul_unix.c.
Note that a function of the same name and purpose exists in
sim/common/callback.c.

This patch eliminates all of the "unresolved testcases" when testing
GDB against the powerpc simulator.

This occurs because the powerpc simulator closes, on behalf of the
testcase, the file descriptors associated with stdin, stdout, and
stderr.  GDB still needs these descriptors to communicate with the
user or, in this case, with the testing framework.
2015-12-29 19:17:11 -05:00
Mike Frysinger 5d01527536 sim: aarch64/msp430: fix disassembler usage
The disasm framework reserves the private_data field for the disassemblers
themselves, not for people who use the disassembler.  Instead, there is an
application_data field for callers such as the sim.  Switch to it to avoid
random corruption/crashes when the disassemblers use private_data.
2015-12-27 01:44:37 -05:00
Mike Frysinger 5e744ef887 sim: unify sim-hload
Pretty much all targets are using this module already, so add it to the
common list of objects.  The only oddball out here is cris and that's
because it supports loading via an offset for all the phdrs.  We drop
support for that.
2015-12-27 00:54:41 -05:00
Mike Frysinger 1b393626ce sim: punt WITH_DEVICES & tconfig.h support
No arch is using this anymore, and we want all new ports using the
hardware framework instead.  Punt WITH_DEVICES and the two callbacks
device_io_{read,write}_buffer.

We can also punt the tconfig.h file as no port is using it anymore.
This fixes in-tree builds that get confused by picking up the wrong
one (common/ vs <port>/) caused by commit ae7d0cac8c.

Any port that needs to set up a global define can use their own
sim-main.h file that they must provide regardless.
2015-12-26 20:38:31 -05:00
Mike Frysinger 466b619e95 sim: bfin: push down mmr address/size checks
The bfin port is using the WITH_DEVICES framework for two reasons:
- get access to the cpu making the request (if available)
- check the alignment & size for core & system MMRs

We addressed the first part with commit dea10706e9,
and we handle the second part with this commit.  Arguably this is more
correct too because trying to do bad reads/writes directly (when devices
support is disabled) often results in bad memory accesses.

As part of this clean up, we also adjust all of the existing logic that
would reject invalid accesses: the code was relying on the checks never
returning, but that's not the case when things like gdb (via the user's
commands) are making the requests.  Thus we'd still end up with bad mem
accesses, or sometimes gdb being hung due to while(1) loops.

Now we can connect (most of) these models into any address and have them
work correctly.
2015-12-26 19:09:43 -05:00
Mike Frysinger 236bf91feb sim: bfin: avoid stack error under asan
We set up an array of 3 elements and then index into it with a 2bit
value.  We check the range before we actually use the pointer, but
the indexing is enough to make asan upset, so just stuff a fourth
value in there to keep things simple.
2015-12-26 18:22:37 -05:00
Mike Frysinger dea10706e9 sim: sim-core: pass down cpu to hw accesses when available
The bfin port has been using the device callback largely so it could be
passed the cpu when available.  Add this logic to the common core code
so all ports get access to the active cpu.

The semantics of these buffer functions are changed slightly in that
errors halt the engine synchronously rather than returning the length
to the caller.  We'll probably adjust this in a follow up commit.

The bfin code isn't updated just yet as it has a bit more logic in the
device layer that needs to be unwound at which point we can delete it
entirely.
2015-12-26 14:22:14 -05:00
Mike Frysinger 26f8bf63bf sim: mips: delete mmu stubs to move to common sim_{read,write}
The only unique thing about mip's sim_{read,write} helpers is the call to
address_translation on the incoming address.  When we look closer at that
function though, we see it's just a stub that maps physical to virtual,
and the cache/return values are hardcoded.  If we delete this function,
we can then collapse all the callers and drop the custom sim_{read,write}
logic entirely.

Some day we might want to add MMU support, but when we do, we'll want to
have the common layers handle things so all targets benefit.
2015-12-26 11:50:59 -05:00
Mike Frysinger 8b494522f9 sim: cris: do not pass cpu when writing memory during init
The point of passing down the cpu to core reads/writes is to signal which
cpu is making the access.  For system accesses (such as internal memory
initialization), passing the cpu down doesn't make sense, and in the case
of early init like cris, can cause crashes.  Since the cpu isn't fully set
up at this point, if the core code tries to access some fields (like the
PC reg), it'll crash.  While cris shouldn't be doing this setup here (it
should be in the inferior stage), we'll deal with that later.
2015-12-26 08:26:28 -05:00
Mike Frysinger 0e9672991e sim: standardize sim_create_inferior handling of argv a bit more
For targets that process argv in sim_create_inferior, improve the code:
- provide more details in the comment
- make the check for when to re-init more robust
- clean out legacy sim_copy_argv code

This will be cleaned up more in the future when we have a common inferior
creation function, but at least help new ports get it right until then.
2015-12-26 07:19:07 -05:00
Mike Frysinger f66affe97c sim: aarch64: move ChangeLog content 2015-12-26 07:12:33 -05:00
Mike Frysinger 2023145711 sim: frv: punt WITH_DEVICE support
The frv port used the device logic to support a single cache address,
and the comments around that are "these were merely copied from a diff
port and are unused", plus the code to attach the memory is "#if 0".
Just punt it all.
2015-12-25 13:22:53 -05:00
Mike Frysinger 9c0c156bb7 sim: m32r: migrate from WITH_DEVICES to WITH_HW
The m32r port was using the device framework to handle two devices: the
cache and uart registers.  Both can be implemented in the newer hardware
framework instead which allows us to drop the device logic entirely, as
well as delete the tconfig.h file.

While creating the new uart device model, I also added support for using
stdin to read/write data rather than only supporting sockets.

This has been lightly tested as there doesn't appear to be test coverage
for the code already.  If anyone still cares about this port, then they
should (hopefully) file bug reports.
2015-12-25 13:09:42 -05:00
Mike Frysinger 34cf511206 sim: cris: migrate from WITH_DEVICES to WITH_HW
The cris port was using the device framework to handle two addresses when
the --cris-900000xx flag was specified.  That can be implemented using the
newer hardware framework instead which allows us to drop the device logic
entirely, as well as delete the tconfig.h file.  Basically we create a new
cris_900000xx device model and move the read logic out of devices.c and
into that.  The rest of the devices logic was callback to the hardware
framework already.
2015-12-25 06:10:03 -05:00
Mike Frysinger 13e49fd636 sim: cris: clean up rvdummy a bit
This fixes a few warnings when compiling the rvdummy tool.
2015-12-25 06:02:17 -05:00
Mike Frysinger d4a587a4ed sim: cris: set up sane default path to rvdummy
Much like we autodetect the path to the run program when there is none
set explicitly, do the same for the rvdummy program.  Otherwise the
default make check fails to execute the helper properly.
2015-12-25 05:51:46 -05:00
Mike Frysinger 49aef5a5b8 sim: hw-properties: delete trace calls
These trace calls don't seem to add anything useful and break the cris
hw tests, so punt them.  They were disabled before commit 6d519a4606
but were re-enabled as part of TRACE macro cleanups.
2015-12-25 05:48:03 -05:00
Mike Frysinger cf59f47ebe sim: drop WITH_ENGINE define
We enable this everywhere already, and all new ports should use the
engine logic, so no point in making it an option to disable.
2015-12-25 04:47:31 -05:00
Mike Frysinger 0d58595077 sim: sim-model: build for everyone
Rather than include this for some targets, set it up so we can build it
all the time via the common code.  This makes it easier for targets to
opt into it when they're ready, increases build coverage, and allows us
to centralize much of the logic.

We also get to delete tconfig.h from two more targets -- they were
setting WITH_DEVICES to 0 which has the same behavior as not defining
it at all.

While the SIM_HAVE_MODEL knob is gone, we now have WITH_MODEL_P, but it
is only used by the common sim-model code.  We use it to declare dummy
model lists when the arch hasn't created its own.
2015-12-25 04:40:31 -05:00
Mike Frysinger 8a0ebee658 sim: move MACH/MODEL types into SIM_xxx namespace
The "MACH" and "MODEL" names are a bit generic and collide with symbols
used by other sections of code (like h8300's opcodes).  Since these are
sim-specific types, they really should have a "SIM_" prefix.
2015-12-25 04:24:06 -05:00
Mike Frysinger 91d6df784d sim: arm: delete unused code
These vestiges of the 20 year old emulator are just getting in the way.
Punt all the dead code we either don't compile or don't use.
2015-12-25 03:09:01 -05:00
Mike Frysinger f0c1b768b4 sim: move WITH_SCACHE_PBB to sim-main.h
This helps us break up tconfig.h more.  Any file using this define should
be pulling in sim-main.h already, so things should continue working.
2015-12-25 02:42:03 -05:00
Mike Frysinger 42a3af5688 sim: device_error: punt
Only four targets implement this function, and three of them do nothing.
The 4th merely calls abort.  Since calls to this function are followed
by calls to sim_hw_abort or sim_io_error, this is largely useless.  In
the two places where we don't, replace the call with sim_engine_abort.
We want to kill off the WITH_DEVICES logic in favor of WITH_HW, so this
is a good first step.
2015-12-25 02:18:16 -05:00
Mike Frysinger 9e8e7dd966 sim: always enable callback memory
We enable WITH_CALLBACK_MEMORY everywhere and don't provide a way to
turn it off, and no target does so.  Make it unconditional for all
to keep things simple.
2015-12-25 00:28:07 -05:00
Mike Frysinger 268c91391a sim: dv-pal: always use CPU_INDEX
Since the core always provides CPU_INDEX, use it.  The current code
doesn't actually use it even though it should since it doesn't include
the right headers.
2015-12-25 00:13:43 -05:00
Mike Frysinger ef04e37198 sim: mips: delete TARGET_TX3904 define
With the LMA cleanup, we no longer need this define.
2015-12-24 22:39:30 -05:00
Mike Frysinger cb379ede3c sim: mips: move SIM_QUIET_NAN_NEGATED to sim-main.h
We want to kill off tconfig.h, so move the one define mips still uses
to sim-main.h.
2015-12-24 22:30:46 -05:00
Mike Frysinger 269362117d sim: make LMA loading the default for all targets
Most targets already default to loading code via their LMA, but for
a few, this means the default changes from loading VMA to LMA.  It's
better to have the different targets be consistent, and allows some
code clean up.
2015-12-24 21:50:17 -05:00
Mike Frysinger 9db2b71908 sim: cris: move option install to sim_open
We've moved custom option install for other targets to sim_open, so update
cris too.  It's the last one using MODULE_LIST, so we can drop that from
the common code too.
2015-12-24 20:34:07 -05:00
Mike Frysinger cec1974488 sim: delete old breakpoint code
This code relies on the old sim-break module, but that was deleted in 2003.
The module only existed for gdb to tell the sim to set breakpoints on its
behalf, but then that logic was abandoned in favor of gdb knowing all about
proper breakpoints (since it does already for non-sim targets).  Some dead
code lived on in the older ports though -- clean it up now.
2015-12-24 20:19:13 -05:00
Mike Frysinger bd3fb5b8fb sim: h8300: move h8300-specific options out of common code
Register the options in sim_open like other arches to avoid having to hack
up the common modules.
2015-12-24 20:11:26 -05:00
Mike Frysinger 84e8e361dd sim: enable watchpoint module everywhere
We build & bundle the watchpoint module everywhere, but we don't make
the command line flags available by default.  A few targets opted in,
but most did not.  Just enable the flag for everyone.  Not all targets
will respect the flags (making them nops), but shouldn't be a big deal.
This is how we handle other common modules already.
2015-12-24 20:03:14 -05:00
Mike Frysinger 3cabaf66d6 sim: delete SIM_HAVE_FLATMEM support
No target has used this, and it's a cheap hack in place in using the
common memory module.  We want everyone using that though, so drop
support for flatmem entirely.
2015-12-24 19:52:13 -05:00
Mike Frysinger b1af947345 sim: delete SIM_HAVE_MEM_SIZE
This define isn't used anywhere (doesn't seem to ever have been used by
versions committed), so delete the commented out code as it's dead.
2015-12-24 19:27:28 -05:00
Mike Frysinger 8abe6c668e sim: delete SIM_HAVE_SIMCACHE
This was used by the old run interface, but we punted that awhile ago,
so drop this define too.
2015-12-24 19:23:51 -05:00
Dominik Vogt 1d19cae752 Fix invalid left shift of negative value
Fix occurrences of left-shifting negative constants in C code.

sim/arm/ChangeLog:

	* thumbemu.c (handle_T2_insn): Fix left shift of negative value.
	* armemu.c (handle_v6_insn): Likewise.

sim/avr/ChangeLog:

	* interp.c (sign_ext): Fix left shift of negative value.

sim/mips/ChangeLog:

	* micromips.igen (process_isa_mode): Fix left shift of negative
	value.

sim/msp430/ChangeLog:

	* msp430-sim.c (get_op, put_op): Fix left shift of negative value.

sim/v850/ChangeLog:

	* simops.c (v850_bins): Fix left shift of negative value.
2015-12-15 14:09:14 +01:00
Nick Clifton caa8d70005 Add support for the MRS instruction to the AArch64 simulator.
* aarch64/simulator.c (system_get): New function.  Provides read
	access to the dczid system register.
	(do_mrs): New function - implements the MRS instruction.
	(dexSystem): Call do_mrs for the MRS instruction.  Halt on
	unimplemented system instructions.
2015-12-15 11:01:03 +00:00
Nick Clifton f7584f0560 Add support for MSP430 F5 hardware multiply.
* msp430-sim.c (sim_open): Check for needed memory at address
	0x500 not 0x200.
	(get_op): Add support for F5 hardware multiply addresses.
	(put_op): Likewise.
2015-12-07 10:19:19 +00:00
Nick Clifton 2e8cf49e13 Add an AArch64 simulator to GDB.
sim	* configure.tgt: Add aarch64 entry.
	* configure: Regenerate.
	* sim/aarch64/configure.ac: New configure template.
	* sim/aarch64/aclocal.m4: Generate.
	* sim/aarch64/config.in: Generate.
	* sim/aarch64/configure: Generate.
	* sim/aarch64/cpustate.c: New file - functions for accessing
	AArch64 registers.
	* sim/aarch64/cpustate.h: New header.
	* sim/aarch64/decode.h: New header.
	* sim/aarch64/interp.c: New file - interface between GDB and
	simulator.
	* sim/aarch64/Makefile.in: New makefile template.
	* sim/aarch64/memory.c: New file - functions for simulating
	aarch64 memory accesses.
	* sim/aarch64/memory.h: New header.
	* sim/aarch64/sim-main.h: New header.
	* sim/aarch64/simulator.c: New file - aarch64 simulator
	functions.
	* sim/aarch64/simulator.h: New header.

include/gdb * sim-aarch64.h: New file.

sim/test * configure: Regenerate.
	* sim/aarch64: New directory.
2015-11-24 08:47:59 +00:00
Mike Frysinger dc11500a11 sim: common: set up CPPFLAGS/CXXFLAGS/LDFLAGS from configure [PR sim/18762]
Make sure we pass down the CPP/CXX/LD flags that configure set up for us
like we already do for C flags.
2015-11-22 02:23:25 -05:00
Mike Frysinger 2561d5808a sim: sim_do_commandf: fix call to va_end [PR sim/19273]
Make sure we call va_end even in the error case.
2015-11-22 02:15:28 -05:00
Mike Frysinger 7c125e3b10 sim: ppc: avoid use of $< in ordinary rules [PR sim/13834]
POSIX does not define $< behavior in ordinary rules, so avoid its use
to fix building on non-GNU make setups.

Reported-by: Christopher January <chris.january@allinea.com>
2015-11-22 01:59:20 -05:00
Mike Frysinger 37258e9950 sim: common: add PRI printf defines
Keeping track of the right printf formats for the various types can be
a pretty big hassle, especially in common code which has to support a
variety of bitsizes.  Take a page from the existing standards and add
a set of PRI macros which hide the details in a common header.
2015-11-22 01:37:24 -05:00
Mike Frysinger 82d442c6c6 sim: avr: move global state to sim/cpu state
We don't want global variables in the sim as all state should be in the
sim state or in the cpu state.  This pushes down all that logic for avr.
2015-11-22 01:12:21 -05:00
Mike Frysinger 807eaf04cb sim: avr: switch to common sim-reg
This is not entirely useful as avr doesn't (yet) store its register
state in the cpu state, but it does allow for switching to the common
code for these functions.
2015-11-22 00:53:23 -05:00
Mike Frysinger 6cc9885631 sim: sh: delete global callback/argv
We can use the sim state everywhere now to get these values on the fly.
2015-11-22 00:53:23 -05:00
Mike Frysinger c1fc4b4d17 sim: h8300: delete global callback/kind/name
We can use the sim state everywhere now to get these values on the fly.
2015-11-22 00:53:23 -05:00
Mike Frysinger d320201dbe sim: mn10300: drop global callback handle
It's used in one place and can easily be replaced by using the sim state.
2015-11-22 00:53:23 -05:00
Mike Frysinger c389945b7a sim: mn10300/v850: drop unused WITH_CORE define
This was dropped from the sim core in 1997, so no point in having these
sim ports continue to define it.
2015-11-17 23:12:59 -05:00
Mike Frysinger cdf850e9d9 sim: always enable modulo memory
Having this be a config option doesn't make sense: the code size is
pretty much the same (as all the logic is still active), and if it's
disabled, the sim throws an error if you try to use it.  That means
we can't break sims that weren't using it before by enabling it all
the time.
2015-11-17 23:12:58 -05:00
Pedro Alves a6760b6154 [sim/ppc] Fix printf_filtered reference
Building a gdb that includes the PPC sim in C++ mode fails to link with:

(...)s.o compile-object-load.o compile-object-run.o compile-loc2c.o compile-c-support.o inflow.o    init.o \
          ../sim/ppc/libsim.a ../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a -lz  ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -ldl -ldl -lncurses -lm -ldl  -lguile-2.0 -lgc  -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic -lexpat -llzma -lbabeltrace -lbabeltrace-ctf  ../libiberty/libiberty.a  build-gnulib/import/libgnu.a
../sim/ppc/libsim.a(sim_calls.o): In function `sim_open':
/home/pedro/gdb/mygit/cxx-convertion/src/sim/ppc/sim_calls.c:73: undefined reference to `printf_filtered'
/home/pedro/gdb/mygit/cxx-convertion/src/sim/ppc/sim_calls.c:73: undefined reference to `printf_filtered'
../sim/ppc/libsim.a(sim_calls.o): In function `sim_close':
/home/pedro/gdb/mygit/cxx-convertion/src/sim/ppc/sim_calls.c:93: undefined reference to `printf_filtered'
/home/pedro/gdb/mygit/cxx-convertion/src/sim/ppc/sim_calls.c:93: undefined reference to `printf_filtered'
../sim/ppc/libsim.a(sim_calls.o): In function `sim_load':
/home/pedro/gdb/mygit/cxx-convertion/src/sim/ppc/sim_calls.c:102: undefined reference to `printf_filtered'
../sim/ppc/libsim.a(sim_calls.o):/home/pedro/gdb/mygit/cxx-convertion/src/sim/ppc/sim_calls.c:102: more undefined references to `printf_filtered' follow
collect2: error: ld returned 1 exit status

The undefined references come from TRACE macro calls, which expand to
calls to printf_filtered.

But note that the sim's 'printf_filtered' is actually a #define to
'sim_io_printf_filtered', in sim_callbacks.h :

 #define printf_filtered sim_io_printf_filtered

AFAICS, this is not meant to call gdb's printf_filtered function.  The
ChangeLog entry that added the printf_filtered macro reads:

 Tue Jul 30 21:12:24 1996  Andrew Cagney  <cagney@kremvax.highland.com.au>

	 * sim_callbacks.h (sim_io_printf_filtered): Replace
	 printf_filtered with a local simulator specific version.  Add
	 #define printf_filtered to simplify updating of existing code.

That is, just another incomplete/partial transition.  Maybe prior to
1996 this was really meant to call gdb's printf_filtered version.

The reference to printf_filtered appears because sim_calls.c, the
compilation unit that fails to link, has this at the top:

 #undef printf_filtered /* blow away the mapping */

presumably so that this further below:

 void
 sim_io_printf_filtered(const char *fmt,
			...)
 {
   (...)
   callbacks->printf_filtered(callbacks, "%s", message);
 }

works.  So those TRACE macros instances in sim_calls.c just happen to
work because gdb is linked in, which satisfies the 'printf_filtered'
reference, when GDB is built in C mode.  When built in C++ mode, the
problem is exposed, as GDB's printf_filtered is mangled.

The fix here is to make the TRACE macro call sim_io_printf_filtered
directly.

(Standalone "run" doesn't fail to link simply because the offending
routines are not part of its link.)

sim/ppc/ChangeLog
2015-11-17  Pedro Alves  <palves@redhat.com>

	* debug.h (TRACE, ITRACE, DTRACE, DITRACE, PTRACE): Call
	sim_io_printf_filtered instead of printf_filtered.
2015-11-17 19:21:21 +00:00
Mike Frysinger 146b80ff18 sim: sim-close: use XCONCAT2 helper
No point in open coding this logic when we've got nifty helpers to do it.
2015-11-17 00:48:07 -05:00
Mike Frysinger 797eee4264 sim: sim-stop/sim-reason/sim-reg: move to common obj list
Now that all arches (for the most part) have moved over, move sim-stop.o,
sim-reason.o, and sim-reg.o to the common object list and out of all the
arch ports.
2015-11-16 00:41:59 -05:00
Mike Frysinger 9db36cf86d sim: cr16: drop global callback state
Now that we have access to the sim state in all the right places,
use existing sim helpers in place of cr16_callback directly.
2015-11-15 21:49:41 -05:00
Mike Frysinger 0ef7f98177 sim: cr16: convert to common sim engine logic
Now that we have access to the sim state everywhere, we can convert to
the common engine logic for overall processing.  This frees us up from
tracking exception state ourselves.
2015-11-15 21:48:58 -05:00
Mike Frysinger 761e171ad8 sim: cr16: convert to common sim memory modules
The cr16 port has a lot of translation/offset logic baked into it, but
it all looks like copy & paste from the d10v port rather than something
the cr16 port wants.
2015-11-15 21:48:06 -05:00
Mike Frysinger 267b3b8e06 sim: cr16: push down sd/cpu vars
By itself, this commit doesn't really change anything.  It lays the
groundwork for using the cpu state in follow up commits, both for
engine state and for cpu state.  Splitting things up this way so it
is easier to see how things have changed.
2015-11-15 21:46:13 -05:00
Mike Frysinger 137fbfd281 sim: cr16: delete unused memory helpers
These aren't used anywhere and are just leftover from the d10v port.
Delete them so follow up commits are easier to follow.
2015-11-15 21:35:31 -05:00
Mike Frysinger c2270cd8a6 sim: cr16: switch to common sim-reg
This is mostly to get us off the weird cr16 specific memory functions,
but it's also a good clean up to move to the common core.
2015-11-15 21:23:09 -05:00
Mike Frysinger 7ea08e8cb7 sim: cr16/d10v: drop redundant call to sim_create_inferior
With the conversion to the nrun frontend, this call should no longer be
necessary.  It also actively crashes when trying to use the sd state.
2015-11-15 20:47:31 -05:00
Mike Frysinger e9b0081f98 sim: d10v: drop global callback state
Now that we have access to the sim state in all the right places,
use existing sim helpers in place of d10v_callback directly.
2015-11-15 20:47:24 -05:00
Mike Frysinger aadc1740c7 sim: d10v: convert to common sim engine logic
Now that we have access to the sim state everywhere, we can convert to
the common engine logic for overall processing.  This frees us up from
tracking exception state ourselves.
2015-11-15 20:47:17 -05:00
Mike Frysinger 679546067e sim: d10v: push down sd/cpu vars
By itself, this commit doesn't really change anything.  It lays the
groundwork for using the cpu state in follow up commits, both for
engine state and for cpu state.  Splitting things up this way so it
is easier to see how things have changed.
2015-11-15 20:47:03 -05:00
Mike Frysinger 8ae8f9c382 sim: h8300: convert to common sim_{reason,stop}
This ends up being pretty easy as the h8300 port already supports
much of the common engine core.
2015-11-15 08:15:04 -05:00
Mike Frysinger 7eed1055b8 sim: mcore: pull cpu state out of global scope
This avoids using global variables to hold the cpu state so we can
better integrate with the sim common code.

There's also a minor fix here where we move the pc register back into
the state that is accessible by the asints array.  When it was pulled
out previously, the reg store/fetch functions broke, but no one really
noticed as the mcore gdb port was dropped a while back.
2015-11-15 08:11:15 -05:00
Mike Frysinger 9ef4651c49 sim: mcore: switch to common sim-reg
This is not entirely useful as mcore doesn't (yet) store its register
state in the cpu state, but it does allow for switching to the common
code for these functions.
2015-11-15 07:59:09 -05:00
Mike Frysinger 5809534fe1 sim: mcore: add a fail testcase 2015-11-15 07:55:48 -05:00
Mike Frysinger 02962cd9ea sim: mcore: convert to common reason/resume logic
Switch over to the common event loop logic so we don't have to maintain
the exception/exit logic ourselves.
2015-11-15 07:55:13 -05:00
Mike Frysinger d2dfd24242 sim: clean up redundant objects
Some of the target makefiles listed objects that were already pulled in
via SIM_NEW_COMMON_OBJS.  Clean those up.
2015-11-15 02:43:11 -05:00
Mike Frysinger 6e4f085c7f sim: sim-close: unify sim_close logic
Other than the nice advantage of all sims having to declare one fewer
common function, this also fixes leakage in pretty much every sim.
Many were not freeing any resources, and a few were inconsistent as
to the ones they did.  Now we have a single module that takes care of
all the logic for us.

Most of the non-cgen based ones could be deleted outright.  The cgen
ones required adding a callback to the arch-specific cleanup func.
The few that still have close callbacks are to manage their internal
state.

We do not convert erc32, m32c, ppc, rl78, or rx as they do not use
the common sim core.
2015-11-15 02:30:19 -05:00
Mike Frysinger 1bd1b71421 sim: m32c: add a basic testsuite 2015-11-15 00:56:09 -05:00
Mike Frysinger 9bea4d16a6 sim: testsuite: support basic vars in flags
Sometimes in tests, we need supplemental files like linker scripts or
board helper files.  There's no way to set those flags in the tests
currently and relative paths don't work (breaks out of tree builds).

Update the main option parser to replace some strings on the fly.  Now
tests can do things like:

Long term we'll want to switch the framework to use the dejagnu helpers
like dg-xxx that gcc & gdb utilize.  But that'll require more rework.
2015-11-15 00:43:48 -05:00
Nick Clifton 634a9f67d9 Update the RX simulator to handle the latest opcode types.
* rx.c (id_names): Add nop4, nop5, nop6 and nop7.
	(decode_opcode): Likewise.
	(get_op): Handle RX_Operand_Zero_Indirect.
	Handle RX_Bad_Size and RX_MAX_SIZE.
	(put_op): Likewise.
	(N_MAP): Increase to 90.
2015-11-10 16:08:35 +00:00
Mike Frysinger 6637a4265e sim: cr16/d10v: localize translation funcs
These functions are only used in the interp module, so there's no point
in exporting them and declaring them in the external sim interface.
2015-11-10 02:17:15 -05:00
Mike Frysinger 1057567ea7 sim: m32c: move test code to testsuite
Various target code belongs in the testsuite/ subdir, so move the m32c
code to match all the other targets.
2015-11-10 00:19:49 -05:00
Mike Frysinger 9b4888d516 sim: m32c: drop redundant dependency info 2015-11-10 00:09:58 -05:00
Mike Frysinger 5697b730e2 sim: h8300: drop unused littleendian variable 2015-11-10 00:07:22 -05:00
James Bowman 8173c2a3c4 sim: ft32: test coverage for link parameters and PM write port
Adds test coverage for recent features.
2015-10-12 20:23:26 -04:00
Mike Frysinger 7d8a636c9a sim: moxie: fix leakage in error path [BZ #18273]
Reported-by: dcb <dcb314@hotmail.com>
2015-10-11 03:56:22 -04:00
Mike Frysinger 3f946aa825 sim: bfin: handle negative left saturated shifts as ashifts [BZ #18407]
When handling left saturated ashifts with negative immediates, they
should be treated as right ashifts.  This matches hardware behavior.

Reported-by: Igor Rayak <igorr@gitatechnologies.com>
2015-10-11 03:42:09 -04:00
James Bowman 395b0d8a3f sim: ft32: correct simulation of MEMCPY and MEMSET
The MEMCPY and MEMSET instructions should only examine the low 15 bits of
their length arguments.
2015-09-29 23:39:24 -04:00
James Bowman 71c34ca7a0 sim: ft32: correctly simulate PM write port
The FT32 simulator was not correctly simulating the behavior of the
program memory (PM) write port.  When it is locked, writes to the
data register do nothing.
2015-09-29 23:36:56 -04:00
Andrew Bennett 8e394ffc7a [PATCH] Add micromips support to the MIPS simulator
2015-09-25  Andrew Bennett  <andrew.bennett@imgtec.com>
 	      Ali Lown  <ali.lown@imgtec.com>

	sim/common/
	* sim-bits.h (EXTEND6): New macro.
	(EXTEND12): New macro.
	(EXTEND25): New macro.

	sim/mips/
	* Makefile.in (tmp-micromips): New rule.
	(tmp-mach-multi): Add support for micromips.
	* configure.ac (mips*-sde-elf* | mips*-mti-elf*): Made a multi sim
	that works for both mips64 and micromips64.
	(mipsisa32r2*-*-*): Made a multi sim that works for mips32 and
	micromips32.
	Add build support for micromips.
	* dsp.igen (do_ph_s_absq, do_w_s_absq, do_qb_s_absq, do_addsc,
	do_addwc, do_bitrev, do_extpv, do_extrv, do_extrv_s_h, do_insv,
	do_lxx do_modsub, do_mthlip, do_mulsaq_s_w_ph, do_ph_packrl, do_qb_pick
	do_ph_pick, do_qb_ph_precequ, do_qb_ph_preceu, do_w_preceq
	do_w_ph_precrq, do_ph_qb_precrq, do_w_ph_rs_precrq do_qb_w_raddu,
	do_rddsp, do_repl, do_shilov, do_ph_shl, do_qb_shl do_w_s_shllv,
	do_ph_shrlv, do_w_r_shrav, do_wrdsp, do_qb_shrav, do_append,
	do_balign, do_ph_w_mulsa, do_ph_qb_precr, do_prepend): New functions.
	Refactored instruction code to use these functions.
	* dsp2.igen: Refactored instruction code to use the new functions.
	* interp.c (decode_coproc): Refactored to work with any instruction
	encoding.
	(isa_mode): New variable
	(RSVD_INSTRUCTION): Changed to 0x00000039.
	* m16.igen (BREAK16): Refactored instruction to use do_break16.
	(JALX32): Add mips32, mips64, mips32r2 and mips64r2 models.
	* micromips.dc: New file.
	* micromips.igen: New file.
	* micromips16.dc: New file.
	* micromipsdsp.igen: New file.
	* micromipsrun.c: New file.
	* mips.igen (do_swc1): Changed to work with any instruction encoding.
	(do_add do_addi do_andi do_dadd do_daddi do_dsll32 do_dsra32
	do_dsrl32, do_dsub, do_break, do_break16, do_clo, do_clz, do_dclo
	do_dclz, do_lb, do_lh, do_lwr, do_lwl, do_lwc, do_lw, do_lwu, do_lhu
	do_ldc, do_lbu, do_ll, do_lld, do_lui, do_madd, do_dsp_madd, do_maddu
	do_dsp_maddu, do_dsp_mfhi, do_dsp_mflo, do_movn, do_movz, do_msub
	do_dsp_msub, do_msubu, do_dsp_msubu, do_mthi, do_dsp_mthi, do_mtlo
	do_dsp_mtlo, do_mul, do_dsp_mult, do_dsp_multu, do_pref, do_sc, do_scd
	do_sub, do_sw, do_teq, do_teqi, do_tge, do_tgei, do_tgeiu, do_tgeu, do_tlt
	do_tlti, do_tltiu, do_tltu, do_tne, do_tnei, do_abs_fmt, do_add_fmt
	do_alnv_ps, do_c_cond_fmt, do_ceil_fmt, do_cfc1, do_ctc1, do_cvt_d_fmt
	do_cvt_l_fmt, do_cvt_ps_s, do_cvt_s_fmt, do_cvt_s_pl, do_cvt_s_pu
	do_cvt_w_fmt, do_div_fmt, do_dmfc1b, do_dmtc1b, do_floor_fmt, do_luxc1_32
	do_luxc1_64, do_lwc1, do_lwxc1, do_madd_fmt, do_mfc1b, do_mov_fmt, do_movtf
	do_movtf_fmt, do_movn_fmt, do_movz_fmt, do_msub_fmt, do_mtc1b, do_mul_fmt
	do_neg_fmt, do_nmadd_fmt, do_nmsub_fmt, do_pll_ps, do_plu_ps, do_pul_ps
	do_puu_ps, do_recip_fmt, do_round_fmt, do_rsqrt_fmt, do_prefx, do_sdc1
	do_suxc1_32, do_suxc1_64, do_sqrt_fmt, do_sub_fmt, do_swc1, do_swxc1
	do_trunc_fmt): New functions, refactored from existing instructions.
	Refactored instruction code to use these functions.
	(RSVD): Changed to use new reserved instruction.
	(loadstore_ea, not_word_value, unpredictable, check_mt_hilo, check_mf_hilo,
	check_mult_hilo, check_div_hilo, check_u64, do_luxc1_32, do_sdc1, do_suxc1_32,
	check_fmt_p, check_fpu, do_load_double, do_store_double):  Added micromips32
	and micromips64 models.
	Added include for micromips.igen and micromipsdsp.igen
	Add micromips32 and micromips64 models.
	(DecodeCoproc): Updated to use new macro definition.
	* mips3264r2.igen (do_dsbh, do_dshd, do_dext, do_dextm, do_dextu, do_di,
	do_dins, do_dinsm, do_ei, do_ext, do_mfhc1, do_mthc1, do_ins, do_dinsu,
	do_seb, do_seh do_rdhwr, do_wsbh): New functions.
	Refactored instruction code to use these functions.
	* sim-main.h (CP0_operation): New enum.
	(DecodeCoproc): Updated macro.
	(IMEM32_MICROMIPS, IMEM16_MICROMIPS, MICROMIPS_MINOR_OPCODE,
	MICROMIPS_DELAYSLOT_SIZE_ANY, MICROMIPS_DELAYSLOT_SIZE_16, MICROMIPS_DELAYSLOT_SIZE_32,
	ISA_MODE_MIPS32 and ISA_MODE_MICROMIPS): New defines.
	(sim_state): Add isa_mode field.

	sim/testsuite/sim/mips/
       * basic.exp (run_micromips_test, run_sim_tests): New functions
	Add support for micromips tests.
	* hilo-hazard-4.s: New file.
	* testutils.inc (_dowrite): Changed reserved instruction encoding.
	(writemsg): Moved the la and li instructions before the data they are
	assigned to, which prevents a bug where MIPS32 relocations are used instead
	of micromips relocations when building for micromips.
2015-09-25 15:52:18 +01:00
James Bowman bcd68f9e44 sim: ft32: add character input port
The FT32 simulator has character output, of course. This patch
adds character input, which lets the simulator run interactive
FT32 applications, e.g. language interpreters.
2015-09-22 22:43:56 -04:00
Nick Clifton 32f25203b4 Fix building GDB for the M32C by providing a stub sim_info function.
* gdb-if.c (sim_info): Stub function to allow GDB to be built
	with this simulator.
2015-08-05 14:58:21 +01:00
H.J. Lu 72f4393d8c Remove leading/trailing white spaces in ChangeLog 2015-07-24 04:16:47 -07:00
Nick Clifton 454de2ee15 Remove extraneous whitespace from ARM sim sources.
* armcopro.c: Remove extraneous whitespace.
	* armdefs.h: Likewise.
	* armfpe.h: Likewise.
	* arminit.c: Likewise.
	* armopts.h: Likewise.
	* armos.c: Likewise.
	* armos.h: Likewise.
	* armrdi.c: Likewise.
	* armsupp.c: Likewise.
	* armvirt.c: Likewise.
	* bag.c: Likewise.
	* bag.h: Likewise.
	* communicate.c: Likewise.
	* communicate.h: Likewise.
	* dbg_conf.h: Likewise.
	* dbg_cp.h: Likewise.
	* dbg_hif.h: Likewise.
	* dbg_rdi.h: Likewise.
	* gdbhost.c: Likewise.
	* gdbhost.h: Likewise.
	* iwmmxt.c: Likewise.
	* iwmmxt.h: Likewise.
	* kid.c: Likewise.
	* main.c: Likewise.
	* maverick.c: Likewise.
	* parent.c: Likewise.
	* thumbemu.c: Likewise.
	* wrapper.c: Likewise.
2015-07-14 12:06:33 +01:00
Nick Clifton db49d3d041 Fix snafu with latest addition to the ARM sim.
* Makefile.in (SIM_EXTRA_CFLAGS): Revert previous delta.
	(SIM_EXTRA_LIBS): Add -lm.
2015-07-02 16:19:09 +01:00
Nick Clifton 73cb0348b2 Add support for ARM v6 instructions.
* Makefile.in (SIM_EXTRA_CFLAGS): Add -lm.
	* armdefs.h (ARMdval, ARMfval): New types.
	(ARM_VFP_reg): New union.
	(struct ARMul_State): Add VFP_Reg and FPSCR fields.
	(VFP_fval, VFP_uword, VFP_sword, VFP_dval, VFP_dword): Accessor
	macros for the new VFP_Reg field.
	* armemu.c (handle_v6_insn): Add code to handle MOVW, MOVT,
	QADD16, QASX, QSAX, QSUB16, QADD8, QSUB8, UADD16, USUB16, UADD8,
	USUB8, SEL, REV, REV16, RBIT, BFC, BFI, SBFX and UBFX
	instructions.
	(handle_VFP_move): New function.
	(ARMul_Emulate16): Add checks for newly supported v6
	instructions.  Add support for VMRS, VMOV and MRC instructions.
	(Multiply64): Allow nRdHi == nRm and/or nRdLo == nRm when
	operating in v6 mode.
	* armemu.h (t_resolved): Define.
	* armsupp.c: Include math.h.
	(handle_VFP_xfer): New function.  Handles VMOV, VSTM, VSTR, VPUSH,
	VSTM, VLDM and VPOP instructions.
	(ARMul_LDC): Test for co-processor 10 or 11 and pass call to the
	new handle_VFP_xfer function.
	(ARMul_STC): Likewise.
	(handle_VFP_op): New function.  Handles VMLA, VMLS, VNMLA, VNMLS,
	VNMUL, VMUL, VADD, VSUB, VDIV, VMOV, VABS, VNEG, VSQRT, VCMP,
	VCMPE and VCVT instructions.
	(ARMul_CDP): Test for co-processor 10 or 11 and pass call to the
	new handle_VFP_op function.
	* thumbemu.c (tBIT, tBITS, ntBIT, ntBITS): New macros.
	(test_cond): New function.  Tests a condition and returns non-zero
	if the condition has been met.
	(handle_IT_block): New function.
	(in_IT_block): New function.
	(IT_block_allow): New function.
	(ThumbExpandImm): New function.
	(handle_T2_insn): New function.  Handles T2 thumb instructions.
	(handle_v6_thumb_insn): Add next_instr and pc parameters.
	(ARMul_ThumbDecode): Add support for IT blocks.  Add support for
	v6 instructions.
	* wrapper.c (sim_create_inferior): Detect a thumb address and call
	SETT appropriately.
2015-06-28 19:14:36 +01:00
Mike Frysinger 602a67cbea sim: trace: drop unused trace_one_insn
Everyone has migrated to the split functions (trace_prefix + trace_generic)
a while ago, so we can drop this one now.
2015-06-24 11:10:30 -04:00
Mike Frysinger 9b6025d169 sim: trace: rename debug_printf fully
Rather than redirect using a define, just rename the symbol fully.
2015-06-24 11:04:43 -04:00
Mike Frysinger fa8f87e53b sim: trace: add a basic cpu register class
The bfin/msp430 ports already had trace logic set up for reading/writing
cpu registers, albeit using different unrelated levels (core & vpu).  Add
a proper register class for these and for other ports.
2015-06-24 10:40:17 -04:00
Mike Frysinger cf304b56ca sim: trace: add set of system helpers
Some code paths trace on a system instance and not a cpu instance (like
the events code), so add some helpers for those cases.
2015-06-24 10:40:17 -04:00
Mike Frysinger 8371bf0cd9 sim: trace: document alu/fpu/vpu trace options better
Make the acronyms clear for people.
2015-06-24 10:16:45 -04:00
Mike Frysinger e750549018 sim: common: replace SIM_FILTER_PATH with lbasename
This helper macro has largely the same behavior as libiberty's lbasename.
There is a slight nuance related to colons, but it's not clear what the
point of that is, and the code implies that it just wants the basename.
2015-06-23 15:07:38 -04:00
Mike Frysinger 8d0978fb4b sim: use AS_HELP_STRING everywhere
This helps standardize the configure --help output.
2015-06-23 15:02:08 -04:00
Mike Frysinger 4953dc2094 sim: trace: do not enable internal debug by default
Since --trace-debug is for people hacking on the sim sources rather than
people just using the sim, default it to off.  This matches the behavior
of other debug knobs we have.
2015-06-23 14:05:38 -04:00
Mike Frysinger b50a153264 sim: assume recentish compiler/systems
Assume the build system supports stdint.h/stdarg.h as those have been
around long enough and we don't care about pre-stdc compilers anymore.
2015-06-23 14:04:49 -04:00
Mike Frysinger ccd4b2953b sim: common: add basic model assert
If the configured in default doesn't match a known value, throw an
assertion failure rather than segfaulting deeper down.
2015-06-21 13:56:24 -04:00
Mike Frysinger f55b33d51b sim: common: use standard intXX_t types for signedXX
Let's assume that the system supports the POSIX int8/16/32/64_t types
as this collapses the logic significantly.
2015-06-21 13:38:12 -04:00
Mike Frysinger 618b526e31 sim: common: standardize multiple include defines
We use SIM_xxx_H in most headers, so convert _SIM_xxx_H_ over to it.
2015-06-21 13:33:27 -04:00
Mike Frysinger 57b42d6489 sim: syscall: simplify unknown syscall trace
Since we always include the raw syscall number when tracing, also
including it in the name when it's unknown is redundant.  Simplify
the code by using a constant string.
2015-06-18 04:07:42 -04:00
Mike Frysinger 7aec3bb968 sim: callback: fix sentinel testing when walking maps
The new helpers for walking the maps tested the wrong value for exiting
the for loop.  This caused crashes when looking up entries that were not
in the map.
2015-06-18 04:02:26 -04:00
Mike Frysinger 7d5c6c43ca sim: syscall: add common sim_syscall helpers
Many ports have the same sim syscall logic, so add some helpers to handle
all the common details.  The arches still have to deal with the unpacking
and packing of the syscall arguments, but the rest of the sim<->callback
glue is now shared.
2015-06-17 13:19:51 -04:00
Mike Frysinger 61a0c964e6 sim: syscall: unify memory helpers
Almost every port implements these two callbacks in the same way, so
unify them in the common layer.
2015-06-17 13:19:51 -04:00
Mike Frysinger 6362a3f875 sim: callback: add human readable strings for debugging to maps
When tracing, we often want to display the human readable name for the
various syscall/errno values.  Rather than make each target duplicate
the lookup, extend the existing maps to include the string directly,
and add helper functions to look up the constants.

While most targets are autogenerated (from libgloss), the bfin/cris
targets have custom maps for the Linux ABI which need to be updated
by hand.
2015-06-17 13:19:51 -04:00
Mike Frysinger aaa9dc0170 sim: bfin: expand CB_SYS_xxx comment 2015-06-12 12:12:52 -04:00
Mike Frysinger 306f4178ef sim: update configure.in->configure.ac docs
A few places still refer to the configure.in file; update them.
2015-06-12 12:11:21 -04:00
Mike Frysinger a348708291 sim: drop -DTRACE from configure
No code uses this anymore and the symbol conflicts with the new TRACE
helper.  Punt it from configure.
2015-06-12 10:40:46 -04:00
Mike Frysinger 5b064994f0 sim: msp430: use new common trace print helpers
Replace the "if (TRACE_xxx_P) trace_generic" form with "TRACE_xxx".
The output is the same, but the code is nicer to read.
2015-06-12 10:14:00 -04:00
Mike Frysinger 0054dcd7b6 sim: moxie: use new common trace defines
Now that there's common helpers for printing trace data, switch to that
to restore the insn tracing support for this target.
2015-06-12 06:57:44 -04:00
Mike Frysinger bb11f3ed2b sim: trace: add common macros for logging info
The Blackfin port had some TRACE_xxx macros for easily logging trace data.
Use these as a base for common ones that have a simple form and match the
existing sets of helper macros.
2015-06-12 06:34:20 -04:00
Mike Frysinger 29bc024d07 sim: mips: switch to common WITH_TRACE_ANY_P
We want to add new common trace helpers including "TRACE", so change the
mips one to the new WITH_TRACE_ANY_P macro since they do the same thing.
2015-06-12 06:28:17 -04:00
Mike Frysinger bffcfec8c3 sim: trace: add WITH_TRACE_ANY_P helper
We have STRACE_ANY_P and TRACE_ANY_P, so add WITH_TRACE_ANY_P to fill
out the API.  This lets us wrap the internal configure symbol.
2015-06-12 06:21:38 -04:00
Mike Frysinger 53d2389fd0 sim: moxie: rename TRACE to MOXIE_TRACE_INSN
We want to add new common trace helpers including "TRACE", so rename the
moxie one to MOXIE_TRACE_INSN.  This also matches what the code is doing.
2015-06-12 06:16:39 -04:00
Mike Frysinger db7858e227 sim: cgen: namespace custom trace functions
The cgen code declares some macros/funcs using the trace_xxx prefix, but
the code isn't generic and only works with cgen targets.  This is blocking
the creation of new common trace functions.

Let's blindly add cgen_xxx prefixes to all these symbols.  Some already
use this convention to avoid conflicts, so it makes sense to align them.
In the future we might want to move some to the common trace core, but
one thing at a time.
2015-06-12 04:19:45 -04:00
Mike Frysinger c1d8560ea5 sim: msp430: delete unused trace macros
These macros were copied from the Blackfin port but never used, so delete
them as part of the trace unification work.
2015-06-11 12:52:20 -04:00
Mike Frysinger 83034798de sim: trace: centralize the system tracing
First we convert the ETRACE_P to STRACE_EVENTS_P.  This means we move from
using the sim_events.trace storage to the common sim_state_base.trace_data
array.  With that deleted, the common trace init code can be simplified so
the sim state works the same as the sim cpu.
2015-06-11 10:39:43 -04:00
Mike Frysinger ce4eda4a58 sim: trace: add STRACE_xxx_P macros
These are the parallel to the TRACE_xxx_P macros and fill out the full
set to match the existing debug one.
2015-06-11 10:37:15 -04:00
Mike Frysinger a6c2a374e0 sim: trace: use existing defines for the useful mask
No point in duplicating the shift logic when we have macros already to
keep that all unified.
2015-06-11 10:29:44 -04:00
Mike Frysinger 9b9c712ceb sim: trace: create a common WITH_TRACE_P macro
This way we can use the IDX macros everywhere and not worry about the
encoding of the WITH_TRACE define in multiple places.
2015-06-11 10:28:58 -04:00
Mike Frysinger 66a19e2f81 sim: frv: drop custom debug mask
This is the only sim that sets up its own WITH_TRACE mask and it conflicts
with the user setting their own list at configure time.  Drop it to match
all the other sims.
2015-06-11 10:22:44 -04:00
Mike Frysinger 09896bd223 sim: m68hc11: delete unused interrupt_names
The interrupts.c file has a static/fuller definition that is used,
so drop this copy in interp.c.
2015-06-11 10:21:32 -04:00
Mike Frysinger a84f8df0e2 sim: m68hc11: switch to common sim_resume
This code already matched the common sim reusme logic, so we can simply
drop it and pull in the common code.
2015-06-11 10:17:54 -04:00
Mike Frysinger 926b1cd8cf sim: mn10300: delete unused memory code
Only one place used get_word/put_word, so inline the usage there.
All the rest is dead code so trim it.
2015-06-11 10:13:49 -04:00
Mike Frysinger 2cc78d4dd7 sim: mn10300: add missing static markings 2015-06-11 07:35:32 -04:00
Mike Frysinger 96eaf29ec4 sim: mn10300: delete unused exception/exited/debug state
The syscall path was the only code checking the custom exception state
after recent cleanups.  Once we change that to the common engine halt
function, we can delete that state entirely.

This also helps highlight some other dead code that we can cull.
2015-06-11 07:29:16 -04:00
Mike Frysinger b0e4c8a581 sim: mn10300: use common size types
No point in open coding this logic here when we have common size types
already that give the right answer.
2015-06-11 07:20:57 -04:00
Mike Frysinger 5d19c36612 sim: m68hc11/mn10300/v850: delete redundant INLINE defines
The sim-inline.h header already takes care of this for us, so punt
the local definitions.
2015-06-11 07:17:12 -04:00
Mike Frysinger 31557eccb2 sim: microblaze: switch to common sim_resume/sim_stop_reason
This allows us to use the common code for all exception handling.
2015-06-11 07:13:22 -04:00
Joel Brobecker bb9e16d4bb Fix latest sim/common/ChangeLog entry. 2015-06-09 14:29:09 -04:00
Joel Brobecker f419f52b9b Remove unnecessary empty line in sim/common/ChangeLog 2015-06-09 14:27:58 -04:00
Mike Stump 509c2f329a Fix spelling mistakes in sim/common/sim-events.c error messages.
sim/common/ChangeLog:

        * sim-events.c (sim_events_schedule_after_signal): Fix spelling
        mistake in call to sim_engine_abort.
        (sim_events_schedule_after_signal): Likewise.
2015-06-09 14:27:46 -04:00
Mike Frysinger 296730a52b sim: erc32: restore attribution 2015-05-17 17:15:36 +08:00
Joel Brobecker 17d88f73c0 Switch erc32 simulator copyright headers to FSF.
Permission was granted by Jiri Gaisler, who has a copyright assignment
on file for GDB.

sim/erc32/ChangeLog:

        * configure.ac: Add copyright header.
        * erc32.c: Change copyright holder to FSF.  Reformat.
        * exec.c, float.c, func.c, interf.c, sis.c, sis.h: Likewise.
        * help.c, startsim: Add copyright header.
2015-05-08 07:23:15 -07:00
DJ Delorie 0952813b0b Make RL78 disassembler and simulator respect ISA for mul/div
[gas]
	* config/rl78-defs.h (rl78_isa_g10): New.
	(rl78_isa_g13): New.
	(rl78_isa_g14): New.
	* config/rl78-parse.y (ISA_G10): New.
	(ISA_G13): New.
	(ISA_G14): New.
	(MULHU, MULH, MULU, DIVHU, DIVWU, MACHU, MACH): Use them.
	* config/tc-rl78.c (rl78_isa_g10): New.
	(rl78_isa_g13): New.
	(rl78_isa_g14): New.

[gdb]
	* rl78-tdep.c (rl78_analyze_prologue): Pass RL78_ISA_DEFAULT to
	rl78_decode_opcode

[include]
	* dis-asm.h (print_insn_rl78_g10): New.
	(print_insn_rl78_g13): New.
	(print_insn_rl78_g14): New.
	(rl78_get_disassembler): New.
	* opcode/rl78.h (RL78_Dis_Isa): New.
	(rl78_decode_opcode): Add ISA parameter.

[opcodes]
	* disassemble.c (disassembler): Choose suitable disassembler based
	on E_ABI.
	* rl78-decode.opc (rl78_decode_opcode): Take ISA parameter.  Use
	it to decode mul/div insns.
	* rl78-decode.c: Regenerate.
	* rl78-dis.c (print_insn_rl78): Rename to...
	(print_insn_rl78_common): ...this, take ISA parameter.
	(print_insn_rl78): New.
	(print_insn_rl78_g10): New.
	(print_insn_rl78_g13): New.
	(print_insn_rl78_g14): New.
	(rl78_get_disassembler): New.

[sim]
	* rl78/cpu.c (g14_multiply): New.
	* rl78/cpu.h (g14_multiply): New.
	* rl78/load.c (rl78_load): Decode ISA completely.
	* rl78/main.c (main): Expand -M to include other ISAs.
	* rl78/rl78.c (decode_opcode): Decode based on ISA.
	* rl78/trace.c (rl78_disasm_fn): New.
	(sim_disasm_init): Reset it.
	(sim_disasm_one): Get correct disassembler for ISA.
2015-04-30 15:25:49 -04:00
Nick Clifton 0a13382c8e Fix problems in the sim sources discovered by running the cppcheck static analysis tool.
erc32	PR 18273
	* sis.c (main): Remove unreachable code.

m68hc11	* gencode.c (gen_fetch_operands): Remove unreachable code.

ppc	* hw_htab.c (htab_map_binary): Fix overlap check.

common	* sim-fpu.c (INLINE_SIM_FPU): Fix static analysis warning by
	increasing parenthesis around casts to signed values.
2015-04-29 16:02:02 +01:00
Senthil Kumar Selvaraj 180d40b903 sim: avr: Fix 'multiple definition of sim_{read,write}'
This patch does whatever was done in
https://sourceware.org/ml/gdb-patches/2015-04/msg00437.html to fix
broken gdb build for the AVR target.
2015-04-27 09:54:37 -04:00
Nick Clifton de7669bfa5 Fix typos in sim sources exposed by static analysis.
bfin	PR 18273
	* bfin-sim.c (decode_dsp32alu_0): Remove spurious check for
	s == 1.

erc32	PR 18273
	* exec.c (add32): Fix typo in check for overflow.

igen	PR 18273
	* misc.c (a2i): Fix typos checking for uppercase letters.
2015-04-24 15:43:21 +01:00
Nick Clifton 63c72d1ae4 Fix typo in check for valid register number in RX sim.
PR sim/18273
	* reg.c (put_reg): Fix check for valid register number.
2015-04-24 15:31:36 +01:00
Mike Frysinger 43236bb255 sim: mcore: clean up printf warnings
These printf statements are showing "word" objects which are typedefed
from long, so make sure to use l with %x when printing them to avoid
warnings from gcc.
2015-04-21 03:10:16 -04:00
Mike Frysinger f63036b811 sim: mcore: convert to common memory/verbose functions
Re-use the existing memory core that handles reads/writes.

The verbose command is converted to the common --verbose flag
since only a few call sites use it now.
2015-04-21 03:10:16 -04:00
Mike Frysinger e53e5aab53 sim: mcore: drop watchpoint/dumpmem/clearstats support
In preparation for converting to the common memory framework, the custom
commands get in our way.  But when we realize that gdb support has been
dropped for mcore, it makes things a bit easier: the main runner does not
let you run arbitrary commands once simulation starts.

So lets disable watchpoint support until it can be converted to the common
watchpoint logic.  There's already an ifdef to let us do that.

We straight up drop support for the dumpmem command (no other sim supports
this, and if it's a feature people want, we can add a common func) and the
clearstats command (not a big deal -- just restart your simulation).

We leave in place the verbose check points as a follow up commit will cut
that over to common logic.
2015-04-21 03:10:16 -04:00
Mike Frysinger 767e68f1b9 sim: mcore: switch to common syscall handling
Now that libgloss has a header tracking the syscalls for this arch, we
can update the database to include it for the symbolic constants/maps.
Then we can switch the mcore syscall callbacks over to the common ones.
2015-04-21 03:10:16 -04:00
Mike Frysinger 248d23e82b sim: gennltvals.sh: handle split out newlib source tree
Since newlib no longer shares the same repo as binutils/gdb, we have to go
searching further afield to locate the sources.  We still look at the top
level for newlib, but if that is not found, we also try up one dir outside
of this source tree.  It sucks, but better than the status quo (no workie).
2015-04-21 03:10:16 -04:00
Jiri Gaisler d3e9b40afb sim/erc32: Switched emulated memory to host endian order.
Change data ordering in emulated memory from target order (big endian)
to host order. Improves performance and simplifies most memory
operations. Requires some byte twisting during stores on little
endian hosts (intel). Also removed support for little-endian binaries.
2015-04-19 02:29:44 -04:00
Mike Frysinger 3ebe2863f7 sim: clean up duplicate sim-engine hooks
Now that we've unified sim-cpu, we can delete the duplicate sim-engine
hooks -- these targets defined these only because they didn't fully
implement the sim-cpu callbacks.
2015-04-18 04:40:27 -04:00
Mike Frysinger e8d3a34fee sim: trim old USING_SIM_BASE_H define
This doesn't appear to have been used since 1998, but wasn't cleaned
up since.  So much for being "quick" ;).
2015-04-18 04:32:56 -04:00
Mike Frysinger 20bca71d82 sim: unify SIM_CPU definition
Since every target typedefs this the same way, move it to the common code.

We have to leave Blackfin behind here for now because of inter-dependencies
on types and headers: sim-base.h includes sim-model.h which needs types in
machs.h which needs types in bfim-sim.h which needs SIM_CPU.
2015-04-18 04:31:36 -04:00
Mike Frysinger 7e83aa92f2 sim: unify sim_cia definition
Almost every target defines sim_cia the same way -- either using the
address_word type directly, or a type of equivalent size.  The only
odd one out is sh64 (who has 32bit address_word and 64bit cia), and
even that case doesn't seem to make sense.  We'll put off clean up
though of sh64 and at least set up a sensible default for everyone.
2015-04-18 04:14:38 -04:00
Mike Frysinger c85fc61074 sim: microblaze: switch to common memory functions
Re-use the existing memory core that handles reads/writes.

This drops support for the dumpmem command, but gdb itself has
support for dumping memory regions.

The verbose command is converted to the common --verbose flag
since only two call sites use it now.

Support for the clearstats command is dropped entirely, but no
other sim really does this, and the same thing can be done by
reloading.  If it's important (clearing cycle stats) to someone,
we can add a common function for it.
2015-04-17 03:15:43 -04:00
Mike Frysinger 034685f9ce sim: replace CIA_{GET,SET} with CPU_PC_{GET,SET}
The CIA_{GET,SET} macros serve the same function as CPU_PC_{GET,SET}
except the latter adds a layer of indirection via the sim state.  This
lets models set up different functions at runtime and doesn't reach so
directly into the arch-specific cpu state.

It also doesn't make sense to have two sets of macros that do exactly
the same thing, so lets standardize on the one that gets us more.
2015-04-17 02:44:30 -04:00
Mike Frysinger 27b97b40bc sim: arm/cr16/d10v/h8300/microblaze/sh: fill out sim-cpu pc fetch/store helpers
This makes the common sim-cpu logic work.
2015-04-17 02:22:16 -04:00
Mike Frysinger 4c0cab1e21 sim: avr/mcore/moxie: fill out sim-cpu pc fetch/store helpers
This makes the common sim-cpu logic work.
2015-04-16 02:13:50 -04:00
Mike Frysinger 78e9aa70fe sim: unify sim-cpu usage
Now that all the targets are utilizing CPU_PC_{FETCH,STORE}, and the
cpu state is multicore, and the STATE_CPU defines match, we can move
it all to the common code.
2015-04-15 02:19:52 -04:00
Mike Frysinger f95f4ed2c4 sim: cris/frv/h8300/iq2000/lm32/m32r/sh64: standardize cpu state
This sets up the sim_state structure and the cpu member to match what we
do in most other sims, and what the common code suggests.  This is a step
to unifying on the sim-cpu.o object.
2015-04-15 01:25:32 -04:00
Mike Frysinger 887bddbcad sim: ppc: fix up version script
The common sim code has switched to using gdb directly; update the
ppc copy too.
2015-04-13 23:17:53 -04:00
Mike Frysinger bf12d44ee0 sim: fix the PKGVERSION define
This should be SIM, not GDB.
2015-04-13 02:41:10 -04:00
Mike Frysinger a542beff94 sim: options: add --version support
The old run frontend had a --version option, but the new common
sim-options file does not.  Restore support for that so we can
get version info out of `run` when using the new frontend.
2015-04-13 02:35:26 -04:00
Mike Frysinger 8c32ba2233 sim: switch to gdb version script
Since the local create-version.sh already points directly into the gdb
source tree, we might as well use the gdb script directly too.
2015-04-13 02:32:58 -04:00
Mike Frysinger 64f14c9707 sim: mn10300: convert to sim-cpu
Make cpu allocation fully dynamic so we can leverage the common
sim-cpu and its APIs.
2015-04-13 02:13:48 -04:00
Mike Frysinger 14c9ad2edb sim: v850: convert to sim-cpu
Make cpu allocation fully dynamic so we can leverage the common
sim-cpu and its APIs.
2015-04-13 02:11:50 -04:00
Mike Frysinger 7bebb329bb sim: mips: convert to sim-cpu
Make cpu allocation fully dynamic so we can leverage the common
sim-cpu and its APIs.
2015-04-13 02:09:55 -04:00
Mike Frysinger bea3f671c5 sim: m68hc11: convert to sim-cpu
Make cpu allocation fully dynamic so we can leverage the common
sim-cpu and its APIs.
2015-04-13 02:07:23 -04:00
Mike Frysinger 8ac57fbde4 sim: mips: fix prototype warnings
Convert a bunch of old style prototypes and tweak various casts
to match the function signatures.
2015-04-13 02:01:11 -04:00
Mike Frysinger 65f9096890 sim: ft32: fix ft32_pc_get logic 2015-04-13 01:54:33 -04:00
Hans-Peter Nilsson a9d9677441 Do unset_currtarget_info ldscript for all simulator testsuites.
sim/testsuite:
	* sim-defs.exp (sim_init): Unset target ldscript here.

sim/testsuite/sim/mips:
	* basic.exp: Don't unset target ldscript here.
2015-04-13 01:56:04 +02:00
Mike Frysinger e787f858a4 sim: arm/mips: fix sim_read/sim_write linkage errors
With sim-hrw.o being built & linked in the common list, some people are
getting linking errors now for these targets.  Move the main objects that
provide these functions before the common list to avoid that.
2015-04-12 05:47:39 -04:00
Mike Frysinger 29f1a5934a sim: ft32: delete sim_read/sim_write funcs
The common sim-hrw.o provides both of these, so simply use them.
2015-04-12 05:13:23 -04:00
Mike Frysinger 122bbfb52a sim: move sim-engine.o/sim-hrw.o to the common list
This makes these two objects available to all sims by default.
2015-04-06 23:56:47 -04:00