Browse Source

Decompiler: adds simple backtrace print, fix warning for catch

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1305 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.1
Xuefer 8 years ago
parent
commit
fea60080b7
  1. 35
      lib/Decompiler.class.php
  2. 5
      mod_disassembler/sample.php

35
lib/Decompiler.class.php

@ -8,6 +8,37 @@ function color($str, $color = 33)
return "\x1B[{$color}m$str\x1B[0m";
}
function printBacktrace() // {{{
{
$backtrace = debug_backtrace();
foreach ($backtrace as $stack) {
$args = array();
foreach ($stack['args'] as $arg) {
if (is_array($arg)) {
$array = array();
foreach ($arg as $key => $value) {
$array[] = var_export($key, true) . " => " . (is_scalar($value) ? var_export($value, true) : gettype($value));
if (count($array) >= 5) {
$array[] = '...';
break;
}
}
$args[] = 'array(' . implode(', ', $array) . ')';
}
else {
$args[] = (string) $arg;
}
}
printf("%d: %s::%s(%s)" . PHP_EOL
, $stack['line']
, isset($stack['class']) ? $stack['class'] : ''
, $stack['function']
, implode(', ', $args)
);
}
}
// }}}
function str($code, $indent = '') // {{{
{
if (is_array($code)) {
@ -735,6 +766,9 @@ class Decompiler
function removeJmpInfo(&$EX, $line) // {{{
{
$opcodes = &$EX['opcodes'];
if (!isset($opcodes[$line]['jmpouts'])) {
printBacktrace();
}
foreach ($opcodes[$line]['jmpouts'] as $jmpTo) {
$jmpins = &$opcodes[$jmpTo]['jmpins'];
$jmpins = array_flip($jmpins);
@ -943,7 +977,6 @@ class Decompiler
$tryRange = array($range[0], $catchFirst - 1);
// search for XC_CATCH
$this->removeJmpInfo($EX, $catchFirst);
for ($i = $catchFirst; $i <= $range[1]; ) {
if ($opcodes[$i]['opcode'] == XC_CATCH) {
$catchOpLine = $i;

5
mod_disassembler/sample.php

@ -411,7 +411,10 @@ default:
declare (ticks=1) {
echo 1;
while (1) {
}
while (1) {
declare (ticks=1) {
echo 2;
}
}

Loading…
Cancel
Save