Skip to content

Instantly share code, notes, and snippets.

@yudhiwidyatama
Last active August 22, 2020 09:04
Show Gist options
  • Save yudhiwidyatama/3e4f67a8a485c4413f8e4e4d5b443cb9 to your computer and use it in GitHub Desktop.
Save yudhiwidyatama/3e4f67a8a485c4413f8e4e4d5b443cb9 to your computer and use it in GitHub Desktop.
Dump php stack for PHP 7.1.8 non-TS, tested on Centos 7.5.1804 with Software Collections PHP 71. Also works on PHP 7.2.24 on CentOS 7.6.181 / Software Collection PHP 72
set $exglobal = (long *)&executor_globals
set $currentExecute = (long*)($exglobal[60])
if ($currentExecute != 0)
while ($currentExecute != 0)
set $currentFunc = (long*)$currentExecute[3]
set $currentScope = (long *)$currentFunc[2]
if ($currentScope ==0)
printf ""
else
set $currentScopeN = (long*)$currentScope[1]
set $currentScopeName = (char *)($currentScopeN+3)
printf "%s::",$currentScopeName
end
set $currentFuncN = (long *)$currentFunc[1]
set $currentFuncname = (char *)($currentFuncN+3)
if ($currentFuncname ==0 )
printf "no_function"
else
printf "%s()",$currentFuncname
end
set $currentOpArray = (long*)($currentFunc[15])
set $currentOpline = (int *) ($currentExecute[0])
if ($currentOpArray != 0) && ($currentOpline != 0)
set $currentFilename = (char*)($currentOpArray+3)
set $currentLineno = $currentOpline[6]
printf "@%s:%d\n",$currentFilename,$currentLineno
else
printf "\n"
end
set $prevExecute = (long*)($currentExecute[6])
set $currentExecute = $prevExecute
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment