
D-52
Motorola DSP56000 Family Optimizing C Compiler User’s Manual
For More Information On This Product,
Go to: www.freescale.com
Motorola
Using GDB under GNU Emacs
D.15 Using GDB under GNU Emacs
A special interface allows you to use GNU Emacs to view (and edit) the source files for
the program you are debugging with GDB.
To use this interface, use the command M-x gdb in Emacs. Give the executable file you
want to debug as an argument. This command starts GDB as a subprocess of Emacs, with
input and output through a newly created Emacs buffer.
Using GDB under Emacs is just like using GDB normally except for two things:
All “terminal” input and output goes through the Emacs buffer. This applies both to
GDB commands and their output, and to the input and output done by the program
you are debugging.
This is useful because it means that you can copy the text of previous commands
and input them again; you can even use parts of the output in this way.
All the facilities of Emacs’s Shell mode are available for this purpose.
GDB displays source code through Emacs. Each time GDB displays a stack frame,
Emacs automatically finds the source file for that frame and puts an arrow (‘=>’) at
the left margin of the current line.
Explicit GDB ‘list’ or search commands still produce output as usual, but you probably
will have no reason to use them.
In the GDB I/O buffer, you can use these special Emacs commands as listed in Table
D-27:
Table D-27. Emac Commands
Commands
Description
M-s
Execute to another source line, like the GDB ‘step’ command.
M-n
Execute to next source line in this function, skipping all function calls, like the GDB ‘next’
command.
M-i
Execute one instruction, like the GDB ‘stepi’ command.
C-c C-f
Execute until exit from the selected stack frame, like the GDB ‘finish’ command.
M-c
Continue execution of the program, like the GDB ‘cont’ command.
M-u
Go up the number of frames indicated by the numeric argument (see section Arguments,
Numeric Arguments, emacs, The GNU Emacs Manual), like the GDB ‘up’ command.
M-d
Go down the number of frames indicated by the numeric argument, like the GDB ‘down’
command.
F
Freescale Semiconductor, Inc.
n
.