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