summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXuefer <xuefer@gmail.com>2015-04-18 13:25:48 +0000
committerXuefer <xuefer@gmail.com>2015-04-18 13:25:48 +0000
commitb2655aeecdaef9d56dd45e5566430d5beedbc022 (patch)
tree0b238e57e57dec9ea0e0bdb478f79e887c86a866
parent8443a1aa2b93adca0a572abc14070568a3f4be22 (diff)
downloadxcache-b2655aeecdaef9d56dd45e5566430d5beedbc022.tar.gz
xcache-b2655aeecdaef9d56dd45e5566430d5beedbc022.zip
phpdop: update for new struct layout
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1587 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
-rwxr-xr-xbin/phpdc.phpr2
-rwxr-xr-xbin/phpdop.phpr22
-rw-r--r--lib/Decompiler.class.php16
-rw-r--r--processor/processor.m48
-rw-r--r--xcache/xc_opcode_spec_def.h12
-rw-r--r--xcache/xc_utils.c5
6 files changed, 46 insertions, 19 deletions
diff --git a/bin/phpdc.phpr b/bin/phpdc.phpr
index 969cbb5..9aa5c7e 100755
--- a/bin/phpdc.phpr
+++ b/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");
}
diff --git a/bin/phpdop.phpr b/bin/phpdop.phpr
index 8159093..03d40d4 100755
--- a/bin/phpdop.phpr
+++ b/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'])) {
diff --git a/lib/Decompiler.class.php b/lib/Decompiler.class.php
index 0381b0c..046ee59 100644
--- a/lib/Decompiler.class.php
+++ b/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;
diff --git a/processor/processor.m4 b/processor/processor.m4
index 2b8f193..e2ab934 100644
--- a/processor/processor.m4
+++ b/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(`
diff --git a/xcache/xc_opcode_spec_def.h b/xcache/xc_opcode_spec_def.h
index 527835f..40ed78a 100644
--- a/xcache/xc_opcode_spec_def.h
+++ b/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
diff --git a/xcache/xc_utils.c b/xcache/xc_utils.c
index 48db730..4c2b576 100644
--- a/xcache/xc_utils.c
+++ b/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) {