Annotation of 43BSDReno/contrib/emacs-18.55/etc/DEBUG, revision 1.1.1.1

1.1       root        1: Debugging GNU Emacs
                      2: Copyright (c) 1985 Richard M. Stallman.
                      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: On 4.2 you will probably find that dbx does not work for
                     16: debugging GNU Emacs.  For one thing, dbx does not keep the
                     17: inferior process's terminal modes separate from its own.
                     18: For another, dbx does not put the inferior in a separate
                     19: process group, which makes trouble when an inferior uses
                     20: interrupt input, which GNU Emacs must do on 4.2.
                     21: 
                     22: dbx has also been observed to have other problems,
                     23: such as getting incorrect values for register variables
                     24: in stack frames other than the innermost one.
                     25: 
                     26: The Emacs distribution now contains GDB, the new source-level
                     27: debugger for the GNU system.  GDB works for debugging Emacs.
                     28: GDB currently runs on vaxes under 4.2 and on Sun 2 and Sun 3
                     29: systems.
                     30: 
                     31: 
                     32: ** Some useful techniques
                     33: 
                     34: `Fsignal' is a very useful place to stop in.
                     35: All Lisp errors go through there.
                     36: 
                     37: It is useful, when debugging, to have a guaranteed way
                     38: to return to the debugger at any time.  If you are using
                     39: interrupt-drived input, which is the default, then Emacs is using
                     40: RAW mode and the only way you can do it is to store
                     41: the code for some character into the variable stop_character:
                     42: 
                     43:     set stop_character = 29
                     44: 
                     45: makes Control-] (decimal code 29) the stop character.
                     46: Typing Control-] will cause immediate stop.  You cannot
                     47: use the set command until the inferior process has been started.
                     48: Put a breakpoint early in `main', or suspend the Emacs,
                     49: to get an opportunity to do the set command.
                     50: 
                     51: If you are using cbreak input (see the Lisp function set-input-mode),
                     52: then typing Control-g will cause a SIGINT, which will return control
                     53: to the debugger immediately unless you have done
                     54: 
                     55:     ignore 3  (in dbx)
                     56: or  handle 3 nostop noprint  (in gdb)
                     57: 
                     58: You will note that most of GNU Emacs is written to avoid
                     59: declaring a local variable in an inner block, even in
                     60: cases where using one would be the cleanest thing to do.
                     61: This is because dbx cannot access any of the variables
                     62: in a function which has even one variable defined in an
                     63: inner block.  A few functions in GNU Emacs do have variables
                     64: in inner blocks, only because I wrote them before realizing
                     65: that dbx had this problem and never rewrote them to avoid it.
                     66: 
                     67: I believe that GDB does not have such a problem.
                     68: 
                     69: 
                     70: ** If GDB does not run and your debuggers can't load Emacs.
                     71: 
                     72: On some systems, no debugger can load Emacs with a symbol table,
                     73: perhaps because they all have fixed limits on the number of symbols
                     74: and Emacs exceeds the limits.  Here is a method that can be used
                     75: in such an extremity.  Do
                     76: 
                     77:     nm -n temacs > nmout
                     78:     strip temacs
                     79:     adb temacs
                     80:     0xd:i
                     81:     0xe:i
                     82:     14:i
                     83:     17:i
                     84:     :r -l loadup   (or whatever)
                     85: 
                     86: It is necessary to refer to the file `nmout' to convert
                     87: numeric addresses into symbols and vice versa.
                     88: 
                     89: It is useful to be running under a window system.
                     90: Then, if Emacs becomes hopelessly wedged, you can create
                     91: another window to do kill -9 in.  kill -ILL is often
                     92: useful too, since that may make Emacs dump core or return
                     93: to adb.
                     94: 
                     95: 
                     96: ** Debugging incorrect screen updating.
                     97: 
                     98: To debug Emacs problems that update the screen wrong, it is useful
                     99: to have a record of what input you typed and what Emacs sent to the
                    100: screen.  To make these records, do
                    101: 
                    102: (open-dribble-file "~/.dribble")
                    103: (open-termscript "~/.termscript")
                    104: 
                    105: The dribble file contains all characters read by Emacs from the
                    106: terminal, and the termscript file contains all characters it sent to
                    107: the terminal.  The use of the directory `~/' prevents interference
                    108: with any other user.
                    109: 
                    110: If you have unreproduceable display problems, put those two expressions
                    111: in your ~/.emacs file.  When the problem happens, exit the Emacs that
                    112: you were running, kill it, and rename the two files.  Then you can start
                    113: another Emacs without clobbering those files, and use it to examine them.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.