public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: binutils@sourceware.org, Alan Modra <amodra@gmail.com>,
	 Nick Clifton <nickc@redhat.com>
Subject: Re: [PATCH] bfd: Print cached message in _bfd_abort
Date: Tue, 5 Mar 2024 06:37:56 -0800	[thread overview]
Message-ID: <CAMe9rOrMiOW18Q_g1F=K9kAsU+hvb3Xu_FPoqVi5tvmbnKqayQ@mail.gmail.com> (raw)
In-Reply-To: <20240302132108.398436-1-hjl.tools@gmail.com>

On Sat, Mar 2, 2024 at 5:21 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> bfd_check_format_matches sets _bfd_error_handler to error_handler_sprintf
> to cache warning and error messages before restoring the original
> _bfd_error_handler.  When something went wrong in between and _bfd_abort
> is called, there is no abort message.  Update _bfd_abort to print cached
> messages.
>
>         PR ld/31444
>         * bfd.c (_bfd_abort): Check and print cached messages.
> ---
>  bfd/bfd.c | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/bfd/bfd.c b/bfd/bfd.c
> index c9f374e0948..be4c9af0f62 100644
> --- a/bfd/bfd.c
> +++ b/bfd/bfd.c
> @@ -2077,7 +2077,26 @@ _bfd_abort (const char *file, int line, const char *fn)
>        /* xgettext:c-format */
>        (_("BFD %s internal error, aborting at %s:%d\n"),
>         BFD_VERSION_STRING, file, line);
> -  _bfd_error_handler (_("Please report this bug.\n"));
> +
> +  struct per_xvec_message **list
> +    = _bfd_per_xvec_warn (error_handler_bfd->xvec, 0);
> +  if (*list)
> +    {
> +      fflush (stdout);
> +      for (struct per_xvec_message *warn = *list; warn;)
> +       {
> +         struct per_xvec_message *next = warn->next;
> +         fputs (warn->message, stderr);
> +         fputc ('\n', stderr);
> +         free (warn);
> +         warn = next;
> +       }
> +      fputs (_("Please report this bug.\n"), stderr);
> +      fflush (stderr);
> +    }
> +  else
> +    _bfd_error_handler (_("Please report this bug.\n"));
> +
>    _exit (EXIT_FAILURE);
>  }
>
> --
> 2.44.0
>

Hi Nick, Alan,

Do you have any comments on this patch?

Thanks.

-- 
H.J.

  reply	other threads:[~2024-03-05 14:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-02 13:21 H.J. Lu
2024-03-05 14:37 ` H.J. Lu [this message]
2024-03-05 21:49   ` Alan Modra
2024-03-05 22:48     ` H.J. Lu

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='CAMe9rOrMiOW18Q_g1F=K9kAsU+hvb3Xu_FPoqVi5tvmbnKqayQ@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=nickc@redhat.com \
    /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).