Commit Graph

3821 Commits

Author SHA1 Message Date
Nick Clifton 67f101eece Ignore DWARF debug information with a version of 0 - assume that it is padding.
PR 19872
bfd	* dwarf2.c (parse_comp_unit): Skip warning about unrecognised
	version number if the version is zero.

bin	* dwarf.c (display_debug_aranges): Skip warning about unrecognised
	version number if the version is zero.
2016-04-04 12:53:33 +01:00
Nick Clifton 7517e550ce Fix more bugs in AArch64 simulator.
* cpustate.c (aarch64_set_reg_s32): New function.
	(aarch64_set_reg_u32): New function.
	(aarch64_get_FP_half): Place half precision value into the correct
	slot of the union.
	(aarch64_set_FP_half): Likewise.
	* cpustate.h: Add prototypes for aarch64_set_reg_s32 and
	aarch64_set_reg_u32.
	* memory.c (FETCH_FUNC): Cast the read value to the access type
	before converting it to the return type.  Rename to FETCH_FUNC64.
	(FETCH_FUNC32): New macro.  Duplicates FETCH_FUNC64 but for 32-bit
	accesses.  Use for 32-bit memory access functions.
	* simulator.c (ldrsb_wb): Use sign extension not zero extension.
	(ldrb_scale_ext, ldrsh32_abs, ldrsh32_wb): Likewise.
	(ldrsh32_scale_ext, ldrsh_abs, ldrsh64_wb): Likewise.
	(ldrsh_scale_ext, ldrsw_abs): Likewise.
	(ldrh32_abs): Store 32 bit value not 64-bits.
	(ldrh32_wb, ldrh32_scale_ext): Likewise.
	(do_vec_MOV_immediate): Fix computation of val.
	(do_vec_MVNI): Likewise.
	(DO_VEC_WIDENING_MUL): New macro.
	(do_vec_mull): Use new macro.
	(do_vec_mul): Use new macro.
	(do_vec_MLA): Read values before writing.
	(do_vec_xtl): Likewise.
	(do_vec_SSHL): Select correct shift value.
	(do_vec_USHL): Likewise.
	(do_scalar_UCVTF): New function.
	(do_scalar_vec): Call new function.
	(store_pair_u64): Treat reads of SP as reads of XZR.
2016-03-30 10:29:04 +01:00
Nick Clifton ef0d8ffc45 Tidy up AArch64 simulator code.
* cpustate.c: Remove space after asterisk in function parameters.
	* decode.h (greg): Delete unused function.
	(vreg, shift, extension, scaling, writeback, condcode): Likewise.
	* simulator.c: Use INSTR macro in more places.
	(HALT_NYI): Use sim_io_eprintf in place of fprintf.
	Remove extraneous whitespace.
2016-03-29 11:34:22 +01:00
Nick Clifton 5ab6d79e70 More AArch64 simulator improvements.
* cpustate.c (aarch64_get_FP_half): New function.  Read a vector
	register as a half precision floating point number.
	(aarch64_set_FP_half): New function.  Similar, but for setting
	a half precision register.
	(aarch64_get_thread_id): New function.  Returns the value of the
	CPU's TPIDR register.
	(aarch64_get_FPCR): New function.  Returns the value of the CPU's
	floating point control register.
	(aarch64_set_FPCR): New function.  Set the value of the CPU's FPCR
	register.
	* cpustate.h: Add prototypes for new functions.
	* sim-main.h (struct _sim_cpu): Add FPCR and tpidr fields.
	* memory.c: Use unaligned core access functions for all memory
	reads and writes.
	* simulator.c (HALT_NYI): Generate an error message if tracing
	will not tell the user why the simulator is halting.
	(HALT_UNREACHABLE): Delete.  Delete (unneeded) uses of the macro.
	(INSTR): New time-saver macro.
	(fldrb_abs): New function.  Loads an 8-bit value using a scaled
	offset.
	(fldrh_abs): New function.  Likewise for 16-bit values.
	(do_vec_SSHL): Allow for negative shift values.
	(do_vec_USHL): Likewise.
	(do_vec_SHL): Correct computation of shift amount.
	(do_vec_SSHR_USHR): Correct decision of signed vs unsigned
	shifts and computation of shift value.
	(clz): New function.  Counts leading zero bits.
	(do_vec_CLZ): New function.  Implements CLZ (vector).
	(do_vec_MOV_element): Call do_vec_CLZ.
	(dexSimpleFPCondCompare): Implement.
	(do_FCVT_half_to_single): New function.  Implements one of the
	FCVT operations.
	(do_FCVT_half_to_double): New function.  Likewise.
	(do_FCVT_single_to_half): New function.  Likewise.
	(do_FCVT_double_to_half): New function.  Likewise.
	(dexSimpleFPDataProc1Source): Call new FCVT functions.
	(do_scalar_SHL): Handle negative shifts.
	(do_scalar_shift): Handle SSHR.
	(do_scalar_USHL): New function.
	(do_double_add): Simplify to just performing a double precision
	add operation.  Move remaining code into...
	(do_scalar_vec): ... New function.
	(dexLoadUnsignedImmediate): Call new fldrb_abs and fldrh_abs
	functions.
	(system_get): Add support for TPIDR, CTR, FPCR, FPSR and CPSR
	registers.
	(system_set): New function.
	(do_MSR_immediate): New function.  Stub for now.
	(do_MSR_reg): New function.  Likewise. Partially implements MSR
	instruction.
	(do_SYS): New function.  Stub for now,
	(dexSystem): Call new functions.
