Browse Source

phpdop: update for new struct layout

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1587 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
master
Xuefer 7 years ago
parent
commit
b2655aeecd
  1. 2
      bin/phpdc.phpr
  2. 22
      bin/phpdop.phpr
  3. 16
      lib/Decompiler.class.php
  4. 8
      processor/processor.m4
  5. 12
      xcache/xc_opcode_spec_def.h
  6. 5
      xcache/xc_utils.c

2
bin/phpdc.phpr

@ -2,7 +2,7 @@
<?php
$srcdir = dirname(__FILE__);
require_once("$srcdir/../lib/Decompiler.class.php");
require_once("$srcdir/../lib/orig/Decompiler.class.php");
if (file_exists("$srcdir/phpdc.debug.php")) {
include("$srcdir/phpdc.debug.php");
}

22
bin/phpdop.phpr

@ -7,28 +7,28 @@ if (file_exists("$srcdir/phpdc.debug.php")) {
include("$srcdir/phpdc.debug.php");
}
function get_op($op)
function get_op($op, $which)
{
switch ($op['op_type']) {
switch ($op[$which . '_type']) {
case 1: // CONST
return var_export($op['constant'], true);
return $op[$which . '.var'] . var_export($op[$which . '.constant'], true);
case 2: // IS_TMP_VAR
return 't@' . $op['var'];
return 't@' . $op[$which . '.var'];
case 4:
return 'v$' . $op['var'];
return 'v$' . $op[$which . '.var'];
case 8: // UNUSED
if (isset($op['opline_num'])) {
return 'l#' . $op['opline_num'];
if (isset($op[$which . '.opline_num'])) {
return 'l#' . $op[$which . '.opline_num'];
}
else {
return '-';
}
default:
return $op['op_type'] . $op['var'];
return $op[$which . '_type'] . '?' . $op[$which . '.var'];
}
}
@ -36,7 +36,7 @@ function dump_opcodes($op_array, $indent = '')
{
global $decompiler;
$types = array('result' => 5, 'op1' => 20, 'op2' => 20);
$types = array('result' => 8, 'op1' => 20, 'op2' => 20);
$opcodes = &$op_array['opcodes'];
$decompiler->fixOpcode($opcodes);
$decompiler->buildJmpInfo($op_array);
@ -51,8 +51,8 @@ function dump_opcodes($op_array, $indent = '')
}
echo str_pad($name, 25);
foreach ($types as $t => $len) {
echo str_pad(isset($op[$t]) ? get_op($op[$t]) : "", $len);
foreach ($types as $which => $len) {
echo str_pad(get_op($op, $which), $len);
}
printf("%5s", isset($op['extended_value']) ? $op['extended_value'] : "");
if (isset($op['jmpouts']) || isset($op['jmpins'])) {

16
lib/Decompiler.class.php

@ -1973,7 +1973,8 @@ class Decompiler
$EX['object'] = null;
$EX['called_scope'] = null;
}
$EX['fbc'] = isset($op2['constant']) ? $op2['constant'] : $this->getOpVal($op2, $EX);
// file_put_contents('/tmp/a', var_export($this->dc['op_array']['literals'], true));
$EX['fbc'] = isset($op2['constant']) ? $op2['var'] . ' ' . $op2['constant'] : $this->getOpVal($op2, $EX);
break;
// }}}
case XC_INIT_FCALL_BY_FUNC: // {{{ deprecated even in PHP 4?
@ -2025,8 +2026,9 @@ class Decompiler
case XC_DECLARE_INHERITED_CLASS:
case XC_DECLARE_INHERITED_CLASS_DELAYED: // {{{
$key = $op1['constant'];
// missing tailing \0 (outside of the string)
// possible missing tailing \0 (outside of the string)
$key = substr($key . ".", 0, strlen($key));
break;
if (!isset($this->dc['class_table'][$key])) {
echo "class not found: ", $key, "\nexisting classes are:\n";
var_dump(array_keys($this->dc['class_table']));
@ -2326,11 +2328,17 @@ class Decompiler
case XC_INIT_CTOR_CALL:
break;
case XC_DECLARE_FUNCTION:
$this->dfunction($this->dc['function_table'][$op1['constant']], $EX['indent']);
$key = $op1['constant'];
// possible missing tailing \0 (outside of the string)
$key = substr($key . ".", 0, strlen($key));
$this->dfunction($this->dc['function_table'][$key], $EX['indent']);
break;
case XC_DECLARE_LAMBDA_FUNCTION: // {{{
ob_start();
$this->dfunction($this->dc['function_table'][$op1['constant']], $EX['indent']);
$key = $op1['constant'];
// possible missing tailing \0 (outside of the string)
$key = substr($key . ".", 0, strlen($key));
$this->dfunction($this->dc['function_table'][$key], $EX['indent']);
$resvar = ob_get_clean();
$istmpres = true;
break;

8
processor/processor.m4

@ -662,10 +662,16 @@ define(`UNION_znode_op', `dnl {{{
', `
IFDASM(`{
zval *zv;
zval *srczv = &dasm->active_op_array_src->literals[SRC(`$1.constant')].constant;
zval *srczv;
srczv = &dasm->active_op_array_src->literals[SRC(`$1.constant')].constant;
if (Z_TYPE_P(srczv) == IS_STRING) {
size_t index = SRC(`$1.constant');
fprintf(stderr, "%p %p %s\n", srczv, Z_STRVAL_P(srczv), Z_STRVAL_P(srczv));
}
ALLOC_ZVAL(zv);
MAKE_COPY_ZVAL(&srczv, zv);
add_assoc_zval_ex(DST(), XCACHE_STRS("$1.constant"), zv);
add_assoc_long_ex(DST(), XCACHE_STRS("$1.var"), SRC(`$1.constant'));
}
', `
IFCOPY(`

12
xcache/xc_opcode_spec_def.h

@ -83,10 +83,14 @@ static const xc_opcode_spec_t xc_opcode_spec[] = {
OPSPEC( UNUSED, STD, STD, TMP) /* 56 ADD_VAR */
OPSPEC( UNUSED, UNUSED, UNUSED, TMP) /* 57 BEGIN_SILENCE */
OPSPEC( UNUSED, TMP, UNUSED, UNUSED) /* 58 END_SILENCE */
#ifdef ZEND_ENGINE_2_4
OPSPEC(INIT_FCALL, UNUSED, STD, UNUSED) /* 59 INIT_FCALL_BY_NAME */
#else
OPSPEC(INIT_FCALL, STD, STD, UNUSED) /* 59 INIT_FCALL_BY_NAME */
#endif
#ifdef ZEND_ENGINE_2
OPSPEC( FCALL, STD, OPLINE, VAR) /* 60 DO_FCALL */
OPSPEC( FCALL, STD, OPLINE, VAR) /* 61 DO_FCALL_BY_NAME */
OPSPEC( FCALL, STD, UNUSED, VAR) /* 60 DO_FCALL */
OPSPEC( FCALL, UNUSED, UNUSED, VAR) /* 61 DO_FCALL_BY_NAME */
#else
OPSPEC( FCALL, STD, UNUSED, VAR)
OPSPEC( FCALL, STD, UNUSED, VAR)
@ -208,7 +212,11 @@ static const xc_opcode_spec_t xc_opcode_spec[] = {
OPSPEC( OPLINE, CLASS, STD, UNUSED) /* 107 CATCH */
# endif
OPSPEC( UNUSED, STD, OPLINE, UNUSED) /* 108 THROW */
# ifdef ZEND_ENGINE_2_4
OPSPEC( FCLASS, UNUSED, STD, CLASS) /* 109 FETCH_CLASS */
# else
OPSPEC( FCLASS, STD, STD, CLASS) /* 109 FETCH_CLASS */
# endif
OPSPEC( UNUSED, STD, UNUSED, VAR) /* 110 CLONE */
# ifdef ZEND_ENGINE_2_4

5
xcache/xc_utils.c

@ -301,6 +301,11 @@ static void xc_fix_opcode_ex_znode(int tofix, xc_op_spec_t spec, Z_OP_TYPEOF_TYP
}
}
switch (*op_type) {
case IS_CONST:
if (spec == OPSPEC_UNUSED || spec == OPSPEC_OPLINE) {
*op_type = IS_UNUSED;
}
break;
case IS_TMP_VAR:
case IS_VAR:
if (tofix) {

Loading…
Cancel
Save