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/compile | |
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/compile')
-rw-r--r-- | gdb/compile/compile-c-support.c | 2 | ||||
-rw-r--r-- | gdb/compile/compile-c-symbols.c | 2 | ||||
-rw-r--r-- | gdb/compile/compile-cplus-symbols.c | 2 | ||||
-rw-r--r-- | gdb/compile/compile-cplus-types.c | 3 | ||||
-rw-r--r-- | gdb/compile/compile-object-load.c | 2 |
5 files changed, 5 insertions, 6 deletions
diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c index 19fcf00..c652c96 100644 --- a/gdb/compile/compile-c-support.c +++ b/gdb/compile/compile-c-support.c @@ -53,7 +53,7 @@ c_get_mode_for_size (int size) mode = "DI"; break; default: - internal_error (__FILE__, __LINE__, _("Invalid GCC mode size %d."), size); + internal_error (_("Invalid GCC mode size %d."), size); } return mode; diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 3a5d70b..ad6daba 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -115,7 +115,7 @@ convert_one_symbol (compile_c_instance *context, sym.symbol->print_name ()); case LOC_UNDEF: - internal_error (__FILE__, __LINE__, _("LOC_UNDEF found for \"%s\"."), + internal_error (_("LOC_UNDEF found for \"%s\"."), sym.symbol->print_name ()); case LOC_COMMON_BLOCK: diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index 4d3f160..b8e8e07 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -109,7 +109,7 @@ convert_one_symbol (compile_cplus_instance *instance, sym.symbol->print_name ()); case LOC_UNDEF: - internal_error (__FILE__, __LINE__, _("LOC_UNDEF found for \"%s\"."), + internal_error (_("LOC_UNDEF found for \"%s\"."), sym.symbol->print_name ()); case LOC_COMMON_BLOCK: diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index 245345d..bd90753 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -178,8 +178,7 @@ type_name_to_scope (const char *type_name, const struct block *block) /* This shouldn't happen since we are not attempting to loop over user input. This name is generated by GDB from debug info. */ - internal_error (__FILE__, __LINE__, - _("malformed TYPE_NAME during parsing")); + internal_error (_("malformed TYPE_NAME during parsing")); } } } diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index f3573cb..4c94ec5 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -678,7 +678,7 @@ compile_object_load (const compile_file_names &file_names, expect_return_type = builtin_type (target_gdbarch ())->builtin_void; break; default: - internal_error (__FILE__, __LINE__, _("invalid scope %d"), scope); + internal_error (_("invalid scope %d"), scope); } if (func_type->num_fields () != expect_parameters) error (_("Invalid %d parameters of function \"%s\" in compiled " |