Improve release doc slightly.
[deliverable/binutils-gdb.git] / gdb / doc / gdb.emacs-m4
CommitLineData
9bcc06ef
RP
1_dnl__ -*- Texinfo -*-
2_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc.
3_dnl__ This file is part of the source for the GDB manual.
16e58d91 4@c M4 FRAGMENT: $Id$
9bcc06ef
RP
5@node Emacs, _GDBN__ Bugs, Sequences, Top
6@chapter Using _GDBN__ under GNU Emacs
7
8@cindex emacs
9A special interface allows you to use GNU Emacs to view (and
10edit) the source files for the program you are debugging with
11_GDBN__.
12
13To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the
14executable file you want to debug as an argument. This command starts
15_GDBN__ as a subprocess of Emacs, with input and output through a newly
16created Emacs buffer.
17
18Using _GDBN__ under Emacs is just like using _GDBN__ normally except for two
19things:
20
21@itemize @bullet
22@item
23All ``terminal'' input and output goes through the Emacs buffer.
24@end itemize
25
26This applies both to _GDBN__ commands and their output, and to the input
27and output done by the program you are debugging.
28
29This is useful because it means that you can copy the text of previous
30commands and input them again; you can even use parts of the output
31in this way.
32
33All the facilities of Emacs' Shell mode are available for this purpose.
34
35@itemize @bullet
36@item
37_GDBN__ displays source code through Emacs.
38@end itemize
39
40Each time _GDBN__ displays a stack frame, Emacs automatically finds the
41source file for that frame and puts an arrow (_0__@samp{=>}_1__) at the
42left margin of the current line. Emacs uses a separate buffer for
43source display, and splits the window to show both your _GDBN__ session
44and the source.
45
46Explicit _GDBN__ @code{list} or search commands still produce output as
47usual, but you probably will have no reason to use them.
48
49@quotation
50@emph{Warning:} If the directory where your program resides is not your
51current directory, it can be easy to confuse Emacs about the location of
52the source files, in which case the auxiliary display buffer will not
53appear to show your source. _GDBN__ can find programs by searching your
54environment's @code{PATH} variable, so the _GDBN__ input and output
55session will proceed normally; but Emacs doesn't get enough information
56back from _GDBN__ to locate the source files in this situation. To
57avoid this problem, either start _GDBN__ mode from the directory where
58your program resides, or specify a full path name when prompted for the
59@kbd{M-x gdb} argument.
60
61A similar confusion can result if you use the _GDBN__ @code{file} command to
62switch to debugging a program in some other location, from an existing
63_GDBN__ buffer in Emacs.
64@end quotation
65
66By default, @kbd{M-x gdb} calls the program called @file{gdb}. If
67you need to call _GDBN__ by a different name (for example, if you keep
68several configurations around, with different names) you can set the
69Emacs variable @code{gdb-command-name}; for example,
70@example
71(setq gdb-command-name "mygdb")
72@end example
73@noindent
74(preceded by @kbd{ESC ESC}, or typed in the @code{*scratch*} buffer, or
75in your @file{.emacs} file) will make Emacs call the program named
76``@code{mygdb}'' instead.
77
78In the _GDBN__ I/O buffer, you can use these special Emacs commands in
79addition to the standard Shell mode commands:
80
81@table @kbd
82@item C-h m
83Describe the features of Emacs' _GDBN__ Mode.
84
85@item M-s
86Execute to another source line, like the _GDBN__ @code{step} command; also
87update the display window to show the current file and location.
88
89@item M-n
90Execute to next source line in this function, skipping all function
91calls, like the _GDBN__ @code{next} command. Then update the display window
92to show the current file and location.
93
94@item M-i
95Execute one instruction, like the _GDBN__ @code{stepi} command; update
96display window accordingly.
97
98@item M-x gdb-nexti
99Execute to next instruction, using the _GDBN__ @code{nexti} command; update
100display window accordingly.
101
102@item C-c C-f
103Execute until exit from the selected stack frame, like the _GDBN__
104@code{finish} command.
105
106@item M-c
107Continue execution of the program, like the _GDBN__ @code{continue}
108command. @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-p}.
109
110@item M-u
111Go up the number of frames indicated by the numeric argument
112(@pxref{Arguments, , Numeric Arguments, emacs, The GNU Emacs Manual}),
113like the _GDBN__ @code{up} command. @emph{Warning:} In Emacs v19, this
114command is @kbd{C-c C-u}.@refill
115
116@item M-d
117Go down the number of frames indicated by the numeric argument, like the
118_GDBN__ @code{down} command. @emph{Warning:} In Emacs v19, this command
119is @kbd{C-c C-d}.
120
121@item C-x &
122Read the number where the cursor is positioned, and insert it at the end
123of the _GDBN__ I/O buffer. For example, if you wish to disassemble code
124around an address that was displayed earlier, type @kbd{disassemble};
125then move the cursor to the address display, and pick up the
126argument for @code{disassemble} by typing @kbd{C-x &}.
127
128You can customize this further on the fly by defining elements of the list
129@code{gdb-print-command}; once it is defined, you can format or
130otherwise process numbers picked up by @kbd{C-x &} before they are
131inserted. A numeric argument to @kbd{C-x &} will both flag that you
132wish special formatting, and act as an index to pick an element of the
133list. If the list element is a string, the number to be inserted is
134formatted using the Emacs function @code{format}; otherwise the number
135is passed as an argument to the corresponding list element.
136
137@end table
138
139In any source file, the Emacs command @kbd{C-x SPC} (@code{gdb-break})
140tells _GDBN__ to set a breakpoint on the source line point is on.
141
142If you accidentally delete the source-display buffer, an easy way to get
143it back is to type the command @code{f} in the _GDBN__ buffer, to
144request a frame display; when you run under Emacs, this will recreate
145the source buffer if necessary to show you the context of the current
146frame.
147
148The source files displayed in Emacs are in ordinary Emacs buffers
149which are visiting the source files in the usual way. You can edit
150the files with these buffers if you wish; but keep in mind that _GDBN__
151communicates with Emacs in terms of line numbers. If you add or
152delete lines from the text, the line numbers that _GDBN__ knows will cease
153to correspond properly to the code.
154
155@c The following dropped because Epoch is nonstandard. Reactivate
156@c if/when v19 does something similar. ---pesch@cygnus.com 19dec1990
157@ignore
158@kindex emacs epoch environment
159@kindex epoch
160@kindex inspect
161
162Version 18 of Emacs has a built-in window system called the @code{epoch}
163environment. Users of this environment can use a new command,
164@code{inspect} which performs identically to @code{print} except that
165each value is printed in its own window.
166@end ignore
This page took 0.063982 seconds and 4 git commands to generate.