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 14:59:04 -0400	[thread overview]
Message-ID: <e2edc424-7728-9ab8-b709-24c7fb7610cd@simark.ca> (raw)
In-Reply-To: <20221017185019.3233941-1-pedro@palves.net>



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

Simon

  reply	other threads:[~2022-10-17 18:59 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 [this message]
2022-10-17 19:26   ` Pedro Alves
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=e2edc424-7728-9ab8-b709-24c7fb7610cd@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).