Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 616 lines (563 sloc) 12.325 kb
cfbf35a Support for ZTS
Marcus Boerger authored
1 define ____executor_globals
6dcb27d - MFH
Marcus Boerger authored
2 if basic_functions_module.zts
3 set $tsrm_ls = ts_resource_ex(0, 0)
49e9d8f Xinchen Hui Fix wrong type in the marco of fetching thread globals
laruence authored
4 set $eg = ((zend_executor_globals*) (*((void ***) $tsrm_ls))[executor_globals_id-1])
5 set $cg = ((zend_compiler_globals*) (*((void ***) $tsrm_ls))[compiler_globals_id-1])
cfbf35a Support for ZTS
Marcus Boerger authored
6 else
7 set $eg = executor_globals
edc7e30 - MFH Add compiler globals as
Marcus Boerger authored
8 set $cg = compiler_globals
cfbf35a Support for ZTS
Marcus Boerger authored
9 end
10 end
11
12 document ____executor_globals
a4e3f29 - MFH Add print_htptr, print_htstr
Marcus Boerger authored
13 portable way of accessing executor_globals, set $eg
edc7e30 - MFH Add compiler globals as
Marcus Boerger authored
14 this also sets compiler_globals to $cg
6dcb27d - MFH
Marcus Boerger authored
15 ZTS detection is automatically based on ext/standard module struct
cfbf35a Support for ZTS
Marcus Boerger authored
16 end
17
e4e7e2b - Added a function to print all CVs from the local scope.
Derick Rethans authored
18 define print_cvs
19 ____executor_globals
20 set $p = $eg.current_execute_data.CVs
21 set $c = $eg.current_execute_data.op_array.last_var
22 set $v = $eg.current_execute_data.op_array.vars
23 set $i = 0
24
25 printf "Compiled variables count: %d\n", $c
26 while $i < $c
27 printf "%d = %s\n", $i, $v[$i].name
28 if $p[$i] != 0
29 printzv *$p[$i]
30 else
31 printf "*uninitialized*\n"
32 end
33 set $i = $i + 1
34 end
35 end
36
c1706b5 add really nice dump_bt function for debugging in gdb
Thies C. Arntzen authored
37 define dump_bt
cfbf35a Support for ZTS
Marcus Boerger authored
38 set $t = $arg0
39 while $t
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
40 printf "[%p] ", $t
c1706b5 add really nice dump_bt function for debugging in gdb
Thies C. Arntzen authored
41 if $t->function_state.function->common.function_name
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
42 if $t->function_state.arguments
43 set $count = (int)*($t->function_state.arguments)
44 printf "%s(", $t->function_state.function->common.function_name
45 while $count > 0
46 set $zvalue = *(zval **)($t->function_state.arguments - $count)
47 set $type = $zvalue->type
48 if $type == 0
49 printf "NULL"
50 end
51 if $type == 1
52 printf "%ld", $zvalue->value.lval
53 end
54 if $type == 2
55 printf "%lf", $zvalue->value.dval
56 end
57 if $type == 3
58 if $zvalue->value.lval
59 printf "true"
60 else
61 printf "false"
17f5bf2 Xinchen Hui Add zbacktrace_ex to .gdbinit which will print extra argument info than ...
laruence authored
62 end
63 end
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
64 if $type == 4
65 printf "array(%d)[%p]", $zvalue->value.ht->nNumOfElements, $zvalue
66 end
67 if $type == 5
68 printf "object[%p]", $zvalue
69 end
70 if $type == 6
71 ____print_str $zvalue->value.str.val $zvalue->value.str.len
72 end
73 if $type == 7
74 printf "resource(#%d)", $zvalue->value.lval
75 end
76 if $type == 8
77 printf "constant"
78 end
79 if $type == 9
80 printf "const_array"
81 end
82 if $type > 9
83 printf "unknown type %d", $type
84 end
85 set $count = $count -1
86 if $count > 0
87 printf ", "
88 end
17f5bf2 Xinchen Hui Add zbacktrace_ex to .gdbinit which will print extra argument info than ...
laruence authored
89 end
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
90 printf ") "
17f5bf2 Xinchen Hui Add zbacktrace_ex to .gdbinit which will print extra argument info than ...
laruence authored
91 else
92 printf "%s() ", $t->function_state.function->common.function_name
93 end
c1706b5 add really nice dump_bt function for debugging in gdb
Thies C. Arntzen authored
94 else
95 printf "??? "
96 end
97 if $t->op_array != 0
98 printf "%s:%d ", $t->op_array->filename, $t->opline->lineno
99 end
100 set $t = $t->prev_execute_data
101 printf "\n"
cfbf35a Support for ZTS
Marcus Boerger authored
102 end
c1706b5 add really nice dump_bt function for debugging in gdb
Thies C. Arntzen authored
103 end
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
104
c1706b5 add really nice dump_bt function for debugging in gdb
Thies C. Arntzen authored
105 document dump_bt
106 dumps the current execution stack. usage: dump_bt executor_globals.current_execute_data
107 end
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
108
109 define printzv
7177ada some improvements to the debugging macros
Sterling Hughes authored
110 set $ind = 1
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
111 ____printzv $arg0 0
112 end
113
114 document printzv
a4e3f29 - MFH Add print_htptr, print_htstr
Marcus Boerger authored
115 prints zval contents
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
116 end
117
7177ada some improvements to the debugging macros
Sterling Hughes authored
118 define ____printzv_contents
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
119 set $zvalue = $arg0
6dcb27d - MFH
Marcus Boerger authored
120 set $type = $zvalue->type
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
121
ea74505 Fix macros after GC patch.
Andrei Zmievski authored
122 printf "(refcount=%d", $zvalue->refcount__gc
123 if $zvalue->is_ref__gc
a4e3f29 - MFH Add print_htptr, print_htstr
Marcus Boerger authored
124 printf ",is_ref"
125 end
126 printf ") "
6dcb27d - MFH
Marcus Boerger authored
127 if $type == 0
128 printf "NULL"
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
129 end
6dcb27d - MFH
Marcus Boerger authored
130 if $type == 1
131 printf "long: %ld", $zvalue->value.lval
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
132 end
6dcb27d - MFH
Marcus Boerger authored
133 if $type == 2
134 printf "double: %lf", $zvalue->value.dval
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
135 end
6dcb27d - MFH
Marcus Boerger authored
136 if $type == 3
137 printf "bool: "
138 if $zvalue->value.lval
139 printf "true"
140 else
141 printf "false"
142 end
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
143 end
6dcb27d - MFH
Marcus Boerger authored
144 if $type == 4
145 printf "array(%d): ", $zvalue->value.ht->nNumOfElements
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
146 if ! $arg1
147 printf "{\n"
148 set $ind = $ind + 1
a4e3f29 - MFH Add print_htptr, print_htstr
Marcus Boerger authored
149 ____print_ht $zvalue->value.ht 1
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
150 set $ind = $ind - 1
151 set $i = $ind
152 while $i > 0
153 printf " "
154 set $i = $i - 1
155 end
156 printf "}"
157 end
6dcb27d - MFH
Marcus Boerger authored
158 set $type = 0
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
159 end
6dcb27d - MFH
Marcus Boerger authored
160 if $type == 5
161 printf "object"
162 ____executor_globals
163 set $handle = $zvalue->value.obj.handle
164 set $handlers = $zvalue->value.obj.handlers
165 if basic_functions_module.zts
166 set $zobj = zend_objects_get_address($zvalue, $tsrm_ls)
167 else
168 set $zobj = zend_objects_get_address($zvalue)
169 end
170 if $handlers->get_class_entry == &zend_std_object_get_class
171 set $cname = $zobj->ce.name
172 else
173 set $cname = "Unknown"
174 end
175 printf "(%s) #%d", $cname, $handle
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
176 if ! $arg1
6dcb27d - MFH
Marcus Boerger authored
177 if $handlers->get_properties == &zend_std_get_properties
178 set $ht = $zobj->properties
179 if $ht
180 printf "(%d): ", $ht->nNumOfElements
181 printf "{\n"
182 set $ind = $ind + 1
a4e3f29 - MFH Add print_htptr, print_htstr
Marcus Boerger authored
183 ____print_ht $ht 1
6dcb27d - MFH
Marcus Boerger authored
184 set $ind = $ind - 1
185 set $i = $ind
186 while $i > 0
187 printf " "
188 set $i = $i - 1
189 end
190 printf "}"
191 else
192 echo "no properties found"
193 end
cfbf35a Support for ZTS
Marcus Boerger authored
194 end
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
195 end
6dcb27d - MFH
Marcus Boerger authored
196 set $type = 0
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
197 end
6dcb27d - MFH
Marcus Boerger authored
198 if $type == 6
78d11cb Michael Wallner - add print_inh (prints a very simple class tree, ie. extensible)
m6w6 authored
199 printf "string(%d): ", $zvalue->value.str.len
200 ____print_str $zvalue->value.str.val $zvalue->value.str.len
6dcb27d - MFH
Marcus Boerger authored
201 end
202 if $type == 7
203 printf "resource: #%d", $zvalue->value.lval
204 end
205 if $type == 8
206 printf "constant"
207 end
208 if $type == 9
209 printf "const_array"
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
210 end
6dcb27d - MFH
Marcus Boerger authored
211 if $type > 9
212 printf "unknown type %d", $type
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
213 end
214 printf "\n"
215 end
216
7177ada some improvements to the debugging macros
Sterling Hughes authored
217 define ____printzv
218 ____executor_globals
219 set $zvalue = $arg0
220
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
221 printf "[%p] ", $zvalue
7177ada some improvements to the debugging macros
Sterling Hughes authored
222
223 if $zvalue == $eg.uninitialized_zval_ptr
224 printf "*uninitialized* "
225 end
226
6dcb27d - MFH
Marcus Boerger authored
227 set $zcontents = (zval*) $zvalue
7177ada some improvements to the debugging macros
Sterling Hughes authored
228 if $arg1
229 ____printzv_contents $zcontents $arg1
230 else
b2ea792 Fixed printzv macro
Moriyoshi Koizumi authored
231 ____printzv_contents $zcontents 0
7177ada some improvements to the debugging macros
Sterling Hughes authored
232 end
233 end
234
235 define ____print_const_table
236 set $ht = $arg0
237 set $p = $ht->pListHead
238
239 while $p != 0
6dcb27d - MFH
Marcus Boerger authored
240 set $const = (zend_constant *) $p->pData
7177ada some improvements to the debugging macros
Sterling Hughes authored
241
242 set $i = $ind
243 while $i > 0
244 printf " "
245 set $i = $i - 1
246 end
247
78d11cb Michael Wallner - add print_inh (prints a very simple class tree, ie. extensible)
m6w6 authored
248 if $p->nKeyLength > 0
249 ____print_str $p->arKey $p->nKeyLength
250 printf " => "
7177ada some improvements to the debugging macros
Sterling Hughes authored
251 else
252 printf "%d => ", $p->h
253 end
254
6dcb27d - MFH
Marcus Boerger authored
255 ____printzv_contents &$const->value 0
7177ada some improvements to the debugging macros
Sterling Hughes authored
256 set $p = $p->pListNext
257 end
258 end
259
260 define print_const_table
261 set $ind = 1
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
262 printf "[%p] {\n", $arg0
7177ada some improvements to the debugging macros
Sterling Hughes authored
263 ____print_const_table $arg0
264 printf "}\n"
265 end
266
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
267 define ____print_ht
a4e3f29 - MFH Add print_htptr, print_htstr
Marcus Boerger authored
268 set $ht = (HashTable*)$arg0
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
269 set $p = $ht->pListHead
270
271 while $p != 0
272 set $i = $ind
273 while $i > 0
274 printf " "
275 set $i = $i - 1
276 end
277
78d11cb Michael Wallner - add print_inh (prints a very simple class tree, ie. extensible)
m6w6 authored
278 if $p->nKeyLength > 0
279 ____print_str $p->arKey $p->nKeyLength
280 printf " => "
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
281 else
282 printf "%d => ", $p->h
283 end
a4e3f29 - MFH Add print_htptr, print_htstr
Marcus Boerger authored
284
285 if $arg1 == 0
286 printf "%p\n", (void*)$p->pData
287 end
288 if $arg1 == 1
289 set $zval = *(zval **)$p->pData
290 ____printzv $zval 1
291 end
292 if $arg1 == 2
293 printf "%s\n", (char*)$p->pData
294 end
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
295
296 set $p = $p->pListNext
297 end
298 end
299
300 define print_ht
301 set $ind = 1
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
302 printf "[%p] {\n", $arg0
a4e3f29 - MFH Add print_htptr, print_htstr
Marcus Boerger authored
303 ____print_ht $arg0 1
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
304 printf "}\n"
305 end
306
307 document print_ht
308 dumps elements of HashTable made of zval
309 end
310
a4e3f29 - MFH Add print_htptr, print_htstr
Marcus Boerger authored
311 define print_htptr
312 set $ind = 1
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
313 printf "[%p] {\n", $arg0
a4e3f29 - MFH Add print_htptr, print_htstr
Marcus Boerger authored
314 ____print_ht $arg0 0
315 printf "}\n"
316 end
317
318 document print_htptr
319 dumps elements of HashTable made of pointers
320 end
321
322 define print_htstr
323 set $ind = 1
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
324 printf "[%p] {\n", $arg0
a4e3f29 - MFH Add print_htptr, print_htstr
Marcus Boerger authored
325 ____print_ht $arg0 2
326 printf "}\n"
327 end
328
329 document print_htstr
330 dumps elements of HashTable made of strings
331 end
332
6dcb27d - MFH
Marcus Boerger authored
333 define ____print_ft
334 set $ht = $arg0
335 set $p = $ht->pListHead
336
337 while $p != 0
338 set $func = (zend_function*)$p->pData
339
340 set $i = $ind
341 while $i > 0
342 printf " "
343 set $i = $i - 1
344 end
345
78d11cb Michael Wallner - add print_inh (prints a very simple class tree, ie. extensible)
m6w6 authored
346 if $p->nKeyLength > 0
347 ____print_str $p->arKey $p->nKeyLength
348 printf " => "
6dcb27d - MFH
Marcus Boerger authored
349 else
350 printf "%d => ", $p->h
351 end
352
353 printf "\"%s\"\n", $func->common.function_name
354 set $p = $p->pListNext
355 end
356 end
357
358 define print_ft
359 set $ind = 1
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
360 printf "[%p] {\n", $arg0
6dcb27d - MFH
Marcus Boerger authored
361 ____print_ft $arg0
362 printf "}\n"
363 end
364
365 document print_ft
366 dumps a function table (HashTable)
367 end
368
55f0daf Michael Wallner - treat interfaces and classes gracefully in print_inh
m6w6 authored
369 define ____print_inh_class
370 set $ce = $arg0
371 if $ce->ce_flags & 0x10 || $ce->ce_flags & 0x20
372 printf "abstract "
373 else
374 if $ce->ce_flags & 0x40
375 printf "final "
376 end
377 end
378 printf "class %s", $ce->name
379 if $ce->parent != 0
380 printf " extends %s", $ce->parent->name
381 end
382 if $ce->num_interfaces != 0
383 printf " implements"
384 set $tmp = 0
385 while $tmp < $ce->num_interfaces
386 printf " %s", $ce->interfaces[$tmp]->name
387 set $tmp = $tmp + 1
388 if $tmp < $ce->num_interfaces
389 printf ","
390 end
391 end
392 end
393 set $ce = $ce->parent
394 end
395
396 define ____print_inh_iface
397 set $ce = $arg0
398 printf "interface %s", $ce->name
399 if $ce->num_interfaces != 0
400 set $ce = $ce->interfaces[0]
401 printf " extends %s", $ce->name
402 else
403 set $ce = 0
404 end
405 end
406
78d11cb Michael Wallner - add print_inh (prints a very simple class tree, ie. extensible)
m6w6 authored
407 define print_inh
408 set $ce = $arg0
409 set $depth = 0
410 while $ce != 0
411 set $tmp = $depth
412 while $tmp != 0
413 printf " "
414 set $tmp = $tmp - 1
415 end
55f0daf Michael Wallner - treat interfaces and classes gracefully in print_inh
m6w6 authored
416 set $depth = $depth + 1
417 if $ce->ce_flags & 0x80
418 ____print_inh_iface $ce
419 else
420 ____print_inh_class $ce
78d11cb Michael Wallner - add print_inh (prints a very simple class tree, ie. extensible)
m6w6 authored
421 end
422 printf " {\n"
423 end
424 while $depth != 0
425 set $tmp = $depth
426 while $tmp != 1
427 printf " "
428 set $tmp = $tmp - 1
429 end
430 printf "}\n"
431 set $depth = $depth - 1
432 end
433 end
434
435 define print_pi
436 set $pi = $arg0
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
437 printf "[%p] {\n", $pi
78d11cb Michael Wallner - add print_inh (prints a very simple class tree, ie. extensible)
m6w6 authored
438 printf " h = %lu\n", $pi->h
439 printf " flags = %d (", $pi->flags
440 if $pi->flags & 0x100
441 printf "ZEND_ACC_PUBLIC"
442 else
443 if $pi->flags & 0x200
444 printf "ZEND_ACC_PROTECTED"
445 else
446 if $pi->flags & 0x400
447 printf "ZEND_ACC_PRIVATE"
448 else
449 if $pi->flags & 0x800
450 printf "ZEND_ACC_CHANGED"
451 end
452 end
453 end
454 end
455 printf ")\n"
456 printf " name = "
457 ____print_str $pi->name $pi->name_length
458 printf "\n}\n"
459 end
460
461 define ____print_str
462 set $tmp = 0
463 set $str = $arg0
464 printf "\""
465 while $tmp < $arg1
466 if $str[$tmp] > 32 && $str[$tmp] < 127
467 printf "%c", $str[$tmp]
468 else
469 printf "\\%o", $str[$tmp]
470 end
471 set $tmp = $tmp + 1
472 end
473 printf "\""
474 end
475
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
476 define printzn
cfbf35a Support for ZTS
Marcus Boerger authored
477 ____executor_globals
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
478 set $ind = 0
479 set $znode = $arg0
480 if $znode->op_type == 1
481 set $optype = "IS_CONST"
482 end
483 if $znode->op_type == 2
484 set $optype = "IS_TMP_VAR"
485 end
486 if $znode->op_type == 4
487 set $optype = "IS_VAR"
488 end
489 if $znode->op_type == 8
490 set $optype = "IS_UNUSED"
491 end
492
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
493 printf "[%p] %s", $znode, $optype
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
494
495 if $znode->op_type == 1
496 printf ": "
3974225 Fixed printzn part.
Moriyoshi Koizumi authored
497 ____printzv &$znode->u.constant 0
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
498 end
499 if $znode->op_type == 2
500 printf ": "
cfbf35a Support for ZTS
Marcus Boerger authored
501 set $tvar = (union _temp_variable *)((char *)$eg.current_execute_data->Ts + $znode->u.var)
3974225 Fixed printzn part.
Moriyoshi Koizumi authored
502 ____printzv ((union _temp_variable *)$tvar)->tmp_var 0
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
503 end
504 if $znode->op_type == 4
505 printf ": "
cfbf35a Support for ZTS
Marcus Boerger authored
506 set $tvar = (union _temp_variable *)((char *)$eg.current_execute_data->Ts + $znode->u.var)
3974225 Fixed printzn part.
Moriyoshi Koizumi authored
507 ____printzv *$tvar->var.ptr_ptr 0
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
508 end
509 if $znode->op_type == 8
510 printf "\n"
511 end
512 end
513
514 document printzn
e184a55 Improved readability of zmemcheck output
Moriyoshi Koizumi authored
515 print type and content of znode.
516 usage: printzn &opline->op1
80bfd18 Added zmemcheck macro, which may help you examine the memory blocks bein...
Moriyoshi Koizumi authored
517 end
518
519 define printzops
520 printf "op1 => "
521 printzn &execute_data->opline.op1
522 printf "op2 => "
523 printzn &execute_data->opline.op2
524 printf "result => "
525 printzn &execute_data->opline.result
526 end
527
528 document printzops
529 dump operands of the current opline
530 end
531
097bfda - Add "zbacktrace" user-defined command.
Moriyoshi Koizumi authored
532 define zbacktrace
533 ____executor_globals
534 dump_bt $eg.current_execute_data
535 end
536
537 document zbacktrace
538 prints backtrace.
539 This command is almost a short cut for
540 > (gdb) ____executor_globals
541 > (gdb) dump_bt $eg.current_execute_data
542 end
543
80bfd18 Added zmemcheck macro, which may help you examine the memory blocks bein...
Moriyoshi Koizumi authored
544 define zmemcheck
545 set $p = alloc_globals.head
546 set $stat = "?"
33fb9a6 Improved zmemcheck macro so it displays the size of each memory block to...
Moriyoshi Koizumi authored
547 set $total_size = 0
80bfd18 Added zmemcheck macro, which may help you examine the memory blocks bein...
Moriyoshi Koizumi authored
548 if $arg0 != 0
549 set $not_found = 1
550 else
551 set $not_found = 0
552 end
33fb9a6 Improved zmemcheck macro so it displays the size of each memory block to...
Moriyoshi Koizumi authored
553 printf " block size status file:line\n"
80bfd18 Added zmemcheck macro, which may help you examine the memory blocks bein...
Moriyoshi Koizumi authored
554 printf "-------------------------------------------------------------------------------\n"
555 while $p
556 set $aptr = $p + sizeof(struct _zend_mem_header) + sizeof(align_test)
557 if $arg0 == 0 || (void *)$aptr == (void *)$arg0
558 if $p->magic == 0x7312f8dc
559 set $stat = "OK"
560 end
561 if $p->magic == 0x99954317
562 set $stat = "FREED"
563 end
564 if $p->magic == 0xfb8277dc
565 set $stat = "CACHED"
566 end
e184a55 Improved readability of zmemcheck output
Moriyoshi Koizumi authored
567 set $filename = strrchr($p->filename, '/')
568 if !$filename
569 set $filename = $p->filename
570 else
571 set $filename = $filename + 1
572 end
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
573 printf " %p ", $aptr
33fb9a6 Improved zmemcheck macro so it displays the size of each memory block to...
Moriyoshi Koizumi authored
574 if $p->size == sizeof(struct _zval_struct) && ((struct _zval_struct *)$aptr)->type >= 0 && ((struct _zval_struct *)$aptr)->type < 10
575 printf "ZVAL?(%-2d) ", $p->size
576 else
577 printf "%-9d ", $p->size
578 end
579 set $total_size = $total_size + $p->size
580 printf "%-06s %s:%d", $stat, $filename, $p->lineno
80bfd18 Added zmemcheck macro, which may help you examine the memory blocks bein...
Moriyoshi Koizumi authored
581 if $p->orig_filename
e184a55 Improved readability of zmemcheck output
Moriyoshi Koizumi authored
582 set $orig_filename = strrchr($p->orig_filename, '/')
583 if !$orig_filename
584 set $orig_filename = $p->orig_filename
585 else
586 set $orig_filename = $orig_filename + 1
587 end
588 printf " <= %s:%d\n", $orig_filename, $p->orig_lineno
589 else
590 printf "\n"
80bfd18 Added zmemcheck macro, which may help you examine the memory blocks bein...
Moriyoshi Koizumi authored
591 end
592 if $arg0 != 0
593 set $p = 0
594 set $not_found = 0
595 else
596 set $p = $p->pNext
597 end
598 else
599 set $p = $p->pNext
600 end
601 end
602 if $not_found
ded11f4 Xinchen Hui Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
laruence authored
603 printf "no such block that begins at %p.\n", $aptr
80bfd18 Added zmemcheck macro, which may help you examine the memory blocks bein...
Moriyoshi Koizumi authored
604 end
33fb9a6 Improved zmemcheck macro so it displays the size of each memory block to...
Moriyoshi Koizumi authored
605 if $arg0 == 0
606 printf "-------------------------------------------------------------------------------\n"
607 printf " total: %d bytes\n", $total_size
608 end
80bfd18 Added zmemcheck macro, which may help you examine the memory blocks bein...
Moriyoshi Koizumi authored
609 end
610
611 document zmemcheck
e184a55 Improved readability of zmemcheck output
Moriyoshi Koizumi authored
612 show status of a memory block.
613 usage: zmemcheck [ptr].
614 if ptr is 0, all blocks will be listed.
6e3faef Added various gdb macros to examine zval, znode, and HashTable
Moriyoshi Koizumi authored
615 end
Something went wrong with that request. Please try again.