diff options
author | Markus Metzger <markus.t.metzger@intel.com> | 2022-01-31 07:24:54 +0100 |
---|---|---|
committer | Markus Metzger <markus.t.metzger@intel.com> | 2022-02-01 17:44:38 +0100 |
commit | cd393cec3ab21f6e8b984dea5dafe2c7a5aec892 (patch) | |
tree | 768a2becd883fa544d482832bc9d153e490824c4 /gdb/nat | |
parent | 219c04fc3b3f7e7e19fc5f8d47e5036c7a80377f (diff) | |
download | gdb-cd393cec3ab21f6e8b984dea5dafe2c7a5aec892.zip gdb-cd393cec3ab21f6e8b984dea5dafe2c7a5aec892.tar.gz gdb-cd393cec3ab21f6e8b984dea5dafe2c7a5aec892.tar.bz2 |
gdb, btrace: improve error messages
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>
Diffstat (limited to 'gdb/nat')
-rw-r--r-- | gdb/nat/linux-btrace.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c index d888075..b0d6dcd 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) |