From: John Baldwin <jhb@FreeBSD.org>
To: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] gdb: improve error reporting from expression parser
Date: Thu, 28 Dec 2023 11:12:30 -0800 [thread overview]
Message-ID: <44359512-5392-46ed-9e80-31052843ba68@FreeBSD.org> (raw)
In-Reply-To: <1dc7fb98343743fe010687ab3d5ccf2474181e64.1703361278.git.aburgess@redhat.com>
On 12/23/23 11:56 AM, Andrew Burgess wrote:
> This commits changes how errors are reported from the expression
> parser. Previously, parser errors were reported like this:
>
> (gdb) p a1 +}= 432
> A syntax error in expression, near `}= 432'.
> (gdb) p a1 +
> A syntax error in expression, near `'.
>
> The first case is fine, a user can figure out what's going wrong, but
> the second case is a little confusing; as the error occurred at the
> end of the expression GDB just reports the empty string to the user.
>
> After this commit the errors are now reported like this:
>
> (gdb) p a1 +}= 432
> A syntax error in expression near '<HERE>' marker in: `a1 +<HERE>}= 432'.
> (gdb) p a1 +
> A syntax error in expression near '<HERE>' marker in: `a1 +<HERE>'.
>
> Now GDB reports the entire expression along with a <HERE> marker to
> indicate where the error occurred.
>
> I did consider trying to have multi-line errors here, in the style
> that gcc produces, with some kind of '~~~~~^' marker on the second
> line to indicate where the error occurred; but I rejected this due to
> the places in GDB where we catch an error and repackage the message
> within some longer string, I don't think multi-line error messages
> would work well in that case.
>
> Adding the '<HERE>' marker was actually a later extension I made. My
> first implementation simply tried to address the empty string
> case (where GDB reports "..., near `'"). Originally I just changed
> this to be:
>
> (gdb) p a1 +
> A syntax error in expression, at the end of `a1 +'.
>
> But then I thought adding the '<HERE>' markers was pretty neat, so I
> did that instead. However, if folk feel the '<HERE>' marker is more
> confusing than helpful I can always fall back to my original plan, and
> just fix the empty string case.
>
> I originally wanted to try and style the '<HERE>' marker, I thought
> that would help make it clear that it wasn't part of the expression.
> However, GDB's error function doesn't support styling right now. We
> could possibly add this in the future, in which case the <HERE> marker
> could be given maybe the metadata style to help it stand out.
>
> I've updated the small number of tests that check for a syntax error,
> and add a couple of extra tests in gdb.base/exprs.exp.
Hmm, I do kind of find the <HERE> approach somewhat verbose (or at least
I feel like it's a bit shouty). I might prefer either your simple fix
for end of string (which I think is a perfectly fine fix), or the more
complicated multi-line error similar to what GCC/clang do for compile
errors. It does sound like the multi-line case might be too complicated
to implement.
--
John Baldwin
next prev parent reply other threads:[~2023-12-28 19:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-23 19:56 [PATCH 0/2] Changes to error reporting from the " Andrew Burgess
2023-12-23 19:56 ` [PATCH 1/2] gdb: improve error reporting from " Andrew Burgess
2023-12-28 19:12 ` John Baldwin [this message]
2023-12-23 19:56 ` [PATCH 2/2] gdb: don't try to style content in error calls Andrew Burgess
2024-01-02 14:43 ` [PATCHv2 0/3] Changes to error reporting from the expression parser Andrew Burgess
2024-01-02 14:43 ` [PATCHv2 1/3] gdb: don't try to style content in error calls Andrew Burgess
2024-01-03 19:50 ` John Baldwin
2024-01-02 14:43 ` [PATCHv2 2/3] gdb: merge error handling from different expression parsers Andrew Burgess
2024-01-02 15:01 ` Lancelot SIX
2024-01-03 9:39 ` Andrew Burgess
2024-01-02 14:43 ` [PATCHv2 3/3] gdb: improve error reporting from expression parser Andrew Burgess
2024-01-03 19:52 ` [PATCHv2 0/3] Changes to error reporting from the " John Baldwin
2024-01-04 9:43 ` Andrew Burgess
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=44359512-5392-46ed-9e80-31052843ba68@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
/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).