all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* highlight current source line during debugging
@ 2013-02-04 22:21 John Yates
  2013-02-05 10:11 ` Stephen Berman
  0 siblings, 1 reply; 5+ messages in thread
From: John Yates @ 2013-02-04 22:21 UTC (permalink / raw)
  To: help-gnu-emacs

When debugging I get a small triangular arrow in the left fringe.
Especially when stepping through disassembled machine instructions it
would be a big help to have the entire current line high lighted in
some fashion.  Can anyone suggest a solution?

/john

(Not subscribed so please include my email address in any reply.)



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

* Re: highlight current source line during debugging
  2013-02-04 22:21 highlight current source line during debugging John Yates
@ 2013-02-05 10:11 ` Stephen Berman
  2013-02-05 14:56   ` John Yates
       [not found]   ` <mailman.19067.1360076660.855.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Stephen Berman @ 2013-02-05 10:11 UTC (permalink / raw)
  To: John Yates; +Cc: help-gnu-emacs

On Mon, 4 Feb 2013 17:21:18 -0500 John Yates <john@yates-sheets.org> wrote:

> When debugging I get a small triangular arrow in the left fringe.
> Especially when stepping through disassembled machine instructions it
> would be a big help to have the entire current line high lighted in
> some fashion.  Can anyone suggest a solution?

A useful package for this is hl-line.  How you use it might depend on
what kind of program you are debugging and what debugger you are using.
As an example, here's how you could get it for Emacs Lisp code using Edebug:

