public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb, btrace: fix error diagnostics
@ 2024-03-07 15:01 Markus Metzger
  2024-03-08  9:07 ` Guinevere Larsen
  2024-03-08 16:21 ` Tom Tromey
  0 siblings, 2 replies; 3+ messages in thread
From: Markus Metzger @ 2024-03-07 15:01 UTC (permalink / raw)
  To: gdb-patches

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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index 50de2415589..f8352b62b8b 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -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.  */
-- 
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] gdb, btrace: fix error diagnostics
  2024-03-07 15:01 [PATCH] gdb, btrace: fix error diagnostics Markus Metzger
@ 2024-03-08  9:07 ` Guinevere Larsen
  2024-03-08 16:21 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Guinevere Larsen @ 2024-03-08  9:07 UTC (permalink / raw)
  To: Markus Metzger, gdb-patches

On 07/03/2024 16:01, Markus Metzger wrote:
> 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.

Hi!

LGTM, Reviewed-By: Guinevere Larsen <blarsen@redhat.com>

-- 
Cheers,
Guinevere Larsen
She/Her/Hers

> ---
>   gdb/nat/linux-btrace.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
> index 50de2415589..f8352b62b8b 100644
> --- a/gdb/nat/linux-btrace.c
> +++ b/gdb/nat/linux-btrace.c
> @@ -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.  */



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb, btrace: fix error diagnostics
  2024-03-07 15:01 [PATCH] gdb, btrace: fix error diagnostics Markus Metzger
  2024-03-08  9:07 ` Guinevere Larsen
@ 2024-03-08 16:21 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2024-03-08 16:21 UTC (permalink / raw)
  To: Markus Metzger; +Cc: gdb-patches

>>>>> Markus Metzger <markus.t.metzger@intel.com> writes:

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

Thank you.  This looks good to me.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-08 16:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-07 15:01 [PATCH] gdb, btrace: fix error diagnostics Markus Metzger
2024-03-08  9:07 ` Guinevere Larsen
2024-03-08 16:21 ` Tom Tromey

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