Merge branch 'master' into test

* master: (67 commits)
  remove the NEWS entry for the reverted fpm fix
  remove the NEWS entry for the reverted fpm fix
  remove the NEWS entry for the reverted fpm fix
  Revert "Fix Bug #67530 	error_log=syslog ignored"
  --enable-fpm for the travis build
  fix the last fpm NEWS entry, the other bug is related, but not the same what we fixed here
  NEWS
  NEWS
  Fix bug #67091: make install fails to install libphp5.so on FreeBSD 10.0
  adding NEWS entry for the fix for bug #65641
  Updated NEWS file for recent phpdbg fixes
  Fixed issue krakjoe/phpdbg#94 - List behavior is inconsistent
  Fix issue krakjoe/phpdbg#97 - list now appends a newline if there is none The prompt should always ensure it is on a newline
  Fixed test
  Inform about back command existence in help - Fixes krakjoe/phpdbg#100 No way to list the current stack/frames
  Fix issue krakjoe/phpdbg#98 break if does not seem to work
  Fix issue krakjoe/phpdbg#99 register function has the same behavior as run
  Fix readline/libedit (Thanks to @remicollet)
  Replace incorrect `E` command with `ev` in watch help
  Fix typo in `finish` help
  ...

Conflicts:
	Zend/zend_ast.c
	Zend/zend_highlight.c
	Zend/zend_indent.c
	ext/spl/spl_array.c
	ext/spl/spl_observer.c
	ext/standard/info.c
This commit is contained in:
Dmitry Stogov 2014-07-01 00:19:41 +04:00
commit acfbb7b6dc
29 changed files with 915 additions and 617 deletions

11
Zend/tests/67468.phpt Normal file
View File

@ -0,0 +1,11 @@
--TEST--
Bug #67468 (Segfault in highlight_file()/highlight_string())
--SKIPIF--
<?php if(!function_exists("leak")) print "skip only for debug builds"; ?>
--FILE--
<?php
highlight_string("<?php __CLASS__;", true);
echo "done";
?>
--EXPECT--
done

12
Zend/tests/bug67368.phpt Normal file
View File

@ -0,0 +1,12 @@
--TEST--
Bug #67368 (Memory leak with immediately dereferenced array in class constant)
--INI--
report_memleaks=1
--FILE--
<?php
class FooBar {
const bar = ["bar" => 3]["bar"];
}
echo "okey";
--EXPECTF--
okey

View File

@ -350,6 +350,20 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
}
}
break;
//???
#if 0
case ZEND_FETCH_DIM_R:
zend_ast_evaluate(&op1, (&ast->u.child)[0], scope TSRMLS_CC);
zend_ast_evaluate(&op2, (&ast->u.child)[1], scope TSRMLS_CC);
{
zval *tmp;
zend_fetch_dimension_by_zval(&tmp, &op1, &op2 TSRMLS_CC);
ZVAL_ZVAL(result, tmp, 1, 1);
}
zval_dtor(&op1);
zval_dtor(&op2);
break;
#endif
default:
zend_error(E_ERROR, "Unsupported constant expression");
}

8
build/libtool.m4 vendored
View File

@ -1532,10 +1532,6 @@ dgux*)
shlibpath_var=LD_LIBRARY_PATH
;;
freebsd1*)
dynamic_linker=no
;;
freebsd* | dragonfly*)
# DragonFly does not have aout. When/if they implement a new
# versioning mechanism, adjust this.
@ -5843,10 +5839,6 @@ _LT_EOF
_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
freebsd1*)
_LT_AC_TAGVAR(ld_shlibs, $1)=no
;;
# FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
# support. Future versions do this automatically, but an explicit c++rt0.o
# does not break anything, and helps significantly (at the cost of a little

View File