2016-03-23 17:37:30 +00:00
Nick Clifton 87bba7a5e0 Fix thinko in new GET_VEC_ELEMENT macro.
* cpustate.c: (GET_VEC_ELEMENT): And fix thinko using macro arguments.
2016-03-18 17:08:27 +00:00
Nick Clifton 4c0ca98e58 Fix code to check for illegal element numbers when accessing AArch64 vector registers in AArch64 sim.
* cpustate.c (GET_VEC_ELEMENT): Fix off by one error checking
	for an invalid element index.
	(SET_VEC_ELEMENT): Likewise.
2016-03-18 14:46:42 +00:00
Nick Clifton e101a78be9 Add simulation of MUL and NEG instructions to AArch64 simulator.
* cpustate.c: Remove spurious spaces from TRACE strings.
	Print hex equivalents of floats and doubles.
	Check element number against array size when accessing vector
	registers.
	* memory.c: Trace memory reads when --trace-memory is enabled.
	Remove float and double load and store functions.
	* memory.h (aarch64_get_mem_float): Delete prototype.
	(aarch64_get_mem_double): Likewise.
	(aarch64_set_mem_float): Likewise.
	(aarch64_set_mem_double): Likewise.
	* simulator (IS_SET): Always return either 0 or 1.
	(IS_CLEAR): Likewise.
	(fldrs_pcrel): Load and store floats using 32-bit memory accesses
	and doubles using 64-bit memory accesses.
	(fldrd_pcrel, fldrs_wb, fldrs_abs, fldrs_scale_ext): Likewise.
	(fldrd_wb, fldrd_abs, fsturs, fsturd, fldurs, fldurd): Likewise.
	(fstrs_abs, fstrs_wb, fstrs_scale_ext, fstrd_abs): Likewise.
	(fstrd_wb, fstrd_scale_ext, store_pair_float): Likewise.
	(store_pair_double, load_pair_float, load_pair_double): Likewise.
	(do_vec_MUL_by_element): New function.
	(do_vec_op2): Call do_vec_MUL_by_element.
	(do_scalar_NEG): New function.
	(do_double_add): Call do_scalar_NEG.
2016-03-18 09:32:32 +00:00
Nick Clifton 57aa174243 Fix bugs in the simulation of the AArch64's ADDP, FADDP, LD1, CCMP and CCMP instructions.
* simulator.c (set_flags_for_sub32): Correct type of signbit.
	(CondCompare): Swap interpretation of bit 30.
	(DO_ADDP): Delete macro.
	(do_vec_ADDP): Copy source registers before starting to update
	destination register.
	(do_vec_FADDP): Likewise.
	(do_vec_load_store): Fix computation of sizeof_operation.
	(rbit64): Fix type of constant.
	(aarch64_step): When displaying insn value, display all 32 bits.
2016-03-03 15:22:53 +00:00
Mike Frysinger 1554f75841 sim: mips: fix prog_bfd usage
We do not want to reference the "base" member directly.  We have the
STATE_PROG_BFD macro instead to look up the prog_bfd member.
2016-02-05 20:27:25 -05:00
Nick Clifton 13754e4c3d Prevent possible undefined behaviour computing the size of the scache by usingunsigned integers instead of signed integers.
* cgen-scache.c (scache_option_handler): Prevent possible
	undefined behaviour computing the size of the scache by using
	unsigned integers instead of signed integers.
2016-02-04 16:27:06 +00:00
Maciej W. Rozycki 3b8f2c8bcf MAINTAINERS: Add Thiemo Seufer back, as a past maintainer
Complement commit 26e0f8dbd8 ("* MAINTAINERS: Remove Thiemo Seufer.").

	* MAINTAINERS (Past sim maintainers): Add Thiemo Seufer.
