XEmacs / src / gdbinit

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# Some useful commands for debugging emacs with gdb 4.14.* or better.
# Install this as your .gdbinit file in your home directory.
# If you have an older version of gdb 4.x, consider using the
# file "gdbinit.pre-4.14" in the XEmacs src directory.
# If you're one of the few who has an XEmacs compiled with
# --use-union-type, you'll need to use the file "gdbinit.union".
# Currently that file is of the pre-4.14 variety, but it should
# be easy to update it to 4.14+, along the same lines as this file.
#
# See also question 2.1.15 of the XEmacs FAQ, titled
# "How to Debug an XEmacs problem with a debugger".

set print union off
set print pretty off

define temacs
  run -batch -l loadup.el run-temacs -q
end

echo \n>>> Use the `temacs' command to run temacs\n\n

# if you use Purify, do this:
# set env PURIFYOPTIONS -pointer-mask=0x0fffffff

################ Print using the Lisp printer

define p1
  call debug_print ($arg0)
  printf "\n"
end

define lbt
# "&" to compensate for GDB struct-passing bug
# but I've removed the &'s because it doesn't work with my GDB,
# and not having them works fine.
call Fbacktrace (Qexternal_debugging_output, Qt)
end

################ Print using GDB built-ins

define xint
print ((int)($arg0 << 4))>>4
end

define xbitvec
print (struct Lisp_Bit_Vector *) ($arg0 & 0xFFFFFFF)
end

define xbuffer
print (struct buffer *) ($arg0 & 0xFFFFFFF)
end

define xbytecode
print (struct Lisp_Bytecode *) ($arg0 & 0xFFFFFFF)
end

define xcharset
print (struct Lisp_Charset *) ($arg0 & 0xFFFFFFF)
end

define xchartab
print (struct Lisp_Char_Table *) ($arg0 & 0xFFFFFFF)
end

define xchartabentry
print (struct Lisp_Char_Table_Entry *) ($arg0 & 0xFFFFFFF)
end

define xcodesys
print (struct Lisp_Coding_System *) ($arg0 & 0xFFFFFFF)
end

define xcolorinst
print (struct Lisp_Color_Instance *) ($arg0 & 0xFFFFFFF)
end

define xcons
print (struct Lisp_Cons *) ($arg0 & 0xFFFFFFF)
end

define xdevice
print (struct device *) ($arg0 & 0xFFFFFFF)
end

define xevent
print (struct Lisp_Event *) ($arg0 & 0xFFFFFFF)
end

define xextent
print (struct extent *) ($arg0 & 0xFFFFFFF)
end

define xextentaux
print (struct extent_auxiliary *) ($arg0 & 0xFFFFFFF)
end

define xextentinfo
print (struct extent_info *) ($arg0 & 0xFFFFFFF)
end

define xfloat
print (struct Lisp_Float *) ($arg0 & 0xFFFFFFF)
output (double) $arg0->data.d
echo \n
end

define xfontinst
print (struct Lisp_Font_Instance *) ($arg0 & 0xFFFFFFF)
end

define xframe
print (struct frame *) ($arg0 & 0xFFFFFFF)
end

define xglyph
print (struct Lisp_Glyph *) ($arg0 & 0xFFFFFFF)
end

define xhashtable
print (struct hashtable_struct *) ($arg0 & 0xFFFFFFF)
end

define ximageinst
print (struct Lisp_Image_Instance *) ($arg0 & 0xFFFFFFF)
end

define xkeymap
print (struct keymap *) ($arg0 & 0xFFFFFFF)
end

define xlstream
print (struct lstream *) ($arg0 & 0xFFFFFFF)
end

define xmarker
print (struct Lisp_Marker *) ($arg0 & 0xFFFFFFF)
end

define xmenubardata
print (struct menubar_data *) ($arg0 & 0xFFFFFFF)
end

define xopaque
print (struct Lisp_Opaque *) ($arg0 & 0xFFFFFFF)
end

define xprocess
print (struct Lisp_Process *) ($arg0 & 0xFFFFFFF)
end

define xrangetab
print (struct Lisp_Range_Table *) ($arg0 & 0xFFFFFFF)
end

define xspec
print (struct Lisp_Specifier *) ($arg0 & 0xFFFFFFF)
end

define xstring
print (struct Lisp_String *) ($arg0 & 0xFFFFFFF)
output (char *) $arg0->_data
echo \n
end

define xsubr
print (struct Lisp_Subr *) ($arg0 & 0xFFFFFFF)
end

define xsubwindow
print (struct Lisp_Subwindow *) ($arg0 & 0xFFFFFFF)
end

define xsymbol
set $tem = (struct Lisp_Symbol *) ($arg0 & 0xFFFFFFF)
output $tem->name->_data
printf "\n"
print $tem
end

define xtoolbarbutton
print (struct toolbar_button *) ($arg0 & 0xFFFFFFF)
end

define xtoolbardata
print (struct toolbar_data *) ($arg0 & 0xFFFFFFF)
end

define xtooltalkmess
print (struct Lisp_Tooltalk_Message *) ($arg0 & 0xFFFFFFF)
end

define xtooltalkpatt
print (struct Lisp_Tooltalk_Pattern *) ($arg0 & 0xFFFFFFF)
end

define xvector
print (struct Lisp_Vector *) ($arg0 & 0xFFFFFFF)
end

define xwindow
print (struct window *) ($arg0 & 0xFFFFFFF)
end

define xwindowconfig
print (struct window_config *) ($arg0 & 0xFFFFFFF)
end

define xrecord
  print ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))
  output (((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation->name)
  echo \n
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_symbol
    xsymbol $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_extent
    xextent $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_marker
    xmarker $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_event
    xevent $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_buffer
    xbuffer $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_window
    xwindow $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_frame
    xframe $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_device
    xdevice $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_console
    xconsole $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_process
    xprocess $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_subr
    xsubr $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_compiled_function
    xbytecode $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_window_configuration
    xwindowconfig $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_float
    xfloat $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_opaque
    xopaque $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_glyph
    xglyph $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_keymap
    xkeymap $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_lstream
    xlstream $arg0
  else
  if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_bit_vector
    xbitvec $arg0
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
  end
end

define frob
  if (enum Lisp_Type) (($arg0 >> 28) & 7) == Lisp_Int
    xint $arg0
  else
  if (enum Lisp_Type) (($arg0 >> 28) & 7) == Lisp_String
    xstring $arg0
  else
  if (enum Lisp_Type) (($arg0 >> 28) & 7) == Lisp_Cons
    xcons $arg0
  else
  if (enum Lisp_Type) (($arg0 >> 28) & 7) == Lisp_Vector
    xvector $arg0
  else
  if (enum Lisp_Type) (($arg0 >> 28) & 7) == Lisp_Record
    xrecord $arg0
  else
    printf "Unknown type?\n"
  end
  end
  end
  end
  end
end

################ Miscellaneous

define xtype
# this is really xgctype, as we mask off the mark bit
output (enum Lisp_Type) (($arg0 >> 28) & 7)
echo \n
end

define xmarkbit
print ($arg0 >> 31)
end

define nilp
print $arg0 == Qnil
end

define xcar
  frob ((struct Lisp_Cons *) ($arg0 & 0xFFFFFFF))->car
end

define xcdr
  frob ((struct Lisp_Cons *) ($arg0 & 0xFFFFFFF))->cdr
end

set $vector_length_mask = ~(1<<31)

define string-length
  print ((struct Lisp_String *) ($arg0 & 0xFFFFFFF))->_size & $vector_length_mask
end

define string-contents
  print (char *) ((struct Lisp_String *) ($ & 0xFFFFFFF))->_data
end

define vector-length
  print ((struct Lisp_Vector *) ($ & 0xFFFFFFF))->size & $vector_length_mask
end

define vector-contents
set $tem = (struct Lisp_Vector *) ($ & 0xFFFFFFF)
print *($tem->contents) @ ($tem->size & $vector_length_mask)
set $ = $tem->contents
end

define symbol-name
set $tem = ((struct Lisp_Symbol *) ($ & 0xFFFFFFF))->name
# output *($tem->_data) @ ($tem->_size & $vector_length_mask)
output ($tem->_data) 
echo \n
set $type = Lisp_String
echo \n
end

define symbol-value
set $tem = ((struct Lisp_Symbol *) ($ & 0xFFFFFFF))->value
end

define symbol-function
set $tem = ((struct Lisp_Symbol *) ($ & 0xFFFFFFF))->function
end

define symbol-plist
set $tem = ((struct Lisp_Symbol *) ($ & 0xFFFFFFF))->plist
end

define wtype
p $->core.widget_class->core_class.class_name
end

define xtname
print XrmQuarkToString(((Object)($))->object.xrm_name)
end

# 
# GDB, with the losing command-line parser that it has,
# cannot handle nested blocks.
# 
define breaks

br Fsignal
# command
# bt 3
# p sig
# xsymbol
# end

br Fkill_emacs
# command
# bt 3
# end

br assertion_failed
# command
# bt 3
# end

end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.