25853
+ ��膩��� 1 Debugging GNU Emacs
32523
+ ��膩��� 2 Copyright (c) 1985, 2000 Free Software Foundation, Inc.
25853
+ ��膩��� 3
+ ��膩��� 4 Permission is granted to anyone to make or distribute verbatim copies
+ ��膩��� 5 of this document as received, in any medium, provided that the
+ ��膩��� 6 copyright notice and permission notice are preserved,
+ ��膩��� 7 and that the distributor grants the recipient permission
+ ��膩��� 8 for further redistribution as permitted by this notice.
+ ��膩��� 9
+ ��膩��� 10 Permission is granted to distribute modified versions
+ ��膩��� 11 of this document, or of portions of it,
+ ��膩��� 12 under the above conditions, provided also that they
+ ��膩��� 13 carry prominent notices stating who last changed them.
+ ��膩��� 14
+ ��膩��� 15 ** Some useful techniques
+ ��膩��� 16
+ ��膩��� 17 `Fsignal' is a very useful place to stop in.
+ ��膩��� 18 All Lisp errors go through there.
+ ��膩��� 19
+ ��膩��� 20 It is useful, when debugging, to have a guaranteed way
+ ��膩��� 21 to return to the debugger at any time. If you are using
+ ��膩��� 22 interrupt-driven input, which is the default, then Emacs is using
+ ��膩��� 23 RAW mode and the only way you can do it is to store
+ ��膩��� 24 the code for some character into the variable stop_character:
+ ��膩��� 25
+ ��膩��� 26 set stop_character = 29
+ ��膩��� 27
+ ��膩��� 28 makes Control-] (decimal code 29) the stop character.
+ ��膩��� 29 Typing Control-] will cause immediate stop. You cannot
+ ��膩��� 30 use the set command until the inferior process has been started.
+ ��膩��� 31 Put a breakpoint early in `main', or suspend the Emacs,
+ ��膩��� 32 to get an opportunity to do the set command.
+ ��膩��� 33
+ ��膩��� 34 If you are using cbreak input (see the Lisp function set-input-mode),
+ ��膩��� 35 then typing Control-g will cause a SIGINT, which will return control
32523
+ ��膩��� 36 to GDB immediately if you type this command first:
25853
+ ��膩��� 37
32523
+ ��膩��� 38 handle 2 stop
25853
+ ��膩��� 39
+ ��膩��� 40
+ ��膩��� 41 ** Examining Lisp object values.
+ ��膩��� 42
+ ��膩��� 43 When you have a live process to debug, and it has not encountered a
+ ��膩��� 44 fatal error, you can use the GDB command `pr'. First print the value
+ ��膩��� 45 in the ordinary way, with the `p' command. Then type `pr' with no
+ ��膩��� 46 arguments. This calls a subroutine which uses the Lisp printer.
+ ��膩��� 47
+ ��膩��� 48 If you can't use this command, either because the process can't run
+ ��膩��� 49 a subroutine or because the data is invalid, you can fall back on
+ ��膩��� 50 lower-level commands.
+ ��膩��� 51
+ ��膩��� 52 Use the `xtype' command to print out the data type of the last data
+ ��膩��� 53 value. Once you know the data type, use the command that corresponds
+ ��膩��� 54 to that type. Here are these commands:
+ ��膩��� 55
+ ��膩��� 56 xint xptr xwindow xmarker xoverlay xmiscfree xintfwd xboolfwd xobjfwd
+ ��膩��� 57 xbufobjfwd xkbobjfwd xbuflocal xbuffer xsymbol xstring xvector xframe
+ ��膩��� 58 xwinconfig xcompiled xcons xcar xcdr xsubr xprocess xfloat xscrollbar
+ ��膩��� 59
+ ��膩��� 60 Each one of them applies to a certain type or class of types.
+ ��膩��� 61 (Some of these types are not visible in Lisp, because they exist only
+ ��膩��� 62 internally.)
+ ��膩��� 63
+ ��膩��� 64 Each x... command prints some information about the value, and
+ ��膩��� 65 produces a GDB value (subsequently available in $) through which you
+ ��膩��� 66 can get at the rest of the contents.
+ ��膩��� 67
+ ��膩��� 68 In general, most of the rest of the contents will be addition Lisp
+ ��膩��� 69 objects which you can examine in turn with the x... commands.
+ ��膩��� 70
+ ��膩��� 71 ** If GDB does not run and your debuggers can't load Emacs.
+ ��膩��� 72
+ ��膩��� 73 On some systems, no debugger can load Emacs with a symbol table,
+ ��膩��� 74 perhaps because they all have fixed limits on the number of symbols
+ ��膩��� 75 and Emacs exceeds the limits. Here is a method that can be used
+ ��膩��� 76 in such an extremity. Do
+ ��膩��� 77
+ ��膩��� 78 nm -n temacs > nmout
+ ��膩��� 79 strip temacs
+ ��膩��� 80 adb temacs
+ ��膩��� 81 0xd:i
+ ��膩��� 82 0xe:i
+ ��膩��� 83 14:i
+ ��膩��� 84 17:i
+ ��膩��� 85 :r -l loadup (or whatever)
+ ��膩��� 86
+ ��膩��� 87 It is necessary to refer to the file `nmout' to convert
+ ��膩��� 88 numeric addresses into symbols and vice versa.
+ ��膩��� 89
+ ��膩��� 90 It is useful to be running under a window system.
+ ��膩��� 91 Then, if Emacs becomes hopelessly wedged, you can create
+ ��膩��� 92 another window to do kill -9 in. kill -ILL is often
+ ��膩��� 93 useful too, since that may make Emacs dump core or return
+ ��膩��� 94 to adb.
+ ��膩��� 95
+ ��膩��� 96
+ ��膩��� 97 ** Debugging incorrect screen updating.
+ ��膩��� 98
+ ��膩��� 99 To debug Emacs problems that update the screen wrong, it is useful
+ ��膩��� 100 to have a record of what input you typed and what Emacs sent to the
+ ��膩��� 101 screen. To make these records, do
+ ��膩��� 102
+ ��膩��� 103 (open-dribble-file "~/.dribble")
+ ��膩��� 104 (open-termscript "~/.termscript")
+ ��膩��� 105
+ ��膩��� 106 The dribble file contains all characters read by Emacs from the
+ ��膩��� 107 terminal, and the termscript file contains all characters it sent to
+ ��膩��� 108 the terminal. The use of the directory `~/' prevents interference
+ ��膩��� 109 with any other user.
+ ��膩��� 110
+ ��膩��� 111 If you have irreproducible display problems, put those two expressions
+ ��膩��� 112 in your ~/.emacs file. When the problem happens, exit the Emacs that
+ ��膩��� 113 you were running, kill it, and rename the two files. Then you can start
+ ��膩��� 114 another Emacs without clobbering those files, and use it to examine them.