2012-10-02 00:02:08 +08:00
|
|
|
define set_ts
|
|
|
|
set $tsrm_ls = $arg0
|
|
|
|
end
|
|
|
|
|
|
|
|
document set_ts
|
|
|
|
set the ts resource, it is impossible for gdb to
|
|
|
|
call ts_resource_ex while no process is running,
|
2018-10-13 20:16:33 +08:00
|
|
|
but we could get the resource from the argument
|
2012-10-02 00:02:08 +08:00
|
|
|
of frame info.
|
|
|
|
end
|
|
|
|
|
2003-04-07 04:19:52 +08:00
|
|
|
define ____executor_globals
|
2006-03-09 07:54:43 +08:00
|
|
|
if basic_functions_module.zts
|
2012-10-02 00:02:08 +08:00
|
|
|
if !$tsrm_ls
|
|
|
|
set $tsrm_ls = ts_resource_ex(0, 0)
|
|
|
|
end
|
2012-03-11 23:12:28 +08:00
|
|
|
set $eg = ((zend_executor_globals*) (*((void ***) $tsrm_ls))[executor_globals_id-1])
|
|
|
|
set $cg = ((zend_compiler_globals*) (*((void ***) $tsrm_ls))[compiler_globals_id-1])
|
2018-05-17 04:01:24 +08:00
|
|
|
set $eg_ptr = $eg
|
2003-04-07 04:19:52 +08:00
|
|
|
else
|
|
|
|
set $eg = executor_globals
|
2009-01-04 23:20:19 +08:00
|
|
|
set $cg = compiler_globals
|
2018-05-17 04:01:24 +08:00
|
|
|
set $eg_ptr = (zend_executor_globals*) &executor_globals
|
2003-04-07 04:19:52 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
document ____executor_globals
|
2007-05-21 05:46:17 +08:00
|
|
|
portable way of accessing executor_globals, set $eg
|
2009-01-04 23:20:19 +08:00
|
|
|
this also sets compiler_globals to $cg
|
2006-03-09 07:54:43 +08:00
|
|
|
ZTS detection is automatically based on ext/standard module struct
|
2003-04-07 04:19:52 +08:00
|
|
|
end
|
|
|
|
|
2009-08-01 20:55:36 +08:00
|
|
|
define print_cvs
|
2017-01-12 12:57:33 +08:00
|
|
|
if $argc == 0
|
|
|
|
____executor_globals
|
|
|
|
set $cv_ex_ptr = $eg.current_execute_data
|
|
|
|
else
|
|
|
|
set $cv_ex_ptr = (zend_execute_data *)$arg0
|
|
|
|
end
|
|
|
|
set $cv_count = $cv_ex_ptr.func.op_array.last_var
|
|
|
|
set $cv = $cv_ex_ptr.func.op_array.vars
|
|
|
|
set $cv_idx = 0
|
|
|
|
set $callFrameSize = (sizeof(zend_execute_data) + sizeof(zval) - 1) / sizeof(zval)
|
2009-08-01 20:55:36 +08:00
|
|
|
|
2017-01-12 12:57:33 +08:00
|
|
|
printf "Compiled variables count: %d\n\n", $cv_count
|
|
|
|
while $cv_idx < $cv_count
|
|
|
|
printf "[%d] '%s'\n", $cv_idx, $cv[$cv_idx].val
|
|
|
|
set $zvalue = ((zval *) $cv_ex_ptr) + $callFrameSize + $cv_idx
|
|
|
|
printzv $zvalue
|
|
|
|
set $cv_idx = $cv_idx + 1
|
2009-08-01 20:55:36 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-12 12:57:33 +08:00
|
|
|
document print_cvs
|
|
|
|
Prints the compiled variables and their values.
|
|
|
|
If a zend_execute_data pointer is set this will print the compiled
|
|
|
|
variables of that scope. If no parameter is used it will use
|
|
|
|
current_execute_data for scope.
|
|
|
|
|
|
|
|
usage: print_cvs [zend_execute_data *]
|
|
|
|
end
|
|
|
|
|
2003-02-14 20:04:03 +08:00
|
|
|
define dump_bt
|
2014-08-28 17:03:27 +08:00
|
|
|
set $ex = $arg0
|
2014-07-08 19:09:01 +08:00
|
|
|
while $ex
|
|
|
|
printf "[%p] ", $ex
|
|
|
|
set $func = $ex->func
|
|
|
|
if $func
|
2014-10-13 02:39:07 +08:00
|
|
|
if $ex->This->value.obj
|
2014-07-08 19:09:01 +08:00
|
|
|
if $func->common.scope
|
|
|
|
printf "%s->", $func->common.scope->name->val
|
2012-09-30 03:16:26 +08:00
|
|
|
else
|
2014-10-13 02:39:07 +08:00
|
|
|
printf "%s->", $ex->This->value.obj->ce.name->val
|
2012-09-30 03:16:26 +08:00
|
|
|
end
|
2014-07-08 19:09:01 +08:00
|
|
|
else
|
|
|
|
if $func->common.scope
|
|
|
|
printf "%s::", $func->common.scope->name->val
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-08-28 17:03:27 +08:00
|
|
|
if $func->common.function_name
|
|
|
|
printf "%s(", $func->common.function_name->val
|
|
|
|
else
|
|
|
|
printf "(main"
|
|
|
|
end
|
2014-07-08 19:09:01 +08:00
|
|
|
|
|
|
|
set $callFrameSize = (sizeof(zend_execute_data) + sizeof(zval) - 1) / sizeof(zval)
|
2012-09-30 03:16:26 +08:00
|
|
|
|
2015-02-10 03:43:22 +08:00
|
|
|
set $count = $ex->This.u2.num_args
|
2014-07-08 19:09:01 +08:00
|
|
|
set $arg = 0
|
|
|
|
while $arg < $count
|
|
|
|
if $arg > 0
|
|
|
|
printf ", "
|
2011-12-06 17:56:01 +08:00
|
|
|
end
|
2014-07-08 19:09:01 +08:00
|
|
|
|
|
|
|
set $zvalue = (zval *) $ex + $callFrameSize + $arg
|
|
|
|
set $type = $zvalue->u1.v.type
|
|
|
|
if $type == 1
|
|
|
|
printf "NULL"
|
|
|
|
end
|
|
|
|
if $type == 2
|
|
|
|
printf "false"
|
|
|
|
end
|
|
|
|
if $type == 3
|
|
|
|
printf "true"
|
|
|
|
end
|
|
|
|
if $type == 4
|
|
|
|
printf "%ld", $zvalue->value.lval
|
|
|
|
end
|
|
|
|
if $type == 5
|
|
|
|
printf "%f", $zvalue->value.dval
|
|
|
|
end
|
|
|
|
if $type == 6
|
|
|
|
____print_str $zvalue->value.str->val $zvalue->value.str->len
|
|
|
|
end
|
|
|
|
if $type == 7
|
2015-08-14 16:20:53 +08:00
|
|
|
printf "array(%d)[%p]", $zvalue->value.arr->nNumOfElements, $zvalue
|
2014-07-08 19:09:01 +08:00
|
|
|
end
|
|
|
|
if $type == 8
|
|
|
|
printf "object[%p]", $zvalue
|
|
|
|
end
|
|
|
|
if $type == 9
|
|
|
|
printf "resource(#%d)", $zvalue->value.lval
|
|
|
|
end
|
|
|
|
if $type == 10
|
|
|
|
printf "reference"
|
|
|
|
end
|
|
|
|
if $type > 10
|
|
|
|
printf "unknown type %d", $type
|
|
|
|
end
|
|
|
|
set $arg = $arg + 1
|
2011-12-06 17:56:01 +08:00
|
|
|
end
|
2014-07-08 19:09:01 +08:00
|
|
|
|
|
|
|
printf ") "
|
2003-02-14 20:04:03 +08:00
|
|
|
else
|
|
|
|
printf "??? "
|
|
|
|
end
|
2014-07-08 19:09:01 +08:00
|
|
|
if $func != 0
|
2014-08-28 17:03:27 +08:00
|
|
|
if $func->type == 2
|
|
|
|
printf "%s:%d ", $func->op_array.filename->val, $ex->opline->lineno
|
|
|
|
else
|
|
|
|
printf "[internal function]"
|
|
|
|
end
|
2003-02-14 20:04:03 +08:00
|
|
|
end
|
2014-07-08 19:09:01 +08:00
|
|
|
set $ex = $ex->prev_execute_data
|
2003-02-14 20:04:03 +08:00
|
|
|
printf "\n"
|
2003-04-07 04:19:52 +08:00
|
|
|
end
|
2003-02-14 20:04:03 +08:00
|
|
|
end
|
2003-03-31 01:45:33 +08:00
|
|
|
|
2003-02-14 20:04:03 +08:00
|
|
|
document dump_bt
|
|
|
|
dumps the current execution stack. usage: dump_bt executor_globals.current_execute_data
|
|
|
|
end
|
2003-03-31 01:45:33 +08:00
|
|
|
|
|
|
|
define printzv
|
2003-05-02 11:12:05 +08:00
|
|
|
set $ind = 1
|
2018-10-13 20:16:33 +08:00
|
|
|
____printzv $arg0 0
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
document printzv
|
2007-05-21 05:46:17 +08:00
|
|
|
prints zval contents
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
|
|
|
|
2003-05-02 11:12:05 +08:00
|
|
|
define ____printzv_contents
|
2003-03-31 01:45:33 +08:00
|
|
|
set $zvalue = $arg0
|
2014-05-26 00:53:28 +08:00
|
|
|
set $type = $zvalue->u1.v.type
|
2003-03-31 01:45:33 +08:00
|
|
|
|
2014-05-29 18:47:40 +08:00
|
|
|
# 15 == IS_INDIRECT
|
2015-09-02 05:52:04 +08:00
|
|
|
if $type > 5 && $type != 15
|
2015-08-18 14:18:57 +08:00
|
|
|
printf "(refcount=%d) ", $zvalue->value.counted->gc.refcount
|
2014-05-29 18:47:40 +08:00
|
|
|
end
|
|
|
|
|
2006-03-09 07:54:43 +08:00
|
|
|
if $type == 0
|
2014-02-20 18:30:06 +08:00
|
|
|
printf "UNDEF"
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
2006-03-09 07:54:43 +08:00
|
|
|
if $type == 1
|
2018-02-15 04:39:01 +08:00
|
|
|
printf "NULL"
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
2006-03-09 07:54:43 +08:00
|
|
|
if $type == 2
|
2014-05-26 00:53:28 +08:00
|
|
|
printf "bool: false"
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
2006-03-09 07:54:43 +08:00
|
|
|
if $type == 3
|
2014-05-26 00:53:28 +08:00
|
|
|
printf "bool: true"
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
2018-02-15 04:39:01 +08:00
|
|
|
if $type == 4
|
2014-02-20 18:30:06 +08:00
|
|
|
printf "long: %ld", $zvalue->value.lval
|
2018-02-15 04:39:01 +08:00
|
|
|
end
|
|
|
|
if $type == 5
|
|
|
|
printf "double: %f", $zvalue->value.dval
|
|
|
|
end
|
|
|
|
if $type == 6
|
|
|
|
printf "string: %s", $zvalue->value.str->val
|
|
|
|
end
|
2018-10-13 20:16:33 +08:00
|
|
|
if $type == 7
|
2014-05-29 18:47:40 +08:00
|
|
|
printf "array: "
|
2003-03-31 01:45:33 +08:00
|
|
|
if ! $arg1
|
|
|
|
set $ind = $ind + 1
|
2015-08-15 02:22:55 +08:00
|
|
|
____print_ht $zvalue->value.arr 1
|
2003-03-31 01:45:33 +08:00
|
|
|
set $ind = $ind - 1
|
|
|
|
set $i = $ind
|
|
|
|
while $i > 0
|
|
|
|
printf " "
|
|
|
|
set $i = $i - 1
|
|
|
|
end
|
|
|
|
end
|
2006-03-09 07:54:43 +08:00
|
|
|
set $type = 0
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
2014-05-26 00:53:28 +08:00
|
|
|
if $type == 8
|
2006-03-09 07:54:43 +08:00
|
|
|
printf "object"
|
|
|
|
____executor_globals
|
|
|
|
set $handle = $zvalue->value.obj.handle
|
|
|
|
set $handlers = $zvalue->value.obj.handlers
|
2017-01-17 13:55:03 +08:00
|
|
|
set $zobj = $zvalue->value.obj
|
|
|
|
set $cname = $zobj->ce->name->val
|
2006-03-09 07:54:43 +08:00
|
|
|
printf "(%s) #%d", $cname, $handle
|
2003-03-31 01:45:33 +08:00
|
|
|
if ! $arg1
|
2006-03-09 07:54:43 +08:00
|
|
|
if $handlers->get_properties == &zend_std_get_properties
|
2017-01-17 13:55:03 +08:00
|
|
|
if $zobj->properties
|
|
|
|
set $ht = $zobj->properties
|
|
|
|
else
|
|
|
|
set $ht = &$zobj->ce->properties_info
|
|
|
|
end
|
|
|
|
printf "\nProperties "
|
2006-03-09 07:54:43 +08:00
|
|
|
if $ht
|
|
|
|
set $ind = $ind + 1
|
2007-05-21 05:46:17 +08:00
|
|
|
____print_ht $ht 1
|
2006-03-09 07:54:43 +08:00
|
|
|
set $ind = $ind - 1
|
|
|
|
set $i = $ind
|
|
|
|
while $i > 0
|
|
|
|
printf " "
|
|
|
|
set $i = $i - 1
|
|
|
|
end
|
|
|
|
else
|
2017-01-17 13:55:03 +08:00
|
|
|
echo "not found"
|
2006-03-09 07:54:43 +08:00
|
|
|
end
|
2003-04-07 04:19:52 +08:00
|
|
|
end
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
2006-03-09 07:54:43 +08:00
|
|
|
set $type = 0
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
2014-05-26 00:53:28 +08:00
|
|
|
if $type == 9
|
2014-02-20 18:30:06 +08:00
|
|
|
printf "resource: #%d", $zvalue->value.res->handle
|
2006-03-09 07:54:43 +08:00
|
|
|
end
|
2014-05-26 00:53:28 +08:00
|
|
|
if $type == 10
|
2014-05-29 04:43:53 +08:00
|
|
|
printf "reference: "
|
|
|
|
____printzv &$zvalue->value.ref->val $arg1
|
2006-03-09 07:54:43 +08:00
|
|
|
end
|
2014-05-26 00:53:28 +08:00
|
|
|
if $type == 11
|
2014-02-20 18:30:06 +08:00
|
|
|
printf "const: %s", $zvalue->value.str->val
|
2006-03-09 07:54:43 +08:00
|
|
|
end
|
2014-05-26 00:53:28 +08:00
|
|
|
if $type == 12
|
2018-02-15 04:39:01 +08:00
|
|
|
printf "CONSTANT_AST"
|
2014-05-26 00:53:28 +08:00
|
|
|
end
|
2014-02-20 18:30:06 +08:00
|
|
|
if $type == 13
|
2018-02-15 04:39:01 +08:00
|
|
|
printf "_BOOL"
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
2014-02-20 18:30:06 +08:00
|
|
|
if $type == 14
|
2018-02-15 04:39:01 +08:00
|
|
|
printf "CALLABLE"
|
2014-02-20 18:30:06 +08:00
|
|
|
end
|
|
|
|
if $type == 15
|
2014-05-29 04:43:53 +08:00
|
|
|
printf "indirect: "
|
|
|
|
____printzv $zvalue->value.zv $arg1
|
2014-02-20 18:30:06 +08:00
|
|
|
end
|
|
|
|
if $type == 17
|
|
|
|
printf "pointer: %p", $zvalue->value.ptr
|
|
|
|
end
|
2018-02-15 04:39:01 +08:00
|
|
|
if $type == 18
|
|
|
|
printf "ITERABLE"
|
|
|
|
end
|
|
|
|
if $type == 19
|
|
|
|
printf "VOID"
|
|
|
|
end
|
|
|
|
if $type == 20
|
|
|
|
printf "_ERROR"
|
|
|
|
end
|
|
|
|
if $type == 16 || $type > 20
|
2006-03-09 07:54:43 +08:00
|
|
|
printf "unknown type %d", $type
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
|
|
|
printf "\n"
|
|
|
|
end
|
|
|
|
|
2003-05-02 11:12:05 +08:00
|
|
|
define ____printzv
|
|
|
|
____executor_globals
|
|
|
|
set $zvalue = $arg0
|
|
|
|
|
2011-12-06 20:32:59 +08:00
|
|
|
printf "[%p] ", $zvalue
|
2003-05-02 11:12:05 +08:00
|
|
|
|
2006-03-09 07:54:43 +08:00
|
|
|
set $zcontents = (zval*) $zvalue
|
2003-05-02 11:12:05 +08:00
|
|
|
if $arg1
|
|
|
|
____printzv_contents $zcontents $arg1
|
|
|
|
else
|
2018-10-13 20:16:33 +08:00
|
|
|
____printzv_contents $zcontents 0
|
2003-05-02 11:12:05 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-17 04:01:24 +08:00
|
|
|
define print_global_vars
|
|
|
|
____executor_globals
|
|
|
|
set $symtable = ((HashTable *)&($eg_ptr->symbol_table))
|
|
|
|
print_ht $symtable
|
|
|
|
end
|
|
|
|
|
|
|
|
document print_global_vars
|
|
|
|
Prints the global variables
|
|
|
|
end
|
|
|
|
|
2003-05-02 11:12:05 +08:00
|
|
|
define print_const_table
|
|
|
|
set $ind = 1
|
2011-12-06 20:32:59 +08:00
|
|
|
printf "[%p] {\n", $arg0
|
2018-02-15 04:39:01 +08:00
|
|
|
____print_ht $arg0 4
|
2003-05-02 11:12:05 +08:00
|
|
|
printf "}\n"
|
|
|
|
end
|
|
|
|
|
2018-02-15 04:39:01 +08:00
|
|
|
document print_const_table
|
|
|
|
Dumps elements of Constants HashTable
|
|
|
|
Example: print_const_table executor_globals.zend_constants
|
|
|
|
end
|
|
|
|
|
2003-03-31 01:45:33 +08:00
|
|
|
define ____print_ht
|
2007-05-21 05:46:17 +08:00
|
|
|
set $ht = (HashTable*)$arg0
|
2014-02-20 18:30:06 +08:00
|
|
|
set $n = $ind
|
|
|
|
while $n > 0
|
|
|
|
printf " "
|
|
|
|
set $n = $n - 1
|
|
|
|
end
|
2014-05-29 18:47:40 +08:00
|
|
|
|
|
|
|
if $ht->u.v.flags & 4
|
|
|
|
printf "Packed"
|
|
|
|
else
|
|
|
|
printf "Hash"
|
|
|
|
end
|
|
|
|
printf "(%d)[%p]: {\n", $ht->nNumOfElements, $ht
|
|
|
|
|
|
|
|
set $num = $ht->nNumUsed
|
|
|
|
set $i = 0
|
|
|
|
set $ind = $ind + 1
|
|
|
|
while $i < $num
|
|
|
|
set $p = (Bucket*)($ht->arData + $i)
|
|
|
|
set $n = $ind
|
|
|
|
if $p->val.u1.v.type > 0
|
|
|
|
while $n > 0
|
|
|
|
printf " "
|
|
|
|
set $n = $n - 1
|
|
|
|
end
|
|
|
|
printf "[%d] ", $i
|
2018-10-13 20:16:33 +08:00
|
|
|
if $p->key
|
2014-05-29 18:47:40 +08:00
|
|
|
printf "%s => ", $p->key->val
|
|
|
|
else
|
2014-02-20 18:30:06 +08:00
|
|
|
printf "%d => ", $p->h
|
|
|
|
end
|
2014-05-29 18:47:40 +08:00
|
|
|
if $arg1 == 0
|
|
|
|
printf "%p\n", (zval *)&$p->val
|
2014-02-20 18:30:06 +08:00
|
|
|
end
|
2014-05-29 18:47:40 +08:00
|
|
|
if $arg1 == 1
|
|
|
|
set $zval = (zval *)&$p->val
|
|
|
|
____printzv $zval 1
|
|
|
|
end
|
|
|
|
if $arg1 == 2
|
|
|
|
printf "%s\n", (char*)$p->val.value.ptr
|
|
|
|
end
|
|
|
|
if $arg1 == 3
|
|
|
|
set $func = (zend_function*)$p->val.value.ptr
|
|
|
|
printf "\"%s\"\n", $func->common.function_name->val
|
|
|
|
end
|
2018-02-15 04:39:01 +08:00
|
|
|
if $arg1 == 4
|
|
|
|
set $const = (zend_constant *)$p->val.value.ptr
|
|
|
|
____printzv $const 1
|
|
|
|
end
|
2014-05-29 18:47:40 +08:00
|
|
|
end
|
|
|
|
set $i = $i + 1
|
|
|
|
end
|
|
|
|
set $ind = $ind - 1
|
|
|
|
printf "}\n"
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
define print_ht
|
2014-02-20 18:30:06 +08:00
|
|
|
set $ind = 0
|
2007-05-21 05:46:17 +08:00
|
|
|
____print_ht $arg0 1
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
document print_ht
|
|
|
|
dumps elements of HashTable made of zval
|
|
|
|
end
|
|
|
|
|
2007-05-21 05:46:17 +08:00
|
|
|
define print_htptr
|
2014-02-20 18:30:06 +08:00
|
|
|
set $ind = 0
|
2007-05-21 05:46:17 +08:00
|
|
|
____print_ht $arg0 0
|
|
|
|
end
|
|
|
|
|
|
|
|
document print_htptr
|
|
|
|
dumps elements of HashTable made of pointers
|
|
|
|
end
|
|
|
|
|
|
|
|
define print_htstr
|
2018-10-13 20:16:33 +08:00
|
|
|
set $ind = 0
|
2007-05-21 05:46:17 +08:00
|
|
|
____print_ht $arg0 2
|
|
|
|
end
|
|
|
|
|
|
|
|
document print_htstr
|
|
|
|
dumps elements of HashTable made of strings
|
|
|
|
end
|
|
|
|
|
2006-03-09 07:54:43 +08:00
|
|
|
define print_ft
|
2014-02-20 18:30:06 +08:00
|
|
|
set $ind = 0
|
|
|
|
____print_ht $arg0 3
|
2006-03-09 07:54:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
document print_ft
|
|
|
|
dumps a function table (HashTable)
|
|
|
|
end
|
|
|
|
|
2006-05-05 23:49:41 +08:00
|
|
|
define ____print_inh_class
|
|
|
|
set $ce = $arg0
|
|
|
|
if $ce->ce_flags & 0x10 || $ce->ce_flags & 0x20
|
|
|
|
printf "abstract "
|
|
|
|
else
|
|
|
|
if $ce->ce_flags & 0x40
|
|
|
|
printf "final "
|
|
|
|
end
|
|
|
|
end
|
2014-02-20 18:30:06 +08:00
|
|
|
printf "class %s", $ce->name->val
|
2006-05-05 23:49:41 +08:00
|
|
|
if $ce->parent != 0
|
2014-02-20 18:30:06 +08:00
|
|
|
printf " extends %s", $ce->parent->name->val
|
2006-05-05 23:49:41 +08:00
|
|
|
end
|
|
|
|
if $ce->num_interfaces != 0
|
|
|
|
printf " implements"
|
|
|
|
set $tmp = 0
|
|
|
|
while $tmp < $ce->num_interfaces
|
2014-02-20 18:30:06 +08:00
|
|
|
printf " %s", $ce->interfaces[$tmp]->name->val
|
2006-05-05 23:49:41 +08:00
|
|
|
set $tmp = $tmp + 1
|
|
|
|
if $tmp < $ce->num_interfaces
|
|
|
|
printf ","
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
set $ce = $ce->parent
|
|
|
|
end
|
|
|
|
|
|
|
|
define ____print_inh_iface
|
|
|
|
set $ce = $arg0
|
2014-02-20 18:30:06 +08:00
|
|
|
printf "interface %s", $ce->name->val
|
2006-05-05 23:49:41 +08:00
|
|
|
if $ce->num_interfaces != 0
|
|
|
|
set $ce = $ce->interfaces[0]
|
2014-02-20 18:30:06 +08:00
|
|
|
printf " extends %s", $ce->name->val
|
2006-05-05 23:49:41 +08:00
|
|
|
else
|
|
|
|
set $ce = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-05-05 23:14:37 +08:00
|
|
|
define print_inh
|
|
|
|
set $ce = $arg0
|
|
|
|
set $depth = 0
|
|
|
|
while $ce != 0
|
|
|
|
set $tmp = $depth
|
|
|
|
while $tmp != 0
|
|
|
|
printf " "
|
|
|
|
set $tmp = $tmp - 1
|
|
|
|
end
|
2006-05-05 23:49:41 +08:00
|
|
|
set $depth = $depth + 1
|
|
|
|
if $ce->ce_flags & 0x80
|
|
|
|
____print_inh_iface $ce
|
|
|
|
else
|
|
|
|
____print_inh_class $ce
|
2006-05-05 23:14:37 +08:00
|
|
|
end
|
|
|
|
printf " {\n"
|
|
|
|
end
|
|
|
|
while $depth != 0
|
|
|
|
set $tmp = $depth
|
|
|
|
while $tmp != 1
|
|
|
|
printf " "
|
|
|
|
set $tmp = $tmp - 1
|
|
|
|
end
|
|
|
|
printf "}\n"
|
|
|
|
set $depth = $depth - 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
define print_pi
|
2017-01-17 13:55:03 +08:00
|
|
|
set $pi = (zend_property_info *)$arg0
|
2018-02-10 01:30:45 +08:00
|
|
|
set $initial_offset = ((uint32_t)(zend_uintptr_t)(&((zend_object*)0)->properties_table[(0)]))
|
|
|
|
set $ptr_to_val = (zval*)((char*)$pi->ce->default_properties_table + $pi->offset - $initial_offset)
|
2011-12-06 20:32:59 +08:00
|
|
|
printf "[%p] {\n", $pi
|
2018-02-10 01:30:45 +08:00
|
|
|
printf " offset = %p\n", $pi->offset
|
2017-01-17 13:55:03 +08:00
|
|
|
printf " ce = [%p] %s\n", $pi->ce, $pi->ce->name->val
|
2018-02-10 01:30:45 +08:00
|
|
|
printf " flags = 0x%x (", $pi->flags
|
2006-05-05 23:14:37 +08:00
|
|
|
if $pi->flags & 0x100
|
|
|
|
printf "ZEND_ACC_PUBLIC"
|
|
|
|
else
|
|
|
|
if $pi->flags & 0x200
|
|
|
|
printf "ZEND_ACC_PROTECTED"
|
|
|
|
else
|
|
|
|
if $pi->flags & 0x400
|
|
|
|
printf "ZEND_ACC_PRIVATE"
|
|
|
|
else
|
|
|
|
if $pi->flags & 0x800
|
2018-02-10 01:30:45 +08:00
|
|
|
printf "ZEND_ACC_EARLY_BINDING"
|
|
|
|
else
|
|
|
|
if $pi->flags & 0x20000
|
|
|
|
printf "ZEND_ACC_SHADOW"
|
|
|
|
end
|
2006-05-05 23:14:37 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
printf ")\n"
|
|
|
|
printf " name = "
|
2017-01-17 13:55:03 +08:00
|
|
|
print_zstr $pi->name
|
2018-02-10 01:30:45 +08:00
|
|
|
printf " default value: "
|
|
|
|
printzv $ptr_to_val
|
2017-01-17 13:55:03 +08:00
|
|
|
printf "}\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
document print_pi
|
|
|
|
Takes a pointer to an object's property and prints the property information
|
|
|
|
usage: print_pi <ptr>
|
2006-05-05 23:14:37 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
define ____print_str
|
|
|
|
set $tmp = 0
|
|
|
|
set $str = $arg0
|
2017-01-17 13:55:03 +08:00
|
|
|
if $argc > 2
|
|
|
|
set $maxlen = $arg2
|
|
|
|
else
|
|
|
|
set $maxlen = 256
|
|
|
|
end
|
|
|
|
|
2006-05-05 23:14:37 +08:00
|
|
|
printf "\""
|
2017-01-17 13:55:03 +08:00
|
|
|
while $tmp < $arg1 && $tmp < $maxlen
|
|
|
|
if $str[$tmp] > 31 && $str[$tmp] < 127
|
2006-05-05 23:14:37 +08:00
|
|
|
printf "%c", $str[$tmp]
|
|
|
|
else
|
|
|
|
printf "\\%o", $str[$tmp]
|
|
|
|
end
|
|
|
|
set $tmp = $tmp + 1
|
|
|
|
end
|
2014-05-27 23:19:12 +08:00
|
|
|
if $tmp != $arg1
|
|
|
|
printf "..."
|
|
|
|
end
|
2006-05-05 23:14:37 +08:00
|
|
|
printf "\""
|
|
|
|
end
|
|
|
|
|
2003-03-31 01:45:33 +08:00
|
|
|
define printzn
|
2003-04-07 04:19:52 +08:00
|
|
|
____executor_globals
|
2003-03-31 01:45:33 +08:00
|
|
|
set $ind = 0
|
|
|
|
set $znode = $arg0
|
|
|
|
if $znode->op_type == 1
|
|
|
|
set $optype = "IS_CONST"
|
|
|
|
end
|
2018-10-13 20:16:33 +08:00
|
|
|
if $znode->op_type == 2
|
2003-03-31 01:45:33 +08:00
|
|
|
set $optype = "IS_TMP_VAR"
|
|
|
|
end
|
2018-10-13 20:16:33 +08:00
|
|
|
if $znode->op_type == 4
|
2003-03-31 01:45:33 +08:00
|
|
|
set $optype = "IS_VAR"
|
|
|
|
end
|
|
|
|
if $znode->op_type == 8
|
|
|
|
set $optype = "IS_UNUSED"
|
|
|
|
end
|
|
|
|
|
2011-12-06 20:32:59 +08:00
|
|
|
printf "[%p] %s", $znode, $optype
|
2003-03-31 01:45:33 +08:00
|
|
|
|
|
|
|
if $znode->op_type == 1
|
|
|
|
printf ": "
|
2003-05-05 19:43:50 +08:00
|
|
|
____printzv &$znode->u.constant 0
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
|
|
|
if $znode->op_type == 2
|
|
|
|
printf ": "
|
2003-04-07 04:19:52 +08:00
|
|
|
set $tvar = (union _temp_variable *)((char *)$eg.current_execute_data->Ts + $znode->u.var)
|
2003-05-05 19:43:50 +08:00
|
|
|
____printzv ((union _temp_variable *)$tvar)->tmp_var 0
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
|
|
|
if $znode->op_type == 4
|
|
|
|
printf ": "
|
2003-04-07 04:19:52 +08:00
|
|
|
set $tvar = (union _temp_variable *)((char *)$eg.current_execute_data->Ts + $znode->u.var)
|
2003-05-05 19:43:50 +08:00
|
|
|
____printzv *$tvar->var.ptr_ptr 0
|
2003-03-31 01:45:33 +08:00
|
|
|
end
|
|
|
|
if $znode->op_type == 8
|
|
|
|
printf "\n"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
document printzn
|
2003-04-07 02:12:16 +08:00
|
|
|
print type and content of znode.
|
2018-10-13 20:16:33 +08:00
|
|
|
usage: printzn &opline->op1
|
2003-04-07 01:53:17 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
define printzops
|
2018-10-13 20:16:33 +08:00
|
|
|
printf "op1 => "
|
2003-04-07 01:53:17 +08:00
|
|
|
printzn &execute_data->opline.op1
|
|
|
|
printf "op2 => "
|
|
|
|
printzn &execute_data->opline.op2
|
|
|
|
printf "result => "
|
|
|
|
printzn &execute_data->opline.result
|
|
|
|
end
|
|
|
|
|
|
|
|
document printzops
|
|
|
|
dump operands of the current opline
|
|
|
|
end
|
|
|
|
|
2017-01-10 05:10:57 +08:00
|
|
|
define print_zstr
|
|
|
|
set $zstr = (zend_string *)$arg0
|
2017-01-17 13:55:03 +08:00
|
|
|
if $argc == 2
|
|
|
|
set $maxlen = $arg1
|
|
|
|
else
|
|
|
|
set $maxlen = $zstr->len
|
|
|
|
end
|
2017-01-10 05:10:57 +08:00
|
|
|
printf "string(%d) ", $zstr->len
|
2017-01-17 13:55:03 +08:00
|
|
|
____print_str $zstr->val $zstr->len $maxlen
|
2017-01-10 05:10:57 +08:00
|
|
|
printf "\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
document print_zstr
|
|
|
|
print the length and contents of a zend string
|
2017-01-17 13:55:03 +08:00
|
|
|
usage: print_zstr <ptr> [max length]
|
2017-01-10 05:10:57 +08:00
|
|
|
end
|
|
|
|
|
2004-02-17 04:20:55 +08:00
|
|
|
define zbacktrace
|
|
|
|
____executor_globals
|
|
|
|
dump_bt $eg.current_execute_data
|
|
|
|
end
|
|
|
|
|
|
|
|
document zbacktrace
|
|
|
|
prints backtrace.
|
|
|
|
This command is almost a short cut for
|
|
|
|
> (gdb) ____executor_globals
|
|
|
|
> (gdb) dump_bt $eg.current_execute_data
|
|
|
|
end
|
|
|
|
|
2014-09-16 14:15:01 +08:00
|
|
|
define lookup_root
|
|
|
|
set $found = 0
|
|
|
|
if gc_globals->roots
|
|
|
|
set $current = gc_globals->roots->next
|
|
|
|
printf "looking ref %p in roots\n", $arg0
|
|
|
|
while $current != &gc_globals->roots
|
|
|
|
if $current->ref == $arg0
|
|
|
|
set $found = $current
|
|
|
|
break
|
|
|
|
end
|
|
|
|
set $current = $current->next
|
|
|
|
end
|
|
|
|
if $found != 0
|
|
|
|
printf "found root %p\n", $found
|
|
|
|
else
|
|
|
|
printf "not found\n"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
document lookup_root
|
|
|
|
lookup a refcounted in root
|
|
|
|
usage: lookup_root [ptr].
|
|
|
|
end
|