| | 261 | Some bugs related to the X protocol disappear when Emacs runs in a |
|---|
| | 262 | synchronous mode. To track down those bugs, we suggest the following |
|---|
| | 263 | procedure: |
|---|
| | 264 | |
|---|
| | 265 | - Run Emacs under a debugger and put a breakpoint inside the |
|---|
| | 266 | primitive function which, when called from Lisp, triggers the X |
|---|
| | 267 | protocol errors. For example, if the errors happen when you |
|---|
| | 268 | delete a frame, put a breakpoint inside `Fdelete_frame'. |
|---|
| | 269 | |
|---|
| | 270 | - When the breakpoint breaks, step through the code, looking for |
|---|
| | 271 | calls to X functions (the ones whose names begin with "X" or |
|---|
| | 272 | "Xt" or "Xm"). |
|---|
| | 273 | |
|---|
| | 274 | - Insert calls to `XSync' before and after each call to the X |
|---|
| | 275 | functions, like this: |
|---|
| | 276 | |
|---|
| | 277 | XSync (f->output_data.x->display_info->display, 0); |
|---|
| | 278 | |
|---|
| | 279 | where `f' is the pointer to the `struct frame' of the selected |
|---|
| | 280 | frame, normally available via XFRAME (selected_frame). (Most |
|---|
| | 281 | functions which call X already have some variable that holds the |
|---|
| | 282 | pointer to the frame, perhaps called `f' or `sf', so you shouldn't |
|---|
| | 283 | need to compute it.) |
|---|
| | 284 | |
|---|
| | 285 | If your debugger can call functions in the program being debugged, |
|---|
| | 286 | you should be able to issue the calls to `XSync' without recompiling |
|---|
| | 287 | Emacs. For example, with GDB, just type: |
|---|
| | 288 | |
|---|
| | 289 | call XSync (f->output_data.x->display_info->display, 0) |
|---|
| | 290 | |
|---|
| | 291 | before and immediately after the suspect X calls. If your |
|---|
| | 292 | debugger does not support this, you will need to add these pairs |
|---|
| | 293 | of calls in the source and rebuild Emacs. |
|---|
| | 294 | |
|---|
| | 295 | Either way, systematically step through the code and issue these |
|---|
| | 296 | calls until you find the first X function called by Emacs after |
|---|
| | 297 | which a call to `XSync' winds up in the function |
|---|
| | 298 | `x_error_quitter'. The first X function call for which this |
|---|
| | 299 | happens is the one that generated the X protocol error. |
|---|
| | 300 | |
|---|
| | 301 | - You should now look around this offending X call and try to figure |
|---|
| | 302 | out what is wrong with it. |
|---|
| | 303 | |
|---|
| | 482 | |
|---|
| | 483 | ** Debugging the TTY (non-windowed) version |
|---|
| | 484 | |
|---|
| | 485 | The most convenient method of debugging the character-terminal display |
|---|
| | 486 | is to do that on a window system such as X. Begin by starting an |
|---|
| | 487 | xterm window, then type these commands inside that window: |
|---|
| | 488 | |
|---|
| | 489 | $ tty |
|---|
| | 490 | $ echo $TERM |
|---|
| | 491 | |
|---|
| | 492 | Let's say these commands print "/dev/ttyp4" and "xterm", respectively. |
|---|
| | 493 | |
|---|
| | 494 | Now start Emacs (the normal, windowed-display session, i.e. without |
|---|
| | 495 | the `-nw' option), and invoke "M-x gdb RET emacs RET" from there. Now |
|---|
| | 496 | type these commands at GDB's prompt: |
|---|
| | 497 | |
|---|
| | 498 | (gdb) set args -nw -t /dev/ttyp4 |
|---|
| | 499 | (gdb) set environment TERM xterm |
|---|
| | 500 | (gdb) run |
|---|
| | 501 | |
|---|
| | 502 | The debugged Emacs should now start in no-window mode with its display |
|---|
| | 503 | directed to the xterm window you opened above. |
|---|
| | 504 | |
|---|
| | 505 | Similar arrangement is possible on a character terminal by using the |
|---|
| | 506 | `screen' package. |
|---|