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/target-descriptions.c | |
parent | 5c831a3c7f3ca98d6aba1200353311e1a1f84c70 (diff) | |
download | gdb-f34652de0b68c4ee3050828b43a2839b852b5821.zip gdb-f34652de0b68c4ee3050828b43a2839b852b5821.tar.gz gdb-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/target-descriptions.c')
-rw-r--r-- | gdb/target-descriptions.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 13cc9e4..44dea71 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -148,8 +148,7 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) return; } - internal_error (__FILE__, __LINE__, - "Type \"%s\" has an unknown kind %d", + internal_error ("Type \"%s\" has an unknown kind %d", e->name.c_str (), e->kind); } @@ -187,8 +186,7 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) return; } - internal_error (__FILE__, __LINE__, - "Type \"%s\" has an unknown kind %d", + internal_error ("Type \"%s\" has an unknown kind %d", e->name.c_str (), e->kind); } @@ -601,8 +599,7 @@ target_clear_description (void) gdbarch_info info; if (!gdbarch_update_p (info)) - internal_error (__FILE__, __LINE__, - _("Could not remove target-supplied description")); + internal_error (_("Could not remove target-supplied description")); } /* Return the global current target description. This should only be @@ -982,8 +979,7 @@ tdesc_register_type (struct gdbarch *gdbarch, int regno) } if (arch_reg->type == NULL) - internal_error (__FILE__, __LINE__, - "Register \"%s\" has an unknown type \"%s\"", + internal_error ("Register \"%s\" has an unknown type \"%s\"", reg->name.c_str (), reg->type.c_str ()); } @@ -1227,8 +1223,7 @@ tdesc_add_compatible (struct target_desc *target_desc, for (const tdesc_compatible_info_up &compat : target_desc->compatible) if (compat->arch () == compatible) - internal_error (__FILE__, __LINE__, - _("Attempted to add duplicate " + internal_error (_("Attempted to add duplicate " "compatible architecture \"%s\""), compatible->printable_name); @@ -1244,8 +1239,7 @@ set_tdesc_property (struct target_desc *target_desc, gdb_assert (key != NULL && value != NULL); if (tdesc_property (target_desc, key) != NULL) - internal_error (__FILE__, __LINE__, - _("Attempted to add duplicate property \"%s\""), key); + internal_error (_("Attempted to add duplicate property \"%s\""), key); target_desc->properties.emplace_back (key, value); } |