@ -272,8 +272,7 @@ static char* get_icu_value_internal( const char* loc_name , char* tag_name, int*
grOffset = findOffset( LOC_GRANDFATHERED , loc_name );
if( grOffset >= 0 ){
if( strcmp(tag_name , LOC_LANG_TAG)==0 ){
tag_value = estrdup(loc_name);
return tag_value;
return estrdup(loc_name);
} else {
/* Since Grandfathered , no value , do nothing , retutn NULL */
return NULL;
@ -283,8 +282,8 @@ static char* get_icu_value_internal( const char* loc_name , char* tag_name, int*
if( fromParseLocale==1 ){
/* Handle singletons */
if( strcmp(tag_name , LOC_LANG_TAG)==0 ){
if( strlen(loc_name)>1 && (isIDPrefix(loc_name) ==1 ) ){
return (char *)loc_name;
if( strlen(loc_name)>1 && (isIDPrefix(loc_name) == 1) ){
return estrdup(loc_name);
}
}
@ -504,6 +503,14 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
RETURN_FALSE;
}
if(loc_name_len > ULOC_FULLNAME_CAPACITY) {
/* See bug 67397: overlong locale names cause trouble in uloc_getDisplayName */
spprintf(&msg , 0, "locale_get_display_%s : name too long", tag_name );
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, msg , 1 TSRMLS_CC );
efree(msg);
RETURN_FALSE;
}
if(loc_name_len == 0) {
loc_name = intl_locale_get_default(TSRMLS_C);
}

View File

@ -10,6 +10,7 @@ var_dump(locale_get_display_name(str_repeat("a", 300), null));
var_dump(locale_get_display_name(str_repeat("a", 512), null));
var_dump(locale_get_display_name(str_repeat("a", 600), null));
--EXPECT--
string(300) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
string(512) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
string(600) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
bool(false)
bool(false)
bool(false)

View File

@ -0,0 +1,21 @@
--TEST--
Bug #67397 (Buffer overflow in locale_get_display_name->uloc_getDisplayName (libicu 4.8.1))
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
--FILE--
<?php
function ut_main()
{
$ret = var_export(ut_loc_get_display_name(str_repeat('*', 256), 'en_us'), true);
$ret .= "\n";
$ret .= var_export(intl_get_error_message(), true);
return $ret;
}
include_once( 'ut_common.inc' );
ut_run();
?>
--EXPECTF--
false
'locale_get_display_name : name too long: U_ILLEGAL_ARGUMENT_ERROR'

View File

@ -63,7 +63,8 @@ function ut_main()
//Some Invalid Tags:
'de-419-DE',
'a-DE',
'ar-a-aaa-b-bbb-a-ccc'
'ar-a-aaa-b-bbb-a-ccc',
'x-AAAAAA',
);
@ -201,3 +202,6 @@ No values found from Locale parsing.
---------------------
ar-a-aaa-b-bbb-a-ccc:
language : 'ar' ,
---------------------
x-AAAAAA:
private0 : 'AAAAAA' ,

View File

@ -1831,7 +1831,9 @@ SPL_METHOD(Array, unserialize)
}
++p;
if (!php_var_unserialize(&members, &p, s + buf_len, &var_hash TSRMLS_CC)) {
ZVAL_UNDEF(&members);
if (!php_var_unserialize(&members, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE(members) != IS_ARRAY) {
zval_ptr_dtor(&members);
goto outexcept;
}

View File

@ -891,7 +891,9 @@ SPL_METHOD(SplObjectStorage, unserialize)
}
++p;
if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
ZVAL_UNDEF(&pmembers);
if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
}

View File

@ -7,6 +7,7 @@ $badblobs = array(
'x:i:2;i:0;,i:1;;i:0;,i:2;;m:a:0:{}',
'x:i:3;O:8:"stdClass":0:{},O:8:"stdClass":0:{};R:2;,i:1;;O:8:"stdClass":0:{},r:2;;m:a:0:{}',
'x:i:3;O:8:"stdClass":0:{},O:8:"stdClass":0:{};r:2;,i:1;;O:8:"stdClass":0:{},r:2;;m:a:0:{}',
'x:i:1;O:8:"stdClass":0:{},N;;m:s:40:"1234567890123456789012345678901234567890"',
);
foreach($badblobs as $blob) {
try {
@ -17,6 +18,7 @@ try {
echo $e->getMessage()."\n";
}
}
echo "DONE\n";
--EXPECTF--
Error at offset 6 of 34 bytes
Error at offset 46 of 89 bytes
@ -42,4 +44,5 @@ object(SplObjectStorage)#2 (1) {
}
}
}
Error at offset 79 of 78 bytes
DONE

