comparison etc/DEBUG @ 90370:e3bacb89536a

Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-46 Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 157-163) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 58-61) - Update from CVS
author Miles Bader <miles@gnu.org>
date Sun, 19 Mar 2006 19:43:57 +0000
parents c5406394f567 aed02e3a8c0f
children 138ce2701550
comparison
equal deleted inserted replaced
90369:88810aee3a45 90370:e3bacb89536a
243 243
244 and, assuming that "xtype" says that args[0] is a symbol: 244 and, assuming that "xtype" says that args[0] is a symbol:
245 245
246 xsymbol 246 xsymbol
247 247
248 ** Using GDB in Emacs
249
250 Debugging with GDB in Emacs offers some advantages over the command line (See
251 the GDB Graphical Interface node of the Emacs manual). There are also some
252 features available just for debugging Emacs:
253
254 1) The command gud-pp isavailable on the tool bar (the `pp' icon) and allows
255 the user to print the s-expression of the variable at point, in the GUD
256 buffer.
257
258 2) Pressing `p' on a component of a watch expression that is a lisp object
259 in the speedbar prints its s-expression in the GUD buffer.
260
261 3) The STOP button on the tool bar is adjusted so that it sends SIGTSTP
262 instead of the usual SIGINT.
263
264 4) The command gud-pv has the global binding 'C-x C-a C-v' and prints the
265 value of the lisp variable at point.
266
248 ** Debugging what happens while preloading and dumping Emacs 267 ** Debugging what happens while preloading and dumping Emacs
249 268
250 Type `gdb temacs' and start it with `r -batch -l loadup dump'. 269 Type `gdb temacs' and start it with `r -batch -l loadup dump'.
251 270
252 If temacs actually succeeds when running under GDB in this way, do not 271 If temacs actually succeeds when running under GDB in this way, do not
485 ** Debugging problems which happen in GC 504 ** Debugging problems which happen in GC
486 505
487 The array `last_marked' (defined on alloc.c) can be used to display up 506 The array `last_marked' (defined on alloc.c) can be used to display up
488 to 500 last objects marked by the garbage collection process. 507 to 500 last objects marked by the garbage collection process.
489 Whenever the garbage collector marks a Lisp object, it records the 508 Whenever the garbage collector marks a Lisp object, it records the
490 pointer to that object in the `last_marked' array. The variable 509 pointer to that object in the `last_marked' array, which is maintained
491 `last_marked_index' holds the index into the `last_marked' array one 510 as a circular buffer. The variable `last_marked_index' holds the
492 place beyond where the pointer to the very last marked object is 511 index into the `last_marked' array one place beyond where the pointer
493 stored. 512 to the very last marked object is stored.
494 513
495 The single most important goal in debugging GC problems is to find the 514 The single most important goal in debugging GC problems is to find the
496 Lisp data structure that got corrupted. This is not easy since GC 515 Lisp data structure that got corrupted. This is not easy since GC
497 changes the tag bits and relocates strings which make it hard to look 516 changes the tag bits and relocates strings which make it hard to look
498 at Lisp objects with commands such as `pr'. It is sometimes necessary 517 at Lisp objects with commands such as `pr'. It is sometimes necessary
499 to convert Lisp_Object variables into pointers to C struct's manually. 518 to convert Lisp_Object variables into pointers to C struct's manually.
519
500 Use the `last_marked' array and the source to reconstruct the sequence 520 Use the `last_marked' array and the source to reconstruct the sequence
501 that objects were marked. 521 that objects were marked. In general, you need to correlate the
502 522 values recorded in the `last_marked' array with the corresponding
503 Once you discover the corrupted Lisp object or data structure, it is 523 stack frames in the backtrace, beginning with the innermost frame.
504 useful to look at it in a fresh Emacs session and compare its contents 524 Some subroutines of `mark_object' are invoked recursively, others loop
505 with a session that you are debugging. 525 over portions of the data structure and mark them as they go. By
526 looking at the code of those routines and comparing the frames in the
527 backtrace with the values in `last_marked', you will be able to find
528 connections between the values in `last_marked'. E.g., when GC finds
529 a cons cell, it recursively marks its car and its cdr. Similar things
530 happen with properties of symbols, elements of vectors, etc. Use
531 these connections to reconstruct the data structure that was being
532 marked, paying special attention to the strings and names of symbols
533 that you encounter: these strings and symbol names can be used to grep
534 the sources to find out what high-level symbols and global variables
535 are involved in the crash.
536
537 Once you discover the corrupted Lisp object or data structure, grep
538 the sources for its uses and try to figure out what could cause the
539 corruption. If looking at the sources doesn;t help, you could try
540 setting a watchpoint on the corrupted data, and see what code modifies
541 it in some invalid way. (Obviously, this technique is only useful for
542 data that is modified only very rarely.)
543
544 It is also useful to look at the corrupted object or data structure in
545 a fresh Emacs session and compare its contents with a session that you
546 are debugging.
506 547
507 ** Debugging problems with non-ASCII characters 548 ** Debugging problems with non-ASCII characters
508 549
509 If you experience problems which seem to be related to non-ASCII 550 If you experience problems which seem to be related to non-ASCII
510 characters, such as \201 characters appearing in the buffer or in your 551 characters, such as \201 characters appearing in the buffer or in your