--- embedaddon/php/.gdbinit 2012/02/21 23:47:51 1.1.1.1 +++ embedaddon/php/.gdbinit 2013/07/22 01:31:35 1.1.1.3 @@ -1,8 +1,21 @@ +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, + but we could get the resource from the argument + of frame info. +end + define ____executor_globals if basic_functions_module.zts - set $tsrm_ls = ts_resource_ex(0, 0) - set $eg = ((zend_executor_globals) (*((void ***) $tsrm_ls))[executor_globals_id-1]) - set $cg = ((zend_compiler_globals) (*((void ***) $tsrm_ls))[compiler_globals_id-1]) + if !$tsrm_ls + set $tsrm_ls = ts_resource_ex(0, 0) + end + set $eg = ((zend_executor_globals*) (*((void ***) $tsrm_ls))[executor_globals_id-1]) + set $cg = ((zend_compiler_globals*) (*((void ***) $tsrm_ls))[compiler_globals_id-1]) else set $eg = executor_globals set $cg = compiler_globals @@ -37,9 +50,101 @@ end define dump_bt set $t = $arg0 while $t - printf "[0x%08x] ", $t - if $t->function_state.function->common.function_name - printf "%s() ", $t->function_state.function->common.function_name + printf "[%p] ", $t + set $fst = $t->function_state + if $fst.function->common.function_name + if $fst.arguments + set $count = (int)*($fst.arguments) + + if $t->object + if $fst.function.common.scope + printf "%s->", $fst.function.common.scope->name + else + if !$eg + ____executor_globals + end + + set $known_class = 0 + if $eg + set $handle = $t->object.value.obj.handle + set $handlers = $t->object.value.obj.handlers + set $zobj = (zend_object *)$eg.objects_store.object_buckets[$handle].bucket.obj.object + + if $handlers->get_class_entry == &zend_std_object_get_class + set $known_class = 1 + + if $handlers.get_class_name + if $handlers.get_class_name != &zend_std_object_get_class_name + set $known_class = 0 + end + end + + if $known_class + printf "%s->", $zobj->ce.name + end + end + end + + if !$known_class + printf "(Unknown)->" + end + end + else + if $fst.function.common.scope + printf "%s::", $fst.function.common.scope->name + end + end + + printf "%s(", $fst.function->common.function_name + while $count > 0 + set $zvalue = *(zval **)($fst.arguments - $count) + set $type = $zvalue->type + if $type == 0 + printf "NULL" + end + if $type == 1 + printf "%ld", $zvalue->value.lval + end + if $type == 2 + printf "%lf", $zvalue->value.dval + end + if $type == 3 + if $zvalue->value.lval + printf "true" + else + printf "false" + end + end + if $type == 4 + printf "array(%d)[%p]", $zvalue->value.ht->nNumOfElements, $zvalue + end + if $type == 5 + printf "object[%p]", $zvalue + end + if $type == 6 + ____print_str $zvalue->value.str.val $zvalue->value.str.len + end + if $type == 7 + printf "resource(#%d)", $zvalue->value.lval + end + if $type == 8 + printf "constant" + end + if $type == 9 + printf "const_array" + end + if $type > 9 + printf "unknown type %d", $type + end + set $count = $count -1 + if $count > 0 + printf ", " + end + end + printf ") " + else + printf "%s() ", $fst.function->common.function_name + end else printf "??? " end @@ -167,7 +272,7 @@ define ____printzv ____executor_globals set $zvalue = $arg0 - printf "[0x%08x] ", $zvalue + printf "[%p] ", $zvalue if $zvalue == $eg.uninitialized_zval_ptr printf "*uninitialized* " @@ -208,7 +313,7 @@ end define print_const_table set $ind = 1 - printf "[0x%08x] {\n", $arg0 + printf "[%p] {\n", $arg0 ____print_const_table $arg0 printf "}\n" end @@ -248,7 +353,7 @@ end define print_ht set $ind = 1 - printf "[0x%08x] {\n", $arg0 + printf "[%p] {\n", $arg0 ____print_ht $arg0 1 printf "}\n" end @@ -259,7 +364,7 @@ end define print_htptr set $ind = 1 - printf "[0x%08x] {\n", $arg0 + printf "[%p] {\n", $arg0 ____print_ht $arg0 0 printf "}\n" end @@ -270,7 +375,7 @@ end define print_htstr set $ind = 1 - printf "[0x%08x] {\n", $arg0 + printf "[%p] {\n", $arg0 ____print_ht $arg0 2 printf "}\n" end @@ -306,7 +411,7 @@ end define print_ft set $ind = 1 - printf "[0x%08x] {\n", $arg0 + printf "[%p] {\n", $arg0 ____print_ft $arg0 printf "}\n" end @@ -383,7 +488,7 @@ end define print_pi set $pi = $arg0 - printf "[0x%08x] {\n", $pi + printf "[%p] {\n", $pi printf " h = %lu\n", $pi->h printf " flags = %d (", $pi->flags if $pi->flags & 0x100 @@ -439,7 +544,7 @@ define printzn set $optype = "IS_UNUSED" end - printf "[0x%08x] %s", $znode, $optype + printf "[%p] %s", $znode, $optype if $znode->op_type == 1 printf ": " @@ -519,7 +624,7 @@ define zmemcheck else set $filename = $filename + 1 end - printf " 0x%08x ", $aptr + printf " %p ", $aptr if $p->size == sizeof(struct _zval_struct) && ((struct _zval_struct *)$aptr)->type >= 0 && ((struct _zval_struct *)$aptr)->type < 10 printf "ZVAL?(%-2d) ", $p->size else @@ -549,7 +654,7 @@ define zmemcheck end end if $not_found - printf "no such block that begins at 0x%08x.\n", $aptr + printf "no such block that begins at %p.\n", $aptr end if $arg0 == 0 printf "-------------------------------------------------------------------------------\n"