aboutsummaryrefslogtreecommitdiff
path: root/sim/common/sim-options.c
AgeCommit message (Collapse)AuthorFilesLines
2023-01-01sim: refresh copyright dates a bitMike Frysinger1-1/+1
Update a few files that were missed, and revert the generated Automake output that uses dates from Automake itself.
2023-01-01Update copyright year range in header of all files managed by GDBJoel Brobecker1-1/+1
This commit is the result of running the gdb/copyright.py script, which automated the update of the copyright year range for all source files managed by the GDB project to be updated to include year 2023.
2022-11-03sim: update --version copyright yearMike Frysinger1-1/+1
Probably should have done this 11 months ago ...
2022-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker1-1/+1
This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
2021-12-04sim: reorder header includesMike Frysinger1-7/+8
We're including system headers after local headers in a bunch of places, but this leads to conflicts when our local headers happen to define symbols that show up in the system headers. Use the more standard order of: * config.h (via defs.h) * system headers * local library headers (e.g. bfd & libiberty) * sim specific headers
2021-11-16sim: run: support concise env var settingsMike Frysinger1-1/+21
Support the same syntax as other common utilities where env vars can be specified before the program to be run without an explicit option. This behavior can be suppressed by using the -- marker.
2021-11-16sim: nrun: add --env-{set,unset,clear} command line optionsMike Frysinger1-0/+99
Provide explicit control over the program's environment with the basic set/unset/clear options. These are a bit clunky to use, but they're functional. The env set operation is split out into a separate function as it'll be used in the next commit. With these in place, we can adjust the custom cris testsuite to use the now standard options and not its one-off hack.
2021-11-15sim: run: fix crash in argc==0 error situationMike Frysinger1-7/+17
The new argv processing code assumed that we were always passed a command line. If we weren't, make sure we don't crash before we get a chance to output an error message about incorrect usage.
2021-11-15sim: run: add --argv0 option to control argv[0]Mike Frysinger1-3/+21
We default argv[0] to the program we run which is a standard *NIX convention, but sometimes we want to be able to control the argv[0] setting independently (especially for programs that inspect argv[0] to change their behavior or output). Add an option to control it.
2021-11-15sim: split program path out of argv vectorMike Frysinger1-1/+4
We use the program argv to both find the program to run (argv[0]) and to hold the arguments to the program. Most of the time this is fine, but if we want to let programs specify argv[0] independently (which is possible in standard *NIX programs), this double duty doesn't work. So let's split the path to the program to run out into a separate field by itself. This simplifies the various sim_open funcs too. By itself, this code is more of a logical cleanup than something that is super useful. But it will open up customization of argv[0] in a follow up commit. Split the changes to make it easier to review.
2021-10-04sim: add --info-target for listing supported BFD targetsMike Frysinger1-0/+19
It can be difficult to guess the exact bfd name, so add an option to list all the targets that the current build supports. This aligns with other simulator options like --info-architecture.
2021-09-11sim: run: change help short option to -hMike Frysinger1-1/+1
It's unclear why -H was picked over the more standard -h, but since -h is still not used, just change -H to -h to match pretty much every other tool in the sourceware tree.
2021-09-09sim: accept -EB/-EL short optionsMike Frysinger1-3/+3
Many GNU tools accept -EB/-EL as short options for selecting big & little endian modes. While the sim has an -E option, it requires spelling out "big" and "little". Adding support for -EB & -EL is thus quite trivial, so lets round it out to be less annoying.
2021-05-16sim: switch config.h usage to defs.hMike Frysinger1-1/+3
The defs.h header will take care of including the various config.h headers. For now, it's just config.h, but we'll add more when we integrate gnulib in. This header should be used instead of config.h, and should be the first include in every .c file. We won't rely on the old behavior where we expected files to include the port's sim-main.h which then includes the common sim-basics.h which then includes config.h. We have a ton of code that includes things before sim-main.h, and it sometimes needs to be that way. Creating a dedicated header avoids the ordering mess and implicit inclusion that shows up otherwise.
2021-05-08sim: use htab_eq_stringTom Tromey1-9/+1
This changes the sim to use htab_eq_string from libiberty. sim/common/ChangeLog 2021-05-08 Tom Tromey <tom@tromey.com> * sim-options.c (compare_strings): Remove. (dup_arg_p): Use htab_eq_string.
2021-05-02sim: add default cases to two switches in sim-options.cSimon Marchi1-0/+2
This is the next compilation error I hit when I build all targets with Clang: /home/simark/src/binutils-gdb/sim/aarch64/../common/sim-options.c:234:12: error: no case matching constant switch condition '0' [-Werror] switch (WITH_ENVIRONMENT) ^~~~~~~~~~~~~~~~ ./config.h:215:26: note: expanded from macro 'WITH_ENVIRONMENT' #define WITH_ENVIRONMENT ALL_ENVIRONMENT ^~~~~~~~~~~~~~~ /home/simark/src/binutils-gdb/sim/aarch64/../common/sim-options.c:276:15: error: no case matching constant switch condition '0' [-Werror] switch (WITH_ALIGNMENT) ^~~~~~~~~~~~~~ /home/simark/src/binutils-gdb/sim/aarch64/../common/sim-config.h:220:24: note: expanded from macro 'WITH_ALIGNMENT' #define WITH_ALIGNMENT 0 ^ This is a little bit special because these are switches on compile-time value. But regardless, the idea is that we logically can't reach the switches if WITH_ENVIRONMENT == 0 or WITH_ALIGNMENT == 0, so the code is correct. In addition to getting rid of the compiler warning, adding default cases to these switches ensure that if we do get in an unexpected situation, it is caught. In GDB, I'd use gdb_assert_not_reached, I don't know if there is something similar in sim so I went with abort. sim/common/ChangeLog: * sim-options.c (standard_option_handler): Add default cases to switches. Change-Id: Ie237d67a201caa6b72de0d17cc815193417156b6
2021-05-01sim: options: fix --help outputMike Frysinger1-0/+1
The hash table rewrite broke --help output due to subtle behavior: calling dup_arg_p(NULL) will create & clear the table, not just create it. The --help output relies on this to clear the table before it shows things.
2021-04-25Use htab_t in sim-options.cTom Tromey1-21/+18
This changes sim-options.c to use the libiberty hash table, rather than its own custom hash table. sim/common/ChangeLog 2021-04-25 Tom Tromey <tom@tromey.com> * sim-options.c (compare_strings): New function. (ARG_HASH_SIZE, ARG_HASH): Remove. (dup_arg_p): Use htab_t. (sim_parse_args): Remove assert.
2021-04-24sim: options: increase max option countMike Frysinger1-1/+4
As we turn on more modules by default for all ports, the number of options has been increasing. The sim-options module has a limit on the number of options it can support, and if it's exceeded, it likes to go into an infinite loop. Increase the ceiling and add an assert so we abort right away instead of hanging. This will be needed to turn on hw support for v850 as it will then exceed the current limit.
2021-01-11sim: clean up C11 header includesMike Frysinger1-8/+0
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-04sim: common: version: add build & homepage info when interactiveMike Frysinger1-0/+15
This mirrors gdb behavior of dumping extra info when being run in interactive mode. It also gives us an excuse to use the otherwise unused sim_print_config.
2021-01-04sim: common: add a version output helper w/copyright+license infoMike Frysinger1-1/+21
This mirrors the existing sim_print_help function, and the behavior of all other GNU tools with their --version.
2021-01-01Update copyright year range in all GDB filesJoel Brobecker1-1/+1
This commits the result of running gdb/copyright.py as per our Start of New Year procedure... gdb/ChangeLog Update copyright year range in copyright header of all GDB files.
2020-01-01Update copyright year range in all GDB files.Joel Brobecker1-1/+1
gdb/ChangeLog: Update copyright year range in all GDB files.
2019-03-28sim/common: Fix warnings: "warning: implicit declaration of function..."Stafford Horne1-0/+2
During building of several cgen simulator's I notices the below warnings. Adding includes fixes these. Including config.h allows stdio.h to properly configure itself to expose asprintf(). The other warnings for abort, free, memset, strlen are trivial. Warnings: ../../../binutils-gdb/sim/or1k/../common/sim-watch.c: In function ‘sim_watchpoint_install’: ../../../binutils-gdb/sim/or1k/../common/sim-watch.c:415:10: warning: implicit declaration of function ‘asprintf’; did you mean ‘vasprintf’? [-Wimplicit-function-declaration] if (asprintf (&name, "watch-%s-%s", ^~~~~~~~ vasprintf ../../../binutils-gdb/sim/lm32/../common/hw-device.c: In function ‘hw_strdup’: ../../../binutils-gdb/sim/lm32/../common/hw-device.c:59:34: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration] char *dup = hw_zalloc (me, strlen (str) + 1); ^~~~~~ ../../../binutils-gdb/sim/lm32/../common/hw-events.c: In function ‘hw_event_queue_schedule’: ../../../binutils-gdb/sim/lm32/../common/hw-events.c:92:3: warning: implicit declaration of function ‘memset’ [-Wimplicit-function-declaration] memset (&dummy, 0, sizeof dummy); ^~~~~~ ../../../binutils-gdb/sim/lm32/../common/hw-handles.c: In function ‘hw_handle_remove_ihandle’: ../../../binutils-gdb/sim/lm32/../common/hw-handles.c:211:4: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration] free (delete); ^~~~ ../../../binutils-gdb/sim/lm32/../common/sim-fpu.c: In function ‘pack_fpu’: ../../../binutils-gdb/sim/lm32/../common/sim-fpu.c:292:7: warning: implicit declaration of function ‘abort’ [-Wimplicit-function-declaration] abort (); ^~~~~ sim/common/ChangeLog: * sim-options.c: Include "config.h". Include <stdio.h>. * sim-watch.c: Include "config.h". Include <stdio.h>. * hw-device.c: Include <string.h>. * hw-events.c: Include <string.h>. * hw-handles.c: Include <stdlib.h>. * sim-fpu.c: Include <stdlib.h>.
2019-01-01Update copyright year range in all GDB files.Joel Brobecker1-1/+1
This commit applies all changes made after running the gdb/copyright.py script. Note that one file was flagged by the script, due to an invalid copyright header (gdb/unittests/basic_string_view/element_access/char/empty.cc). As the file was copied from GCC's libstdc++-v3 testsuite, this commit leaves this file untouched for the time being; a patch to fix the header was sent to gcc-patches first. gdb/ChangeLog: Update copyright year range in all GDB files.
2018-01-02Update copyright year range in all GDB filesJoel Brobecker1-1/+1
gdb/ChangeLog: Update copyright year range in all GDB files
2017-01-01update copyright year range in GDB filesJoel Brobecker1-1/+1
This applies the second part of GDB's End of Year Procedure, which updates the copyright year range in all of GDB's files. gdb/ChangeLog: Update copyright year range in all GDB files.
2016-01-10sim: move many common settings from CPPFLAGS to config.hMike Frysinger1-2/+0
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-06sim: sim_{create_inferior,open,parse_args}: constify argv/env slightlyMike Frysinger1-1/+1
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-04sim: parse_args: polish getopt error messageMike Frysinger1-1/+1
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-03sim: parse_args: display getopt error ourselvesMike Frysinger1-1/+27
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-03sim: use libiberty countargv in more placesMike Frysinger1-2/+1
A bunch of places open code the countargv implementation, or outright duplicate it (as count_argc). Replace all of those w/countargv.
2016-01-03sim: convert to bfd_endianMike Frysinger1-4/+4
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-01GDB copyright headers update after running GDB's copyright.py script.Joel Brobecker1-1/+1
gdb/ChangeLog: Update year range in copyright notice of all files.
2015-12-24sim: make LMA loading the default for all targetsMike Frysinger1-9/+1
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-24sim: h8300: move h8300-specific options out of common codeMike Frysinger1-29/+0
Register the options in sim_open like other arches to avoid having to hack up the common modules.
2015-12-24sim: delete SIM_HAVE_FLATMEM supportMike Frysinger1-38/+0
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-04-13sim: options: add --version supportMike Frysinger1-0/+11
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-02-03sim: Call freeargv() when failure occursChen Gang1-1/+4
After successfully call buildargv(), the code need to be sure of calling freeargv() in any cases. 2015-02-02 Chen Gang <gang.chen.5i5j@gmail.com> * common/sim-options.c (sim_args_command): Call freeargv() when failure occurs.
2015-01-01Update year range in copyright notice of all files owned by the GDB project.Joel Brobecker1-1/+1
gdb/ChangeLog: Update year range in copyright notice of all files.
2014-03-10sim: constify arg to sim_do_commandMike Frysinger1-1/+1
It is rare for people to want to modify the cmd arg. In general, they really shouldn't be, but a few still do. For those who misbehave, dupe the string locally so they can bang on it.
2014-01-01Update Copyright year range in all files maintained by GDB.Joel Brobecker1-1/+1
2013-09-03sim: mark complete_option_list args const to fix build warningsMike Frysinger1-1/+1
The completion API was updated, but this func missed having its text/word args const.
2013-03-15gdb:Steve Ellcey1-1/+1
2013-03-15 Steve Ellcey <sellcey@mips.com> * remote-sim.c (sim_command_completer): Make char arguments const. include: 2013-03-15 Steve Ellcey <sellcey@mips.com> * gdb/remote-sim.h (sim_command_completer): Make char arguments const. sim: 2013-03-15 Steve Ellcey <sellcey@mips.com> * arm/wrapper.c (sim_complete_command): Make char arguments const. * avr/interp.c (sim_complete_command): Ditto. * common/sim-options.c (sim_complete_command): Ditto. * cr16/interp.c (sim_complete_command): Ditto. * erc32/interf.c (sim_complete_command): Ditto. * m32c/gdb-if.c (sim_complete_command): Ditto. * microblaze/interp.c (sim_complete_command): Ditto. * ppc/sim_calls.c (sim_complete_command): Ditto. * rl78/gdb-if.c (sim_complete_command): Ditto. * rx/gdb-if.c (sim_complete_command): Ditto. * sh/interp.c (sim_complete_command): Ditto.
2013-01-01Update years in copyright notice for the GDB files.Joel Brobecker1-2/+1
Two modifications: 1. The addition of 2013 to the copyright year range for every file; 2. The use of a single year range, instead of potentially multiple year ranges, as approved by the FSF.
2012-01-04Copyright year update in most files of the GDB Project.Joel Brobecker1-2/+2
gdb/ChangeLog: Copyright year update in most files of the GDB Project.
2011-05-27sim: fix minor --sysroot mem leakMike Frysinger1-3/+7
The current --sysroot parsing attempts to keep from leaking memory by treating the empty string specially (sine this is the initial value), but it ends up leaking memory when the arg is an empty string. So if someone uses --sysroot "", the old value is leaked, as is the new one. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-05-11sim: fix func call style (space before paren)Mike Frysinger1-1/+1
Committed this as obvious: -foo(...); +foo (...); Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-04-15gdb: sim: add style fixes lost between git->cvsMike Frysinger1-0/+1