1
0
Fork 0

move files to subdirs

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@982 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
This commit is contained in:
Xuefer 2012-07-17 08:35:45 +00:00
parent f9f7ff5d27
commit ef5a13d72a
58 changed files with 400 additions and 431 deletions

View File

@ -1,7 +1,7 @@
XCACHE_PROC_SRC=$(srcdir)/processor/main.m4
XCACHE_PROC_OUT=$(builddir)/processor.out
XCACHE_PROC_C=$(builddir)/processor_real.c
XCACHE_PROC_H=$(builddir)/processor.h
XCACHE_PROC_C=$(builddir)/main/xc_processor_real.c
XCACHE_PROC_H=$(builddir)/main/xc_processor.h
XCACHE_INCLUDES_SRC=$(srcdir)/includes.c
XCACHE_INCLUDES_I=$(builddir)/includes.i
XCACHE_STRUCTINFO_OUT=$(builddir)/structinfo.m4
@ -9,9 +9,9 @@ XCACHE_STRUCTINFO_OUT=$(builddir)/structinfo.m4
$(XCACHE_INCLUDES_I): $(XCACHE_INCLUDES_SRC) $(srcdir)/xcache.h
$(CC) -I. -I$(srcdir) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -E $(XCACHE_INCLUDES_SRC) -o $(XCACHE_INCLUDES_I)
$(XCACHE_STRUCTINFO_OUT): $(XCACHE_INCLUDES_I) $(srcdir)/mkstructinfo.awk
$(XCACHE_STRUCTINFO_OUT): $(XCACHE_INCLUDES_I) $(srcdir)/gen_structinfo.awk
@echo $(XCACHE_STRUCTINFO_OUT) is optional if XCache test is not enabled, feel free if it awk failed to produce it
-$(XCACHE_AWK) -f $(srcdir)/mkstructinfo.awk < $(XCACHE_INCLUDES_I) > $(XCACHE_STRUCTINFO_OUT).tmp && mv $(XCACHE_STRUCTINFO_OUT).tmp $(XCACHE_STRUCTINFO_OUT)
-$(XCACHE_AWK) -f $(srcdir)/gen_structinfo.awk < $(XCACHE_INCLUDES_I) > $(XCACHE_STRUCTINFO_OUT).tmp && mv $(XCACHE_STRUCTINFO_OUT).tmp $(XCACHE_STRUCTINFO_OUT)
$(XCACHE_PROC_OUT): $(XCACHE_PROC_SRC) $(XCACHE_STRUCTINFO_OUT) $(XCACHE_PROC_SOURCES)
$(M4) -D srcdir=$(XCACHE_BACKTICK)"$(srcdir)'" -D builddir=$(XCACHE_BACKTICK)"$(builddir)'" $(XCACHE_ENABLE_TEST) $(XCACHE_PROC_SRC) > $(XCACHE_PROC_OUT).tmp
@ -25,13 +25,13 @@ $(XCACHE_PROC_C): $(XCACHE_PROC_OUT) $(XCACHE_PROC_H)
cp $(XCACHE_PROC_OUT) $(XCACHE_PROC_C)
-$(XCACHE_INDENT) < $(XCACHE_PROC_OUT) > $(XCACHE_PROC_C).tmp && mv $(XCACHE_PROC_C).tmp $(XCACHE_PROC_C)
$(builddir)/processor.lo: $(XCACHE_PROC_C) $(XCACHE_PROC_H) $(srcdir)/processor.c
$(builddir)/main/xc_processor.lo: $(XCACHE_PROC_C) $(XCACHE_PROC_H) $(srcdir)/main/xc_processor.c
$(builddir)/disassembler.lo: $(XCACHE_PROC_H) $(srcdir)/processor.c
$(builddir)/submodules/xc_disassembler.lo: $(XCACHE_PROC_H) $(srcdir)/main/xc_processor.c
$(builddir)/opcode_spec.lo: $(srcdir)/xcache.h $(srcdir)/opcode_spec.c $(srcdir)/opcode_spec_def.h $(srcdir)/const_string.h
$(builddir)/xc_opcode_spec.lo: $(srcdir)/xcache.h $(srcdir)/xc_opcode_spec.c $(srcdir)/xc_opcode_spec_def.h $(srcdir)/xc_const_string.h
$(builddir)/xcache.lo: $(XCACHE_PROC_H) $(srcdir)/xc_shm.h $(srcdir)/stack.h $(srcdir)/xcache_globals.h $(srcdir)/xcache.c $(srcdir)/foreachcoresig.h $(srcdir)/utils.h
$(builddir)/xcache.lo: $(XCACHE_PROC_H) $(srcdir)/main/xc_shm.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache_globals.h $(srcdir)/xcache.c $(srcdir)/util/xc_foreachcoresig.h $(srcdir)/main/xc_utils.h
xcachesvnclean: clean
cat $(srcdir)/.cvsignore | grep -v ^Makefile | grep -v ^config.nice | xargs rm -rf

View File

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

View File

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

View File