2016-02-03 18:26:50 +00:00
Andrew Bennett 3d304f48ca MIPS: Only build microMIPS specific simulator functions if microMIPS support is required.
This fixes PR sim/19441.  In the MIPS simulator the microMIPS
functions in micromips.igen were not predicated on the microMIPS
models.  This was causing build issues for some target triples.
This patch sets all the microMIPS specific functions to only be built if
the micromips32, micromips64 or micromipsdsp models are used.

	PR sim/19441
	* micromips.igen (delayslot_micromips): Enable for `micromips32',
	`micromips64' and `micromipsdsp' only.
	(process_isa_mode): Enable for `micromips32' and `micromips64' only.
	(do_micromips_jalr, do_micromips_jal): Likewise.
	(compute_movep_src_reg): Likewise.
	(compute_andi16_imm): Likewise.
	(convert_fmt_micromips): Likewise.
	(convert_fmt_micromips_cvt_d): Likewise.
	(convert_fmt_micromips_cvt_s): Likewise.
	(FMT_MICROMIPS): Likewise.
	(FMT_MICROMIPS_CVT_D): Likewise.
	(FMT_MICROMIPS_CVT_S): Likewise.
2016-01-18 21:50:00 +00:00
Joel Brobecker f749ed6079 Minor comment fixes in sim/common/sim-fpu.c.
This patch makes a fair number of fixes in the various comments of
sim-fpu.c, mostly to either better conform to the GNU Coding Standards
(sentences start with a capital letter, end with a period), or to
fix spelling mistakes.

sim/common/ChangeLog:

        * sim-fpu.c: Minor comment fixes throughout.
2016-01-17 09:34:29 +04:00
Joel Brobecker 3c8e93b7fa minor reformatting in sim/common/sim-fpu.c.
This patch just makes a copy of formatting changes to better conform
with the GNU Coding Style.

sim/common/ChangeLog:

        * sim-fpu.c (print_bits): Minor reformatting (no code change).
        (sim_fpu_map): Likewise.
2016-01-17 09:33:49 +04:00
Mike Frysinger b36d953bce sim: mips: workaround 32-bit addr sign extensions
The mips bfd will sign extend 32-bit addresses into 64-bit values,
so if the entry happens to be 0x80000000 or higher, it is turned to
0xffffffff80000000 which points to memory that doesn't exist.

This wasn't an issue until commit 26f8bf63bf
as all addresses were automatically truncated there in the translate
function to 32-bits.  When we cleaned up that code, the full 64-bits
were checked leading to many test failures for mips-sde-elf targets
and such.
2016-01-12 01:42:22 -05:00
Mike Frysinger 34ac507d94 sim: config: do not try to align settings
We try to align the output for a few settings, but not most of them.
Drop the aligning entirely to be lazy.
2016-01-11 00:58:55 -05:00
Mike Frysinger ce39bd3890 sim: move many common settings from CPPFLAGS to config.h
Rather than stuffing the command line with a bunch of -D flags, start
moving things to config.h which is managed by autoheader.  This makes
the makefile a bit simpler and the build output tighter, and it makes
the migration to automake easier as there are fewer vars to juggle.

We'll want to move the other options out too, but it'll take more work.
2016-01-10 18:54:41 -05:00
Mike Frysinger e19418e02e sim: drop unused SIM_AC_OPTION_PACKAGES
This was imported from the ppc sim, but that was only used to control
a single file, and that is already governed by the hw models.  There's
no need to have a sep configure option here, especially since none of
the other sims are using it.  Even when the code is enabled, there's
no runtime overhead.
2016-01-10 17:54:04 -05:00
Mike Frysinger 16f7876d71 sim: allow the environment configure option everywhere
Currently ports have to call SIM_AC_OPTION_ENVIRONMENT explicitly in
order to make the configure flag available.  There's no real reason
to not allow this flag for all ports, so move it to the common sim
macro.  This way we get standard behavior across all ports too.
2016-01-10 17:03:36 -05:00
Mike Frysinger 35656e9521 sim: allow the assert configure option everywhere
Currently ports have to call SIM_AC_OPTION_ASSERT explicitly in order
to make the configure flag available, which none of them do.  There's
no real reason to not allow this flag for all ports, so move it to the
common sim macro.  This way we get standard behavior across all ports.
2016-01-10 16:13:13 -05:00
Mike Frysinger 99d8e87993 sim: drop targ-vals.def->nltvals.def indirection
We don't have alternative nltvals.def files, so always symlinking
the targ-vals.def file to it doesn't gain us anything.  It does
make the build more complicated though and a pain to convert to
something newer (like automake).  Drop the symlinking entirely.

