aboutsummaryrefslogtreecommitdiffstats
path: root/etc/DEBUG
diff options
context:
space:
mode:
authorEli Zaretskii2016-09-05 19:32:21 +0300
committerEli Zaretskii2016-09-05 19:32:21 +0300
commit304a5c8ef9a7ff86b85ee2b32834f72eb86e17f4 (patch)
treefb86cd473a185a1fd1ca7b10afe822c4030cc223 /etc/DEBUG
parent56bf7d7e274e1ab68c28516026d0510173c41904 (diff)
downloademacs-304a5c8ef9a7ff86b85ee2b32834f72eb86e17f4.tar.gz
emacs-304a5c8ef9a7ff86b85ee2b32834f72eb86e17f4.zip
; * etc/DEBUG: Improve documentation of getting control to GDB.
Suggested by Alain Schneble <a.s@realize.ch>.
Diffstat (limited to 'etc/DEBUG')
-rw-r--r--etc/DEBUG71
1 files changed, 49 insertions, 22 deletions
diff --git a/etc/DEBUG b/etc/DEBUG
index eef67dad500..17c41092a67 100644
--- a/etc/DEBUG
+++ b/etc/DEBUG
@@ -190,24 +190,40 @@ kick in, provided that you run under GDB.
190 190
191** Getting control to the debugger 191** Getting control to the debugger
192 192
193Setting a breakpoint in a strategic place, after loading Emacs into
194the debugger, but before running it, is the most efficient way of
195making sure control will be returned to the debugger when you need
196that.
197
193'Fsignal' is a very useful place to put a breakpoint in. All Lisp 198'Fsignal' is a very useful place to put a breakpoint in. All Lisp
194errors go through there. If you are only interested in errors that 199errors go through there. If you are only interested in errors that
195would fire the debugger, breaking at 'maybe_call_debugger' is useful. 200would fire the Lisp debugger, breaking at 'maybe_call_debugger' is
201useful.
196 202
197It is useful, when debugging, to have a guaranteed way to return to 203Another technique for get control to the debugger is to put a
198the debugger at any time. When using X, this is easy: type C-z at the 204breakpoint in some rarely used function. One such convenient function
199window where Emacs is running under GDB, and it will stop Emacs just 205is Fredraw_display, which you can invoke at will interactively with
200as it would stop any ordinary program. When Emacs is running in a 206"M-x redraw-display RET".
201terminal, things are not so easy. 207
208It is also useful to have a guaranteed way to return to the debugger
209at any arbitrary time. When using X, this is easy: type C-z at the
210window where you are interacting with GDB, and it will stop Emacs just
211as it would stop any ordinary program. When Emacs is displaying on a
212text terminal, things are not so easy, so we describe the various
213alternatives below (however, those of them that use signals only work
214on Posix systems).
202 215
203The src/.gdbinit file in the Emacs distribution arranges for SIGINT 216The src/.gdbinit file in the Emacs distribution arranges for SIGINT
204(C-g in Emacs) to be passed to Emacs and not give control back to GDB. 217(C-g in Emacs on a text-mode frame) to be passed to Emacs and not give
205On modern POSIX systems, you can override that with this command: 218control back to GDB. On modern systems, you can override that with
219this command:
206 220
207 handle SIGINT stop nopass 221 handle SIGINT stop nopass
208 222
209After this 'handle' command, SIGINT will return control to GDB. If 223After this 'handle' command, SIGINT will return control to GDB. If
210you want the C-g to cause a QUIT within Emacs as well, omit the 'nopass'. 224you want the C-g to cause a QUIT within Emacs as well, omit the 'nopass'.
225See the GDB manual for more details about signal handling and the
226'handle' command.
211 227
212A technique that can work when 'handle SIGINT' does not is to store 228A technique that can work when 'handle SIGINT' does not is to store
213the code for some character into the variable stop_character. Thus, 229the code for some character into the variable stop_character. Thus,
@@ -216,26 +232,37 @@ the code for some character into the variable stop_character. Thus,
216 232
217makes Control-] (decimal code 29) the stop character. 233makes Control-] (decimal code 29) the stop character.
218Typing Control-] will cause immediate stop. You cannot 234Typing Control-] will cause immediate stop. You cannot
219use the set command until the inferior process has been started. 235use the set command until the inferior process has been started, so
220Put a breakpoint early in 'main', or suspend the Emacs, 236start Emacs with the 'start' command, to get an opportunity to do the
221to get an opportunity to do the set command. 237above 'set' command.
222 238
223Another technique for get control to the debugger is to put a 239On a Posix host, you can also send a signal using the 'kill' command
224breakpoint in some rarely used function. One such convenient function 240from a shell prompt, like this:
225is Fredraw_display, which you can invoke at will interactively with
226"M-x redraw-display RET".
227 241
228When Emacs is running in a terminal, it is sometimes useful to use a separate 242 kill -TSTP Emacs-PID
229terminal for the debug session. This can be done by starting Emacs as usual,
230then attaching to it from gdb with the 'attach' command which is explained in
231the node "Attach" of the GDB manual.
232 243
233On MS-Windows, you can start Emacs in its own separate terminal by 244where Emacs-PID is the process ID of Emacs being debugged. Other
234setting the new-console option before running Emacs under GDB: 245useful signals to send are SIGUSR1 and SIGUSR2; see "Error Debugging"
246in the ELisp manual for how to use those.
247
248When Emacs is displaying on a text terminal, it is useful to have a
249separate terminal for the debug session. This can be done by starting
250Emacs as usual, then attaching to it from gdb with the 'attach'
251command which is explained in the node "Attach" of the GDB manual.
252
253On MS-Windows, you can alternatively start Emacs from its own separate
254console by setting the new-console option before running Emacs under
255GDB:
235 256
236 (gdb) set new-console 1 257 (gdb) set new-console 1
237 (gdb) run 258 (gdb) run
238 259
260If you do this, then typing C-c or C-BREAK into the console window
261through which you interact with GDB will stop Emacs and return control
262to the debugger, no matter if Emacs displays GUI or text-mode frames.
263This is the only reliable alternative on MS-Windows to get control to
264the debugger, besides setting breakpoints in advance.
265
239** Examining Lisp object values. 266** Examining Lisp object values.
240 267
241When you have a live process to debug, and it has not encountered a 268When you have a live process to debug, and it has not encountered a
@@ -848,7 +875,7 @@ directed to the xterm window you opened above.
848Similar arrangement is possible on a character terminal by using the 875Similar arrangement is possible on a character terminal by using the
849'screen' package. 876'screen' package.
850 877
851On MS-Windows, you can start Emacs in its own separate terminal by 878On MS-Windows, you can start Emacs in its own separate console by
852setting the new-console option before running Emacs under GDB: 879setting the new-console option before running Emacs under GDB:
853 880
854 (gdb) set new-console 1 881 (gdb) set new-console 1