@ -1,10 +1,10 @@
dnl vim:ts=2:sw=2:expandtab
AC_DEFUN([XCACHE_OPTION], [
AC_DEFUN([XCACHE_MODULE], [
PHP_ARG_ENABLE(xcache-$1, for XCache $1,
[ --enable-xcache-$2 XCache: $4], no, no)
if test "$PHP_$3" != "no"; then
xcache_sources="$xcache_sources $1.c"
xcache_sources="$xcache_sources submodules/xc_$1.c"
XCACHE_MODULES="$XCACHE_MODULES $1"
HAVE_$3=1
AC_DEFINE([HAVE_$3], 1, [Define for XCache: $4])
@ -17,37 +17,38 @@ PHP_ARG_ENABLE(xcache, for XCache support,
[ --enable-xcache Include XCache support.])
if test "$PHP_XCACHE" != "no"; then
PHP_ARG_ENABLE(xcache-constant, for XCache handle of compile time constant,
PHP_ARG_ENABLE(xcache-constant, for XCache handle of compile time constant,
[ --enable-xcache-constant XCache: Handle new constants made by php compiler (e.g.: for __halt_compiler)], yes, no)
if test "$PHP_XCACHE_CONSTANT" != "no"; then
AC_DEFINE([HAVE_XCACHE_CONSTANT], 1, [Define to enable XCache handling of compile time constants])
fi
if test "$PHP_XCACHE_CONSTANT" != "no"; then
AC_DEFINE([HAVE_XCACHE_CONSTANT], 1, [Define to enable XCache handling of compile time constants])
fi
xcache_sources="processor.c \
xcache_sources="
main/xc_const_string.c \
main/xc_lock.c \
main/xc_mem.c \
main/xc_opcode_spec.c \
main/xc_processor.c \
main/xc_shm.c \
main/xc_shm_mmap.c \
main/xc_utils.c \
util/xc_stack.c \
xcache.c \
mmap.c \
mem.c \
xc_shm.c \
const_string.c \
opcode_spec.c \
stack.c \
utils.c \
lock.c \
"
XCACHE_MODULES="cacher"
XCACHE_OPTION([optimizer], [optimizer ], [XCACHE_OPTIMIZER], [(N/A)])
XCACHE_OPTION([coverager], [coverager ], [XCACHE_COVERAGER], [Enable code coverage dumper, useful for testing php scripts])
XCACHE_OPTION([assembler], [assembler ], [XCACHE_ASSEMBLER], [(N/A)])
XCACHE_OPTION([disassembler], [disassembler], [XCACHE_DISASSEMBLER], [Enable opcode to php variable dumper, NOT for production server])
XCACHE_OPTION([encoder], [encoder ], [XCACHE_ENCODER], [(N/A)])
XCACHE_OPTION([decoder], [decoder ], [XCACHE_DECODER], [(N/A)])
XCACHE_MODULE([optimizer], [optimizer ], [XCACHE_OPTIMIZER], [(N/A)])
XCACHE_MODULE([coverager], [coverager ], [XCACHE_COVERAGER], [Enable code coverage dumper, useful for testing php scripts])
XCACHE_MODULE([assembler], [assembler ], [XCACHE_ASSEMBLER], [(N/A)])
XCACHE_MODULE([disassembler], [disassembler], [XCACHE_DISASSEMBLER], [Enable opcode to php variable dumper, NOT for production server])
XCACHE_MODULE([encoder], [encoder ], [XCACHE_ENCODER], [(N/A)])
XCACHE_MODULE([decoder], [decoder ], [XCACHE_DECODER], [(N/A)])
AC_DEFINE_UNQUOTED([XCACHE_MODULES], "$XCACHE_MODULES", [Define what modules is built with XCache])
PHP_ARG_ENABLE(xcache-test, for XCache self test,
[ --enable-xcache-test XCache: Enable self test - FOR DEVELOPERS ONLY!!], no, no)
if test "$PHP_XCACHE_TEST" != "no"; then
XCACHE_ENABLE_TEST=-DXCACHE_ENABLE_TEST
xcache_sources="$xcache_sources xc_malloc.c"
xcache_sources="$xcache_sources main/xc_malloc.c"
AC_DEFINE([HAVE_XCACHE_TEST], 1, [Define to enable XCache self test])
else
XCACHE_ENABLE_TEST=
@ -115,20 +116,4 @@ if test "$PHP_XCACHE" != "no"; then
dnl $ac_srcdir etc require PHP_NEW_EXTENSION
XCACHE_PROC_SOURCES=`ls $ac_srcdir/processor/*.m4`
PHP_SUBST([XCACHE_PROC_SOURCES])
AC_MSG_CHECKING(if you have opcode_spec_def.h for XCache)
if test -e "$ac_srcdir/opcode_spec_def.h" ; then
AC_DEFINE([HAVE_XCACHE_OPCODE_SPEC_DEF], 1, [Define if you have opcode_spec_def.h for XCache])
AC_MSG_RESULT(yes)
else
dnl check for features depend on opcode_spec_def.h
AC_MSG_RESULT(no)
define([ERROR], [
AC_MSG_ERROR([cannot build with $1, $ac_srcdir/opcode_spec_def.h required])
])
if test "$PHP_XCACHE_DISASSEMBLER" != "no" ; then
ERROR(disassembler)
fi
undefine([ERROR])
fi
fi

View File

@ -11,16 +11,17 @@ if (PHP_XCACHE != "no") {
}
// }}}
var xcache_sources = "processor.c \
var xcache_sources = "
main/xc_processor.c \
main/xc_const_string.c \
main/xc_lock.c \
main/xc_mem.c \
main/xc_opcode_spec.c \
main/xc_shm.c \
main/xc_shm_mmap.c \
main/xc_utils.c \
util/xc_stack.c \
xcache.c \
mmap.c \
mem.c \
xc_shm.c \
const_string.c \
opcode_spec.c \
stack.c \
utils.c \
lock.c \
";
// {{{ add sources on enabled
ARG_ENABLE("xcache-optimizer", "(N/A)", "no");
@ -40,7 +41,7 @@ if (PHP_XCACHE != "no") {
var uname = name.toUpperCase();
var withval = eval("PHP_XCACHE_" + uname);
if (withval != "no") {
xcache_sources += " " + name + ".c";
xcache_sources += " submodules/xc_" + name + ".c";
XCACHE_MODULES += " " + name;
STDOUT.WriteLine("Enabling XCache Module: " + name);
AC_DEFINE("HAVE_XCACHE_" + uname, 1, "Define for XCache: " + name)
@ -75,7 +76,7 @@ if (PHP_XCACHE != "no") {
ARG_ENABLE("xcache-test", "XCache: Enable self test - FOR DEVELOPERS ONLY!!", "no");
if (PHP_XCACHE_TEST != "no") {
ADD_FLAG("XCACHE_ENABLE_TEST", "-DXCACHE_ENABLE_TEST");
xcache_sources += " xc_malloc.c";
xcache_sources += " main/xc_malloc.c";
AC_DEFINE("HAVE_XCACHE_TEST", 1, "Define to enable XCache self test");
}
else {
@ -129,23 +130,4 @@ if (PHP_XCACHE != "no") {
/// }}}
XCACHE_PROC_SOURCES=glob(srcdir + "\\processor\\*.m4").join(' ');
ADD_FLAG("XCACHE_PROC_SOURCES", XCACHE_PROC_SOURCES);
// {{{ check for opcode_spec_def.h
STDOUT.Write("Checking if you have opcode_spec_def.h for XCache ... ");
var file = srcdir + "\\opcode_spec_def.h";
if (FSO.FileExists(file)) {
STDOUT.WriteLine("yes");
AC_DEFINE("HAVE_XCACHE_OPCODE_SPEC_DEF", 1, "Define if you have opcode_spec_def.h for XCache");
}
else {
STDOUT.WriteLine("no");
// check for features depend on opcode_spec_def.h
var xcache_require_opcode_spec_def = function(withval, name) {
if (withval != "no") {
ERROR(file + " is required to enable XCache " + name);
}
}
xcache_require_opcode_spec_def(PHP_XCACHE_DISASSEMBLER, "disassembler");
}
// }}}
}

105
devel/prepare.devel Executable file
View File

@ -0,0 +1,105 @@
#! /bin/bash
SELF="$0"
if test -e prepare.devel.inc ; then
. prepare.devel.inc
else
echo prepare.devel.inc is required, see prepare.devel.inc.example >&2
exit
fi
CTAGS=`which ctags 2>/dev/null || which exuberant-ctags 2>/dev/null `
AWK=`which gawk 2>/dev/null || which awk 2>/dev/null `
make_all() {
make_xc_opcode_spec_def.h
make_xc_const_string
test -e tags && echo tags exists, skipping. use \""$0" tags\" to rebuild || make_tags
}
make_clean() {
make_clean_xc_const_string
echo "*" rm -f tags xc_opcode_spec_def.h
rm -f tags xc_opcode_spec_def.h
}
make_xc_const_string() {
make_xc_const_string_opcodes_php4.x.h
make_xc_const_string_opcodes_php5.0.h
make_xc_const_string_opcodes_php5.1.h
make_xc_const_string_opcodes_php5.4.h
make_xc_const_string_opcodes_php6.x.h
}
make_clean_xc_const_string() {
echo "*" rm -f main/xc_const_string_opcodes_php*.h{,.tmp}
rm -f main/xc_const_string_opcodes_php*.h
}
make_xc_const_string_opcodes_php4.x.h() {
precheck main/xc_const_string_opcodes_php4.x.h "${PHP4_x_DIR}/Zend/zend_compile.h" && "$AWK" -f ./devel/gen_const_string_opcodes.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O"
}
make_xc_const_string_opcodes_php5.0.h() {
precheck main/xc_const_string_opcodes_php5.0.h "${PHP5_0_DIR}/Zend/zend_compile.h" && "$AWK" -f ./devel/gen_const_string_opcodes.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O"
}
make_xc_const_string_opcodes_php5.1.h() {
precheck main/xc_const_string_opcodes_php5.1.h "${PHP5_1_DIR}/Zend/zend_vm_def.h" && "$AWK" -f ./devel/gen_const_string_opcodes.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O"
}
make_xc_const_string_opcodes_php5.4.h() {
precheck main/xc_const_string_opcodes_php5.4.h "${PHP5_4_DIR}/Zend/zend_vm_def.h" && "$AWK" -f ./devel/gen_const_string_opcodes.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O"
}
make_xc_const_string_opcodes_php6.x.h() {
precheck main/xc_const_string_opcodes_php6.x.h "${PHP6_x_DIR}/Zend/zend_vm_def.h" && "$AWK" -f ./devel/gen_const_string_opcodes.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O"
}
make_xc_opcode_spec_def.h() {
precheck main/xc_opcode_spec_def.h "${EA_DIR}/opcodes.c" && "$AWK" -f ./devel/gen_xc_opcode_spec.awk < "$I" > "$O"
}
make_tags() {
if test -z "$CTAGS" ; then
echo tool ctags not found, skip building tags >&2
return
fi
if test -d "${PHP_DEVEL_DIR}" ; then
echo "* Making tags with ${PHP_DEVEL_DIR}"
"$CTAGS" -R . "${PHP_DEVEL_DIR}/main" "${PHP_DEVEL_DIR}/Zend" "${PHP_DEVEL_DIR}/TSRM" "${PHP_DEVEL_DIR}/ext/standard"
else
echo "* Making tags without php source files"
"$CTAGS" -R .
fi
}
error() {
echo "$@" >&2
}
precheck() {
if test -e "$2" ; then :; else
error X skipping "$1" because "$2" not found
return 1
fi
if test "$1" -ot "$2" ; then :; else
echo O "$1" is up to date.
return 1
fi
O="$1"
I="$2"
echo "* Making $1 from $2"
return 0
}
if test -z "$1" ; then
make_all
else
while ! test -z "$1" ; do
eval "make_$1"
shift
done
fi

View File

@ -1,4 +1,4 @@
# copy this file as devel.prepare.inc before modifying
# copy this file as ../devel.prepare.inc before modifying
PHP4_x_DIR=
PHP5_0_DIR=
PHP5_1_DIR=

137
devel/run Executable file
View File

@ -0,0 +1,137 @@
#!/bin/bash
# this script is for developers only
. run.cfg
basename=$(basename $(pwd))
if echo $basename | grep -- - >/dev/null; then :; else
dirs=${dirs:-php5-debug}
for dir in $dirs; do
cd ../${basename}-${dir} || exit
rm -f php-src
find -L . -type l | xargs rm -f
lndir ../$basename >/dev/null
find . -iname .\*.swp | xargs rm -f
ln -sf ~/src/php/$dir php-src
for i in ~/src/php/$dir/sapi/cgi/php{,-cgi}; do
[[ -r $i ]] && ln -sf "$i" php-cgi
done
ln -sf ~/src/php/$dir/sapi/cli/php php-cli
pwd
$0 "$@"
done
exit
fi
phpbasename=${basename#*-}
xcachebasename=${basename%%-*}
if [[ ! -z $1 ]]; then
type=$1
shift
if [[ ! -z $1 ]]; then
args=("$@")
elif [[ -z $args ]]; then
args=(test.php)
fi
fi
case $type in
prepare)
exec ./devel/prepare.devel
;;
tags)
exec ./devel/prepare.devel tags
;;
rebuild)
PHPDIRS=${PHPDIRS:-$HOME/test}
if [[ ! -x $PHPDIRS/$phpbasename/bin/phpize ]]; then
echo $PHPDIRS/$phpbasename/bin/phpize not found
exit
fi
export PATH=$PHPDIRS/$phpbasename/bin:$PATH
phpize --clean \
&& phpize \
&& CFLAGS="-Wall -Wno-unused -W -Wshadow -std=gnu99" ./configure --enable-xcache-disassembler --enable-xcache-test --enable-xcache-constant \
&& make
exit
;;
make)
MAKEARGS=("$@")
;;
esac
LANG=C /usr/bin/make $MAKEOPTS "${MAKEARGS[@]}" 2>&1 | hi error implicit warn FAIL
ret=${PIPESTATUS[0]}
if [[ $ret -ne 0 || $type = make ]]; then
exit $ret
fi
cmd=()
tracer=()
case "$basename" in
*-apache1*)
cmd=($HOME/apache1/bin/httpd -X)
;;
*-apache*)
exit 1
;;
*)
cmd=(./php-cgi -q -c php.ini)
"${cmd[@]}" -v
;;
esac
case "${args[0]}" in
fcgi)
args=(-b 1026)
shift
;;
esac
case "$type" in
ltr*)
export USE_ZEND_ALLOC=0
tracer=(ltrace -s1024 -e malloc,realloc,free,write)
;;
str*)
tracer=(strace -s1024 -T ./php-cgi)
;;
gdb)
#USE_ZEND_ALLOC=0
tracer=(gdb --args)
;;
val*)
export USE_ZEND_ALLOC=0
tracer=(valgrind --gen-suppressions=all)
;;
dc)
exec ./php-cli -c php.ini ./bin/phpdc.phpr "${args[@]}" | tee decompiled.php
;;
dop)
exec ./php-cli -c php.ini ./bin/phpdop.phpr "${args[@]}"
;;
retest)
exec make xcachetest "$@" TESTS="`grep '^/.*\.phpt$' php_test_results_*.txt | uniq | xargs`"
;;
test)
case "${args[0]}" in
*.phpt)
exec make xcachetest TEST_ARGS=-v TESTS="${args[*]}"
;;
*/)
exec make xcachetest TESTS="${args[@]}"
;;
*)
exec make xcachetest
;;
esac
;;
esac
export XCACHE_SKIP_FCGI_WARNING=1
echo "${tracer[@]}" "${cmd[@]}" "${args[@]}"
exec "${tracer[@]}" "${cmd[@]}" "${args[@]}"

