Skip to content

Commit

Permalink
Use zbacktrace_ex instead of zbacktrace(actullay is dump_bt)
Browse files Browse the repository at this point in the history
Use %p instead of "0x08x" (IMO this is used for print pointer, which, unfortunately, don't work under x64)
If there is any wrong, plz revert this, thanks
  • Loading branch information
laruence committed Dec 6, 2011
1 parent c6d7204 commit ded11f4
Showing 1 changed file with 57 additions and 77 deletions.
134 changes: 57 additions & 77 deletions .gdbinit
Expand Up @@ -37,61 +37,57 @@ end
define dump_bt define dump_bt
set $t = $arg0 set $t = $arg0
while $t while $t
printf "[0x%08x] ", $t printf "[%p] ", $t
if $t->function_state.function->common.function_name if $t->function_state.function->common.function_name
if !$__plain if $t->function_state.arguments
if $t->function_state.arguments set $count = (int)*($t->function_state.arguments)
set $count = (int)*($t->function_state.arguments) printf "%s(", $t->function_state.function->common.function_name
printf "%s(", $t->function_state.function->common.function_name while $count > 0
while $count > 0 set $zvalue = *(zval **)($t->function_state.arguments - $count)
set $zvalue = *(zval **)($t->function_state.arguments - $count) set $type = $zvalue->type
set $type = $zvalue->type if $type == 0
if $type == 0 printf "NULL"
printf "NULL" end
end if $type == 1
if $type == 1 printf "%ld", $zvalue->value.lval
printf "%ld", $zvalue->value.lval end
end if $type == 2
if $type == 2 printf "%lf", $zvalue->value.dval
printf "%lf", $zvalue->value.dval end
end if $type == 3
if $type == 3 if $zvalue->value.lval
if $zvalue->value.lval printf "true"
printf "true" else
else printf "false"
printf "false"
end
end
if $type == 4
printf "array(%d)[0x%08x]", $zvalue->value.ht->nNumOfElements, $zvalue
end
if $type == 5
printf "object[0x%08x]", $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
end end
printf ") " if $type == 4
else printf "array(%d)[%p]", $zvalue->value.ht->nNumOfElements, $zvalue
printf "%s() ", $t->function_state.function->common.function_name 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 end
printf ") "
else else
printf "%s() ", $t->function_state.function->common.function_name printf "%s() ", $t->function_state.function->common.function_name
end end
Expand Down Expand Up @@ -222,7 +218,7 @@ define ____printzv
____executor_globals ____executor_globals
set $zvalue = $arg0 set $zvalue = $arg0


printf "[0x%08x] ", $zvalue printf "[%p] ", $zvalue


if $zvalue == $eg.uninitialized_zval_ptr if $zvalue == $eg.uninitialized_zval_ptr
printf "*uninitialized* " printf "*uninitialized* "
Expand Down Expand Up @@ -263,7 +259,7 @@ end


define print_const_table define print_const_table
set $ind = 1 set $ind = 1
printf "[0x%08x] {\n", $arg0 printf "[%p] {\n", $arg0
____print_const_table $arg0 ____print_const_table $arg0
printf "}\n" printf "}\n"
end end
Expand Down Expand Up @@ -303,7 +299,7 @@ end


define print_ht define print_ht
set $ind = 1 set $ind = 1
printf "[0x%08x] {\n", $arg0 printf "[%p] {\n", $arg0
____print_ht $arg0 1 ____print_ht $arg0 1
printf "}\n" printf "}\n"
end end
Expand All @@ -314,7 +310,7 @@ end


define print_htptr define print_htptr
set $ind = 1 set $ind = 1
printf "[0x%08x] {\n", $arg0 printf "[%p] {\n", $arg0
____print_ht $arg0 0 ____print_ht $arg0 0
printf "}\n" printf "}\n"
end end
Expand All @@ -325,7 +321,7 @@ end


define print_htstr define print_htstr
set $ind = 1 set $ind = 1
printf "[0x%08x] {\n", $arg0 printf "[%p] {\n", $arg0
____print_ht $arg0 2 ____print_ht $arg0 2
printf "}\n" printf "}\n"
end end
Expand Down Expand Up @@ -361,7 +357,7 @@ end


define print_ft define print_ft
set $ind = 1 set $ind = 1
printf "[0x%08x] {\n", $arg0 printf "[%p] {\n", $arg0
____print_ft $arg0 ____print_ft $arg0
printf "}\n" printf "}\n"
end end
Expand Down Expand Up @@ -438,7 +434,7 @@ end


define print_pi define print_pi
set $pi = $arg0 set $pi = $arg0
printf "[0x%08x] {\n", $pi printf "[%p] {\n", $pi
printf " h = %lu\n", $pi->h printf " h = %lu\n", $pi->h
printf " flags = %d (", $pi->flags printf " flags = %d (", $pi->flags
if $pi->flags & 0x100 if $pi->flags & 0x100
Expand Down Expand Up @@ -494,7 +490,7 @@ define printzn
set $optype = "IS_UNUSED" set $optype = "IS_UNUSED"
end end


printf "[0x%08x] %s", $znode, $optype printf "[%p] %s", $znode, $optype


if $znode->op_type == 1 if $znode->op_type == 1
printf ": " printf ": "
Expand Down Expand Up @@ -535,7 +531,6 @@ end


define zbacktrace define zbacktrace
____executor_globals ____executor_globals
set $__plain = 1
dump_bt $eg.current_execute_data dump_bt $eg.current_execute_data
end end


Expand All @@ -546,21 +541,6 @@ document zbacktrace
> (gdb) dump_bt $eg.current_execute_data > (gdb) dump_bt $eg.current_execute_data
end end


define zbacktrace_ex
____executor_globals
set $__plain = 0
dump_bt $eg.current_execute_data
set $__plain = 1
end

document zbacktrace_ex
prints backtrace with arguments info
This command is almost a short cut for
> set $__plain = 0
> (gdb) ____executor_globals
> (gdb) dump_bt $eg.current_execute_data
end

define zmemcheck define zmemcheck
set $p = alloc_globals.head set $p = alloc_globals.head
set $stat = "?" set $stat = "?"
Expand Down Expand Up @@ -590,7 +570,7 @@ define zmemcheck
else else
set $filename = $filename + 1 set $filename = $filename + 1
end 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 if $p->size == sizeof(struct _zval_struct) && ((struct _zval_struct *)$aptr)->type >= 0 && ((struct _zval_struct *)$aptr)->type < 10
printf "ZVAL?(%-2d) ", $p->size printf "ZVAL?(%-2d) ", $p->size
else else
Expand Down Expand Up @@ -620,7 +600,7 @@ define zmemcheck
end end
end end
if $not_found 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 end
if $arg0 == 0 if $arg0 == 0
printf "-------------------------------------------------------------------------------\n" printf "-------------------------------------------------------------------------------\n"
Expand Down

0 comments on commit ded11f4

Please sign in to comment.