unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Emacs 24 Debugger for Former Emacs 23 Debugger Users
@ 2015-06-11 19:36 Richard Wordingham
  2015-06-12  9:30 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Wordingham @ 2015-06-11 19:36 UTC (permalink / raw)
  To: help-gnu-emacs

Emacs 23 make a pleasant GUI for simple debugging of single-threaded C
programs.  I would like to be able to pleasantly debug programs in
later versions of Emacs.  My immediate target is Emacs 24.4, for am I
running that with patches to enable me to work with 'complex text' as
the text-rendering fraternity call it.  (I don't know if these patches
are in Emacs 25.)  So far, Emacs seems to give me the best terminal
window for complex text as well.  However, the Emacs 24.4 debugger
takes time to master, and I don't use it enough to learn and remember a
lot about the debugger.  I would appreciate some help.

The debugging flow when I have a good ideas as to where the bug is
coming from is simple with Emacs 23.  For example:

* Emacs 23 - Productive Experience *

emacs23 -Q& # OK, -Q cripples me.  It's just to keep Eli happy.
M-x gdb

I get prompt 'Run gdb (like this): gdb --annotate=3 cegrep'.  This
seems fine, as I am debugging program cegrep and am in the directory
containing the executable and its source code.  I hit return.  At the
end of the start-up messages I see the important message 'Reading
symbols from /home/richard/unicode/regex/cegrep...done.'; I know I have
successfully loaded the program I want to debug.

The sole frame is now visiting buffer *gud-cegrep*. 

Now I proceed to set a breakpoint just before where the program seems
to go wrong:

C-x 5 2 ; Open a new frame
C-x C-f cegrep.c ; Use the frame to visit the file with the bug.  I
have a ribbon of debugger command icons at the top of the frame.  The
windowing system gives the frame the title 'cegrep.c', which is also
reassuring.

I then use the vanilla navigation commands to scroll to where I want to
set break.  I  left click in the 'fringe' to the left of the line I want
to break to, between the text and the scroll bar on the left, and a red
dot appears.  This is a very useful way of seeing where the break points
are.

I then switch back to frame labelled *gud-cegrep* and, at the (gdb)
prompt, issue my command to start the program:

run -A1 the cegrep.c ; I know, a bit incestuous using the source code
                     ; as input data.

The *gud-cegrep* frame loses focus; focus switches to the cegrep.c
frame, and a black triangle shows that the program is at the break
point.  I then click the 'next-line' icon in the frames window.  The
program advance to the statement on the next line, which is 'break'.  I
then click the icon again.  The program advances to a line outside the
window, and the window scrolls to follow the program counter.

I now want to read a variable's value in hex, so I switch focus to the
gud-cegrep frame and enter the command print/x *optr.  The value is
displayed in the gud-cegrep frame, which continues to hold a single
window, visiting buffer *gud-cegrep*.  The frame displaying the buffer
cegrep.c remains unchanged.

All this works fine, well at least if your monitor(s) can display
several frames side by side.

* Emacs 24 - Naive Attempt. *

For this I run GNU Emacs 24.4.5 built from the tarball using the key
command 
../configure –with-x-toolkit –prefix=/opt/local

Fire it up: /opt/local/bin/emacs -Q&
M-x gdb

I get prompt 'Run gdb (like this): gdb -i=mi cegrep'.  This
seems fine, as I am debugging program cegrep and am in the directory
containing the executable and its source code.  I hit return.  At the
end of the start-up messages I see the important message 'Reading
symbols from /home/richard/unicode/regex/cegrep...done.'; I know I have
successfully loaded the program I want to debug.

C-x 5 2 ; Open a new frame
C-x C-f cegrep.c ; Use the frame to visit the file with the bug.  I
have a ribbon of debugger command icons at the top of the frame.  The
windowing system gives the frame the title 'cegrep.c', which is also
reassuring.

I then use the vanilla navigation commands to scroll to where I want to
set break.  I  left click in the 'fringe' to the left of the line I want
to break to, to the left of the text, and, as before,  a red dot
appears. (The scroll bar is on the right now, but that's probably
nothing to do with Emacs.)

I then switch back to frame labelled *gud-cegrep* and, at the (gdb)
prompt, issue my command to start the program:

run -A1 the cegrep.c

First shock - I lose half the *gud-cegrep* frame to another window
displaying cegrep.c.  Focus goes to the window displaying buffer
*gud-cegrep*.  In both windows, the black triangular pointer shows
that the program is at the break point.

I switch focus back to the cegrep.c frame, and click on the 'next line'
button, which now has both text and an icon.  That visibly advances the
program position to the next line in both windows displaying buffer
cegrep.c.  I click again, and the program position disappears out of
view in both windows.  The windows do not scroll.

Perhaps I am not supposed to control program advance from my preferred
frame.  So I go back to the gud-cegrep frame, and reissue the command

run -A1 the cegrep.c

This restores the break point and current program location to both
windows. I click next-line twice, and the small window for the source
file in the *gud-cegrep* frame scrolls to show the place of
execution. This is unpleasant. 

* Discussion and Questions *

Now, Eli Zaretski told me that the old gud-gdb interface is still
available in Emacs 24, but my experience with trying to use that was
going to be another horror story. (OK, maybe it isn't really a horror
story until I put my fist through the monitor.  I am already tensed up
when I have to resort to the debugger.)  However, I was using the
enhanced gdb interface in Emacs 23, so gud-gdb isn't what I wanted.

Now, I do know the command goto-line, so I could get used to debugging
with Emacs 24 once I could no longer maintain Emacs 23 just as a
debugger.  It is possible to scroll the large source window by copying
the line number.  It also appears that there is a "GUD, refresh" menu
command that will do the scrolling more simply.  The command's default
binding is C-x C-a C-l (is the memonic "HAL!"?), but fortunately the
command name gud-refresh is memorable.

However, is there any way to make the window scroll automatically? Even
better, to also stop the frame I am working in from losing focus.  Have
I encountered a bug?

Richard.















emacs 










The base operating system is 



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

end of thread, other threads:[~2015-06-12  9:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-11 19:36 Emacs 24 Debugger for Former Emacs 23 Debugger Users Richard Wordingham
2015-06-12  9:30 ` Eli Zaretskii

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