From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1805) id 1FAA93858CD1; Mon, 11 Mar 2024 11:34:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FAA93858CD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1710156866; bh=ef0Gjmqd/6U7sbP73Xn2flovYi5PP3g4hXLigGgbBjE=; h=From:To:Subject:Date:From; b=GrSqI7RK6Y7i0neQNA4n43G1MBYwGuUITJVpsHeZNy+0NZwP3dnG3bmspdf0PlTgh bV4wDbk4w9Q/EzQvy67hAd9+VaD6jsKqPrivvddvsBNI8h1tM9Muis0Tfk7Myc2Z/R J9ur7bKvCjEBeCy7/CAnHlpRLxc6aBBciZY7qtqU= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Markus Metzger To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb, btrace: fix error diagnostics X-Act-Checkin: binutils-gdb X-Git-Author: Markus Metzger X-Git-Refname: refs/heads/master X-Git-Oldrev: 5eb2254a1d1d69980601e6530ee63e0e0e6a6c33 X-Git-Newrev: b792eb47f25f577ccef365fc9a5c20d55fad42d5 Message-Id: <20240311113426.1FAA93858CD1@sourceware.org> Date: Mon, 11 Mar 2024 11:34:26 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db792eb47f25f= 577ccef365fc9a5c20d55fad42d5 commit b792eb47f25f577ccef365fc9a5c20d55fad42d5 Author: Markus Metzger Date: Fri Feb 18 13:53:31 2022 +0100 gdb, btrace: fix error diagnostics =20 When we improved error messages in =20 cd393cec3ab gdb, btrace: improve error messages =20 we cleared the original errno. When the error reason can not be explai= ned in a more detailed error message, and we fall back to the default error message, it now gives Success as error. =20 Restore the original errno to fix that. Diff: --- 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 =3D errno; + switch (orig_errno) { case EPERM: case EACCES: @@ -443,7 +444,7 @@ diagnose_perf_event_open_fail () break; } =20 - error (_("Failed to start recording: %s"), safe_strerror (errno)); + error (_("Failed to start recording: %s"), safe_strerror (orig_errno)); } =20 /* Get the linux version of a btrace_target_info. */