Subject: Re: bug#61453: It is annoying to have to type 'print foo' before each .gdbinit command.

From: Alan Mackenzie <[email-masked]>
Date: Sun, 12 Feb 2023 13:34:36 +0000

Hello, Eli.

On Sun, Feb 12, 2023 at 15:08:52 +0200, Eli Zaretskii wrote:
> > Date: Sun, 12 Feb 2023 13:01:57 +0000
> > From: Alan Mackenzie <[email-masked]>

> > In a GDB session, whilst debugging Emacs, it is common to want to print,
> > for example, the current value of Lisp variable foo.  At the moment, one
> > has to type

> >     p foo
> >     xpr

> > ..  This need, continually to type p (or print) is irritating.  It should
> > be possible simply to type

> >     xpr foo

> > ..  The same applies to many other commands in .gdbinit.

> > The following patch fixes this irritation.  It allows a user to type xpr
> > foo, yet also preserves the old version with no arguments, which can be
> > handy, sometimes.

> > I propose this patch be applied to the master branch.

> What's wrong with the existing "pp" command?  I think it covers all
> your needs, and doesn't need any changes to existing xFOO commands.

The pp comand does nothing on my setup except for scrolling the gdb
window up one line.  Its help text says "Works only when an inferior
emacs is executing.".  I normally start the target Emacs on a separate
Linux console, then attach it to my gdb session with the attach command.
I don't really know what "an inferior emacs" means, though I'm sure I
could find out if I read etc/DEBUG more carefully.

Besides, even if pp worked for me, there will be times when the other
commands will be handy (otherwise they wouldn't be there).  I've never
actually used pp.  I use xpr all the time.

Incidentally, I sneaked in a correction to nextcons which currently has:

    p $.u.cdr

, and which (presumably) since a change in lisp.h needs to be

    p $.u.s.u.cdr

..  I don't understand why we have members car and cdr wrapped in so many
unions and structs.

So, I still think my patch would be a good idea.

-- 
Alan Mackenzie (Nuremberg, Germany).