1
main/README Normal file
View File

@ -0,0 +1 @@
understructure

View File

@ -1,5 +1,5 @@
#include "xcache.h"
#include "const_string.h"
#include "xc_const_string.h"
/* {{{ xc_get_op_type */
static const char *const op_type_names[] = {
@ -62,15 +62,15 @@ const char *xc_get_data_type(zend_uchar data_type)
/* }}} */
/* {{{ xc_get_opcode */
#if PHP_MAJOR_VERSION >= 6
# include "const_string_opcodes_php6.x.h"
# include "xc_const_string_opcodes_php6.x.h"
#elif defined(ZEND_ENGINE_2_4)
# include "const_string_opcodes_php5.4.h"
# include "xc_const_string_opcodes_php5.4.h"
#elif defined(ZEND_ENGINE_2_1)
# include "const_string_opcodes_php5.1.h"
# include "xc_const_string_opcodes_php5.1.h"
#elif defined(ZEND_ENGINE_2)
# include "const_string_opcodes_php5.0.h"
# include "xc_const_string_opcodes_php5.0.h"
#else
# include "const_string_opcodes_php4.x.h"
# include "xc_const_string_opcodes_php4.x.h"
#endif
zend_uchar xc_get_opcode_count()

View File

@ -18,7 +18,7 @@ typedef int HANDLE;
FILE_ATTRIBUTE_NORMAL, \
NULL)
#endif
#include "lock.h"
#include "xc_lock.h"
struct _xc_lock_t {
HANDLE fd;

View File

@ -9,8 +9,8 @@
#endif
#include "xc_shm.h"
#include "php.h"
#include "align.h"
#include "utils.h"
#include "xc_utils.h"
#include "util/xc_align.h"
struct _xc_malloc_mem_t {
const xc_mem_handlers_t *handlers;

View File

@ -17,8 +17,9 @@
#define XC_MEMBLOCK_IMPL _xc_mem_block_t
#define XC_MEM_IMPL _xc_mem_mem_t
#include "xc_shm.h"
#include "align.h"
#include "utils.h"
#include "xc_utils.h"
#include "util/xc_align.h"
#include "util/xc_trace.h"
#if 0
#undef ALLOC_DEBUG_BLOCK_CHECK

View File

@ -1,8 +1,7 @@
#include "xcache.h"
#include "opcode_spec.h"
#include "const_string.h"
#include "xc_opcode_spec.h"
#include "xc_const_string.h"
#ifdef HAVE_XCACHE_OPCODE_SPEC_DEF
/* {{{ opcode_spec */
#define OPSPEC(ext, op1, op2, res) { OPSPEC_##ext, OPSPEC_##op1, OPSPEC_##op2, OPSPEC_##res },
#ifdef ZEND_ENGINE_2
@ -10,7 +9,7 @@
#else
# define OPSPEC_VAR_2 OPSPEC_VAR
#endif
#include "opcode_spec_def.h"
#include "xc_opcode_spec_def.h"
zend_uchar xc_get_opcode_spec_count()
{
@ -29,7 +28,6 @@ const xc_opcode_spec_t *xc_get_opcode_spec(zend_uchar opcode)
return &xc_opcode_spec[opcode];
}
/* }}} */
#endif
/* {{{ op_spec */
#define OPSPECS_DEF_NAME(name) #name,

1
main/xc_processor.c Normal file
View File

@ -0,0 +1 @@
#include "xc_processor_real.c"

View File

@ -13,7 +13,7 @@ struct _xc_shm_t {
typedef struct XC_SHM_IMPL xc_shm_t;
typedef size_t xc_shmsize_t;
#include "mem.h"
#include "xc_mem.h"
/* shm */
#define XC_SHM_CAN_READONLY(func) int func(xc_shm_t *shm)

View File

@ -31,7 +31,7 @@
#include "php.h"
#define XC_SHM_IMPL _xc_mmap_shm_t
#include "xc_shm.h"
#include "utils.h"
#include "xc_utils.h"
#ifndef max
#define max(a, b) ((a) < (b) ? (b) : (a))

View File

@ -1,12 +1,11 @@
#include "xcache.h"
#include "stack.h"
#include "xcache_globals.h"
#include "utils.h"
#include "xc_utils.h"
#ifdef ZEND_ENGINE_2_1
#include "zend_vm.h"
#endif
#include "opcode_spec.h"
#include "xc_opcode_spec.h"
#undef NDEBUG
#include "assert.h"
@ -282,7 +281,6 @@ int xc_redo_pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */
}
/* }}} */
#ifdef HAVE_XCACHE_OPCODE_SPEC_DEF
static void xc_fix_opcode_ex_znode(int tofix, xc_op_spec_t spec, Z_OP_TYPEOF_TYPE *op_type, znode_op *op, int type TSRMLS_DC) /* {{{ */
{
#ifdef ZEND_ENGINE_2
@ -347,7 +345,6 @@ int xc_undo_fix_opcode(zend_op_array *op_array TSRMLS_DC) /* {{{ */
return 0;
}
/* }}} */
#endif
int xc_foreach_early_binding_class(zend_op_array *op_array, void (*callback)(zend_op *opline, int oplineno, void *data TSRMLS_DC), void *data TSRMLS_DC) /* {{{ */
{

View File

@ -1,45 +1,6 @@
#include "php.h"
#include "xcache.h"
#ifdef XCACHE_DEBUG
# define IFDEBUG(x) (x)
int xc_vtrace(const char *fmt, va_list args);
int xc_trace(const char *fmt, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
# ifdef ZEND_WIN32
static inline int TRACE(const char *fmt, ...)
{
va_list args;
int ret;
va_start(args, fmt);
ret = xc_vtrace(fmt, args);
va_end(args);
return ret;
}
# else
# define TRACE(fmt, ...) \
xc_trace("%s:%d: " fmt "\r\n", __FILE__, __LINE__, __VA_ARGS__)
# endif /* ZEND_WIN32 */
# undef NDEBUG
# undef inline
# define inline
#else /* XCACHE_DEBUG */
# ifdef ZEND_WIN32
static inline int TRACE_DUMMY(const char *fmt, ...)
{
return 0;
}
# define TRACE 1 ? 0 : TRACE_DUMMY
# else
# define TRACE(fmt, ...) do { } while (0)
# endif /* ZEND_WIN32 */
# define IFDEBUG(x) do { } while (0)
#endif /* XCACHE_DEBUG */
#include <assert.h>
int xc_util_init(int module_number TSRMLS_DC);
void xc_util_destroy();
@ -107,52 +68,3 @@ size_t xc_dirname(char *path, size_t len);
long xc_atol(const char *str, int len);
#define zend_atol xc_atol
#endif
typedef struct {
zend_uint size;
zend_uint cnt;
void *data;
} xc_vector_t;
#define xc_vector_init(type, vector) do { \
(vector)->cnt = 0; \
(vector)->size = 0; \
(vector)->data = NULL; \
} while (0)
#define xc_vector_add(type, vector, value) do { \
if ((vector)->cnt == (vector)->size) { \
if ((vector)->size) { \
(vector)->size <<= 1; \
(vector)->data = erealloc((vector)->data, sizeof(type) * (vector)->size); \
} \
else { \
(vector)->size = 8; \
(vector)->data = emalloc(sizeof(type) * (vector)->size); \
} \
} \
((type *) (vector)->data)[(vector)->cnt++] = value; \
} while (0)
static inline void *xc_vector_detach_impl(xc_vector_t *vector)
{
void *data = vector->data;
vector->data = NULL;
vector->size = 0;
vector->cnt = 0;
return data;
}
#define xc_vector_detach(type, vector) ((type *) xc_vector_detach_impl(vector))
static inline void xc_vector_free_impl(xc_vector_t *vector TSRMLS_DC)
{
if (vector->data) {
efree(vector->data);
}
vector->size = 0;
vector->cnt = 0;
}
#define xc_vector_free(type, vector) xc_vector_free_impl(vector TSRMLS_CC)

View File

@ -1,105 +0,0 @@
#! /bin/bash
SELF="$0"
if test -e prepare.devel.inc ; then
. prepare.devel.inc
else
echo prepare.devel.inc is required, see prepare.devel.inc.example >&2
exit
fi
CTAGS=`which ctags 2>/dev/null || which exuberant-ctags 2>/dev/null `
AWK=`which gawk 2>/dev/null || which awk 2>/dev/null `
make_all() {
make_opcode_spec_def.h
make_const_string
test -e tags && echo tags exists, skipping. use \""$0" tags\" to rebuild || make_tags
}
make_clean() {
make_clean_const_string
echo "*" rm -f tags opcode_spec_def.h
rm -f tags opcode_spec_def.h
}
make_const_string() {
make_const_string_opcodes_php4.x.h
make_const_string_opcodes_php5.0.h
make_const_string_opcodes_php5.1.h
make_const_string_opcodes_php5.4.h
make_const_string_opcodes_php6.x.h
}
make_clean_const_string() {
echo "*" rm -f const_string_opcodes_php*.h{,.tmp}
rm -f const_string_opcodes_php*.h
}
make_const_string_opcodes_php4.x.h() {
precheck const_string_opcodes_php4.x.h "${PHP4_x_DIR}/Zend/zend_compile.h" && "$AWK" -f ./mkopcode.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O"
}
make_const_string_opcodes_php5.0.h() {
precheck const_string_opcodes_php5.0.h "${PHP5_0_DIR}/Zend/zend_compile.h" && "$AWK" -f ./mkopcode.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O"
}
make_const_string_opcodes_php5.1.h() {
precheck const_string_opcodes_php5.1.h "${PHP5_1_DIR}/Zend/zend_vm_def.h" && "$AWK" -f ./mkopcode.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O"
}
make_const_string_opcodes_php5.4.h() {
precheck const_string_opcodes_php5.4.h "${PHP5_4_DIR}/Zend/zend_vm_def.h" && "$AWK" -f ./mkopcode.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O"
}
make_const_string_opcodes_php6.x.h() {
precheck const_string_opcodes_php6.x.h "${PHP6_x_DIR}/Zend/zend_vm_def.h" && "$AWK" -f ./mkopcode.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O"
}
make_opcode_spec_def.h() {
precheck "opcode_spec_def.h" "${EA_DIR}/opcodes.c" && "$AWK" -f ./mkopcode_spec.awk < "$I" > "$O"
}
make_tags() {
if test -z "$CTAGS" ; then
echo tool ctags not found, skip building tags >&2
return
fi
if test -d "${PHP_DEVEL_DIR}" ; then
echo "* Making tags with ${PHP_DEVEL_DIR}"
"$CTAGS" -R . "${PHP_DEVEL_DIR}/main" "${PHP_DEVEL_DIR}/Zend" "${PHP_DEVEL_DIR}/TSRM" "${PHP_DEVEL_DIR}/ext/standard"
else
echo "* Making tags without php source files"
"$CTAGS" -R .
fi
}
error() {
echo "$@" >&2
}
precheck() {
if test -e "$2" ; then :; else
error X skipping "$1" because "$2" not found
return 1
fi
if test "$1" -ot "$2" ; then :; else
echo O "$1" is up to date.
return 1
fi
O="$1"
I="$2"
echo "* Making $1 from $2"
return 0
}
if test -z "$1" ; then
make_all
else
while ! test -z "$1" ; do
eval "make_$1"
shift
done
fi

View File

@ -1 +0,0 @@
#include "processor_real.c"

View File

@ -10,10 +10,9 @@ divert(0)
#include "zend_ini.h"
#include "xcache.h"
#include "align.h"
#include "const_string.h"
#include "processor.h"
#include "stack.h"
#include "util/xc_align.h"
#include "xc_const_string.h"
#include "xc_processor.h"
#include "xcache_globals.h"
#if defined(HARDENING_PATCH_HASH_PROTECT) && HARDENING_PATCH_HASH_PROTECT

104
run
View File

@ -1,102 +1,2 @@
#!/bin/bash
# this script is for developers only
. run.cfg
basename=$(basename $(pwd))
if echo $basename | grep -- - >/dev/null; then :; else
dirs=${dirs:-php5-debug}
for dir in $dirs; do
cd ../${basename}-${dir} || exit
pwd
$0 "$@"
done
exit
fi
if [[ ! -z $1 ]]; then
type=$1
shift
if [[ ! -z $1 ]]; then
args=("$@")
elif [[ -z $args ]]; then
args=(test.php)
fi
fi
if [[ $type = make ]]; then
MAKEARGS=("$@")
fi
LANG=C /usr/bin/make $MAKEOPTS "${MAKEARGS[@]}" 2>&1 | hi error warn FAIL
ret=${PIPESTATUS[0]}
if [[ $ret -ne 0 || $type = make ]]; then
exit $ret
fi
cmd=()
tracer=()
case "$basename" in
*-apache1*)
cmd=($HOME/apache1/bin/httpd -X)
;;
*-apache*)
exit 1
;;
*)
cmd=(./php-cgi -q -c php.ini)
"${cmd[@]}" -v
;;
esac
case "${args[0]}" in
fcgi)
args=(-b 1026)
shift
;;
esac
case "$type" in
ltr*)
export USE_ZEND_ALLOC=0
tracer=(ltrace -s1024 -e malloc,realloc,free,write)
;;
str*)
tracer=(strace -s1024 -T ./php-cgi)
;;
gdb)
#USE_ZEND_ALLOC=0
tracer=(gdb --args)
;;
val*)
export USE_ZEND_ALLOC=0
tracer=(valgrind --gen-suppressions=all)
;;
dc)
exec ./php-cli -c php.ini ./phpdc.phpr "${args[@]}" | tee decompiled.php
;;
dop)
exec ./php-cgi -q -c php.ini ./phpdop.phpr "${args[@]}"
;;
retest)
exec make xcachetest "$@" TESTS="`grep '^/.*\.phpt$' php_test_results_*.txt | uniq | xargs`"
;;
test)
case "${args[0]}" in
*.phpt)
exec make xcachetest TEST_ARGS=-v TESTS="${args[*]}"
;;
*/)
exec make xcachetest TESTS="${args[@]}"
;;
*)
exec make xcachetest
;;
esac
;;
esac
export XCACHE_SKIP_FCGI_WARNING=1
echo "${tracer[@]}" "${cmd[@]}" "${args[@]}"
exec "${tracer[@]}" "${cmd[@]}" "${args[@]}"
#!/bin/sh
exec devel/run "$@"

