Browse Source

phpdop: show jumpouts/jmpins

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1338 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.1
Xuefer 7 years ago
parent
commit
70c75c5277
2 changed files with 27 additions and 10 deletions
  1. +16
    -4
      bin/phpdop.phpr
  2. +11
    -6
      lib/Decompiler.class.php

+ 16
- 4
bin/phpdop.phpr View File

@ -32,12 +32,15 @@ function get_op($op)
}
}
function dump_opcodes($opcodes, $indent = '')
function dump_opcodes($op_array, $indent = '')
{
global $decompiler;
$types = array('result' => 5, 'op1' => 20, 'op2' => 20);
foreach ($decompiler->fixOpcode($opcodes) as $line => $op) {
$opcodes = &$op_array['opcodes'];
$decompiler->fixOpcode($opcodes);
$decompiler->buildJmpInfo($op_array);
foreach ($opcodes as $line => $op) {
echo $indent;
echo sprintf("%3d ", $op['lineno']);
echo sprintf("%3d ", $line);
@ -52,6 +55,15 @@ function dump_opcodes($opcodes, $indent = '')
echo str_pad(isset($op[$t]) ? get_op($op[$t]) : "", $len);
}
printf("%5s", isset($op['extended_value']) ? $op['extended_value'] : "");
if (isset($op['jmpouts']) || isset($op['jmpins'])) {
printf("%10s %10s"
, (isset($op['jmpouts']) ? '>' . implode(',', $op['jmpouts']) : '')
, (isset($op['jmpins']) ? '<' . implode(',', $op['jmpins']) : '')
);
}
if (isset($op['isCatchBegin'])) {
echo 'CB';
}
echo "\n";
}
@ -69,7 +81,7 @@ function dump_function($name, $func, $indent = '')
var_dump($func);
echo $indent, 'function ', $name, "\n";
if (isset($op_array)) {
dump_opcodes($op_array['opcodes'], " " . $indent);
dump_opcodes($op_array, " " . $indent);
}
}
@ -125,6 +137,6 @@ if (isset($funcs)) {
}
}
if (isset($op_array)) {
dump_opcodes($op_array['opcodes']);
dump_opcodes($op_array);
}

+ 11
- 6
lib/Decompiler.class.php View File

@ -706,7 +706,7 @@ class Decompiler
return $ret;
}
// }}}
function &fixOpcode($opcodes, $removeTailing = false, $defaultReturnValue = null) // {{{
function fixOpCode(&$opcodes, $removeTailing = false, $defaultReturnValue = null) // {{{
{
$last = count($opcodes) - 1;
for ($i = 0; $i <= $last; $i ++) {
@ -757,7 +757,6 @@ class Decompiler
}
}
}
return $opcodes;
}
// }}}
function decompileBasicBlock(&$EX, $range, $unhandled = false) // {{{
@ -1296,12 +1295,10 @@ class Decompiler
}
}
// }}}
function &dop_array($op_array, $indent = '') // {{{
function buildJmpInfo(&$op_array) // {{{ build jmpins/jmpouts to op_array
{
$op_array['opcodes'] = $this->fixOpcode($op_array['opcodes'], true, $indent == '' ? 1 : null);
$opcodes = &$op_array['opcodes'];
$last = count($opcodes) - 1;
// {{{ build jmpins/jmpouts to op_array
for ($i = 0; $i <= $last; $i ++) {
$op = &$opcodes[$i];
$op['line'] = $i;
@ -1384,7 +1381,15 @@ class Decompiler
$opcodes[$catch_op]['isCatchBegin'] = true;
}
}
// }}}
}
// }}}
function &dop_array($op_array, $indent = '') // {{{
{
$this->fixOpCode($op_array['opcodes'], true, $indent == '' ? 1 : null);
$this->buildJmpInfo($op_array);
$opcodes = &$op_array['opcodes'];
$last = count($opcodes) - 1;
// build semi-basic blocks
$nextbbs = array();
$starti = 0;


Loading…
Cancel
Save