public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH] internal_error: remove need to pass __FILE__/__LINE__
Date: Mon, 17 Oct 2022 15:27:54 -0400	[thread overview]
Message-ID: <6e5b27a9-abd4-60f3-fc3a-d9f8fa9f6a64@simark.ca> (raw)
In-Reply-To: <feb8bfbb-c348-e34f-ef2e-3988b4c83b86@palves.net>



On 2022-10-17 15:26, Pedro Alves wrote:
> 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.

Fine with me.

>> 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.

Sure, it's just an idea for eventually.

Simon

  reply	other threads:[~2022-10-17 19:27 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
2022-10-17 19:27     ` Simon Marchi [this message]
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=6e5b27a9-abd4-60f3-fc3a-d9f8fa9f6a64@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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).