]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb, btrace: fix error diagnostics
authorMarkus Metzger <markus.t.metzger@intel.com>
Fri, 18 Feb 2022 12:53:31 +0000 (13:53 +0100)
committerMarkus Metzger <markus.t.metzger@intel.com>
Mon, 11 Mar 2024 11:33:50 +0000 (11:33 +0000)
When we improved error messages in

    cd393cec3ab gdb, btrace: improve error messages

we cleared the original errno.  When the error reason can not be explained
in a more detailed error message, and we fall back to the default error
message, it now gives Success as error.

Restore the original errno to fix that.

gdb/nat/linux-btrace.c

index 50de24155890447ddb24c88a541b11a42869c9ef..f8352b62b8b6828e64ba1dd6d4e5a0b673f66b85 100644 (file)
@@ -422,7 +422,8 @@ cpu_supports_bts (void)
 static void
 diagnose_perf_event_open_fail ()
 {
-  switch (errno)
+  int orig_errno = errno;
+  switch (orig_errno)
     {
     case EPERM:
     case EACCES:
@@ -443,7 +444,7 @@ diagnose_perf_event_open_fail ()
       break;
     }
 
-  error (_("Failed to start recording: %s"), safe_strerror (errno));
+  error (_("Failed to start recording: %s"), safe_strerror (orig_errno));
 }
 
 /* Get the linux version of a btrace_target_info.  */