From f34652de0b68c4ee3050828b43a2839b852b5821 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 17 Oct 2022 17:12:20 +0100 Subject: 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 Change-Id: Ia6f372c11550ca876829e8fd85048f4502bdcf06 --- gdb/language.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'gdb/language.c') diff --git a/gdb/language.c b/gdb/language.c index 076e429..3962ee8 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -189,8 +189,7 @@ set_language_command (const char *ignore, } } - internal_error (__FILE__, __LINE__, - "Couldn't find language `%s' in known languages list.", + internal_error ("Couldn't find language `%s' in known languages list.", language); } @@ -216,8 +215,7 @@ show_range_command (struct ui_file *file, int from_tty, tmp = "warn"; break; default: - internal_error (__FILE__, __LINE__, - "Unrecognized range check setting."); + internal_error ("Unrecognized range check setting."); } gdb_printf (file, @@ -263,8 +261,7 @@ set_range_command (const char *ignore, } else { - internal_error (__FILE__, __LINE__, - _("Unrecognized range check setting: \"%s\""), range); + internal_error (_("Unrecognized range check setting: \"%s\""), range); } if (range_check == range_check_warn || ((range_check == range_check_on) @@ -292,8 +289,7 @@ show_case_command (struct ui_file *file, int from_tty, tmp = "off"; break; default: - internal_error (__FILE__, __LINE__, - "Unrecognized case-sensitive setting."); + internal_error ("Unrecognized case-sensitive setting."); } gdb_printf (file, @@ -334,8 +330,7 @@ set_case_command (const char *ignore, int from_tty, struct cmd_list_element *c) } else { - internal_error (__FILE__, __LINE__, - "Unrecognized case-sensitive setting: \"%s\"", + internal_error ("Unrecognized case-sensitive setting: \"%s\"", case_sensitive); } @@ -418,7 +413,7 @@ range_error (const char *string,...) gdb_printf (gdb_stderr, "\n"); break; default: - internal_error (__FILE__, __LINE__, _("bad switch")); + internal_error (_("bad switch")); } va_end (args); } -- cgit v1.1