* [PATCH v2] gdb, btrace: improve error messages
@ 2022-02-01 15:01 Markus Metzger
2022-02-01 15:17 ` Simon Marchi
0 siblings, 1 reply; 3+ messages in thread
From: Markus Metzger @ 2022-02-01 15:01 UTC (permalink / raw)
To: simon.marchi; +Cc: gdb-patches, Simon Sobisch
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 | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index d8880756aad..b0d6dcd7cf1 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -427,9 +427,11 @@ diagnose_perf_event_open_fail ()
case EACCES:
{
static const char filename[] = "/proc/sys/kernel/perf_event_paranoid";
+ errno = 0;
gdb_file_up file = gdb_fopen_cloexec (filename, "r");
if (file.get () == nullptr)
- break;
+ error (_("Failed to open %s (%s). Your system does not support "
+ "process recording."), filename, safe_strerror (errno));
int level, found = fscanf (file.get (), "%d", &level);
if (found == 1 && level > 2)
@@ -571,7 +573,22 @@ 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 (_("Failed to open %s (%s). You do not have permission "
+ "to use Intel PT."), filename, safe_strerror (errno));
+
+ case ENOTDIR:
+ case ENOENT:
+ error (_("Failed to open %s (%s). Your system does not support "
+ "Intel PT."), filename, safe_strerror (errno));
+
+ default:
+ error (_("Failed to open %s: %s."), filename, safe_strerror (errno));
+ }
int type, found = fscanf (file.get (), "%d", &type);
if (found != 1)
--
2.34.1
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] gdb, btrace: improve error messages
2022-02-01 15:01 [PATCH v2] gdb, btrace: improve error messages Markus Metzger
@ 2022-02-01 15:17 ` Simon Marchi
2022-02-01 16:40 ` Simon Sobisch
0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2022-02-01 15:17 UTC (permalink / raw)
To: Markus Metzger; +Cc: gdb-patches, Simon Sobisch
On 2022-02-01 10:01, Markus Metzger 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.
That looks good to me, but you might want to see if the other Simon has
some feedback.
Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] gdb, btrace: improve error messages
2022-02-01 15:17 ` Simon Marchi
@ 2022-02-01 16:40 ` Simon Sobisch
0 siblings, 0 replies; 3+ messages in thread
From: Simon Sobisch @ 2022-02-01 16:40 UTC (permalink / raw)
To: Simon Marchi, Markus Metzger; +Cc: gdb-patches
Am 01.02.2022 um 16:17 schrieb Simon Marchi:
>
>
> On 2022-02-01 10:01, Markus Metzger 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.
>
> That looks good to me, but you might want to see if the other Simon has
> some feedback.
>
> Simon
>
I like it very much, thanks to both of you!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-01 16:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-01 15:01 [PATCH v2] gdb, btrace: improve error messages Markus Metzger
2022-02-01 15:17 ` Simon Marchi
2022-02-01 16:40 ` Simon Sobisch
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).