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
12 define ____executor_globals
13 if basic_functions_module.zts
15 set $tsrm_ls = ts_resource_ex(0, 0)
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])
20 set $eg = executor_globals
21 set $cg = compiler_globals
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
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
38 printf "Compiled variables count: %d\n", $c
40 printf "%d = %s\n", $i, $v[$i].name
44 printf "*uninitialized*\n"
54 set $fst = $t->function_state
55 if $fst.function->common.function_name
57 set $count = (int)*($fst.arguments)
60 if $fst.function.common.scope
61 printf "%s->", $fst.function.common.scope->name
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
73 if $handlers->get_class_entry == &zend_std_object_get_class
76 if $handlers.get_class_name
77 if $handlers.get_class_name != &zend_std_object_get_class_name
83 printf "%s->", $zobj->ce.name
93 if $fst.function.common.scope
94 printf "%s::", $fst.function.common.scope->name
98 printf "%s(", $fst.function->common.function_name
100 set $zvalue = *(zval **)($fst.arguments - $count)
101 set $type = $zvalue->type
106 printf "%ld", $zvalue->value.lval
109 printf "%lf", $zvalue->value.dval
112 if $zvalue->value.lval
119 printf "array(%d)[%p]", $zvalue->value.ht->nNumOfElements, $zvalue
122 printf "object[%p]", $zvalue
125 ____print_str $zvalue->value.str.val $zvalue->value.str.len
128 printf "resource(#%d)", $zvalue->value.lval
137 printf "unknown type %d", $type
139 set $count = $count -1
146 printf "%s() ", $fst.function->common.function_name
152 printf "%s:%d ", $t->op_array->filename, $t->opline->lineno
154 set $t = $t->prev_execute_data
160 dumps the current execution stack. usage: dump_bt executor_globals.current_execute_data
172 define ____printzv_contents
174 set $type = $zvalue->type
176 printf "(refcount=%d", $zvalue->refcount__gc
177 if $zvalue->is_ref__gc
185 printf "long: %ld", $zvalue->value.lval
188 printf "double: %lf", $zvalue->value.dval
192 if $zvalue->value.lval
199 printf "array(%d): ", $zvalue->value.ht->nNumOfElements
203 ____print_ht $zvalue->value.ht 1
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)
222 set $zobj = zend_objects_get_address($zvalue)
224 if $handlers->get_class_entry == &zend_std_object_get_class
225 set $cname = $zobj->ce.name
227 set $cname = "Unknown"
229 printf "(%s) #%d", $cname, $handle
231 if $handlers->get_properties == &zend_std_get_properties
232 set $ht = $zobj->properties
234 printf "(%d): ", $ht->nNumOfElements
246 echo "no properties found"
253 printf "string(%d): ", $zvalue->value.str.len
254 ____print_str $zvalue->value.str.val $zvalue->value.str.len
257 printf "resource: #%d", $zvalue->value.lval
266 printf "unknown type %d", $type
275 printf "[%p] ", $zvalue
277 if $zvalue == $eg.uninitialized_zval_ptr
278 printf "*uninitialized* "
281 set $zcontents = (zval*) $zvalue
283 ____printzv_contents $zcontents $arg1
285 ____printzv_contents $zcontents 0
289 define ____print_const_table
291 set $p = $ht->pListHead
294 set $const = (zend_constant *) $p->pData
302 if $p->nKeyLength > 0
303 ____print_str $p->arKey $p->nKeyLength
306 printf "%d => ", $p->h
309 ____printzv_contents &$const->value 0
310 set $p = $p->pListNext
314 define print_const_table
316 printf "[%p] {\n", $arg0
317 ____print_const_table $arg0
322 set $ht = (HashTable*)$arg0
323 set $p = $ht->pListHead
332 if $p->nKeyLength > 0
333 ____print_str $p->arKey $p->nKeyLength
336 printf "%d => ", $p->h
340 printf "%p\n", (void*)$p->pData
343 set $zval = *(zval **)$p->pData
347 printf "%s\n", (char*)$p->pData
350 set $p = $p->pListNext
356 printf "[%p] {\n", $arg0
362 dumps elements of HashTable made of zval
367 printf "[%p] {\n", $arg0
373 dumps elements of HashTable made of pointers
378 printf "[%p] {\n", $arg0
384 dumps elements of HashTable made of strings
389 set $p = $ht->pListHead
392 set $func = (zend_function*)$p->pData
400 if $p->nKeyLength > 0
401 ____print_str $p->arKey $p->nKeyLength
404 printf "%d => ", $p->h
407 printf "\"%s\"\n", $func->common.function_name
408 set $p = $p->pListNext
414 printf "[%p] {\n", $arg0
420 dumps a function table (HashTable)
423 define ____print_inh_class
425 if $ce->ce_flags & 0x10 || $ce->ce_flags & 0x20
428 if $ce->ce_flags & 0x40
432 printf "class %s", $ce->name
434 printf " extends %s", $ce->parent->name
436 if $ce->num_interfaces != 0
439 while $tmp < $ce->num_interfaces
440 printf " %s", $ce->interfaces[$tmp]->name
442 if $tmp < $ce->num_interfaces
447 set $ce = $ce->parent
450 define ____print_inh_iface
452 printf "interface %s", $ce->name
453 if $ce->num_interfaces != 0
454 set $ce = $ce->interfaces[0]
455 printf " extends %s", $ce->name
470 set $depth = $depth + 1
471 if $ce->ce_flags & 0x80
472 ____print_inh_iface $ce
474 ____print_inh_class $ce
485 set $depth = $depth - 1
491 printf "[%p] {\n", $pi
492 printf " h = %lu\n", $pi->h
493 printf " flags = %d (", $pi->flags
494 if $pi->flags & 0x100
495 printf "ZEND_ACC_PUBLIC"
497 if $pi->flags & 0x200
498 printf "ZEND_ACC_PROTECTED"
500 if $pi->flags & 0x400
501 printf "ZEND_ACC_PRIVATE"
503 if $pi->flags & 0x800
504 printf "ZEND_ACC_CHANGED"
511 ____print_str $pi->name $pi->name_length
520 if $str[$tmp] > 32 && $str[$tmp] < 127
521 printf "%c", $str[$tmp]
523 printf "\\%o", $str[$tmp]
534 if $znode->op_type == 1
535 set $optype = "IS_CONST"
537 if $znode->op_type == 2
538 set $optype = "IS_TMP_VAR"
540 if $znode->op_type == 4
541 set $optype = "IS_VAR"
543 if $znode->op_type == 8
544 set $optype = "IS_UNUSED"
547 printf "[%p] %s", $znode, $optype
549 if $znode->op_type == 1
551 ____printzv &$znode->u.constant 0
553 if $znode->op_type == 2
555 set $tvar = (union _temp_variable *)((char *)$eg.current_execute_data->Ts + $znode->u.var)
556 ____printzv ((union _temp_variable *)$tvar)->tmp_var 0
558 if $znode->op_type == 4
560 set $tvar = (union _temp_variable *)((char *)$eg.current_execute_data->Ts + $znode->u.var)
561 ____printzv *$tvar->var.ptr_ptr 0
563 if $znode->op_type == 8
569 print type and content of znode.
570 usage: printzn &opline->op1
575 printzn &execute_data->opline.op1
577 printzn &execute_data->opline.op2
579 printzn &execute_data->opline.result
583 dump operands of the current opline
588 dump_bt $eg.current_execute_data
593 This command is almost a short cut for
594 > (gdb) ____executor_globals
595 > (gdb) dump_bt $eg.current_execute_data
599 set $p = alloc_globals.head
607 printf " block size status file:line\n"
608 printf "-------------------------------------------------------------------------------\n"
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
615 if $p->magic == 0x99954317
618 if $p->magic == 0xfb8277dc
621 set $filename = strrchr($p->filename, '/')
623 set $filename = $p->filename
625 set $filename = $filename + 1
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
631 printf "%-9d ", $p->size
633 set $total_size = $total_size + $p->size
634 printf "%-06s %s:%d", $stat, $filename, $p->lineno
636 set $orig_filename = strrchr($p->orig_filename, '/')
638 set $orig_filename = $p->orig_filename
640 set $orig_filename = $orig_filename + 1
642 printf " <= %s:%d\n", $orig_filename, $p->orig_lineno
657 printf "no such block that begins at %p.\n", $aptr
660 printf "-------------------------------------------------------------------------------\n"
661 printf " total: %d bytes\n", $total_size
666 show status of a memory block.
667 usage: zmemcheck [ptr].
668 if ptr is 0, all blocks will be listed.