View File

@ -1,11 +1,8 @@
#include "disassembler.h"
#include "xc_disassembler.h"
#include "xcache.h"
#include "utils.h"
#include "processor.h"
#include "xc_utils.h"
#include "xc_processor.h"
#ifndef HAVE_XCACHE_OPCODE_SPEC_DEF
#error disassembler cannot be built without xcache/opcode_spec_def.h
#endif
static void xc_dasm(zval *output, zend_op_array *op_array TSRMLS_DC) /* {{{ */
{
const Bucket *b;

1
util/README Normal file
View File

@ -0,0 +1 @@
generic utility stuffs unrelatived to ZendEngine

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include <assert.h>
#include "stack.h"
#include "xc_stack.h"
typedef xc_stack_t* S;
void xc_stack_init_ex(S stack, int initsize)

View File

@ -1,3 +1,5 @@
#ifndef __XC_UTIL_STACK
#define __XC_UTIL_STACK
typedef struct {
void **data;
@ -16,3 +18,5 @@ void *xc_stack_get(S stack, int n);
int xc_stack_count(S stack);
void xc_stack_reverse(S stack);
#undef S
#endif /* __XC_UTIL_STACK */

56
util/xc_vector.h Normal file
View File

@ -0,0 +1,56 @@
#ifndef XC_VECTOR_H_0957AC4E1A44E838C7B8DBECFF9C4B3B
#define XC_VECTOR_H_0957AC4E1A44E838C7B8DBECFF9C4B3B
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
typedef struct {
zend_uint size;
zend_uint cnt;
void *data;
} xc_vector_t;
#define xc_vector_init(type, vector) do { \
(vector)->cnt = 0; \
(vector)->size = 0; \
(vector)->data = NULL; \
} while (0)
#define xc_vector_add(type, vector, value) do { \
if ((vector)->cnt == (vector)->size) { \
if ((vector)->size) { \
(vector)->size <<= 1; \
(vector)->data = erealloc((vector)->data, sizeof(type) * (vector)->size); \
} \
else { \
(vector)->size = 8; \
(vector)->data = emalloc(sizeof(type) * (vector)->size); \
} \
} \
((type *) (vector)->data)[(vector)->cnt++] = value; \
} while (0)
static inline void *xc_vector_detach_impl(xc_vector_t *vector)
{
void *data = vector->data;
vector->data = NULL;
vector->size = 0;
vector->cnt = 0;
return data;
}
#define xc_vector_detach(type, vector) ((type *) xc_vector_detach_impl(vector))
static inline void xc_vector_free_impl(xc_vector_t *vector TSRMLS_DC)
{
if (vector->data) {
efree(vector->data);
}
vector->size = 0;
vector->cnt = 0;
}
#define xc_vector_free(type, vector) xc_vector_free_impl(vector TSRMLS_CC)
#endif /* XC_VECTOR_H_0957AC4E1A44E838C7B8DBECFF9C4B3B */

View File

@ -26,16 +26,18 @@
#ifdef ZEND_ENGINE_2_1
#include "ext/date/php_date.h"
#endif
#include "optimizer.h"
#include "coverager.h"
#include "disassembler.h"
#include "align.h"
#include "stack.h"
#include "submodules/xc_optimizer.h"
#include "submodules/xc_coverager.h"
#include "submodules/xc_disassembler.h"
#include "xcache_globals.h"
#include "processor.h"
#include "const_string.h"
#include "opcode_spec.h"
#include "utils.h"
#include "xc_processor.h"
#include "xc_const_string.h"
#include "xc_opcode_spec.h"
#include "xc_utils.h"
#include "util/xc_align.h"
#include "util/xc_stack.h"
#include "util/xc_vector.h"
#include "util/xc_trace.h"
#define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > (pentry)->ctime + (time_t) (pentry)->ttl)
#define CHECK(x, e) do { if ((x) == NULL) { zend_error(E_ERROR, "XCache: " e); goto err; } } while (0)
@ -71,10 +73,10 @@ static char *xc_mmap_path = NULL;
static char *xc_coredump_dir = NULL;
static zend_bool xc_disable_on_crash = 0;
static xc_hash_t xc_php_hcache = { 0 };
static xc_hash_t xc_php_hentry = { 0 };
static xc_hash_t xc_var_hcache = { 0 };
static xc_hash_t xc_var_hentry = { 0 };
static xc_hash_t xc_php_hcache = { 0, 0, 0 };
static xc_hash_t xc_php_hentry = { 0, 0, 0 };
static xc_hash_t xc_var_hcache = { 0, 0, 0 };
static xc_hash_t xc_var_hentry = { 0, 0, 0 };
static zend_ulong xc_php_ttl = 0;
static zend_ulong xc_var_maxttl = 0;
@ -113,7 +115,7 @@ static zend_bool xc_zend_extension_faked = 0;
# define zend_extension_entry xcache_zend_extension_entry
#endif
ZEND_DLEXPORT zend_extension zend_extension_entry;
ZEND_DECLARE_MODULE_GLOBALS(xcache);
ZEND_DECLARE_MODULE_GLOBALS(xcache)
typedef enum { XC_TYPE_PHP, XC_TYPE_VAR } xc_entry_type_t;
/* }}} */
@ -3270,7 +3272,6 @@ PHP_FUNCTION(xcache_get_op_spec)
xc_call_getter(xc_get_op_spec, xc_get_op_spec_count(), INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
#ifdef HAVE_XCACHE_OPCODE_SPEC_DEF
/* {{{ proto string xcache_get_opcode_spec(int opcode) */
PHP_FUNCTION(xcache_get_opcode_spec)
{
@ -3294,7 +3295,6 @@ PHP_FUNCTION(xcache_get_opcode_spec)
RETURN_NULL();
}
/* }}} */
#endif
/* {{{ proto mixed xcache_get_special_value(zval value)
XCache internal use only: For decompiler to get static value with type fixed */
PHP_FUNCTION(xcache_get_special_value)
@ -3397,9 +3397,7 @@ static zend_function_entry xcache_functions[] = /* {{{ */
PHP_FE(xcache_get_op_type, NULL)
PHP_FE(xcache_get_data_type, NULL)
PHP_FE(xcache_get_opcode, NULL)
#ifdef HAVE_XCACHE_OPCODE_SPEC_DEF
PHP_FE(xcache_get_opcode_spec, NULL)
#endif
PHP_FE(xcache_is_autoglobal, NULL)
PHP_FE(xcache_inc, NULL)
PHP_FE(xcache_dec, NULL)
@ -3519,7 +3517,7 @@ static void xcache_init_crash_handler() /* {{{ */
/* old signal handlers {{{ */
typedef void (*xc_sighandler_t)(int);
#define FOREACH_SIG(sig) static xc_sighandler_t old_##sig##_handler = NULL
#include "foreachcoresig.h"
#include "util/xc_foreachcoresig.h"
#undef FOREACH_SIG
/* }}} */
static void xcache_signal_handler(int sig);
@ -3533,7 +3531,7 @@ static void xcache_restore_crash_handler() /* {{{ */
signal(sig, SIG_DFL); \
} \
} while (0)
#include "foreachcoresig.h"
#include "util/xc_foreachcoresig.h"
#undef FOREACH_SIG
}
/* }}} */
@ -3541,7 +3539,7 @@ static void xcache_init_crash_handler() /* {{{ */
{
#define FOREACH_SIG(sig) \
old_##sig##_handler = signal(sig, xcache_signal_handler)
#include "foreachcoresig.h"
#include "util/xc_foreachcoresig.h"
#undef FOREACH_SIG
}
/* }}} */

View File

@ -20,7 +20,7 @@
#include <config.h>
#endif
#include "xc_shm.h"
#include "lock.h"
#include "xc_lock.h"
#if !defined(ZEND_ENGINE_2_4) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4 || PHP_MAJOR_VERSION > 5)
# define ZEND_ENGINE_2_4

View File

@ -1,3 +1,4 @@
#include "util/xc_stack.h"
ZEND_BEGIN_MODULE_GLOBALS(xcache)
zend_bool initial_compile_file_called; /* true is origin_compile_file is called */