comparison etc/DEBUG @ 71445:241a58942caf

Mention `pv variable' to print value of Lisp variables. Mention `xpr' and fix example to use it. Add section describing commands such as `pit' that are useful for debugging redisplay related problems.
author Kim F. Storm <storm@cua.dk>
date Fri, 23 Jun 2006 14:37:10 +0000
parents aed02e3a8c0f
children 8c249825e7f3
comparison
equal deleted inserted replaced
71444:6379f5eeecbd 71445:241a58942caf
82 in the ordinary way, with the `p' command. Then type `pr' with no 82 in the ordinary way, with the `p' command. Then type `pr' with no
83 arguments. This calls a subroutine which uses the Lisp printer. 83 arguments. This calls a subroutine which uses the Lisp printer.
84 84
85 You can also use `pp value' to print the emacs value directly. 85 You can also use `pp value' to print the emacs value directly.
86 86
87 Note: It is not a good idea to try `pr' or `pp' if you know that Emacs 87 To see the current value of a Lisp Variable, use `pv variable'.
88
89 Note: It is not a good idea to try `pr', `pp', or `pv' if you know that Emacs
88 is in deep trouble: its stack smashed (e.g., if it encountered SIGSEGV 90 is in deep trouble: its stack smashed (e.g., if it encountered SIGSEGV
89 due to stack overflow), or crucial data structures, such as `obarray', 91 due to stack overflow), or crucial data structures, such as `obarray',
90 corrupted, etc. In such cases, the Emacs subroutine called by `pr' 92 corrupted, etc. In such cases, the Emacs subroutine called by `pr'
91 might make more damage, like overwrite some data that is important for 93 might make more damage, like overwrite some data that is important for
92 debugging the original problem. 94 debugging the original problem.
95 Emacs while it was inside `select'. This is in fact what happens if 97 Emacs while it was inside `select'. This is in fact what happens if
96 you stop Emacs while it is waiting. In such a situation, don't try to 98 you stop Emacs while it is waiting. In such a situation, don't try to
97 use `pr'. Instead, use `s' to step out of the system call. Then 99 use `pr'. Instead, use `s' to step out of the system call. Then
98 Emacs will be between instructions and capable of handling `pr'. 100 Emacs will be between instructions and capable of handling `pr'.
99 101
100 If you can't use `pr' command, for whatever reason, you can fall back 102 If you can't use `pr' command, for whatever reason, you can use the
101 on lower-level commands. Use the `xtype' command to print out the 103 `xpr' command to print out the data type and value of the last data
102 data type of the last data value. Once you know the data type, use 104 value, For example:
103 the command that corresponds to that type. Here are these commands: 105
106 p it->object
107 xpr
108
109 You may also analyze data values using lower-level commands. Use the
110 `xtype' command to print out the data type of the last data value.
111 Once you know the data type, use the command that corresponds to that
112 type. Here are these commands:
104 113
105 xint xptr xwindow xmarker xoverlay xmiscfree xintfwd xboolfwd xobjfwd 114 xint xptr xwindow xmarker xoverlay xmiscfree xintfwd xboolfwd xobjfwd
106 xbufobjfwd xkbobjfwd xbuflocal xbuffer xsymbol xstring xvector xframe 115 xbufobjfwd xkbobjfwd xbuflocal xbuffer xsymbol xstring xvector xframe
107 xwinconfig xcompiled xcons xcar xcdr xsubr xprocess xfloat xscrollbar 116 xwinconfig xcompiled xcons xcar xcdr xsubr xprocess xfloat xscrollbar
108 117
130 139
131 Then Emacs hits the breakpoint: 140 Then Emacs hits the breakpoint:
132 141
133 (gdb) p frame 142 (gdb) p frame
134 $1 = 139854428 143 $1 = 139854428
135 (gdb) xtype 144 (gdb) xpr
136 Lisp_Vectorlike 145 Lisp_Vectorlike
137 PVEC_FRAME 146 PVEC_FRAME
138 (gdb) xframe
139 $2 = (struct frame *) 0x8560258 147 $2 = (struct frame *) 0x8560258
148 "emacs@localhost"
140 (gdb) p *$ 149 (gdb) p *$
141 $3 = { 150 $3 = {
142 size = 1073742931, 151 size = 1073742931,
143 next = 0x85dfe58, 152 next = 0x85dfe58,
144 name = 140615219, 153 name = 140615219,
145 [...] 154 [...]
146 } 155 }
147 (gdb) p $3->name 156
148 $4 = 140615219 157 Now we can use `pr' to print the frame parameters:
149 158
150 Now we can use `pr' to print the name of the frame: 159 (gdb) pp $->param_alist
151 160 ((background-mode . light) (display-type . color) [...])
152 (gdb) pr 161
153 "emacs@steenrod.math.nwu.edu"
154 162
155 The Emacs C code heavily uses macros defined in lisp.h. So suppose 163 The Emacs C code heavily uses macros defined in lisp.h. So suppose
156 we want the address of the l-value expression near the bottom of 164 we want the address of the l-value expression near the bottom of
157 `add_command_key' from keyboard.c: 165 `add_command_key' from keyboard.c:
158 166
242 xtype 250 xtype
243 251
244 and, assuming that "xtype" says that args[0] is a symbol: 252 and, assuming that "xtype" says that args[0] is a symbol:
245 253
246 xsymbol 254 xsymbol
255
256 ** Debugging Emacs Redisplay problems
257
258 The src/.gdbinit file defines many useful commands for dumping redisplay
259 related data structures in a terse and user-friendly format:
260
261 `ppt' prints value of PT, narrowing, and gap in current buffer.
262 `pit' dumps the current display iterator `it'.
263 `pwin' dumps the current window 'win'.
264 `prow' dumps the current glyph_row `row'.
265 `pg' dumps the current glyph `glyph'.
266 `pgi' dumps the next glyph.
267 `pgrow' dumps all glyphs in current glyph_row `row'.
268 `pcursor' dumps current output_cursor.
269
270 The above commands also exist in a version with an `x' suffix which
271 takes an object of the relevant type as argument.
247 272
248 ** Using GDB in Emacs 273 ** Using GDB in Emacs
249 274
250 Debugging with GDB in Emacs offers some advantages over the command line (See 275 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 276 the GDB Graphical Interface node of the Emacs manual). There are also some