From: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>
To: Eli Zaretskii <eliz@gnu.org>, John Baldwin <jhb@FreeBSD.org>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH v4 2/2] gdb: raise and handle NOT_AVAILABLE_ERROR when accessing frame PC
Date: Wed, 27 Dec 2023 18:41:52 +0000 [thread overview]
Message-ID: <DM4PR11MB7303ADF3D5AC9F274165C2B6C49FA@DM4PR11MB7303.namprd11.prod.outlook.com> (raw)
In-Reply-To: <838r5ogiqs.fsf@gnu.org>
On Thursday, December 21, 2023 7:42 AM, Eli Zaretskii wrote:
> > Date: Wed, 20 Dec 2023 14:00:03 -0800
> > From: John Baldwin <jhb@FreeBSD.org>
> >
> > > --- a/gdb/amd64-linux-nat.c
> > > +++ b/gdb/amd64-linux-nat.c
> > > @@ -223,7 +223,10 @@ amd64_linux_nat_target::fetch_registers (struct regcache *regcache,
> int regnum)
> > > elf_gregset_t regs;
> > >
> > > if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0)
> > > - perror_with_name (_("Couldn't get registers"));
> > > + {
> > > + std::string msg = perror_string (_("Couldn't get registers"));
> > > + throw_error (NOT_AVAILABLE_ERROR, "%s", msg.c_str ());
> > > + }
> >
> > Should other nat backends for other OS's (and other arches) also
> > make this change when failing to fetch registers?
>
> That's probably a good idea, yes.
Yes. I didn't do that, however, because I don't have a chance to do regression
testing for the other targets.
> But I also wonder whether the difference between
>
> Couldn't get registers: No such process.
>
> or
>
> Could not read registers; remote failure reply 'E01'
>
> and
>
> <PC register is not available>
>
> or
>
> Backtrace stopped: not enough registers or memory available to unwind further
>
> is such a significant improvement in terms of UX. Both the "before"
> and "after" messages allude to issues that are extremely technical and
> obscure, IMO. If anything, "No such process" sounds better to me than
> "<PC register is not available>", because the former explicitly
> explains the reason in high-level terms understood by anyone, while
> the latter alludes to the PC register, which is a GDB abstraction, and
> the fact that some register is not available doesn't necessarily tell
> me what is wrong in practical terms.
>
> IOW, it seems to me that, when we catch the error, we ought to produce
> some meaningful message, and with this change we don't yet do that.
>
> Does this make sense?
We can remember the reason in regcache for why a particular register became
unavailable and use that reason in the error messages. With such a change,
the output for the first case would become
(gdb) start
...
(gdb) info inferior
Num Description Connection Executable
* 1 process 1017286 1 (native) /tmp/a.out
(gdb) shell kill -9 1017286
(gdb) maintenance flush register-cache
Register cache flushed.
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7ffff7d87740 (LWP 1017286) "a.out" <Couldn't get registers: No such process>
(gdb) backtrace
#0 <Couldn't get registers: No such process>
Backtrace stopped: not enough registers or memory available to unwind further
(gdb) inferior 1
[Switching to inferior 1 [process 1017286] (/tmp/a.out)]
[Switching to thread 1 (Thread 0x7ffff7d87740 (LWP 1017286))]
#0 <Couldn't get registers: No such process>
(gdb) thread
[Current thread is 1 (Thread 0x7ffff7d87740 (LWP 1017286))]
(gdb)
Does this look acceptable?
Regards
-Baris
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
prev parent reply other threads:[~2023-12-27 18:42 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-08 9:15 [PATCH v2 0/2] Querying registers of already-exited processes Tankut Baris Aktemur
2022-02-08 9:15 ` [PATCH v2 1/2] gdb/regcache: return REG_UNAVAILABLE if raw_update raises NOT_AVAILABLE_ERROR Tankut Baris Aktemur
2022-03-16 15:18 ` Bruno Larsen
2022-03-23 12:55 ` Aktemur, Tankut Baris
2022-02-08 9:15 ` [PATCH v2 2/2] gdb: raise and handle NOT_AVAILABLE_ERROR when accessing frame PC Tankut Baris Aktemur
2022-03-16 17:26 ` Bruno Larsen
2022-03-23 12:55 ` Aktemur, Tankut Baris
2022-03-23 13:34 ` Bruno Larsen
2022-03-24 8:46 ` Aktemur, Tankut Baris
2022-02-22 7:31 ` [PATCH v2 0/2] Querying registers of already-exited processes Aktemur, Tankut Baris
2022-03-07 8:00 ` Aktemur, Tankut Baris
2022-03-23 13:05 ` [PATCH v3 " Tankut Baris Aktemur
2022-03-23 13:05 ` [PATCH v3 1/2] gdb/regcache: return REG_UNAVAILABLE in raw_read if NOT_AVAILABLE_ERROR is seen Tankut Baris Aktemur
2022-03-23 13:05 ` [PATCH v3 2/2] gdb: raise and handle NOT_AVAILABLE_ERROR when accessing frame PC Tankut Baris Aktemur
2022-05-04 7:19 ` [PATCH v3 0/2] Querying registers of already-exited processes Aktemur, Tankut Baris
2022-12-23 17:10 ` Aktemur, Tankut Baris
2023-01-17 20:40 ` Aktemur, Tankut Baris
2023-01-24 10:35 ` Aktemur, Tankut Baris
2023-01-31 20:14 ` Aktemur, Tankut Baris
2023-02-20 13:07 ` Aktemur, Tankut Baris
2023-03-03 7:46 ` Aktemur, Tankut Baris
2023-03-28 13:40 ` Aktemur, Tankut Baris
2023-12-18 14:40 ` [PATCH v4 " Tankut Baris Aktemur
2023-12-18 14:40 ` [PATCH v4 1/2] gdb/regcache: return REG_UNAVAILABLE in raw_read if NOT_AVAILABLE_ERROR is seen Tankut Baris Aktemur
2023-12-18 14:40 ` [PATCH v4 2/2] gdb: raise and handle NOT_AVAILABLE_ERROR when accessing frame PC Tankut Baris Aktemur
2023-12-20 22:00 ` John Baldwin
2023-12-21 6:41 ` Eli Zaretskii
2023-12-27 18:41 ` Aktemur, Tankut Baris [this message]
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=DM4PR11MB7303ADF3D5AC9F274165C2B6C49FA@DM4PR11MB7303.namprd11.prod.outlook.com \
--to=tankut.baris.aktemur@intel.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=jhb@FreeBSD.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).