aboutsummaryrefslogtreecommitdiff
path: root/sim/common
AgeCommit message (Collapse)AuthorFilesLines
2021-04-18sim: moxie: switch syscalls to common nltvalsMike Frysinger3-0/+37
Rather than hand duplicate the syscall constants, switch to the common nltvals framework. I made sure the constants have the same values before & after too :).
2021-04-18sim: sh: switch syscalls to common nltvalsMike Frysinger3-0/+45
Rather than hand duplicate the syscall table, switch to the common nltvals framework. We have to tweak the constant names, but we get everything else for free. I made sure the constants have the same values before & after too :).
2021-04-18sim: rx: switch syscalls to common nltvalsMike Frysinger3-0/+37
Rather than hand duplicate the syscall table, switch to the common nltvals framework. We have to tweak the constant names, but we get everything else for free. I made sure the constants have the same values before & after too :).
2021-04-18sim: m32c: switch syscalls to common nltvalsMike Frysinger3-0/+37
Rather than hand duplicate the syscall table, switch to the common nltvals framework. We have to tweak the constant names, but we get everything else for free. I made sure the constants have the same values before & after too :).
2021-04-18sim: iq2000: switch syscalls to common nltvalsMike Frysinger3-0/+38
Rather than hand duplicate the syscall table, switch to the common nltvals framework. We have to tweak the constant names, but we get everything else for free. I made sure the constants have the same values before & after too :).
2021-04-18sim: syscall: add getpid supportMike Frysinger2-0/+8
Hoist the Blackfin implementation up to the common one.
2021-04-15sim: Add SIM_EXTRA_CFLAGS after CSEARCH.John Baldwin2-4/+9
The bfin sim adds include paths for the SDL libraries. These include paths might include headers for different version of binutils. Move SIM_EXTRA_CFLAGS after CSEARCH to ensure local includes are always preferred to external includes. sim/common/ChangeLog: * Make-common.in (CONFIG_CFLAGS): Remove SIM_EXTRA_CFLAGS. (ALL_CLAGS, COMMON_DEP_CFLAGS): Add SIM_EXTRA_CFLAGS after CSEARCH.
2021-04-12sim: cgen: move cgen_cpu_max_extra_bytes logic into the common codeMike Frysinger3-7/+21
Every arch handles this the same way, so move it to the common code. This will also make unifying the sim_cpu structure easier.
2021-04-08Do not use old-style definitions in simTom Tromey2-18/+11
This changes all the non-generated (hand-written) code in sim to use "new" (post-K&R) style function definitions. 2021-04-08 Tom Tromey <tom@tromey.com> * bpf.c (bpf_def_model_init): Use new-style declaration. sim/common/ChangeLog 2021-04-08 Tom Tromey <tom@tromey.com> * cgen-utils.c (RORQI, ROLQI, RORHI, ROLHI, RORSI, ROLSI): Use new-style declaration. sim/erc32/ChangeLog 2021-04-08 Tom Tromey <tom@tromey.com> * sis.c (run_sim, main): Use new-style declaration. * interf.c (run_sim, sim_open, sim_close, sim_load) (sim_create_inferior, sim_store_register, sim_fetch_register) (sim_info, sim_stop_reason, flush_windows, sim_do_command): Use new-style declaration. * help.c (usage, gen_help): Use new-style declaration. * func.c (batch, set_regi, set_rega, disp_reg, limcalc) (reset_stat, show_stat, init_bpt, int_handler, init_signals) (disp_fpu, disp_regs, disp_ctrl, disp_mem, dis_mem, event) (init_event, set_int, advance_time, now, wait_for_irq, check_bpt) (reset_all, sys_reset, sys_halt): Use new-style declaration. * float.c (get_accex, clear_accex, set_fsr): Use new-style declaration. * exec.c (sub_cc, add_cc, log_cc, dispatch_instruction, fpexec) (chk_asi, execute_trap, check_interrupts, init_regs): Use new-style declaration. * erc32.c (init_sim, reset, decode_ersr, mecparerror) (error_mode, decode_memcfg, decode_wcr, decode_mcr, sim_halt) (close_port, exit_sim, mec_reset, mec_intack, chk_irq, mec_irq) (set_sfsr, mec_read, mec_write, init_stdio, restore_stdio) (port_init, read_uart, write_uart, flush_uart, uarta_tx) (uartb_tx, uart_rx, uart_intr, uart_irq_start, wdog_intr) (wdog_start, rtc_intr, rtc_start, rtc_counter_read) (rtc_scaler_set, rtc_reload_set, gpt_intr, gpt_start) (gpt_counter_read, gpt_scaler_set, gpt_reload_set, timer_ctrl) (memory_read, memory_write, get_mem_ptr, sis_memory_write) (sis_memory_read): Use new-style declaration. sim/frv/ChangeLog 2021-04-08 Tom Tromey <tom@tromey.com> * sim-if.c (sim_open, frv_sim_close, sim_create_inferior): Use new-style declaration. sim/h8300/ChangeLog 2021-04-08 Tom Tromey <tom@tromey.com> * compile.c (cmdline_location): Use new-style declaration. sim/iq2000/ChangeLog 2021-04-08 Tom Tromey <tom@tromey.com> * sim-if.c (sim_open, sim_create_inferior): Use new-style declaration. * iq2000.c (fetch_str): Use new-style declaration. sim/lm32/ChangeLog 2021-04-08 Tom Tromey <tom@tromey.com> * sim-if.c (sim_open, sim_create_inferior): Use new-style declaration. sim/m32r/ChangeLog 2021-04-08 Tom Tromey <tom@tromey.com> * sim-if.c (sim_open, sim_create_inferior): Use new-style declaration.
2021-04-08sim: set ASAN_OPTIONS=detect_leaks=0 when running igen and opc2cSimon Marchi1-0/+4
The igen/dgen and opc2c tools leak their heap-allocated memory (on purpose) at program exit, which makes AddressSanitizer fail the tool execution. This breaks the build, as it makes the tool return a non-zero exit code. Fix that by disabling leak detection through the setting of that environment variable. I also changed the opc2c rules for m32c to go through a temporary file. What happened is that the failing opc2c would produce an incomplete file (probably because ASan exits the process before stdout is flushed). This meant that further make attempts didn't try to re-create the file, as it already existed. A "clean" was therefore necessary. This can also happen in regular builds if the user interrupts the build (^C) in the middle of the opc2c execution and tries to resume it. Going to a temporary file avoids this issue. sim/m32c/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running opc2c. sim/mips/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running igen. sim/mn10300/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running igen. sim/ppc/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running igen. sim/v850/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running igen. Change-Id: I00f21d4dc1aff0ef73471925d41ce7c23e83e082
2021-04-03sim: add preliminary support for --enable-targetsMike Frysinger2-1/+11
This doesn't actually create one `run` program like other projects, but creates multiple `run-$arch` targets. While it might not seem that useful initially, this has some nice properties: - Allows us to quickly build all sim targets in a single tree. - Positions us better for converting targets over to a proper multitarget build+install. We don't have the ability to actually run tests against them, but that's due to a limitation in gas: it doesn't support multitarget. If that ever changes, we should be able to turn on our tests too. We can improve the test framework to fallback to a system toolchain if available to help mitigate that.
2021-04-02sim: unify toolchain settingsMike Frysinger2-1/+7
The toplevel, common, and igen dirs all have their own code for setting up toolchain settings. Unify all of that in a new macro.
2021-03-13sim: rename BUILD_LDFLAGS to LDFLAGS_FOR_BUILDMike Frysinger2-1/+6
The rest of the binutils tree renamed this variable many years ago.
2021-03-13sim: introduce {COMPILE,LINK}_FOR_BUILDMike Frysinger2-2/+14
These use the same pattern as seen in the opcodes/ dir and in automake in general (ish). This helps simplify the boilerplate for building and linking build-time code, and fixes some inconsistency in flag usage. For rules that were compiling+linking in a single step, split them into separate steps so we can apply the correct set of options. This matches automake behavior too.
2021-03-07sim: testsuite: merge into toplevel automakeMike Frysinger2-1/+4
This allows us to delete most of our custom test logic, and avoids a recursive make for minor speed up.
2021-02-28sim: delete unused SIM_EXTRA_LIBDEPSMike Frysinger2-4/+6
This was last used 15 years ago, so clearly not important enough to keep around. Punt it.
2021-02-27sim: delete redundant SIM_EXTRA_ALLMike Frysinger2-3/+6
We don't need a variable to add a dependency to the "all" target, and having one doesn't really add value. Switch to the target directly for the few ports that actually use this.
2021-02-21sim: common: split up acinclude.m4 into individual m4 filesMike Frysinger2-875/+4
This file is quite large and is getting unmanageable. Split it apart to follow aclocal best practices by putting one-macro-per-file. There shouldn't be any real functional changes here as can be seen in the configure script regens.
2021-02-13sim: switch to AC_CONFIG_MACRO_DIRSMike Frysinger2-14/+4
Rather than hand maintain m4 includes in various autotool files, use AC_CONFIG_MACRO_DIRS to declare the relevant search paths. This simplifies the code, makes it more robust, and cleans out unused logic from configure.
2021-02-13sim: common: delete unused aclocal.m4Mike Frysinger2-15/+4
This was missed when we deleted the common/configure build logic.
2021-02-06sim: watchpoints: use common sim_pc_getMike Frysinger5-10/+87
Few arches implement STATE_WATCHPOINTS()->pc while all of them implement sim_pc_get. Lets switch the sim-watch core for monitoring pc events to the sim_pc_get API so this module works for all ports, and then we can delete this old back channel of snooping in the port's cpu state -- the code needs the pointer to the pc storage so that it can read out bytes and compare them to the watchrange. This also fixes the logic on multi-cpu sims by removing the limitation of only being able to watch CPU0's state.
2021-02-06sim: add ChangeLog entries for last commitsMike Frysinger1-0/+5
2021-02-06sim: common: switch AC_CONFIG_HEADERSMike Frysinger1-2/+1
The AC_CONFIG_HEADER macro is long deprecated, so switch to the newer form. This also gets rid of the position limitation, and drops support for an argument to SIM_AC_COMMON which we haven't used anywhere.
2021-02-06sim: drop use of bfd/configure.hostMike Frysinger3-8/+8
These settings might have made sense in darker compiler times, but I think they're largely obsolete now. Looking through the values that get used in HDEFINES, it's quite limited, and configure itself should handle them. If we still need something, we can leverage standard autoconf macros instead, after we get a clear user report. TDEFINES was never set anywhere and was always empty, so prune that.
2021-02-04sim: riscv: new portMike Frysinger3-0/+56
This is a hand-written implementation that should have fairly complete coverage for the base integer instruction set ("i"), and for the atomic ("a") and integer multiplication+division ("m") extensions. It also covers 32-bit & 64-bit targets. The unittest coverage is a bit weak atm, but should get better.
2021-01-31sim: cgen-trace: tweak printf callMike Frysinger2-1/+5
GCC warns that we pass a non-string literal as the format string, so add an explicit "%s" to make it happy.
2021-01-31sim: cgen-accfp: Fix pointer sign warningsStafford Horne2-3/+9
When compiling we get the following warnings: common/cgen-accfp.c: In function 'fixsfsi': common/cgen-accfp.c:370:18: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign] sim_fpu_to32i (&res, &op1, sim_fpu_round_near); ^ common/cgen-accfp.c: In function 'fixdfsi': common/cgen-accfp.c:381:18: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign] sim_fpu_to32i (&res, &op1, sim_fpu_round_near); ^
2021-01-30sim: common: change gennltvals helper to PythonMike Frysinger4-239/+238
This tool is only run by developers and not in a release build, so rewrite it in Python to make it more maintainable.
2021-01-30sim: watchpoints: change sizeof_pc to sizeof(sim_cia)Mike Frysinger3-4/+9
Existing ports already have sizeof_pc set to the same size as sim_cia, so simply make that part of the core code. We already assume this in places by way of sim_pc_{get,set}, and this is how it's documented in the sim-base.h API. There is code to allow sims to pick different register word sizes from address sizes, but most ports use the defaults for both (32-bits), and the few that support multiple register sizes never change the address size (so address defaults to register). I can't think of any machine where the register hardware size would be larger than the address word size either. We have ABIs that behave that way (e.g. x32), but the hardware is still equivalent register sized.
2021-01-30sim: profile: fix bucketing with 64-bit targetsMike Frysinger2-2/+6
When the target's PC is 64-bits, this shift expands into a range of 8 * 8 - 1 which doesn't work with 32-bit constants. Force it to be a 64-bit value all the time and let the compiler truncate it.
2021-01-30sim: hw: replace fgets with getlineMike Frysinger2-30/+41
This avoids fixed sized buffers on the stack.
2021-01-30sim: common: sort nltvals.defMike Frysinger3-90/+95
This was largely already done, but I think people didn't quite notice.
2021-01-18sim: common: simplify version scriptMike Frysinger3-13/+15
We don't use the host & target aliases, so don't bother emitting them.
2021-01-18sim: common: delete configure & MakefileMike Frysinger4-3887/+4
This was mostly orphaned a while back, but left behind so people could still run `make headers`. Merge that one target to the top sim dir and delete all the build logic. This should avoid confusing people further.
2021-01-18sim: common: modernize gennltvals.shMike Frysinger4-167/+237
It's not 1996 anymore, so stop writing shell code like it is, and rewrite it with modern POSIX shell standards. This makes it much more user friendly. Then regenerate the file with latest newlib sources to verify.
2021-01-13sim: watch: add basic default handler that trapsMike Frysinger2-1/+18
The default watchpoint handler is NULL. That means any port that sets the STATE_WATCHPOINTS->pc field will crash if you try to use the --watch options but don't configure the interrupt handler. In the past, you had to setup STATE_WATCHPOINTS->pc if you wanted to support PC profiling, and while that was fixed a while ago, we have a lot of ports who still configure it. We already add a default set of interrupts (just "int") if the port doesn't define any. Let's also add a default handler that raises a SIGTRAP. When connected to gdb, this is a breakpoint which is what people would expect. When running standalone, it'll abort the sim, but it's unclear whether there's anything better to do there. This really is just to make the watchpoint module more usable out of the box for most ports with very little setup, at least inside of gdb.
2021-01-13sim: watch: fix range expression processingMike Frysinger2-1/+5
The code supports a <start>[,<end>] syntax, but the logic for handling the <end> check was broken: it would detect the first byte was ",", but then include that in the strtoul call meaning the result is always 0. Further, it (re)assigned to arg0 when it meant arg1 which means this code always processed a range expression as 0,0. Oops.
2021-01-13sim: watch: fix pc watchpoints on little endian host systemsMike Frysinger4-5/+14
My change 1ac72f0659d64d6a14da862242db0d841d2878d0 ("sim: convert to bfd_endian") subtly broke the watchpoint module on little endian host systems. The old code used 0 to mean "whatever the host endian is", and while that was changed to use BFD_ENDIAN_UNKNOWN, this caller was missed. Since its API used an int instead of an enum, the coercion from 0 to the BFD endian enum was silently missed, and 0 happens to be BFD_ENDIAN_BIG. Instead of restoring the old logic by passing in BFD_ENDIAN_UNKNOWN, we know the right host endian at compile time, so use that directly.
2021-01-12sim: common: use #error properlyMike Frysinger2-1/+5
2021-01-11sim: always call SIM_AC_OPTION_WARNINGSMike Frysinger2-1/+7
Now that all ports have opted in to this, we can require it in the core. It guarantees that new ports have them turned on, and defaults to -Werror in the hopes that new ports keep their code clean from the start. We do this as a sep commit to make it clear that there are no changes to existing ports as they've all explicitly called it already.
2021-01-11sim: common: fix printf formatsMike Frysinger2-1/+6
For 32-bit targets, %x happens to work for unsigned_word. But for 64-bit targets, it's too small, and gcc throws an error. Use the right printf format define for them.
2021-01-11sim: clean up C11 header includesMike Frysinger28-187/+16
Since we require C11 now, we can assume many headers exist, and clean up all of the conditional includes. It's not like any of this code actually accounted for the headers not existing, just whether we could include them. The strings.h cleanup is a little nuanced: it isn't in C11, but every use of it in the codebase will include strings.h only if string.h doesn't exist. Since we now assume the C11 string.h exists, we'll never include strings.h, so we can delete it.
2021-01-09sim: common: clean up asprintf includes a bitMike Frysinger4-5/+7
Delete stale prototypes that libiberty.h already provides, and add missing libiberty.h includes to files that use those functions.
2021-01-09sim: clean up stale AC_PREREQ refsMike Frysinger2-12/+5
This was purged from the tree when we upgraded to autoconf-2.69, but a few references in the sim tree were missed.
2021-01-09sim: enable -Werror by default for some archesMike Frysinger2-5/+11
We've had this off for a long time because the sim code was way too full of warnings for it to be feasible. However, I've cleaned things up significantly from when this was first merged, and we can start to turn this around. Change the macro to enable -Werror by default, and allow ports to opt out. New ports will get it automatically (and we can push back on them if they try to turn it off). Also turn it off for the few ports that still hit warnings for me. All the rest will get the new default, and we'll wait for feedback if/when new issues come up.
2021-01-09sim: hw: rework code to avoid gcc warningsMike Frysinger2-7/+8
Newer gcc thinks we might return a pointer to a stack buffer, but we don't -- we strdup it before returning. Rework the code to just malloc the buffer from the start and avoid the stack+strdup.
2021-01-09sim: common: add missing stdlib.h for abort()Mike Frysinger5-0/+9
2021-01-08sim: require a C11 compilerMike Frysinger3-1/+34
With GDB requiring a C++11 compiler now, this hopefully shouldn't be a big deal. It's been 10 years since C11 came out, so should be plenty of time to upgrade. This will allow us to start cleaning up random header logic and many of our non-standard custom types.
2021-01-07gdb/sim: add support for exporting memory mapMike Frysinger2-0/+61
This allows gdb to quickly dump & process the memory map that the sim knows about. This isn't fully accurate, but is largely limited by the gdb memory map format. While the sim supports RWX bits, gdb can only handle RW or RO regions.
2021-01-04sim: update bug URI to https://Mike Frysinger2-1/+6