public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: "libstdc++" <libstdc++@gcc.gnu.org>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: What should a std::error_code pretty printer show?
Date: Mon, 16 Aug 2021 20:30:46 +0100	[thread overview]
Message-ID: <CAH6eHdTwnD0Jiipe9+AmKojjq58JsKWQJyUozzLFKFDZLh=oFQ@mail.gmail.com> (raw)
In-Reply-To: <CAH6eHdQGRDCPtkA3_pV_nWVPKGkSw=rCThVxkdaX1XUDhdEtcA@mail.gmail.com>

On Mon, 16 Aug 2021 at 17:51, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>
> On Mon, 16 Aug 2021 at 13:11, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> >
> >
> >
> > On Mon, 16 Aug 2021, 12:55 Jonathan Wakely, <jwakely.gcc@gmail.com> wrote:
> >>
> >> I'm adding a GDB printer for std::error_code.What I have now prints
> >> the category name as a quoted string, followed by the error value:
> >>
> >> {"system": 0}
> >> {"system": 1234}
> >>
> >> If the category is std::generic_category() then it also shows the
> >> strerror description:
> >
> >
> > I should probably extend this special case for the generic category to also apply to the system category when the OS is POSIX-based. For POSIX systems, the system error numbers are generic errno values.
> >
> >
> >>
> >> {"generic": 13 "Permission denied"}
> >>
> >> But I'd also like it to show the errno macro, but I'm not sure what's
> >> the best way to show it.
> >>
> >> Does this seem OK?
> >>
> >> {"generic": 13 EACCES "Permission denied"}
> >>
> >> I think that's a bit too verbose.
> >>
> >> Would {"generic": EACCES} be better? You can always use ec.value() to
> >> get the numeric value, and strerror to get the description if you want
> >> those.
>
> Here's what I plan to commit. It just uses {"generic": EACCES} for
> known categories that use errno values, and {"foo": 99} for other
> error categories.
>
>
> It also supports std::error_condition (using the same printer and the
> same output formats).

Actually, the proposal in PR 65230 would mean that we should print { }
if the object has its default-constructed state, i.e. {"system": 0}
for error_code and {"generic": 0} for error_condition. I'll make that
change before pushing anything to master.

Other suggestions for improvement (or just agreeing with the
direction) are welcome.

      reply	other threads:[~2021-08-16 19:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16 11:55 Jonathan Wakely
2021-08-16 12:11 ` Jonathan Wakely
2021-08-16 16:51   ` Jonathan Wakely
2021-08-16 19:30     ` Jonathan Wakely [this message]

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='CAH6eHdTwnD0Jiipe9+AmKojjq58JsKWQJyUozzLFKFDZLh=oFQ@mail.gmail.com' \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.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).