From: Simon Marchi <simon.marchi@polymtl.ca>
To: Markus Metzger <markus.t.metzger@intel.com>, gdb-patches@sourceware.org
Cc: Simon Sobisch <simonsobisch@gnu.org>
Subject: Re: [PATCH] gdb, btrace: improve error messages
Date: Tue, 1 Feb 2022 09:17:11 -0500 [thread overview]
Message-ID: <f123b099-6191-869a-ce46-8469e99b4dd9@polymtl.ca> (raw)
In-Reply-To: <20220201121046.2160219-1-markus.t.metzger@intel.com>
On 2022-02-01 07:10, Markus Metzger via Gdb-patches wrote:
> When trying to use 'record btrace' on a system that does not support it,
> the error message isn't as clear as it could be. See
> https://sourceware.org/pipermail/gdb/2022-January/049870.html.
>
> Improve the error message in a few cases.
>
> Reported-by: Simon Sobisch <simonsobisch@gnu.org>
> ---
> gdb/nat/linux-btrace.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
> index d8880756aad..13ed493495d 100644
> --- a/gdb/nat/linux-btrace.c
> +++ b/gdb/nat/linux-btrace.c
> @@ -429,7 +429,7 @@ diagnose_perf_event_open_fail ()
> static const char filename[] = "/proc/sys/kernel/perf_event_paranoid";
> gdb_file_up file = gdb_fopen_cloexec (filename, "r");
> if (file.get () == nullptr)
> - break;
> + error (_("Your system does not support process recording."));
>
> int level, found = fscanf (file.get (), "%d", &level);
> if (found == 1 && level > 2)
> @@ -571,7 +571,20 @@ perf_event_pt_event_type ()
> errno = 0;
> gdb_file_up file = gdb_fopen_cloexec (filename, "r");
> if (file.get () == nullptr)
> - error (_("Failed to open %s: %s."), filename, safe_strerror (errno));
> + switch (errno)
> + {
> + case EACCES:
> + case EFAULT:
> + case EPERM:
> + error (_("You do not have permission to use Intel PT."));
> +
> + case ENOTDIR:
> + case ENOENT:
> + error (_("Your system does not support Intel PT."));
> +
> + default:
> + error (_("Failed to open %s: %s."), filename, safe_strerror (errno));
> + }
>
> int type, found = fscanf (file.get (), "%d", &type);
> if (found != 1)
I think the more detailed messages are nice. But I would still mention
the underlying error, to indicate how GDB reached that conclusion. That
gives the user has something to grab onto to understand and fix the
problem. For example:
Failed to open %s (%s). You do not have permission to use Intel PT.
where the %s are respectively the filename and the strerror.
Simon
prev parent reply other threads:[~2022-02-01 14:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-01 12:10 Markus Metzger
2022-02-01 14:17 ` Simon Marchi [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=f123b099-6191-869a-ce46-8469e99b4dd9@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.com \
--cc=simonsobisch@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).