I'm following these steps to locate the current PHP function call as below:
Run dummy script:
$ gdb -ex run --args php -r "sleep(10);"
Pressed Ctrl+C to get back to
gdb
to run:(gdb) bt full #1 0x00007ffff6007dd4 in __sleep (seconds=0) at ../sysdeps/unix/sysv/linux/sleep.c:137 ts = {tv_sec = 8, tv_nsec = 306649388} set = {__val = {65536, 0 <repeats 15 times>}} oset = {__val = {0, 4469319, 4294967295, 8081486, 140737319884960, 140737354070488, 15761488, 15454080, 15337134, 140737354001040, 0, 7307048, 16048064, 206158430232, 140737488342304, 140737488342096}} result = <optimized out> #2 0x00000000006156ef in zif_sleep () No symbol table info available. #3 0x00000000006ddd7b in dtrace_execute_internal () No symbol table info available. #4 0x000000000079dde5 in ?? () No symbol table info available. #5 0x0000000000717b18 in execute_ex () No symbol table info available. #6 0x00000000006ddc79 in dtrace_execute_ex () No symbol table info available. #7 0x00000000006e1b0a in zend_eval_stringl () No symbol table info available. #8 0x00000000006e1bf9 in zend_eval_stringl_ex () ... (gdb) frame 2 #2 0x00000000006156ef in zif_sleep () (gdb) print (char *)(executor_globals.function_state_ptr->function)->common.function_name Attempt to extract a component of a value that is not a structure. (gdb) print (char *)(executor_globals.function_state_ptr->function) Attempt to extract a component of a value that is not a structure. (gdb) print (char *)(executor_globals) $2 = 0xffffffffffffcf48 <error: Cannot access memory at address 0xffffffffffffcf48>
So it seems
executor_globals
symbol is not available. Is it because the binary has been optimized, I'm in the wrong frame or something else? Or I should uselldb
instead?
print (char *) (blarflgrumpf)
). This seems like your binary has been compiled with optimization on (which could put some variables into registers, withoutgdb
knowing, and relying on the (wrong) stack value). Try to compile/linkphp
with-O0
and-g
. Also, unless you cut some parts of the backtrace, your stack is probably broken, asexecute_ex
seems to have been called out of thin air. This broken stack may be the reason for all sorts of unexpected behaviour.execute
call, while you only haveexecute_ex
; ifexecutor_globals
is indeed a global variable, the stack frame shouldn't matter, but if it's local, you shouldn't find it in thezif_sleep
frame. I wonder how up-to-date the site is you linked to. But as the value ofexecutor_globals
is wrong, and your PHP site says "Important! To get a backtrace with correct information you must have PHP configured with --enable-debug! ", I think you need to recompile.