aboutsummaryrefslogtreecommitdiff
path: root/gdb/ui-out.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2022-10-17 17:12:20 +0100
committerPedro Alves <pedro@palves.net>2022-10-19 15:32:36 +0100
commitf34652de0b68c4ee3050828b43a2839b852b5821 (patch)
tree851720f14f2ac022c3e82428254edf161d619e91 /gdb/ui-out.c
parent5c831a3c7f3ca98d6aba1200353311e1a1f84c70 (diff)
downloadbinutils-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/ui-out.c')
-rw-r--r--gdb/ui-out.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index e34e40f..0da2b3a 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -212,16 +212,14 @@ class ui_out_table
void ui_out_table::start_body ()
{
if (m_state != state::HEADERS)
- internal_error (__FILE__, __LINE__,
- _("extra table_body call not allowed; there must be only "
+ internal_error (_("extra table_body call not allowed; there must be only "
"one table_body after a table_begin and before a "
"table_end."));
/* Check if the number of defined headers matches the number of expected
columns. */
if (m_headers.size () != m_nr_cols)
- internal_error (__FILE__, __LINE__,
- _("number of headers differ from number of table "
+ internal_error (_("number of headers differ from number of table "
"columns."));
m_state = state::BODY;
@@ -235,8 +233,7 @@ void ui_out_table::append_header (int width, ui_align alignment,
const std::string &col_hdr)
{
if (m_state != state::HEADERS)
- internal_error (__FILE__, __LINE__,
- _("table header must be specified after table_begin and "
+ internal_error (_("table header must be specified after table_begin and "
"before table_body."));
std::unique_ptr<ui_out_hdr> header (new ui_out_hdr (m_headers.size () + 1,
@@ -354,8 +351,7 @@ void
ui_out::table_begin (int nr_cols, int nr_rows, const std::string &tblid)
{
if (m_table_up != nullptr)
- internal_error (__FILE__, __LINE__,
- _("tables cannot be nested; table_begin found before \
+ internal_error (_("tables cannot be nested; table_begin found before \
previous table_end."));
m_table_up.reset (new ui_out_table (level () + 1, nr_cols, tblid));
@@ -368,8 +364,7 @@ ui_out::table_header (int width, ui_align alignment,
const std::string &col_name, const std::string &col_hdr)
{
if (m_table_up == nullptr)
- internal_error (__FILE__, __LINE__,
- _("table_header outside a table is not valid; it must be \
+ internal_error (_("table_header outside a table is not valid; it must be \
after a table_begin and before a table_body."));
m_table_up->append_header (width, alignment, col_name, col_hdr);
@@ -381,8 +376,7 @@ void
ui_out::table_body ()
{
if (m_table_up == nullptr)
- internal_error (__FILE__, __LINE__,
- _("table_body outside a table is not valid; it must be "
+ internal_error (_("table_body outside a table is not valid; it must be "
"after a table_begin and before a table_end."));
m_table_up->start_body ();
@@ -394,8 +388,7 @@ void
ui_out::table_end ()
{
if (m_table_up == nullptr)
- internal_error (__FILE__, __LINE__,
- _("misplaced table_end or missing table_begin."));
+ internal_error (_("misplaced table_end or missing table_begin."));
do_table_end ();
@@ -772,8 +765,7 @@ ui_out::vmessage (const ui_file_style &in_style, const char *format,
call_do_message (style, current_substring, 0);
break;
default:
- internal_error (__FILE__, __LINE__,
- _("failed internal consistency check"));
+ internal_error (_("failed internal consistency check"));
}
}
}
@@ -833,8 +825,7 @@ ui_out::verify_field (int *fldno, int *width, ui_align *align)
if (m_table_up != nullptr
&& m_table_up->current_state () != ui_out_table::state::BODY)
{
- internal_error (__FILE__, __LINE__,
- _("table_body missing; table fields must be \
+ internal_error (_("table_body missing; table fields must be \
specified after table_body and inside a list."));
}
@@ -846,8 +837,7 @@ specified after table_body and inside a list."));
&& m_table_up->get_next_header (fldno, width, align, &text))
{
if (*fldno != current->field_count ())
- internal_error (__FILE__, __LINE__,
- _("ui-out internal error in handling headers."));
+ internal_error (_("ui-out internal error in handling headers."));
}
else
{