Annotation of embedaddon/php/.gdbinit, revision 1.1.1.2
1.1 misho 1: define ____executor_globals
2: if basic_functions_module.zts
3: set $tsrm_ls = ts_resource_ex(0, 0)
1.1.1.2 ! misho 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])
1.1 misho 6: else
7: set $eg = executor_globals
8: set $cg = compiler_globals
9: end
10: end
11:
12: document ____executor_globals
13: portable way of accessing executor_globals, set $eg
14: this also sets compiler_globals to $cg
15: ZTS detection is automatically based on ext/standard module struct
16: end
17:
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:
37: define dump_bt
38: set $t = $arg0
39: while $t
1.1.1.2 ! misho 40: printf "[%p] ", $t
1.1 misho 41: if $t->function_state.function->common.function_name
1.1.1.2 ! misho 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"
! 62: end
! 63: end
! 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
! 89: end
! 90: printf ") "
! 91: else
! 92: printf "%s() ", $t->function_state.function->common.function_name
! 93: end
1.1 misho 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"
102: end
103: end
104:
105: document dump_bt
106: dumps the current execution stack. usage: dump_bt executor_globals.current_execute_data
107: end
108:
109: define printzv
110: set $ind = 1
111: ____printzv $arg0 0
112: end
113:
114: document printzv
115: prints zval contents
116: end
117:
118: define ____printzv_contents
119: set $zvalue = $arg0
120: set $type = $zvalue->type
121:
122: printf "(refcount=%d", $zvalue->refcount__gc
123: if $zvalue->is_ref__gc
124: printf ",is_ref"
125: end
126: printf ") "
127: if $type == 0
128: printf "NULL"
129: end
130: if $type == 1
131: printf "long: %ld", $zvalue->value.lval
132: end
133: if $type == 2
134: printf "double: %lf", $zvalue->value.dval
135: end
136: if $type == 3
137: printf "bool: "
138: if $zvalue->value.lval
139: printf "true"
140: else
141: printf "false"
142: end
143: end
144: if $type == 4
145: printf "array(%d): ", $zvalue->value.ht->nNumOfElements
146: if ! $arg1
147: printf "{\n"
148: set $ind = $ind + 1
149: ____print_ht $zvalue->value.ht 1
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
158: set $type = 0
159: end
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
176: if ! $arg1
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
183: ____print_ht $ht 1
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
194: end
195: end
196: set $type = 0
197: end
198: if $type == 6
199: printf "string(%d): ", $zvalue->value.str.len
200: ____print_str $zvalue->value.str.val $zvalue->value.str.len
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"
210: end
211: if $type > 9
212: printf "unknown type %d", $type
213: end
214: printf "\n"
215: end
216:
217: define ____printzv
218: ____executor_globals
219: set $zvalue = $arg0
220:
1.1.1.2 ! misho 221: printf "[%p] ", $zvalue
1.1 misho 222:
223: if $zvalue == $eg.uninitialized_zval_ptr
224: printf "*uninitialized* "
225: end
226:
227: set $zcontents = (zval*) $zvalue
228: if $arg1
229: ____printzv_contents $zcontents $arg1
230: else
231: ____printzv_contents $zcontents 0
232: end
233: end
234:
235: define ____print_const_table
236: set $ht = $arg0
237: set $p = $ht->pListHead
238:
239: while $p != 0
240: set $const = (zend_constant *) $p->pData
241:
242: set $i = $ind
243: while $i > 0
244: printf " "
245: set $i = $i - 1
246: end
247:
248: if $p->nKeyLength > 0
249: ____print_str $p->arKey $p->nKeyLength
250: printf " => "
251: else
252: printf "%d => ", $p->h
253: end
254:
255: ____printzv_contents &$const->value 0
256: set $p = $p->pListNext
257: end
258: end
259:
260: define print_const_table
261: set $ind = 1
1.1.1.2 ! misho 262: printf "[%p] {\n", $arg0
1.1 misho 263: ____print_const_table $arg0
264: printf "}\n"
265: end
266:
267: define ____print_ht
268: set $ht = (HashTable*)$arg0
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:
278: if $p->nKeyLength > 0
279: ____print_str $p->arKey $p->nKeyLength
280: printf " => "
281: else
282: printf "%d => ", $p->h
283: end
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
295:
296: set $p = $p->pListNext
297: end
298: end
299:
300: define print_ht
301: set $ind = 1
1.1.1.2 ! misho 302: printf "[%p] {\n", $arg0
1.1 misho 303: ____print_ht $arg0 1
304: printf "}\n"
305: end
306:
307: document print_ht
308: dumps elements of HashTable made of zval
309: end
310:
311: define print_htptr
312: set $ind = 1
1.1.1.2 ! misho 313: printf "[%p] {\n", $arg0
1.1 misho 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
1.1.1.2 ! misho 324: printf "[%p] {\n", $arg0
1.1 misho 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:
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:
346: if $p->nKeyLength > 0
347: ____print_str $p->arKey $p->nKeyLength
348: printf " => "
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
1.1.1.2 ! misho 360: printf "[%p] {\n", $arg0
1.1 misho 361: ____print_ft $arg0
362: printf "}\n"
363: end
364:
365: document print_ft
366: dumps a function table (HashTable)
367: end
368:
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:
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
416: set $depth = $depth + 1
417: if $ce->ce_flags & 0x80
418: ____print_inh_iface $ce
419: else
420: ____print_inh_class $ce
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
1.1.1.2 ! misho 437: printf "[%p] {\n", $pi
1.1 misho 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:
476: define printzn
477: ____executor_globals
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:
1.1.1.2 ! misho 493: printf "[%p] %s", $znode, $optype
1.1 misho 494:
495: if $znode->op_type == 1
496: printf ": "
497: ____printzv &$znode->u.constant 0
498: end
499: if $znode->op_type == 2
500: printf ": "
501: set $tvar = (union _temp_variable *)((char *)$eg.current_execute_data->Ts + $znode->u.var)
502: ____printzv ((union _temp_variable *)$tvar)->tmp_var 0
503: end
504: if $znode->op_type == 4
505: printf ": "
506: set $tvar = (union _temp_variable *)((char *)$eg.current_execute_data->Ts + $znode->u.var)
507: ____printzv *$tvar->var.ptr_ptr 0
508: end
509: if $znode->op_type == 8
510: printf "\n"
511: end
512: end
513:
514: document printzn
515: print type and content of znode.
516: usage: printzn &opline->op1
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:
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:
544: define zmemcheck
545: set $p = alloc_globals.head
546: set $stat = "?"
547: set $total_size = 0
548: if $arg0 != 0
549: set $not_found = 1
550: else
551: set $not_found = 0
552: end
553: printf " block size status file:line\n"
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
567: set $filename = strrchr($p->filename, '/')
568: if !$filename
569: set $filename = $p->filename
570: else
571: set $filename = $filename + 1
572: end
1.1.1.2 ! misho 573: printf " %p ", $aptr
1.1 misho 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
581: if $p->orig_filename
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"
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
1.1.1.2 ! misho 603: printf "no such block that begins at %p.\n", $aptr
1.1 misho 604: end
605: if $arg0 == 0
606: printf "-------------------------------------------------------------------------------\n"
607: printf " total: %d bytes\n", $total_size
608: end
609: end
610:
611: document zmemcheck
612: show status of a memory block.
613: usage: zmemcheck [ptr].
614: if ptr is 0, all blocks will be listed.
615: end
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>