diff options
author | Pedro Alves <pedro@palves.net> | 2022-10-17 17:12:20 +0100 |
---|---|---|
committer | Pedro Alves <pedro@palves.net> | 2022-10-19 15:32:36 +0100 |
commit | f34652de0b68c4ee3050828b43a2839b852b5821 (patch) | |
tree | 851720f14f2ac022c3e82428254edf161d619e91 /gdb/osabi.c | |
parent | 5c831a3c7f3ca98d6aba1200353311e1a1f84c70 (diff) | |
download | binutils-f34652de0b68c4ee3050828b43a2839b852b5821.zip binutils-f34652de0b68c4ee3050828b43a2839b852b5821.tar.gz binutils-f34652de0b68c4ee3050828b43a2839b852b5821.tar.bz2 |
internal_error: remove need to pass __FILE__/__LINE__
Currently, every internal_error call must be passed __FILE__/__LINE__
explicitly, like:
internal_error (__FILE__, __LINE__, "foo %d", var);
The need to pass in explicit __FILE__/__LINE__ is there probably
because the function predates widespread and portable variadic macros
availability. We can use variadic macros nowadays, and in fact, we
already use them in several places, including the related
gdb_assert_not_reached.
So this patch renames the internal_error function to something else,
and then reimplements internal_error as a variadic macro that expands
__FILE__/__LINE__ itself.
The result is that we now should call internal_error like so:
internal_error ("foo %d", var);
Likewise for internal_warning.
The patch adjusts all calls sites. 99% of the adjustments were done
with a perl/sed script.
The non-mechanical changes are in gdbsupport/errors.h,
gdbsupport/gdb_assert.h, and gdb/gdbarch.py.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ia6f372c11550ca876829e8fd85048f4502bdcf06
Diffstat (limited to 'gdb/osabi.c')
-rw-r--r-- | gdb/osabi.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/gdb/osabi.c b/gdb/osabi.c index f1b7f22..57e2df6 100644 --- a/gdb/osabi.c +++ b/gdb/osabi.c @@ -156,8 +156,7 @@ gdbarch_register_osabi (enum bfd_architecture arch, unsigned long machine, if (osabi == GDB_OSABI_UNKNOWN) { internal_error - (__FILE__, __LINE__, - _("gdbarch_register_osabi: An attempt to register a handler for " + (_("gdbarch_register_osabi: An attempt to register a handler for " "OS ABI \"%s\" for architecture %s was made. The handler will " "not be registered"), gdbarch_osabi_name (osabi), @@ -174,8 +173,7 @@ gdbarch_register_osabi (enum bfd_architecture arch, unsigned long machine, && (*handler_p)->osabi == osabi) { internal_error - (__FILE__, __LINE__, - _("gdbarch_register_osabi: A handler for OS ABI \"%s\" " + (_("gdbarch_register_osabi: A handler for OS ABI \"%s\" " "has already been registered for architecture %s"), gdbarch_osabi_name (osabi), arch_info->printable_name); @@ -266,8 +264,7 @@ gdbarch_lookup_osabi (bfd *abfd) if (osabi < GDB_OSABI_UNKNOWN || osabi >= GDB_OSABI_INVALID) { internal_error - (__FILE__, __LINE__, - _("gdbarch_lookup_osabi: invalid OS ABI (%d) from sniffer " + (_("gdbarch_lookup_osabi: invalid OS ABI (%d) from sniffer " "for architecture %s flavour %d"), (int) osabi, bfd_printable_arch_mach (bfd_get_arch (abfd), 0), @@ -285,8 +282,7 @@ gdbarch_lookup_osabi (bfd *abfd) || (!match_specific && sniffer->arch == bfd_arch_unknown)) { internal_error - (__FILE__, __LINE__, - _("gdbarch_lookup_osabi: multiple %sspecific OS ABI " + (_("gdbarch_lookup_osabi: multiple %sspecific OS ABI " "match for architecture %s flavour %d: first " "match \"%s\", second match \"%s\""), match_specific ? "" : "non-", @@ -644,8 +640,7 @@ set_osabi (const char *args, int from_tty, struct cmd_list_element *c) } } if (i == GDB_OSABI_INVALID) - internal_error (__FILE__, __LINE__, - _("Invalid OS ABI \"%s\" passed to command handler."), + internal_error (_("Invalid OS ABI \"%s\" passed to command handler."), set_osabi_string); } @@ -653,7 +648,7 @@ set_osabi (const char *args, int from_tty, struct cmd_list_element *c) graceful here. */ gdbarch_info info; if (! gdbarch_update_p (info)) - internal_error (__FILE__, __LINE__, _("Updating OS ABI failed.")); + internal_error (_("Updating OS ABI failed.")); } static void @@ -680,8 +675,7 @@ _initialize_gdb_osabi () { if (strcmp (gdb_osabi_names[GDB_OSABI_INVALID].pretty, "<invalid>") != 0) internal_error - (__FILE__, __LINE__, - _("_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent")); + (_("_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent")); /* Register a generic sniffer for ELF flavoured files. */ gdbarch_register_osabi_sniffer (bfd_arch_unknown, |