diff options
author | Tom de Vries <tdevries@suse.de> | 2022-06-01 19:29:40 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2022-06-01 19:29:40 +0200 |
commit | fc18b1c5afd77960b221d81f382de5c9cf5e75d9 (patch) | |
tree | b6a939c3f2d3b47bc5f92f5971b6b49468fd9f5f /gdb/osabi.c | |
parent | 80fa4b2a606763e71c4b599fa88288f554a0ea5b (diff) | |
download | binutils-fc18b1c5afd77960b221d81f382de5c9cf5e75d9.zip binutils-fc18b1c5afd77960b221d81f382de5c9cf5e75d9.tar.gz binutils-fc18b1c5afd77960b221d81f382de5c9cf5e75d9.tar.bz2 |
[gdb] Fix warning in foreach_arch selftests
When running the selftests, I run into:
...
$ gdb -q -batch -ex "maint selftest"
...
Running selftest execute_cfa_program::aarch64:ilp32.
warning: A handler for the OS ABI "GNU/Linux" is not built into this
configuration of GDB. Attempting to continue with the default aarch64:ilp32
settings.
...
and likewise for execute_cfa_program::i8086 and
execute_cfa_program::ia64-elf32.
The warning can easily be reproduced outside the selftests by doing:
...
$ gdb -q -batch -ex "set arch aarch64:ilp32"
...
and can be prevented by first doing "set osabi none".
Fix the warning by setting osabi to none while doing selftests that iterate
over all architectures.
Tested on x86_64-linux.
Diffstat (limited to 'gdb/osabi.c')
-rw-r--r-- | gdb/osabi.c | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/gdb/osabi.c b/gdb/osabi.c index bbd7635..776e620 100644 --- a/gdb/osabi.c +++ b/gdb/osabi.c @@ -32,7 +32,7 @@ #endif /* State for the "set osabi" command. */ -static enum { osabi_auto, osabi_default, osabi_user } user_osabi_state; +static enum gdb_osabi_mode user_osabi_state; static enum gdb_osabi user_selected_osabi; static const char *gdb_osabi_available_names[GDB_OSABI_INVALID + 3] = { "auto", @@ -595,15 +595,48 @@ generic_elf_osabi_sniffer (bfd *abfd) return osabi; } +/* See osabi.h. */ + +void +set_osabi (enum gdb_osabi_mode mode, enum gdb_osabi osabi) +{ + if (mode == osabi_auto) + user_osabi_state = osabi_auto; + else if (mode == osabi_default) + { + user_selected_osabi = GDB_OSABI_DEFAULT; + user_osabi_state = osabi_user; + } + else + { + user_selected_osabi = osabi; + user_osabi_state = osabi_user; + } + + /* NOTE: At some point (true multiple architectures) we'll need to be more + graceful here. */ + gdbarch_info info; + if (! gdbarch_update_p (info)) + internal_error (__FILE__, __LINE__, _("Updating OS ABI failed.")); +} + +/* See osabi.h. */ + +void +get_osabi (enum gdb_osabi_mode &mode, enum gdb_osabi &osabi) +{ + mode = user_osabi_state; + osabi = user_selected_osabi; +} + static void set_osabi (const char *args, int from_tty, struct cmd_list_element *c) { if (strcmp (set_osabi_string, "auto") == 0) - user_osabi_state = osabi_auto; + set_osabi (osabi_auto, GDB_OSABI_INVALID); else if (strcmp (set_osabi_string, "default") == 0) { - user_selected_osabi = GDB_OSABI_DEFAULT; - user_osabi_state = osabi_user; + set_osabi (osabi_default, GDB_OSABI_INVALID); } else { @@ -615,8 +648,7 @@ set_osabi (const char *args, int from_tty, struct cmd_list_element *c) if (strcmp (set_osabi_string, gdbarch_osabi_name (osabi)) == 0) { - user_selected_osabi = osabi; - user_osabi_state = osabi_user; + set_osabi (osabi_user, osabi); break; } } @@ -625,12 +657,6 @@ set_osabi (const char *args, int from_tty, struct cmd_list_element *c) _("Invalid OS ABI \"%s\" passed to command handler."), set_osabi_string); } - - /* NOTE: At some point (true multiple architectures) we'll need to be more - graceful here. */ - gdbarch_info info; - if (! gdbarch_update_p (info)) - internal_error (__FILE__, __LINE__, _("Updating OS ABI failed.")); } static void |