In the future, we'll want to explode this file anyways into the
respective arch dirs so things can be selected dynamically at
runtime, so it's not like we'll be bringing this back.
2016-01-10 04:01:16 -05:00
Mike Frysinger 6d90347b5d sim: mips: drop SIM_AC_OPTION_SMP call
No other port calls this macro directly, and mips has it hardcoded
to the default -- disabling smp.  In the future we'll enable this
for all targets in common code, so tidy up the mips code now.
2016-01-10 03:42:06 -05:00
Mike Frysinger 347fe5bb86 sim: allow the inline configure option everywhere
Currently ports have to call SIM_AC_OPTION_INLINE explicitly in order
to make the configure flag available.  There's no real reason to not
allow this flag for all ports, so move it to the common sim macro.
This way we get standard behavior across all ports too.
2016-01-10 03:36:32 -05:00
Mike Frysinger 0dc73ef7c3 sim: drop --enable-sim-{regparm,stdcall} options
These options were never exposed for most sims (just the ppc one),
and they are really only useful on 32-bit x86 systems.  Considering
modern systems tend to be 64-bit x86_64 and how well modern compilers
are at optimizing code, these have outlived their usefulness.
2016-01-10 03:15:01 -05:00
Mike Frysinger 22be3fbeac sim: drop --enable-sim-cflags option
No other sub directory provides such a configuration option, so
drop it from the sim dir as well.  This cleans up a good bit of
code in the process.

If people want to use custom flags for just the sim, they can
still run configure+make by hand in the sim subdir and use the
normal CFLAGS settings.
2016-01-10 02:54:59 -05:00
Mike Frysinger 5295724cdc sim: stop configuring common subdir
Now that cconfig.h doesn't exist, there's no need to build in the common
subdir anymore.  We leave the configure/Makefile files in there as there
is a helper for developers to generate the nltvals.def file.  Once that
gets cleaned up in the future though, we can drop the build logic too.
2016-01-09 03:52:30 -05:00
Mike Frysinger 936df7568a sim: drop common/cconfig.h in favor of a single config.h
The common subdir sets up a cconfig.h file to hold checks for the common
code.  In practice, most files still end up using config.h instead which
just leads to confusion.

Merge all the configure checks that went into cconfig.h into SIM_AC_COMMON
so we can drop the cconfig.h file altogether.  Now there is only a single
config.h file like normal.
2016-01-09 03:52:30 -05:00
Mike Frysinger b900245c3b sim: config: drop use of __DATE__/__TIME__
These don't add a whole lot of useful info, and people don't like them as
it makes builds unreproducible, so just drop them.
2016-01-06 21:52:57 -05:00
Mike Frysinger 2e3d4f4d5d sim: sim_{create_inferior,open,parse_args}: constify argv/env slightly
2016-01-03  Mike Frysinger  <vapier@gentoo.org>

	* sim-options.c (sim_parse_args): Mark argv array const.
	* sim-options.h (sim_parse_args): Likewise.
2016-01-06 21:48:59 -05:00
Joel Brobecker 6847703472 Change copyright owner to FSF in sim/testsuite/sim/mips/hilo-hazard-4.s
sim/testsuite/sim/mips/ChangeLog:

        * hilo-hazard-4.s: Change copyright ownder to FSF.
2016-01-06 09:41:15 +04:00
Mike Frysinger 402cf05346 sim: msp430: drop duplicate sim_load_file call
There's no need, or desire, to call sim_load_file from sim_open.  The
higher levels (gdb/run) take care of calling sim_load for us already.
2016-01-05 14:37:46 -05:00
Mike Frysinger 1a846c6262 sim: aarch64: switch to common disassembler tracing
The output should largely be the same.
2016-01-05 14:37:46 -05:00
Mike Frysinger 824c862804 sim: bfin: add support disasm tracing 2016-01-05 14:37:45 -05:00
Mike Frysinger 70d3944832 sim: msp430: switch to common disassembler tracing
The output format is a bit different, but the new form matches all the
other trace lines.  Otherwise, it should be functionally equivalent.
2016-01-05 14:37:33 -05:00
Mike Frysinger bfb2629c16 sim: trace: add support for disassembling
Some targets have started to add support for calling the disassembler
automatically when executing code.  Add support for that directly into
the trace core.
2016-01-05 14:28:37 -05:00
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