public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Markus Metzger <markus.t.metzger@intel.com>
To: gdb-patches@sourceware.org
Cc: Simon Sobisch <simonsobisch@gnu.org>
Subject: [PATCH] gdb, btrace: improve error messages
Date: Tue,  1 Feb 2022 13:10:46 +0100	[thread overview]
Message-ID: <20220201121046.2160219-1-markus.t.metzger@intel.com> (raw)

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)
-- 
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


             reply	other threads:[~2022-02-01 12:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01 12:10 Markus Metzger [this message]
2022-02-01 14:17 ` Simon Marchi

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=20220201121046.2160219-1-markus.t.metzger@intel.com \
    --to=markus.t.metzger@intel.com \
    --cc=gdb-patches@sourceware.org \
    --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).