(defadvice edebug-overlay-arrow (around highlight-line activate)
  "Highlight line currently being edebugged."
  (require 'hl-line)
  (hl-line-mode)
  ad-do-it)

(defun my-edebug-quit ()
  "Stop edebugging and remove highlighting."
  (interactive)
  (hl-line-mode -1)
  (top-level))

(define-key edebug-mode-map [remap top-level] 'my-edebug-quit)

HTH

Steve Berman



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

* Re: highlight current source line during debugging
  2013-02-05 10:11 ` Stephen Berman
@ 2013-02-05 14:56   ` John Yates
  2013-02-05 22:36     ` Stephen Berman
       [not found]   ` <mailman.19067.1360076660.855.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 5+ messages in thread
From: John Yates @ 2013-02-05 14:56 UTC (permalink / raw)
  To: Stephen Berman; +Cc: help-gnu-emacs

Hi Stephen,

Thanks for this suggestion.  To implement it seems to require that one
know the name of the elisp function which places the overlay arrow.  I
have been having a hard time figuring this out for gdb disassembly
buffers.

Performing cleanup based on an event in the buffer seems fragile.
Would it not be better to hook buffer destruction?

Finally, does this technique keep the line high lighted even when the
buffer is not selected?  In a normal debugging session it is the
buffer with the gdb prompt that is selected most of the time.

/john

On Tue, Feb 5, 2013 at 4:11 AM, Stephen Berman <stephen.berman@gmx.net> wrote:
> On Mon, 4 Feb 2013 17:21:18 -0500 John Yates <john@yates-sheets.org> wrote:
>
>> When debugging I get a small triangular arrow in the left fringe.
>> Especially when stepping through disassembled machine instructions it
>> would be a big help to have the entire current line high lighted in
>> some fashion.  Can anyone suggest a solution?
>
> A useful package for this is hl-line.  How you use it might depend on
> what kind of program you are debugging and what debugger you are using.
> As an example, here's how you could get it for Emacs Lisp code using Edebug:
>
> (defadvice edebug-overlay-arrow (around highlight-line activate)
>   "Highlight line currently being edebugged."
>   (require 'hl-line)
>   (hl-line-mode)
>   ad-do-it)
>
> (defun my-edebug-quit ()
>   "Stop edebugging and remove highlighting."
>   (interactive)
>   (hl-line-mode -1)
>   (top-level))
>
> (define-key edebug-mode-map [remap top-level] 'my-edebug-quit)
>
> HTH
>
> Steve Berman



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

* Re: highlight current source line during debugging
       [not found]   ` <mailman.19067.1360076660.855.help-gnu-emacs@gnu.org>
@ 2013-02-05 15:16     ` Sebastien Vauban
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastien Vauban @ 2013-02-05 15:16 UTC (permalink / raw)
  To: help-gnu-emacs-mXXj517/zsQ

Hi John and Stephen,

John Yates wrote:
> On Tue, Feb 5, 2013 at 4:11 AM, Stephen Berman <stephen.berman-hi6Y0CQ0nG0@public.gmane.org> wrote:
>> On Mon, 4 Feb 2013 17:21:18 -0500 John Yates <john-PO2BLuPRH6jaffYhi5Xx8Q@public.gmane.org> wrote:
>>
>>> When debugging I get a small triangular arrow in the left fringe.
>>> Especially when stepping through disassembled machine instructions it
>>> would be a big help to have the entire current line high lighted in
>>> some fashion.  Can anyone suggest a solution?
>>
>> A useful package for this is hl-line.  How you use it might depend on
>> what kind of program you are debugging and what debugger you are using.
>> As an example, here's how you could get it for Emacs Lisp code using Edebug:
>>
>> (defadvice edebug-overlay-arrow (around highlight-line activate)
>>   "Highlight line currently being edebugged."
>>   (require 'hl-line)
>>   (hl-line-mode)
>>   ad-do-it)
>>
>> (defun my-edebug-quit ()
>>   "Stop edebugging and remove highlighting."
>>   (interactive)
>>   (hl-line-mode -1)
>>   (top-level))
>>
>> (define-key edebug-mode-map [remap top-level] 'my-edebug-quit)
>
> Thanks for this suggestion.  To implement it seems to require that one
> know the name of the elisp function which places the overlay arrow.  I
> have been having a hard time figuring this out for gdb disassembly
> buffers.
>
> Performing cleanup based on an event in the buffer seems fragile.
> Would it not be better to hook buffer destruction?
>
> Finally, does this technique keep the line high lighted even when the
> buffer is not selected?  In a normal debugging session it is the
> buffer with the gdb prompt that is selected most of the time.

You could have a look at for another (?) solution (see last entry):

  http://www.emacswiki.org/emacs/DebuggingWithEmacs

BTW, I've the same wish for EDebug. Don't know whether that code can be
adapted to serve so.

Best regards,
  Seb

-- 
Sebastien Vauban


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

* Re: highlight current source line during debugging
  2013-02-05 14:56   ` John Yates
@ 2013-02-05 22:36     ` Stephen Berman
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Berman @ 2013-02-05 22:36 UTC (permalink / raw)
  To: John Yates; +Cc: help-gnu-emacs

On Tue, 5 Feb 2013 08:56:38 -0600 John Yates <john@yates-sheets.org> wrote:

> Thanks for this suggestion.  To implement it seems to require that one
> know the name of the elisp function which places the overlay arrow.  I
> have been having a hard time figuring this out for gdb disassembly
> buffers.

I'm not familiar with these, nor with the code for them, but glancing at
gdb-mi.el it looks like the overlay arrow is set in
gdb-disassembly-handler-custom, though I can't tell whether you can
advise this to get line highlighting.  I also notice that gud.el appears
to provide support for hl-line (see gud-display-line), so maybe that can
be adapted to gdb disassembly buffers.

> Performing cleanup based on an event in the buffer seems fragile.

Do you mean the way I remapped top-level?  This is just what is bound to
`q' in edebug-mode-map.  When I'm debugging elisp code, I often quit
when I've found the bug, so this is a natural point to remove
highlighting.  The code I posted doesn't remove highlighting when the
instrumented function returns, but the following does (this is rather
heavy-handed, but I can't think of a better way at the moment):

(defun my-edebug-finish ()
  "Finish edebugging and remove highlighting."
  (interactive)
  (unless edebug-active
    (hl-line-mode -1)))

(add-hook 'post-command-hook 'my-edebug-finish)

> Would it not be better to hook buffer destruction?

Well, if you kill the buffer you're debugging, that will automatically
end hl-line-mode, which is buffer-local, so in that case there's nothing
more to clean up.  My approach provides highlighting only while
debugging, so when you're finished (or quit in the middle), you still
have the code buffer but no more highlighting.

> Finally, does this technique keep the line high lighted even when the
> buffer is not selected?  In a normal debugging session it is the
> buffer with the gdb prompt that is selected most of the time.

The highlighting remains until removed by (hl-line-mode -1), even when
the buffer is not current.

Steve Berman



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

end of thread, other threads:[~2013-02-05 22:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-04 22:21 highlight current source line during debugging John Yates
2013-02-05 10:11 ` Stephen Berman
2013-02-05 14:56   ` John Yates
2013-02-05 22:36     ` Stephen Berman
     [not found]   ` <mailman.19067.1360076660.855.help-gnu-emacs@gnu.org>
2013-02-05 15:16     ` Sebastien Vauban

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.