Update .gdbinit

This commit is contained in:
Xinchen Hui 2014-02-20 18:30:06 +08:00
parent cc15eb500e
commit 15e9bfa048

225
.gdbinit
View File

@ -173,19 +173,20 @@ define ____printzv_contents
set $zvalue = $arg0 set $zvalue = $arg0
set $type = $zvalue->type set $type = $zvalue->type
printf "(refcount=%d", $zvalue->refcount__gc if $type >= 7
if $zvalue->is_ref__gc printf "(refcount=%d", $zvalue->value.counted->refcount
printf ",is_ref"
end
printf ") " printf ") "
else
printf "(refcount=NaN)"
end
if $type == 0 if $type == 0
printf "NULL" printf "UNDEF"
end end
if $type == 1 if $type == 1
printf "long: %ld", $zvalue->value.lval printf "NULL"
end end
if $type == 2 if $type == 2
printf "double: %f", $zvalue->value.dval printf "indirect: %p", (void*)$zvalue->value.zv
end end
if $type == 3 if $type == 3
printf "bool: " printf "bool: "
@ -196,9 +197,19 @@ define ____printzv_contents
end end
end end
if $type == 4 if $type == 4
printf "array(%d): ", $zvalue->value.ht->nNumOfElements printf "long: %ld", $zvalue->value.lval
end
if $type == 5
printf "double: %f", $zvalue->value.dval
end
if $type == 6
end
if $type == 7
printf "string: %s", $zvalue->value.str->val
end
if $type == 8
printf "array: ", $zvalue->value.arr->ht.nNumUsed
if ! $arg1 if ! $arg1
printf "{\n"
set $ind = $ind + 1 set $ind = $ind + 1
____print_ht $zvalue->value.ht 1 ____print_ht $zvalue->value.ht 1
set $ind = $ind - 1 set $ind = $ind - 1
@ -207,32 +218,21 @@ define ____printzv_contents
printf " " printf " "
set $i = $i - 1 set $i = $i - 1
end end
printf "}"
end end
set $type = 0 set $type = 0
end end
if $type == 5 if $type == 9
printf "object" printf "object"
____executor_globals ____executor_globals
set $handle = $zvalue->value.obj.handle set $handle = $zvalue->value.obj.handle
set $handlers = $zvalue->value.obj.handlers set $handlers = $zvalue->value.obj.handlers
if basic_functions_module.zts set $zobj = $zvalue->value.obj
set $zobj = zend_objects_get_address($zvalue, $tsrm_ls) set $cname = $zobj->ce->name->val
else
set $zobj = zend_objects_get_address($zvalue)
end
if $handlers->get_class_entry == &zend_std_object_get_class
set $cname = $zobj->ce.name
else
set $cname = "Unknown"
end
printf "(%s) #%d", $cname, $handle printf "(%s) #%d", $cname, $handle
if ! $arg1 if ! $arg1
if $handlers->get_properties == &zend_std_get_properties if $handlers->get_properties == &zend_std_get_properties
set $ht = $zobj->properties set $ht = $zobj->properties
if $ht if $ht
printf "(%d): ", $ht->nNumOfElements
printf "{\n"
set $ind = $ind + 1 set $ind = $ind + 1
____print_ht $ht 1 ____print_ht $ht 1
set $ind = $ind - 1 set $ind = $ind - 1
@ -241,7 +241,6 @@ define ____printzv_contents
printf " " printf " "
set $i = $i - 1 set $i = $i - 1
end end
printf "}"
else else
echo "no properties found" echo "no properties found"
end end
@ -249,20 +248,31 @@ define ____printzv_contents
end end
set $type = 0 set $type = 0
end end
if $type == 6 if $type == 10
printf "string(%d): ", $zvalue->value.str.len printf "resource: #%d", $zvalue->value.res->handle
____print_str $zvalue->value.str.val $zvalue->value.str.len
end end
if $type == 7 if $type == 11
printf "resource: #%d", $zvalue->value.lval printf "reference: %p", $zvalue->value.ref
end end
if $type == 8 if $type == 12
printf "constant" printf "const: %s", $zvalue->value.str->val
end end
if $type == 9 if $type == 13
printf "const_array" printf "const_array"
end end
if $type > 9 if $type == 14
printf "const_ast"
end
if $type == 15
printf "callable"
end
if $type == 16
printf "string_offset"
end
if $type == 17
printf "pointer: %p", $zvalue->value.ptr
end
if $type > 17
printf "unknown type %d", $type printf "unknown type %d", $type
end end
printf "\n" printf "\n"
@ -274,10 +284,6 @@ define ____printzv
printf "[%p] ", $zvalue printf "[%p] ", $zvalue
if $zvalue == $eg.uninitialized_zval_ptr
printf "*uninitialized* "
end
set $zcontents = (zval*) $zvalue set $zcontents = (zval*) $zvalue
if $arg1 if $arg1
____printzv_contents $zcontents $arg1 ____printzv_contents $zcontents $arg1
@ -320,42 +326,92 @@ end
define ____print_ht define ____print_ht
set $ht = (HashTable*)$arg0 set $ht = (HashTable*)$arg0
set $p = $ht->pListHead set $n = $ind
while $n > 0
while $p != 0
set $i = $ind
while $i > 0
printf " " printf " "
set $i = $i - 1 set $n = $n - 1
end end
if $ht->flags & 4
if $p->nKeyLength > 0 set $num = $ht->nNumUsed
____print_str $p->arKey $p->nKeyLength set $i = 0
printf " => " printf "Packed(%d)[%p]: {\n", $ht->nNumOfElements, $ht
else set $ind = $ind + 1
while $i < $num
set $p = (Bucket*)($ht->arData + $i)
set $n = $ind
if $p->val.type > 0
while $n > 0
printf " "
set $n = $n - 1
end
printf "[%d]", $i
printf "%d => ", $p->h printf "%d => ", $p->h
end
if $arg1 == 0 if $arg1 == 0
printf "%p\n", (void*)$p->pData printf "%p\n", (zval *)&$p->val
end end
if $arg1 == 1 if $arg1 == 1
set $zval = *(zval **)$p->pData set $zval = (zval *)&$p->val
____printzv $zval 1 ____printzv $zval 1
end end
if $arg1 == 2 if $arg1 == 2
printf "%s\n", (char*)$p->pData printf "%s\n", (char*)$p->val.value.ptr
end end
if $arg1 == 3
set $p = $p->pListNext set $func = (zend_function*)$p->val.value.ptr
printf "\"%s\"\n", $func->common.function_name->val
end
end
set $i = $i + 1
end
set $ind = $ind - 1
printf "}\n"
else
set $num = $ht->nTableSize
set $i = 0
printf "Hash(%d)[%p]: {\n", $ht->nNumOfElements, $ht
set $ind = $ind + 1
while $i < $num
set $hash = $ht->arHash[$i]
if $hash != -1
set $p = (Bucket*)($ht->arData + $hash)
if $p->val.type > 0
set $n = $ind
while $n > 0
printf " "
set $n = $n - 1
end
printf "[%d]", $i
if $p->key
printf "%s => ", $p->key->val
else
printf "%d => ", $p->h
end
if $arg1 == 0
printf "%p\n", (zval *)&$p->val
end
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
end
end
set $i = $i + 1
end
set $ind = $ind - 1
printf "}\n"
end end
end end
define print_ht define print_ht
set $ind = 1 set $ind = 0
printf "[%p] {\n", $arg0
____print_ht $arg0 1 ____print_ht $arg0 1
printf "}\n"
end end
document print_ht document print_ht
@ -363,10 +419,8 @@ document print_ht
end end
define print_htptr define print_htptr
set $ind = 1 set $ind = 0
printf "[%p] {\n", $arg0
____print_ht $arg0 0 ____print_ht $arg0 0
printf "}\n"
end end
document print_htptr document print_htptr
@ -374,46 +428,17 @@ document print_htptr
end end
define print_htstr define print_htstr
set $ind = 1 set $ind = 0
printf "[%p] {\n", $arg0
____print_ht $arg0 2 ____print_ht $arg0 2
printf "}\n"
end end
document print_htstr document print_htstr
dumps elements of HashTable made of strings dumps elements of HashTable made of strings
end end
define ____print_ft
set $ht = $arg0
set $p = $ht->pListHead
while $p != 0
set $func = (zend_function*)$p->pData
set $i = $ind
while $i > 0
printf " "
set $i = $i - 1
end
if $p->nKeyLength > 0
____print_str $p->arKey $p->nKeyLength
printf " => "
else
printf "%d => ", $p->h
end
printf "\"%s\"\n", $func->common.function_name
set $p = $p->pListNext
end
end
define print_ft define print_ft
set $ind = 1 set $ind = 0
printf "[%p] {\n", $arg0 ____print_ht $arg0 3
____print_ft $arg0
printf "}\n"
end end
document print_ft document print_ft
@ -429,15 +454,15 @@ define ____print_inh_class
printf "final " printf "final "
end end
end end
printf "class %s", $ce->name printf "class %s", $ce->name->val
if $ce->parent != 0 if $ce->parent != 0
printf " extends %s", $ce->parent->name printf " extends %s", $ce->parent->name->val
end end
if $ce->num_interfaces != 0 if $ce->num_interfaces != 0
printf " implements" printf " implements"
set $tmp = 0 set $tmp = 0
while $tmp < $ce->num_interfaces while $tmp < $ce->num_interfaces
printf " %s", $ce->interfaces[$tmp]->name printf " %s", $ce->interfaces[$tmp]->name->val
set $tmp = $tmp + 1 set $tmp = $tmp + 1
if $tmp < $ce->num_interfaces if $tmp < $ce->num_interfaces
printf "," printf ","
@ -449,10 +474,10 @@ end
define ____print_inh_iface define ____print_inh_iface
set $ce = $arg0 set $ce = $arg0
printf "interface %s", $ce->name printf "interface %s", $ce->name->val
if $ce->num_interfaces != 0 if $ce->num_interfaces != 0
set $ce = $ce->interfaces[0] set $ce = $ce->interfaces[0]
printf " extends %s", $ce->name printf " extends %s", $ce->name->val
else else
set $ce = 0 set $ce = 0
end end
@ -618,9 +643,9 @@ define zmemcheck
if $p->magic == 0xfb8277dc if $p->magic == 0xfb8277dc
set $stat = "CACHED" set $stat = "CACHED"
end end
set $filename = strrchr($p->filename, '/') set $filename = strrchr($p->filename->val, '/')
if !$filename if !$filename
set $filename = $p->filename set $filename = $p->filename->val
else else
set $filename = $filename + 1 set $filename = $filename + 1
end end