Mercurial > hg > xemacs-beta
comparison src/.gdbinit @ 398:74fd4e045ea6 r21-2-29
Import from CVS: tag r21-2-29
| author | cvs |
|---|---|
| date | Mon, 13 Aug 2007 11:13:30 +0200 |
| parents | |
| children | a86b2b5e0111 |
comparison
equal
deleted
inserted
replaced
| 397:f4aeb21a5bad | 398:74fd4e045ea6 |
|---|---|
| 1 # -*- ksh -*- | |
| 2 # Copyright (C) 1998 Free Software Foundation, Inc. | |
| 3 | |
| 4 # This file is part of XEmacs. | |
| 5 | |
| 6 # XEmacs is free software; you can redistribute it and/or modify it | |
| 7 # under the terms of the GNU General Public License as published by the | |
| 8 # Free Software Foundation; either version 2, or (at your option) any | |
| 9 # later version. | |
| 10 | |
| 11 # XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 # for more details. | |
| 15 | |
| 16 # You should have received a copy of the GNU General Public License | |
| 17 # along with XEmacs; see the file COPYING. If not, write to | |
| 18 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 19 # Boston, MA 02111-1307, USA. | |
| 20 | |
| 21 # Author: Martin Buchholz | |
| 22 | |
| 23 # Some useful commands for debugging emacs with gdb 4.16 or better. | |
| 24 # | |
| 25 # Since this file is called `.gdbinit', it will be read by gdb | |
| 26 # automatically when gdb is run in the build directory, which is where | |
| 27 # developers usually debug their xemacs. You can also source this | |
| 28 # file from your ~/.gdbinit, if you like. | |
| 29 # | |
| 30 # Configure xemacs with --debug, and compile with -g. | |
| 31 # | |
| 32 # See also the question of the XEmacs FAQ, titled | |
| 33 # "How to Debug an XEmacs problem with a debugger". | |
| 34 # | |
| 35 # This can be used to debug XEmacs no matter how the following are | |
| 36 # specified: | |
| 37 | |
| 38 # USE_UNION_TYPE | |
| 39 | |
| 40 # (the above all have configure equivalents) | |
| 41 | |
| 42 # Some functions defined here require a running process, but most | |
| 43 # don't. Considerable effort has been expended to this end. | |
| 44 | |
| 45 # See the dbg_ C support code in src/alloc.c that allows the functions | |
| 46 # defined in this file to work correctly. | |
| 47 | |
| 48 set print union off | |
| 49 set print pretty off | |
| 50 | |
| 51 define decode_object | |
| 52 set $obj = (unsigned long) $arg0 | |
| 53 if $obj & 1 | |
| 54 # It's an int | |
| 55 set $val = $obj >> 1 | |
| 56 set $type = Lisp_Type_Int | |
| 57 else | |
| 58 set $type = $obj & dbg_typemask | |
| 59 if $type == Lisp_Type_Char | |
| 60 set $val = ($obj & dbg_valmask) >> dbg_gctypebits | |
| 61 else | |
| 62 # It's a record pointer | |
| 63 set $val = $obj | |
| 64 end | |
| 65 end | |
| 66 | |
| 67 if $type == Lisp_Type_Record | |
| 68 set $lheader = (struct lrecord_header *) $val | |
| 69 set $imp = lrecord_implementations_table[$lheader->type] | |
| 70 else | |
| 71 set $imp = -1 | |
| 72 end | |
| 73 end | |
| 74 | |
| 75 document decode_object | |
| 76 Usage: decode_object lisp_object | |
| 77 Extract implementation information from a Lisp Object. | |
| 78 Defines variables $val, $type and $imp. | |
| 79 end | |
| 80 | |
| 81 define xint | |
| 82 decode_object $arg0 | |
| 83 print ((long) $val) | |
| 84 end | |
| 85 | |
| 86 define xtype | |
| 87 decode_object $arg0 | |
| 88 if $type == Lisp_Type_Int | |
| 89 echo int\n | |
| 90 else | |
| 91 if $type == Lisp_Type_Char | |
| 92 echo char\n | |
| 93 else | |
| 94 if $type == Lisp_Type_Symbol | |
| 95 echo symbol\n | |
| 96 else | |
| 97 if $type == Lisp_Type_String | |
| 98 echo string\n | |
| 99 else | |
| 100 if $type == Lisp_Type_Vector | |
| 101 echo vector\n | |
| 102 else | |
| 103 if $type == Lisp_Type_Cons | |
| 104 echo cons\n | |
| 105 else | |
| 106 printf "record type: %s\n", $imp->name | |
| 107 # barf | |
| 108 end | |
| 109 end | |
| 110 end | |
| 111 end | |
| 112 end | |
| 113 end | |
| 114 end | |
| 115 | |
| 116 document xtype | |
| 117 Usage: xtype lisp_object | |
| 118 Print the Lisp type of a lisp object. | |
| 119 end | |
| 120 | |
| 121 define lisp-shadows | |
| 122 run -batch -vanilla -f list-load-path-shadows | |
| 123 end | |
| 124 | |
| 125 document lisp-shadows | |
| 126 Usage: lisp-shadows | |
| 127 Run xemacs to check for lisp shadows | |
| 128 end | |
| 129 | |
| 130 define environment-to-run-temacs | |
| 131 unset env EMACSLOADPATH | |
| 132 set env EMACSBOOTSTRAPLOADPATH=../lisp/:.. | |
| 133 set env EMACSBOOTSTRAPMODULEPATH=../modules/:.. | |
| 134 end | |
| 135 | |
| 136 define run-temacs | |
| 137 environment-to-run-temacs | |
| 138 run -batch -l ../lisp/loadup.el run-temacs -q | |
| 139 end | |
| 140 | |
| 141 document run-temacs | |
| 142 Usage: run-temacs | |
| 143 Run temacs interactively, like xemacs. | |
| 144 Use this with debugging tools (like purify) that cannot deal with dumping, | |
| 145 or when temacs builds successfully, but xemacs does not. | |
| 146 end | |
| 147 | |
| 148 define check-xemacs | |
| 149 run -batch -l ../tests/automated/test-harness.el -f batch-test-emacs ../tests/automated | |
| 150 end | |
| 151 | |
| 152 document check-xemacs | |
| 153 Usage: check-xemacs | |
| 154 Run the test suite. Equivalent to 'make check'. | |
| 155 end | |
| 156 | |
| 157 define check-temacs | |
| 158 environment-to-run-temacs | |
| 159 run -batch -l ../lisp/loadup.el run-temacs -q -batch -l ../tests/automated/test-harness.el -f batch-test-emacs ../tests/automated | |
| 160 end | |
| 161 | |
| 162 document check-temacs | |
| 163 Usage: check-temacs | |
| 164 Run the test suite on temacs. Equivalent to 'make check-temacs'. | |
| 165 Use this with debugging tools (like purify) that cannot deal with dumping, | |
| 166 or when temacs builds successfully, but xemacs does not. | |
| 167 end | |
| 168 | |
| 169 define update-elc | |
| 170 environment-to-run-temacs | |
| 171 run -batch -l ../lisp/update-elc.el | |
| 172 end | |
| 173 | |
| 174 document update-elc | |
| 175 Usage: update-elc | |
| 176 Run the core lisp byte compilation part of the build procedure. | |
| 177 Use when debugging temacs, not xemacs! | |
| 178 Use this when temacs builds successfully, but xemacs does not. | |
| 179 end | |
| 180 | |
| 181 define dump-temacs | |
| 182 environment-to-run-temacs | |
| 183 run -batch -l ../lisp/loadup.el dump | |
| 184 end | |
| 185 | |
| 186 document dump-temacs | |
| 187 Usage: dump-temacs | |
| 188 Run the dumping part of the build procedure. | |
| 189 Use when debugging temacs, not xemacs! | |
| 190 Use this when temacs builds successfully, but xemacs does not. | |
| 191 end | |
| 192 | |
| 193 # if you use Purify, do this: | |
| 194 # export PURIFYOPTIONS='-pointer-mask=0x0fffffff' | |
| 195 | |
| 196 define ldp | |
| 197 printf "%s", "Lisp => " | |
| 198 call debug_print($arg0) | |
| 199 end | |
| 200 | |
| 201 document ldp | |
| 202 Usage: ldp lisp_object | |
| 203 Print a Lisp Object value using the Lisp printer. | |
| 204 Requires a running xemacs process. | |
| 205 end | |
| 206 | |
| 207 define lbt | |
| 208 call debug_backtrace() | |
| 209 end | |
| 210 | |
| 211 document lbt | |
| 212 Usage: lbt | |
| 213 Print the current Lisp stack trace. | |
| 214 Requires a running xemacs process. | |
| 215 end | |
| 216 | |
| 217 | |
| 218 define leval | |
| 219 ldp Feval(Fcar(Fread_from_string(build_string($arg0),Qnil,Qnil))) | |
| 220 end | |
| 221 | |
| 222 document leval | |
| 223 Usage: leval "SEXP" | |
| 224 Eval a lisp expression. | |
| 225 Requires a running xemacs process. | |
| 226 | |
| 227 Example: | |
| 228 (gdb) leval "(+ 1 2)" | |
| 229 Lisp ==> 3 | |
| 230 end | |
| 231 | |
| 232 | |
| 233 define wtype | |
| 234 print $arg0->core.widget_class->core_class.class_name | |
| 235 end | |
| 236 | |
| 237 define xtname | |
| 238 print XrmQuarkToString(((Object)($arg0))->object.xrm_name) | |
| 239 end | |
| 240 | |
| 241 # GDB's command language makes you want to ... | |
| 242 | |
| 243 define pstruct | |
| 244 set $xstruct = (struct $arg0 *) $val | |
| 245 print $xstruct | |
| 246 print *$xstruct | |
| 247 end | |
| 248 | |
| 249 define pobj | |
| 250 decode_object $arg0 | |
| 251 if $type == Lisp_Type_Int | |
| 252 printf "Integer: %d\n", $val | |
| 253 else | |
| 254 if $type == Lisp_Type_Char | |
| 255 if $val > 32 && $val < 128 | |
| 256 printf "Char: %c\n", $val | |
| 257 else | |
| 258 printf "Char: %d\n", $val | |
| 259 end | |
| 260 else | |
| 261 if $type == Lisp_Type_String || $imp == &lrecord_string | |
| 262 pstruct Lisp_String | |
| 263 else | |
| 264 if $type == Lisp_Type_Cons || $imp == &lrecord_cons | |
| 265 pstruct Lisp_Cons | |
| 266 else | |
| 267 if $type == Lisp_Type_Symbol || $imp == &lrecord_symbol | |
| 268 pstruct Lisp_Symbol | |
| 269 printf "Symbol name: %s\n", $xstruct->name->data | |
| 270 else | |
| 271 if $type == Lisp_Type_Vector || $imp == &lrecord_vector | |
| 272 pstruct Lisp_Vector | |
| 273 printf "Vector of length %d\n", $xstruct->size | |
| 274 #print *($xstruct->data) @ $xstruct->size | |
| 275 else | |
| 276 if $imp == &lrecord_bit_vector | |
| 277 pstruct Lisp_Bit_Vector | |
| 278 else | |
| 279 if $imp == &lrecord_buffer | |
| 280 pstruct buffer | |
| 281 else | |
| 282 if $imp == &lrecord_char_table | |
| 283 pstruct Lisp_Char_Table | |
| 284 else | |
| 285 if $imp == &lrecord_char_table_entry | |
| 286 pstruct Lisp_Char_Table_Entry | |
| 287 else | |
| 288 if $imp == &lrecord_charset | |
| 289 pstruct Lisp_Charset | |
| 290 else | |
| 291 if $imp == &lrecord_coding_system | |
| 292 pstruct Lisp_Coding_System | |
| 293 else | |
| 294 if $imp == &lrecord_color_instance | |
| 295 pstruct Lisp_Color_Instance | |
| 296 else | |
| 297 if $imp == &lrecord_command_builder | |
| 298 pstruct command_builder | |
| 299 else | |
| 300 if $imp == &lrecord_compiled_function | |
| 301 pstruct Lisp_Compiled_Function | |
| 302 else | |
| 303 if $imp == &lrecord_console | |
| 304 pstruct console | |
| 305 else | |
| 306 if $imp == &lrecord_database | |
| 307 pstruct Lisp_Database | |
| 308 else | |
| 309 if $imp == &lrecord_device | |
| 310 pstruct device | |
| 311 else | |
| 312 if $imp == &lrecord_event | |
| 313 pstruct Lisp_Event | |
| 314 else | |
| 315 if $imp == &lrecord_extent | |
| 316 pstruct extent | |
| 317 else | |
| 318 if $imp == &lrecord_extent_auxiliary | |
| 319 pstruct extent_auxiliary | |
| 320 else | |
| 321 if $imp == &lrecord_extent_info | |
| 322 pstruct extent_info | |
| 323 else | |
| 324 if $imp == &lrecord_face | |
| 325 pstruct Lisp_Face | |
| 326 else | |
| 327 if $imp == &lrecord_float | |
| 328 pstruct Lisp_Float | |
| 329 else | |
| 330 if $imp == &lrecord_font_instance | |
| 331 pstruct Lisp_Font_Instance | |
| 332 else | |
| 333 if $imp == &lrecord_frame | |
| 334 pstruct frame | |
| 335 else | |
| 336 if $imp == &lrecord_glyph | |
| 337 pstruct Lisp_Glyph | |
| 338 else | |
| 339 if $imp == &lrecord_hash_table | |
| 340 pstruct Lisp_Hash_Table | |
| 341 else | |
| 342 if $imp == &lrecord_image_instance | |
| 343 pstruct Lisp_Image_Instance | |
| 344 else | |
| 345 if $imp == &lrecord_keymap | |
| 346 pstruct Lisp_Keymap | |
| 347 else | |
| 348 if $imp == &lrecord_lcrecord_list | |
| 349 pstruct lcrecord_list | |
| 350 else | |
| 351 if $imp == &lrecord_lstream | |
| 352 pstruct lstream | |
| 353 else | |
| 354 if $imp == &lrecord_marker | |
| 355 pstruct Lisp_Marker | |
| 356 else | |
| 357 if $imp == &lrecord_opaque | |
| 358 pstruct Lisp_Opaque | |
| 359 else | |
| 360 if $imp == &lrecord_opaque_ptr | |
| 361 pstruct Lisp_Opaque_Ptr | |
| 362 else | |
| 363 if $imp == &lrecord_popup_data | |
| 364 pstruct popup_data | |
| 365 else | |
| 366 if $imp == &lrecord_process | |
| 367 pstruct Lisp_Process | |
| 368 else | |
| 369 if $imp == &lrecord_range_table | |
| 370 pstruct Lisp_Range_Table | |
| 371 else | |
| 372 if $imp == &lrecord_specifier | |
| 373 pstruct Lisp_Specifier | |
| 374 else | |
| 375 if $imp == &lrecord_subr | |
| 376 pstruct Lisp_Subr | |
| 377 else | |
| 378 if $imp == &lrecord_symbol_value_buffer_local | |
| 379 pstruct symbol_value_buffer_local | |
| 380 else | |
| 381 if $imp == &lrecord_symbol_value_forward | |
| 382 pstruct symbol_value_forward | |
| 383 else | |
| 384 if $imp == &lrecord_symbol_value_lisp_magic | |
| 385 pstruct symbol_value_lisp_magic | |
| 386 else | |
| 387 if $imp == &lrecord_symbol_value_varalias | |
| 388 pstruct symbol_value_varalias | |
| 389 else | |
| 390 if $imp == &lrecord_toolbar_button | |
| 391 pstruct toolbar_button | |
| 392 else | |
| 393 if $imp == &lrecord_tooltalk_message | |
| 394 pstruct Lisp_Tooltalk_Message | |
| 395 else | |
| 396 if $imp == &lrecord_tooltalk_pattern | |
| 397 pstruct Lisp_Tooltalk_Pattern | |
| 398 else | |
| 399 if $imp == &lrecord_weak_list | |
| 400 pstruct weak_list | |
| 401 else | |
| 402 if $imp == &lrecord_window | |
| 403 pstruct window | |
| 404 else | |
| 405 if $imp == &lrecord_window_configuration | |
| 406 pstruct window_config | |
| 407 else | |
| 408 echo Unknown Lisp Object type\n | |
| 409 print $arg0 | |
| 410 # Barf, gag, retch | |
| 411 end | |
| 412 end | |
| 413 end | |
| 414 end | |
| 415 end | |
| 416 end | |
| 417 end | |
| 418 end | |
| 419 end | |
| 420 end | |
| 421 end | |
| 422 end | |
| 423 end | |
| 424 end | |
| 425 end | |
| 426 # Repeat after me... gdb sux, gdb sux, gdb sux... | |
| 427 end | |
| 428 end | |
| 429 end | |
| 430 end | |
| 431 end | |
| 432 end | |
| 433 end | |
| 434 end | |
| 435 end | |
| 436 end | |
| 437 end | |
| 438 end | |
| 439 end | |
| 440 end | |
| 441 end | |
| 442 end | |
| 443 end | |
| 444 end | |
| 445 # Are we having fun yet?? | |
| 446 end | |
| 447 end | |
| 448 end | |
| 449 end | |
| 450 end | |
| 451 end | |
| 452 end | |
| 453 end | |
| 454 end | |
| 455 end | |
| 456 end | |
| 457 end | |
| 458 end | |
| 459 end | |
| 460 end | |
| 461 end | |
| 462 end | |
| 463 end | |
| 464 | |
| 465 document pobj | |
| 466 Usage: pobj lisp_object | |
| 467 Print the internal C representation of a Lisp Object. | |
| 468 end | |
| 469 | |
| 470 # ------------------------------------------------------------- | |
| 471 # functions to test the debugging support itself. | |
| 472 # If you change this file, make sure the following still work... | |
| 473 # ------------------------------------------------------------- | |
| 474 define test_xtype | |
| 475 printf "Vemacs_major_version: " | |
| 476 xtype Vemacs_major_version | |
| 477 printf "Vhelp_char: " | |
| 478 xtype Vhelp_char | |
| 479 printf "Qnil: " | |
| 480 xtype Qnil | |
| 481 printf "Qunbound: " | |
| 482 xtype Qunbound | |
| 483 printf "Vobarray: " | |
| 484 xtype Vobarray | |
| 485 printf "Vall_weak_lists: " | |
| 486 xtype Vall_weak_lists | |
| 487 printf "Vxemacs_codename: " | |
| 488 xtype Vxemacs_codename | |
| 489 end | |
| 490 | |
| 491 define test_pobj | |
| 492 printf "Vemacs_major_version: " | |
| 493 pobj Vemacs_major_version | |
| 494 printf "Vhelp_char: " | |
| 495 pobj Vhelp_char | |
| 496 printf "Qnil: " | |
| 497 pobj Qnil | |
| 498 printf "Qunbound: " | |
| 499 pobj Qunbound | |
| 500 printf "Vobarray: " | |
| 501 pobj Vobarray | |
| 502 printf "Vall_weak_lists: " | |
| 503 pobj Vall_weak_lists | |
| 504 printf "Vxemacs_codename: " | |
| 505 pobj Vxemacs_codename | |
| 506 end | |
| 507 |
