Annotation of 43BSD/contrib/emacs/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: I have included in the distribution a version of
                     16: dbx (for the Vax) which can debug GNU Emacs.
                     17: The dbx that I found installed originally has
                     18: several serious bugs that prevent it from loading
                     19: GNU Emacs and cause GNU Emacs to malfunction.
                     20: 
                     21: This debugger is the file  tdbx  in directory ../dbx.
                     22: It has the same commands that dbx standardly has.
                     23: (You may have to run  make  in that directory to create tdbx.)
                     24: 
                     25: The file .dbxinit in ../src defines some useful aliases;
                     26: it also sets up signal handling in a way that permits
                     27: GNU Emacs to work properly.
                     28: 
                     29: Some problems remain in this version of dbx.  For example, the only
                     30: useful way to print a Lisp_Object is in hex.  The only way to do this
                     31: is &variable/X.  The top two digits are the data type (with the mark
                     32: bit in the sign bit during garbage collection) and the remaining six
                     33: digits are the value or pointer.
                     34: 
                     35: The `where' command (abbreviated `w') tends to get confused
                     36: and print infinite garbage past the end of the real contents
                     37: of the stack.  Be prepared to stop it with Control-c.
                     38: 
                     39: The `stop in' command tends to get into an infinite loop.
                     40: If this happens, just type Control-c.  You will find that
                     41: the stop has been established properly.
                     42: 
                     43: If you stop a looping dbx command with Control-c, it signals
                     44: both dbx and the debugged Emacs.  As a result, the next time
                     45: you continue or step Emacs, it will stop immediately and say
                     46: "interrupt".  You must continue or step it again.
                     47: I tried to fix this, by making the debugged process run in
                     48: a different process group, but could not get it to work.
                     49: 
                     50: 
                     51: `Fsignal' is a very useful place to stop in.
                     52: All Lisp errors go through there.
                     53: 
                     54: It is useful, when debugging, to have a guaranteed way
                     55: to return to the debugger at any time.  If you are using
                     56: interrupt-drived input, which is the default, then Emacs is using
                     57: RAW mode and the only way you can do it is to store
                     58: the code for some character into the variable stop_character:
                     59: 
                     60:     set stop_character = 29
                     61: 
                     62: makes Control-] (decimal code 29) the stop character.
                     63: Typing Control-] will cause immediate stop.  You cannot
                     64: use the set command until the inferior process has been started.
                     65: Put a breakpoint early in `main', or suspend the Emacs,
                     66: to get an opportunity to do the set command.
                     67: 
                     68: If you are using cbreak input (see the Lisp function set-input-mode),
                     69: then typing Control-g will cause a SIGINT, which will return control
                     70: to dbx immediately unless you have done
                     71: 
                     72:     ignore 3
                     73: 
                     74: 
                     75: You will note that most of GNU Emacs is written to avoid
                     76: declaring a local variable in an inner block, even in
                     77: cases where using one would be the cleanest thing to do.
                     78: This is because dbx cannot access any of the variables
                     79: in a function which has even one variable defined in an
                     80: inner block.  A few functions in GNU Emacs do have variables
                     81: in inner blocks, only because I wrote them before realizing
                     82: that dbx had this problem and never rewrote them to avoid it.
                     83: 
                     84: 
                     85: dbx has many other deficiencies.  If I find that I can really
                     86: use it as part of GNU, I will fix them.  If I will have to
                     87: write another debugger, fixing dbx further is useless to me.
                     88: 
                     89: 
                     90: ** Debugging on a Sun.
                     91: 
                     92: On Sun 68000 systems, I found that no debugger could load
                     93: Emacs with a symbol table.  However, I was able to debug
                     94: by doing
                     95: 
                     96:     nm -n temacs > nmout
                     97:     strip temacs
                     98:     adb temacs
                     99:     0xd:i
                    100:     0xe:i
                    101:     14:i
                    102:     17:i
                    103:     :r -l loadup   (or whatever)
                    104: 
                    105: It is necessary to refer to the file `nmout' to convert
                    106: numeric addresses into symbols and vice versa.
                    107: 
                    108: It is useful to be running under the window system.
                    109: Then, if Emacs becomes hopelessly wedged, you can create
                    110: another window to do kill -9 in.  kill -ILL is often
                    111: useful too, since that may make Emacs dump core or return
                    112: to adb.
                    113: 
                    114: ** Debugging incorrect screen updating.
                    115: 
                    116: To debug Emacs problems that update the screen wrong, it is useful
                    117: to have a record of what input you typed and what Emacs sent to the
                    118: screen.  To make these records, do
                    119: 
                    120: (open-dribble-file "~/.dribble")
                    121: (open-termscript "~/.termscript")
                    122: 
                    123: The dribble file contains all characters read by Emacs from the
                    124: terminal, and the termscript file contains all characters it sent to
                    125: the terminal.  The use of the directory `~/' prevents interference
                    126: with any other user.
                    127: 
                    128: If you have unreproduceable display problems, put those two expressions
                    129: in your ~/.emacs file.  When the problem happens, exit the Emacs that
                    130: you were running, kill it, and rename the two files.  Then you can start
                    131: another Emacs without clobbering those files, and look at them in it.

unix.superglobalmegacorp.com

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