View File

@ -861,16 +861,16 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
php_info_print_table_start();
php_info_print_table_header(2, "Variable", "Value");
if ((data = zend_hash_str_find(&EG(symbol_table).ht, "PHP_SELF", sizeof("PHP_SELF")-1)) != NULL) {
if ((data = zend_hash_str_find(&EG(symbol_table).ht, "PHP_SELF", sizeof("PHP_SELF")-1)) != NULL && Z_TYPE_P(data) == IS_STRING) {
php_info_print_table_row(2, "PHP_SELF", Z_STRVAL_P(data));
}
if ((data = zend_hash_str_find(&EG(symbol_table).ht, "PHP_AUTH_TYPE", sizeof("PHP_AUTH_TYPE")-1)) != NULL) {
if ((data = zend_hash_str_find(&EG(symbol_table).ht, "PHP_AUTH_TYPE", sizeof("PHP_AUTH_TYPE")-1)) != NULL && Z_TYPE_P(data) == IS_STRING) {
php_info_print_table_row(2, "PHP_AUTH_TYPE", Z_STRVAL_P(data));
}
if ((data = zend_hash_str_find(&EG(symbol_table).ht, "PHP_AUTH_USER", sizeof("PHP_AUTH_USER")-1)) != NULL) {
if ((data = zend_hash_str_find(&EG(symbol_table).ht, "PHP_AUTH_USER", sizeof("PHP_AUTH_USER")-1)) != NULL && Z_TYPE_P(data) == IS_STRING) {
php_info_print_table_row(2, "PHP_AUTH_USER", Z_STRVAL_P(data));
}
if ((data = zend_hash_str_find(&EG(symbol_table).ht, "PHP_AUTH_PW", sizeof("PHP_AUTH_PW")-1)) != NULL) {
if ((data = zend_hash_str_find(&EG(symbol_table).ht, "PHP_AUTH_PW", sizeof("PHP_AUTH_PW")-1)) != NULL && Z_TYPE_P(data) == IS_STRING) {
php_info_print_table_row(2, "PHP_AUTH_PW", Z_STRVAL_P(data));
}
php_print_gpcse_array(ZEND_STRL("_REQUEST") TSRMLS_CC);

View File

@ -0,0 +1,15 @@
--TEST--
phpinfo() Type Confusion Information Leak Vulnerability
--FILE--
<?php
$PHP_SELF = 1;
phpinfo(INFO_VARIABLES);
?>
==DONE==
--EXPECTF--
phpinfo()
PHP Variables
%A
==DONE==

View File

@ -1075,6 +1075,9 @@ static int fpm_conf_process_all_pools() /* {{{ */
}
}
for (kv = wp->config->php_admin_values; kv; kv = kv->next) {
if (!strcasecmp(kv->key, "error_log") && !strcasecmp(kv->value, "syslog")) {
continue;
}
for (p = options; *p; p++) {
if (!strcasecmp(kv->key, *p)) {
fpm_evaluate_full_path(&kv->value, wp, NULL, 0);

View File

@ -1137,19 +1137,6 @@ static void init_request_info(TSRMLS_D)
TRANSLATE_SLASHES(env_document_root);
}
if (env_path_translated != NULL && env_redirect_url != NULL &&
env_path_translated != script_path_translated &&
strcmp(env_path_translated, script_path_translated) != 0) {
/*
* pretty much apache specific. If we have a redirect_url
* then our script_filename and script_name point to the
* php executable
*/
script_path_translated = env_path_translated;
/* we correct SCRIPT_NAME now in case we don't have PATH_INFO */
env_script_name = env_redirect_url;
}
#ifdef __riscos__
/* Convert path to unix format*/
__riscosify_control |= __RISCOSIFY_DONT_CHECK_DIR;
@ -1318,7 +1305,7 @@ static void init_request_info(TSRMLS_D)
efree(pt);
}
} else {
/* make sure path_info/translated are empty */
/* make sure original values are remembered in ORIG_ copies if we've changed them */
if (!orig_script_filename ||
(script_path_translated != orig_script_filename &&
strcmp(script_path_translated, orig_script_filename) != 0)) {
@ -1327,16 +1314,6 @@ static void init_request_info(TSRMLS_D)
}
script_path_translated = _sapi_cgibin_putenv("SCRIPT_FILENAME", script_path_translated TSRMLS_CC);
}
if (env_redirect_url) {
if (orig_path_info) {
_sapi_cgibin_putenv("ORIG_PATH_INFO", orig_path_info TSRMLS_CC);
_sapi_cgibin_putenv("PATH_INFO", NULL TSRMLS_CC);
}
if (orig_path_translated) {
_sapi_cgibin_putenv("ORIG_PATH_TRANSLATED", orig_path_translated TSRMLS_CC);
_sapi_cgibin_putenv("PATH_TRANSLATED", NULL TSRMLS_CC);
}
}
if (env_script_name != orig_script_name) {
if (orig_script_name) {
_sapi_cgibin_putenv("ORIG_SCRIPT_NAME", orig_script_name TSRMLS_CC);

View File

@ -26,6 +26,9 @@ install-phpdbg: $(BUILD_BINARY)
@$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/log
@$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/run
@$(INSTALL) -m 0755 $(BUILD_BINARY) $(INSTALL_ROOT)$(bindir)/$(program_prefix)phpdbg$(program_suffix)$(EXEEXT)
@echo "Installing phpdbg man page: $(INSTALL_ROOT)$(mandir)/man1/"
@$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man1
@$(INSTALL_DATA) sapi/phpdbg/phpdbg.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)phpdbg$(program_suffix).1
clean-phpdbg:
@echo "Cleaning phpdbg object files ..."

View File

@ -21,7 +21,7 @@ if test "$PHP_PHPDBG" != "no"; then
PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE"
PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c"
if test "$PHP_READLINE" != "no"; then
if test "$PHP_READLINE" != "no" -o "$PHP_LIBEDIT" != "no"; then
PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS"
fi

59
sapi/phpdbg/phpdbg.1 Normal file
View File

@ -0,0 +1,59 @@
.TH PHPDBG 1
.SH NAME
phpdbg \- The interactive PHP debugger
.SH SYNOPSIS
.B phpdbg
[OPTION]
[\fB\-e\fIFILE\fR]
.SH DESCRIPTION
.B phpdbg
a lightweight, powerful, easy to use debugging platform for PHP5.
.SH OPTIONS
The following switches are implemented (just like cli SAPI):
.TP
.BR \-n
No \fBphp.ini\fR file will be used
.TP
.BR \-c \fIpath\fB|\fIfile\fR
Look for \fBphp.ini\fR file in the directory \fIpath\fR or use the specified \fIfile\fR
.TP
.BR \-z \fIfile\fR
Load Zend extension \fIfile\fR
.TP
.BR \-d \fIfoo\fB[=\fIbar\fB]\fR
Define INI entry \fIfoo\fR with value \fIbar\fR
.PP The following switches change the default behaviour of phpdbg:
.TP
.BR \-v
Disables quietness
.TP
.BR \-s
Enabled stepping
.TP
.BR -e \fIfile\fR
Sets execution context
.TP
.BR \-b
Disables use of colour on the console
.TP
.BR \-I
Ignore .phpdbginit (default init file)
.TP
.BR \-i \fIpath\fB|\ffile\fR
Override .phpgdbinit location (implies -I)
.TP
.BR \-O \fIfile\fR
Set oplog output to \fIfile\fR
.TP
.BR \-q
Do not print banner on startup
.TP
.BR \-r
Jump straight to run
.TP
.BR \-E
Enable step through eval()
.SH NOTES
Passing -rr will cause phpdbg to quit after execution, rather than returning to the console
.SH AUTHOR
Written by Felipe Pena, Joe Watkins and Bob Weinand, formatted by Ondřej Surý for Debian project.

View File

@ -64,10 +64,13 @@
# include "TSRM.h"
#endif
#ifdef HAVE_LIBREADLINE
#ifdef LIBREADLINE
# include <readline/readline.h>
# include <readline/history.h>
#endif
#ifdef HAVE_LIBEDIT
# include <editline/readline.h>
#endif
#include "phpdbg_lexer.h"
#include "phpdbg_cmd.h"

View File

@ -792,7 +792,7 @@ PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, char **why TSRMLS_DC)
PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
{
char *cmd = NULL;
#ifndef HAVE_LIBREADLINE
#if !defined(HAVE_LIBREADLINE) && !defined(HAVE_LIBEDIT)
char buf[PHPDBG_MAX_CMD];
#endif
char *buffer = NULL;
@ -811,7 +811,7 @@ disconnect:
return NULL;
}
#ifndef HAVE_LIBREADLINE
#if !defined(HAVE_LIBREADLINE) && !defined(HAVE_LIBEDIT)
if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
if (!phpdbg_write("%s", phpdbg_get_prompt(TSRMLS_C))) {
goto disconnect;
@ -850,7 +850,7 @@ readline:
buffer = estrdup(cmd);
#ifdef HAVE_LIBREADLINE
#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
if (!buffered && cmd &&
!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
free(cmd);

View File

@ -318,8 +318,9 @@ phpdbg_help_text_t phpdbg_help_text[] = {
"**Information**" CR
" **list** list PHP source" CR
" **info** displays information on the debug session" CR
" **print** show opcodes " CR
" **print** show opcodes" CR
" **frame** select a stack frame and print a stack frame summary" CR
" **back** shows the current backtrace" CR
" **help** provide help on a topic" CR CR
"**Starting and Stopping Execution**" CR
@ -613,7 +614,7 @@ phpdbg_help_text_t phpdbg_help_text[] = {
{"finish",
"The **finish** command causes control to be passed back to the vm, continuing execution. Any "
"breakpoints that are encountered within the current stack frame will be skipped. Execution "
"will then continue until the next breakpoint after leaving the stack frame or unitil "
"will then continue until the next breakpoint after leaving the stack frame or until "
"completion of the script" CR CR
"Note when **step**ping is enabled, any opcode steps within the current stack frame are also "
@ -629,7 +630,7 @@ phpdbg_help_text_t phpdbg_help_text[] = {
"**Examples**" CR CR
" $P frame 2" CR
" $P E $count" CR
" $P ev $count" CR
" Go to frame 2 and print out variable **$count** in that frame" CR CR
"Note that this frame scope is discarded when execution continues, with the execution frame "

File diff suppressed because it is too large Load Diff

View File

@ -43,21 +43,21 @@ restart:
/*!re2c
re2c:yyfill:check = 0;
T_TRUE "true"
T_YES "yes"
T_ON "on"
T_ENABLED "enabled"
T_FALSE "false"
T_NO "no"
T_OFF "off"
T_DISABLED "disabled"
T_EVAL "ev"
T_SHELL "sh"
T_IF "if"
T_RUN "run"
T_TRUE 'true'
T_YES 'yes'
T_ON 'on'
T_ENABLED 'enabled'
T_FALSE 'false'
T_NO 'no'
T_OFF 'off'
T_DISABLED 'disabled'
T_EVAL 'ev'
T_SHELL 'sh'
T_IF 'if'
T_RUN 'run'
T_RUN_SHORT "r"
WS [ \r\n\t]+
DIGITS [0-9\.]+
DIGITS [-]?[0-9\.]+
ID [^ \r\n\t:#\000]+
ADDR [0][x][a-fA-F0-9]+
OPCODE (ZEND_|zend_)([A-Za-z])+
@ -69,7 +69,7 @@ INPUT [^\n\000]+
return 0;
}
<NORMAL>{T_IF} {
<NORMAL>{T_IF}{WS} {
YYSETCONDITION(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_IF;
@ -91,13 +91,13 @@ INPUT [^\n\000]+
return T_COLON;
}
<NORMAL>{T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE} {
<NORMAL>({T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE}){WS} {
phpdbg_init_param(yylval, NUMERIC_PARAM);
yylval->num = 1;
return T_TRUTHY;
}
<NORMAL>{T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE} {
<NORMAL>({T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE}){WS} {
phpdbg_init_param(yylval, NUMERIC_PARAM);
yylval->num = 0;
return T_FALSY;
@ -142,17 +142,17 @@ INPUT [^\n\000]+
goto restart;
}
<INITIAL>{T_EVAL} {
<INITIAL>{T_EVAL}{WS} {
YYSETCONDITION(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_EVAL;
}
<INITIAL>{T_SHELL} {
<INITIAL>{T_SHELL}{WS} {
YYSETCONDITION(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_SHELL;
}
<INITIAL>{T_RUN}|{T_RUN_SHORT} {
<INITIAL>({T_RUN}|{T_RUN_SHORT}){WS} {
YYSETCONDITION(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_RUN;

View File

@ -130,14 +130,14 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig
char *opened = NULL;
char buffer[8096] = {0,};
long line = 0;
php_stream *stream = NULL;
if (VCWD_STAT(filename, &st) == FAILURE) {
phpdbg_error("Failed to stat file %s", filename);
return;
}
stream = php_stream_open_wrapper(filename, "rb", USE_PATH, &opened);
if (!stream) {
@ -145,11 +145,17 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig
return;
}
if (offset < 0) {
count += offset;
offset = 0;
}
while (php_stream_gets(stream, buffer, sizeof(buffer)) != NULL) {
long linelen = strlen(buffer);
++line;
if (!offset || offset <= line) {
/* Without offset, or offset reached */
if (offset <= line) {
if (!highlight) {
phpdbg_write("%05ld: %s", line, buffer);
} else {
@ -159,10 +165,15 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig
phpdbg_write(">%05ld: %s", line, buffer);
}
}
if (buffer[linelen - 1] != '\n') {
phpdbg_write("\n");
}
}
if ((count + (offset-1)) == line)
if (count > 0 && count + offset - 1 < line) {
break;
}
}
php_stream_close(stream);

View File

@ -436,7 +436,7 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 25
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 41
#define YYLAST 42
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 21
@ -493,8 +493,8 @@ static const yytype_uint8 yytranslate[] =
static const yytype_uint8 yyprhs[] =
{
0, 0, 3, 5, 7, 8, 10, 13, 17, 22,
27, 33, 37, 43, 47, 49, 51, 53, 55, 57,
59, 61, 64, 67, 70, 72
27, 33, 37, 43, 47, 50, 52, 54, 56, 58,
60, 62, 64, 67, 70, 72
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
@ -504,9 +504,9 @@ static const yytype_int8 yyrhs[] =
23, 24, -1, 18, 10, 14, -1, 18, 10, 12,
14, -1, 13, 18, 10, 14, -1, 13, 18, 10,
12, 14, -1, 18, 11, 18, -1, 18, 11, 18,
12, 14, -1, 18, 12, 14, -1, 17, -1, 16,
-1, 15, -1, 7, -1, 8, -1, 14, -1, 18,
-1, 6, 19, -1, 3, 19, -1, 5, 19, -1,
12, 14, -1, 18, 12, 14, -1, 6, 19, -1,
17, -1, 16, -1, 15, -1, 7, -1, 8, -1,
14, -1, 18, -1, 3, 19, -1, 5, 19, -1,
4, -1, 4, 19, -1
};
@ -514,8 +514,8 @@ static const yytype_int8 yyrhs[] =
static const yytype_uint8 yyrline[] =
{
0, 66, 66, 67, 68, 72, 73, 77, 82, 87,
97, 107, 112, 118, 124, 125, 126, 127, 128, 129,
130, 134, 139, 144, 149, 153
97, 107, 112, 118, 124, 129, 130, 131, 132, 133,
134, 135, 139, 144, 149, 153
};
#endif
@ -552,15 +552,15 @@ static const yytype_uint8 yyr1[] =
{
0, 21, 22, 22, 22, 23, 23, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 25, 25, 25, 25, 25
24, 24, 25, 25, 25, 25
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 1, 1, 0, 1, 2, 3, 4, 4,
5, 3, 5, 3, 1, 1, 1, 1, 1, 1,
1, 2, 2, 2, 1, 2
5, 3, 5, 3, 2, 1, 1, 1, 1, 1,
1, 1, 2, 2, 1, 2
};
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
@ -568,9 +568,9 @@ static const yytype_uint8 yyr2[] =
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
4, 0, 24, 0, 0, 17, 18, 0, 19, 16,
15, 14, 20, 0, 2, 5, 3, 22, 25, 23,
21, 0, 0, 0, 0, 1, 6, 0, 0, 7,
4, 0, 24, 0, 0, 18, 19, 0, 20, 17,
16, 15, 21, 0, 2, 5, 3, 22, 25, 23,
14, 0, 0, 0, 0, 1, 6, 0, 0, 7,
11, 13, 0, 9, 8, 0, 10, 12
};
@ -585,16 +585,16 @@ static const yytype_int8 yydefgoto[] =
#define YYPACT_NINF -11
static const yytype_int8 yypact[] =
{
-3, -10, 10, 11, 12, -11, -11, 14, -11, -11,
-11, -11, -4, 28, 9, -11, -11, -11, -11, -11,
-11, 23, 6, 16, 21, -11, -11, 7, 22, -11,
25, -11, 24, -11, -11, 26, -11, -11
-3, -10, 11, 12, 13, -11, -11, 15, -11, -11,
-11, -11, -4, 29, 10, -11, -11, -11, -11, -11,
-11, 24, 7, 17, 22, -11, -11, 8, 23, -11,
26, -11, 25, -11, -11, 27, -11, -11
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
-11, -11, -11, 27, -11
-11, -11, -11, 28, -11
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@ -604,10 +604,10 @@ static const yytype_int8 yypgoto[] =
static const yytype_uint8 yytable[] =
{
1, 2, 3, 4, 5, 6, 22, 23, 24, 17,
7, 8, 9, 10, 11, 12, 5, 6, 28, 32,
29, 33, 7, 8, 9, 10, 11, 12, 25, 18,
19, 20, 21, 27, 30, 31, 34, 35, 36, 0,
37, 26
7, 8, 9, 10, 11, 12, 4, 5, 6, 28,
32, 29, 33, 7, 8, 9, 10, 11, 12, 25,
18, 19, 20, 21, 27, 30, 31, 34, 35, 36,
0, 37, 26
};
#define yypact_value_is_default(yystate) \
@ -619,10 +619,10 @@ static const yytype_uint8 yytable[] =
static const yytype_int8 yycheck[] =
{
3, 4, 5, 6, 7, 8, 10, 11, 12, 19,
13, 14, 15, 16, 17, 18, 7, 8, 12, 12,
14, 14, 13, 14, 15, 16, 17, 18, 0, 19,
19, 19, 18, 10, 18, 14, 14, 12, 14, -1,
14, 14
13, 14, 15, 16, 17, 18, 6, 7, 8, 12,
12, 14, 14, 13, 14, 15, 16, 17, 18, 0,
19, 19, 19, 18, 10, 18, 14, 14, 12, 14,
-1, 14, 14
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@ -1563,48 +1563,6 @@ yyreduce:
case 14:
/* Line 1802 of yacc.c */
#line 124 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 15:
/* Line 1802 of yacc.c */
#line 125 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 16:
/* Line 1802 of yacc.c */
#line 126 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 17:
/* Line 1802 of yacc.c */
#line 127 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 18:
/* Line 1802 of yacc.c */
#line 128 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 19:
/* Line 1802 of yacc.c */
#line 129 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 20:
/* Line 1802 of yacc.c */
#line 130 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 21:
/* Line 1802 of yacc.c */
#line 134 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = COND_PARAM;
(yyval).str = (yyvsp[(2) - (2)]).str;
@ -1612,6 +1570,48 @@ yyreduce:
}
break;
case 15:
/* Line 1802 of yacc.c */
#line 129 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 16:
/* Line 1802 of yacc.c */
#line 130 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 17:
/* Line 1802 of yacc.c */
#line 131 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 18:
/* Line 1802 of yacc.c */
#line 132 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 19:
/* Line 1802 of yacc.c */
#line 133 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 20:
/* Line 1802 of yacc.c */
#line 134 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 21:
/* Line 1802 of yacc.c */
#line 135 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 22:
/* Line 1802 of yacc.c */
#line 139 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"

View File

@ -121,6 +121,11 @@ parameter
$$.len = $1.len;
$$.num = $3.num;
}
| T_IF T_INPUT {
$$.type = COND_PARAM;
$$.str = $2.str;
$$.len = $2.len;
}
| T_OPCODE { $$ = $1; }
| T_ADDR { $$ = $1; }
| T_LITERAL { $$ = $1; }
@ -131,12 +136,7 @@ parameter
;
full_expression
: T_IF T_INPUT {
$$.type = COND_PARAM;
$$.str = $2.str;
$$.len = $2.len;
}
| T_EVAL T_INPUT {
: T_EVAL T_INPUT {
$$.type = EVAL_PARAM;
$$.str = $2.str;
$$.len = $2.len;

View File

@ -732,6 +732,11 @@ PHPDBG_COMMAND(print) /* {{{ */
#else
phpdbg_writeln("Readline\tno");
#endif
#ifdef HAVE_LIBEDIT
phpdbg_writeln("Libedit\t\tyes");
#else
phpdbg_writeln("Libedit\t\tno");
#endif
phpdbg_writeln("Exec\t\t%s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none");
phpdbg_writeln("Compiled\t%s", PHPDBG_G(ops) ? "yes" : "no");

View File

@ -400,12 +400,16 @@ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */
}
/* create cached prompt */
#ifndef HAVE_LIBEDIT
/* TODO: libedit doesn't seems to support coloured prompt */
if ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED)) {
asprintf(
&PHPDBG_G(prompt)[1], "\033[%sm%s\033[0m ",
PHPDBG_G(colors)[PHPDBG_COLOR_PROMPT]->code,
PHPDBG_G(prompt)[0]);
} else {
} else
#endif
{
asprintf(
&PHPDBG_G(prompt)[1], "%s ",
PHPDBG_G(prompt)[0]);

View File

@ -13,6 +13,7 @@ fi
./configure --quiet \
$DEBUG \
$TS \
--enable-fpm \
--with-pdo-mysql=mysqlnd \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \