Skip to content

Instantly share code, notes, and snippets.

@yudhiwidyatama
Created August 22, 2020 09:54
Show Gist options
  • Save yudhiwidyatama/07ccd5515ecf7ef2b0fe0c86797b9c0e to your computer and use it in GitHub Desktop.
Save yudhiwidyatama/07ccd5515ecf7ef2b0fe0c86797b9c0e to your computer and use it in GitHub Desktop.
Dump PHP stack for PHP 7.0.27 non-TS, tested on CentOS Linux release 7.7.1908 with Software Collections PHP 7.0
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)
ignore-errors printf "%s::",$currentScopeName
end
set $currentFuncN = (long *)$currentFunc[1]
set $currentFuncname = (char *)($currentFuncN+3)
if ($currentFuncname ==0 )
printf "no_function"
else
ignore-errors 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]
ignore-errors printf "@%s:%d\n",$currentFilename,$currentLineno
else
printf "\n"
end
set $prevExecute = (long*)($currentExecute[7])
set $currentExecute = $prevExecute
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment