Subject: bug#13845: 24.3.50; gud commands stop responding when using gdb-mi

From: Jean-Philippe Gravel <[email-masked]>
Date: Mon, 29 Apr 2013 23:32:51 -0400

Hi,

I have a fix ready for this bug.  I just got write access to the
repository and this will be the first commit I do on my own. I would
therefore like to request a code review to make sure I got everything
right.

My branch is available on launchpad:
https://code.launchpad.net/~jpgravel/emacs/bug13845

Please consider all revisions from 112234 to 112242.  Revision 112233
is already in the trunk.

The core of this branch consists of a rework of the way pending
triggers are implemented.  The new implementation will allow easy
cleanup of dead pending triggers, whenever they are detected.  There
used to be two lists to keep track of the commands sent to gdb:
gdb-handler-alist and gdb-pending-triggers.  The first one was storing
the callback to invoke when receiving the reply form GDB, the second
was flagging some of those commands as pending, to prevent GDB from
sending the same commands until the reply is received.  With my
changes, the two lists are merged into gdb-handler-list, making it
easier to cleanly insert and remove handlers.

I thought of two ways of detecting dead pending triggers:
 1 - It seems that GDB always replies in the same order Emacs sends
commands.  Replies from GDB are therefore always received in
increasing numerical order.  Based on this observation, we can remove
old pending triggers as soon as newer replies are received from GDB.
 2 - We could add a timeout mechanism that would remove pending
triggers if no replies is received after a certain amount of time.

With this branch, I only implemented option 1, which can be
enabled/disabled using `gdb-discard-unordered-replies'.  I may
implement Option 2 in a subsequent commit.

Regarding this branch, I have three questions:
 - I needed the function cl-find-if and cl-delete-if.  It seems there
is a long history about not using the functions from cl.el at runtime.
 It also seems that lots of devs simply re-implemented those functions
in their own modules.  I couldn't find the functions I needed in a
genetic utility package (other than cl.el).  Instead, I found them
re-implemented as erc-delete-if and org-find-if.  For now, I copied
those two functions in gdb-mi.el but I can't help but wonder if there
is a place where those functions could be moved so that different
modules could share their implementation.
 - I removed two strange ^L characters in gdb-mi.el.  Am I right to
remove them?  Do they mean anything, or are they garbage ASCII
character that got there by mistake?
 - When doing my commit, do I need to specify a bug tracker with the
--fixes option, or is "--fixes 13845" enough?

Thanks,
Jean-Philippe