help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gud keybindings


From: Yuri Khan
Subject: Re: Gud keybindings
Date: Thu, 14 Aug 2014 10:48:37 +0700

On Thu, Aug 14, 2014 at 2:14 AM, Emanuel Berg <embe8573@student.uu.se> wrote:
> Yuri Khan <yuri.v.khan@gmail.com> writes:
>
>> * What would I need to do if I wanted to implement
>> single-letter key bindings for Gud commands? Define a
>> minor mode with an appropriate keymap that sets
>> buffer-read-only when enabled and restores it when
>> disabled? How do I arrange for this mode to be
>> enabled when visiting any source buffer if and only
>> if Gud is active?
>
> For what modes do you want it?

Major modes, you mean? Ideally, this is not dependent on mode but on
whether the buffer visits a file that is a source of the program
currently being debugged. (Which might involve C++, plain C, and any
other languages that are compiled to standard .o files with
gdb-compatible debug info.) I think I would settle for just all
c++-mode buffers while Gud is active, but this has to include both
buffers that were opened before Gud is started and new buffers spawned
while debugging.

> For one or but a few, how about binding the self-insert
> keys to either self-insert, or, if buffer-read-only (or
> `Gud-alive-p' if such a predicate exists - otherwise
> write it). I don't think that'll be too slow/much work
> for just a couple of keys.

That would work but is inelegant. Here in C++ world, we don’t pay for
what we don’t use — having each keypress of “s” check if Gud is active
runs very much counter to that principle.

> If it is, you can write a defun, we-are-debugging which
> rebinds the keys, and correspondingly no-bugs-left to
> reset. You can automatize this second part like, if a
> non-debug key is pressed, it is not only self-inserted,
> it also disables the debugging keys.

This equates to a global minor mode, doesn’t it?

And no, I don’t want to get out of debugging if I inadvertently press
an editing key. Editing sources of the program being debugged can
cause much confusion.


>> I am trying to debug C++ programs using Emacs, Gud
>> and GDB. This involves setting breakpoints, stepping
>> through and over function calls, and examining
>> variables.
>
> Yeah, you got GDB to work with C++ on Linux? I asked
> about it on gnu.gdb.bug and it seems the post is
> archived here:

For me, it has always worked out of the box (except that printing
standard containers is not pretty, and evaluating any expressions that
involve inlineable functions may fail because their code is optimized
out of the binary).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]