Skip to content

Instantly share code, notes, and snippets.

@yudhiwidyatama
Last active April 18, 2022 14:28
Show Gist options
  • Save yudhiwidyatama/f59ff25091cca77f8448cfe8ee977904 to your computer and use it in GitHub Desktop.
Save yudhiwidyatama/f59ff25091cca77f8448cfe8ee977904 to your computer and use it in GitHub Desktop.
Dump PHP stack for PHP 7.3.11, tested on CentOS 7.6.1810 with Software Collections PHP 7.3
set $exglobal = (long *)&executor_globals
set $currentExecute = (long*)($exglobal[61])
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]
if ($currentFuncN == 0 )
printf "no_function"
else
set $currentFuncname = (char *)($currentFuncN+3)
if ($currentFuncname ==0 )
printf "no_function"
else
printf "%s()",$currentFuncname
end
end
set $currentFuncType = (char*)$currentFunc
set $funcType = * ($currentFuncType)
if ($funcType == 2)
set $currentOpArray = (long*)($currentFunc[16])
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
else
printf "@internal\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