unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Two changes to tooltip.el (proposal)
@ 2002-11-19 19:24 Nick Roberts
  2002-11-20 11:46 ` Kim F. Storm
  2002-11-25 12:37 ` Richard Stallman
  0 siblings, 2 replies; 4+ messages in thread
From: Nick Roberts @ 2002-11-19 19:24 UTC (permalink / raw)


These are changes that will work with gud.el (and not currently with gdb-ui.el)

1) tooltip.el uses the function `tooltip-gud-print-command' called from
`tooltip-identifier-from-point' to parse a variable name to display a variable
value as a tooltip in GUD. According to the documentation the identifier is
extracted using the current syntax table. It doesn't seem to be very good and
only really seems to work for simple variable names. But there is already a
function in gud.el, called `gud-find-c-expr', that does a very good job for this.
I suggest using this so that `tooltip-identifier-from-point' would become :

(defun tooltip-identifier-from-point (point)
  "Extract the identifier at POINT, if any."
  (save-excursion
    (goto-char point)
    (gud-find-c-expr)))

The current `tooltip-identifier-from-point' returns nil if no identifier exists
at point whereas `gud-find-c-expr' returns the empty string (""). This doesn't
seem to cause a problem though.

2) A good way to step through a program in gdb is to n<RET> and then simply
keep pressing <RET> to repeat the last command (`next' in this case). The
function `tooltip-gud-print-command' uses the gdb command `print' to display a
variable value as a tooltip in GUD. This puts `print' into the command
history. If you stop to look at a variable as a tooltip and then go back
to the GUD buffer and press <RET>, the command `print' is executed rather than
`next'. If, however, you replace `print' in `tooltip-gud-print-command' with
`server print' it doesn't go into the command history and things behave as you
would expect. So I suggest the following :

(defun tooltip-gud-print-command (expr)
  "Return a suitable command to print the expression EXPR.
If TOOLTIP-GUD-DEREFERENCE is t, also prepend a `*' to EXPR."
  (when tooltip-gud-dereference
    (setq expr (concat "*" expr)))
  (case tooltip-gud-debugger
    (gdb (concat "server print " expr))
    (dbx (concat "print " expr))
    (xdb (concat "p " expr))
    (sdb (concat expr "/"))
    (perldb expr)))

To the emacs maintainers : Shall I install these changes ?

Nick

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

* Re: Two changes to tooltip.el (proposal)
  2002-11-19 19:24 Two changes to tooltip.el (proposal) Nick Roberts
@ 2002-11-20 11:46 ` Kim F. Storm
  2002-11-20 23:33   ` Nick Roberts
  2002-11-25 12:37 ` Richard Stallman
  1 sibling, 1 reply; 4+ messages in thread
From: Kim F. Storm @ 2002-11-20 11:46 UTC (permalink / raw)
  Cc: emacs-devel

Nick Roberts <nick@nick.uklinux.net> writes:

> 
> (defun tooltip-identifier-from-point (point)
>   "Extract the identifier at POINT, if any."
>   (save-excursion
>     (goto-char point)
>     (gud-find-c-expr)))

Maybe this would be safer:

        (if (fboundp 'gud-find-c-expr)
            (gud-find-c-expr)
          ... old tooltip-identifier-from-point code goes here ...
          )


> ... `server print' ...

Very nice!  

I haven't been able to find any documentation on the "server" prefix;
what does it mean?  Is it related to the gdbserver program?  In that
case, does it change the semantics of the print command so that
debugging a program via gdbserver may not work properly with the change?

Even if it is harmless, are you sure "server print" is supported by
all gdb versions (do we care -- probably most systems running emacs 21.x
also have a fairly new version of gdb ?)

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Two changes to tooltip.el (proposal)
  2002-11-20 11:46 ` Kim F. Storm
@ 2002-11-20 23:33   ` Nick Roberts
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Roberts @ 2002-11-20 23:33 UTC (permalink / raw)
  Cc: emacs-devel


 > > 
 > > (defun tooltip-identifier-from-point (point)
 > >   "Extract the identifier at POINT, if any."
 > >   (save-excursion
 > >     (goto-char point)
 > >     (gud-find-c-expr)))
 > 
 > Maybe this would be safer:
 > 
 >         (if (fboundp 'gud-find-c-expr)
 >             (gud-find-c-expr)
 >           ... old tooltip-identifier-from-point code goes here ...
 >           )
 > 

`tooltip-identifier-from-point' is only used by gud so `gud-find-c-expr'
will always be defined. Actually, I think the functions that provide
the tooltips for gud should be should really be in gud.el.

 > I haven't been able to find any documentation on the "server" prefix;
 > what does it mean?  Is it related to the gdbserver program?  In that
 > case, does it change the semantics of the print command so that
 > debugging a program via gdbserver may not work properly with the change?
 > 
 > Even if it is harmless, are you sure "server print" is supported by
 > all gdb versions (do we care -- probably most systems running emacs 21.x
 > also have a fairly new version of gdb ?)

The server prefix is described in the Annotations section of the Gdb info
pages.  Annotations have been around for a long time so I presume the server
prefix has too. Eli could probably tell you more.

It has nothing to do with the gdbserver program as far as I know.

Nick

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

* Re: Two changes to tooltip.el (proposal)
  2002-11-19 19:24 Two changes to tooltip.el (proposal) Nick Roberts
  2002-11-20 11:46 ` Kim F. Storm
@ 2002-11-25 12:37 ` Richard Stallman
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2002-11-25 12:37 UTC (permalink / raw)
  Cc: emacs-devel

Please do install these changes.
In general, you may as well make whatever changes
you see fit in the tooltip support for GUD mode.

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

end of thread, other threads:[~2002-11-25 12:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-19 19:24 Two changes to tooltip.el (proposal) Nick Roberts
2002-11-20 11:46 ` Kim F. Storm
2002-11-20 23:33   ` Nick Roberts
2002-11-25 12:37 ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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