public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Simon Marchi <simark@simark.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH] internal_error: remove need to pass __FILE__/__LINE__
Date: Mon, 17 Oct 2022 20:26:52 +0100	[thread overview]
Message-ID: <feb8bfbb-c348-e34f-ef2e-3988b4c83b86@palves.net> (raw)
In-Reply-To: <e2edc424-7728-9ab8-b709-24c7fb7610cd@simark.ca>

On 2022-10-17 7:59 p.m., Simon Marchi wrote:
> 
> 
> On 2022-10-17 14:50, Pedro Alves wrote:
>> 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.
> 
> I think it's a good change, but as a result gdb_assert_not_reached and
> internal_error become essentially the same thing.  Can we just keep one?

Most probably.  I prefer keeping internal_error for it being more pervasive
and older.  gdb_assert_not_reached is a more recent addition.

> The only difference is that gdb_assert_not_reached includes the
> function name, but I don't think it's an important difference.  I think
> we could switch to a single one that does include the function name.

I don't think it needs to be in this patch, though?

This one is just making internal_error more convenient to call.  We can
always look at doing something to its internals separately.

  reply	other threads:[~2022-10-17 19:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17 18:50 Pedro Alves
2022-10-17 18:59 ` Simon Marchi
2022-10-17 19:26   ` Pedro Alves [this message]
2022-10-17 19:27     ` Simon Marchi
2022-10-17 19:37       ` Pedro Alves
2022-10-17 19:45         ` Simon Marchi
2022-10-18 11:15           ` Pedro Alves
2022-10-18 14:53             ` Simon Marchi
2022-10-19 14:47               ` Pedro Alves
2022-10-18 12:34           ` Bruno Larsen
2022-10-18 14:55             ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=feb8bfbb-c348-e34f-ef2e-3988b4c83b86@palves.net \
    --to=pedro@palves.net \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).