diff options
author | krakjoe <joe.watkins@live.co.uk> | 2014-02-21 21:31:01 +0000 |
---|---|---|
committer | krakjoe <joe.watkins@live.co.uk> | 2014-02-21 21:31:01 +0000 |
commit | ee6cc5ba603cfc7204d090a7b93b1cd5094396f4 (patch) | |
tree | 318d6f7b2e212c7acb4598e9377889fd32c0d9ce | |
parent | e37144f44b4f5d7869f84a6ba1ed3891d07d0708 (diff) | |
download | php-git-ee6cc5ba603cfc7204d090a7b93b1cd5094396f4.tar.gz |
do not allow abbreivation of anything without alias, fixes input for sh/ev
-rw-r--r-- | dev/phpdbg_lexer.l | 4 | ||||
-rw-r--r-- | phpdbg_break.c | 4 | ||||
-rw-r--r-- | phpdbg_cmd.c | 14 | ||||
-rw-r--r-- | phpdbg_help.c | 49 | ||||
-rw-r--r-- | phpdbg_lexer.c | 137 | ||||
-rw-r--r-- | phpdbg_prompt.c | 92 | ||||
-rw-r--r-- | phpdbg_prompt.h | 4 |
7 files changed, 142 insertions, 162 deletions
diff --git a/dev/phpdbg_lexer.l b/dev/phpdbg_lexer.l index 5f4652fc3d..90f9f0c63a 100644 --- a/dev/phpdbg_lexer.l +++ b/dev/phpdbg_lexer.l @@ -29,8 +29,8 @@ T_FALSE ?i:"false" T_NO ?i:"no" T_OFF ?i:"off" T_DISABLED ?i:"disabled" -T_EVAL ?i:"eval" -T_SHELL ?i:"shell" +T_EVAL ?i:"ev" +T_SHELL ?i:"sh" T_IF ?i:"if" WS [ \r\n\t]+ diff --git a/phpdbg_break.c b/phpdbg_break.c index 79091d27e6..be76b22b05 100644 --- a/phpdbg_break.c +++ b/phpdbg_break.c @@ -35,8 +35,8 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); * Commands */ const phpdbg_command_t phpdbg_break_commands[] = { - PHPDBG_BREAK_COMMAND_D(at, "specify breakpoint by location and condition", 'A', break_at, NULL, "*c"), - PHPDBG_BREAK_COMMAND_D(del, "delete breakpoint by identifier number", 'd', break_del, NULL, "n"), + PHPDBG_BREAK_COMMAND_D(at, "specify breakpoint by location and condition", '@', break_at, NULL, "*c"), + PHPDBG_BREAK_COMMAND_D(del, "delete breakpoint by identifier number", '~', break_del, NULL, "n"), PHPDBG_END_COMMAND }; diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 813911d9a3..814939758a 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -655,8 +655,14 @@ PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t * /* match full, case insensitive, command name */ if (strncasecmp(command->name, name->str, name->len) == SUCCESS) { if (matches < 3) { - matched[matches] = command; - matches++; + + /* only allow abbreviating commands that can be aliased */ + if (((name->len != command->name_len) && command->alias) || + (name->len == command->name_len)) { + matched[matches] = command; + matches++; + } + /* exact match */ if (name->len == command->name_len) @@ -748,10 +754,10 @@ PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) { switch (top->type) { case EVAL_PARAM: - return PHPDBG_COMMAND_HANDLER(eval)(top TSRMLS_CC); + return PHPDBG_COMMAND_HANDLER(ev)(top TSRMLS_CC); case SHELL_PARAM: - return PHPDBG_COMMAND_HANDLER(shell)(top TSRMLS_CC); + return PHPDBG_COMMAND_HANDLER(sh)(top TSRMLS_CC); case STR_PARAM: { handler = phpdbg_stack_resolve( diff --git a/phpdbg_help.c b/phpdbg_help.c index 993a9c9909..e091fb86f6 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -328,23 +328,23 @@ phpdbg_help_text_t phpdbg_help_text[] = { "**Starting and Stopping Execution**" CR " **exec** set execution context" CR -" **clean** clean the execution environment" CR " **run** attempt execution" CR -" **eval** evaluate some code" CR " **step** Enable or disable per opcode stepping mode" CR " **next** continue execution" CR " **until** continue execution up to the given location" CR " **finish** continue up to end of the current execution frame" CR " **leave** continue up to end of the current execution frame and halt after the calling instruction" CR " **break** set a breakpoint at the specified target" CR -" **clear** clear one or all breakpoints" CR CR +" **ev** evaluate some code" CR +" **clear** clear one or all breakpoints" CR +" **clean** clean the execution environment" CR CR "**Miscellaneous**" CR " **quiet** silence some output" CR " **set** set the phpdbg configuration" CR " **source** execute a phpdbginit script" CR " **register** register a phpdbginit function as a command alias" CR -" **shell** shell a command" CR +" **sh** shell a command" CR " **quit** exit phpdbg" CR CR "Type **help <command>** or (**help alias**) to get detailed help on any of the above commands, " @@ -416,7 +416,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { }, {"syntax", CR -"All **phpdbg** commands are case sensitive. Commands start with a keyword, and some (**break**, " +"Commands start with a keyword, and some (**break**, " "**info**, **set**, **print** and **list**) may include a subcommand keyword. All keywords are " "lower case but also have a single letter alias that may be used as an alternative to typing in the" "keyword in full. Note some aliases are uppercase, and that keywords cannot be abbreviated other " @@ -444,27 +444,18 @@ phpdbg_help_text_t phpdbg_help_text[] = { " $P q" CR " Quit the debugger" CR CR -" $P eval $total[2]" CR -" $P E $total[2]" CR +" $P ev $total[2]" CR " Evaluate and print the variable $total[2] in the current stack frame" CR " " CR -" $P break lineno 200" CR +" $P break 200" CR " $P b my_source.php:200" CR " Break at line 200 in the current source and in file **my_source.php**. " CR CR -" $P b A ClassX::get_args if $arg[0] == \"fred\"" CR -" $P b d 3" CR +" $P b @ ClassX::get_args if $arg[0] == \"fred\"" CR +" $P b ~ 3" CR " Break at ClassX::get_args() if $arg[0] == \"fred\" and delete breakpoint 3" CR CR "**Examples of invalid commands**" CR -" $P break line 23" CR -" The command keyword is **lineno**; **line** is not allowed" CR CR - -" $P NEXT" CR -" Commands are case sensitive. The keyword is **next**" CR CR - -" $P s on" CR -" **step** takes an integer argument **0** or **1**; on/off is not allowed." CR CR " $P #This is a comment" CR " Comments introduced by the **#** character are only allowed in **phpdbginit** script files." @@ -549,6 +540,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { " Break when the condition ($cnt > 10) evaluates to true" CR CR " $P break at phpdbg::isGreat if $opt == 'S'" CR +" $P break @ phpdbg::isGreat if $opt == 'S'" CR " Break at any opcode in phpdbg::isGreat when the condition ($opt == 'S') is true" CR CR " $P break at test.php:20 if !isset($x)" CR @@ -559,7 +551,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { " Break on any occurence of the opcode ZEND_ADD" CR CR " $P break del 2" CR -" $P b d 2" CR +" $P b ~ 2" CR " Remove breakpoint 2" CR CR "Note: Conditional breaks are costly in terms of runtime overhead. Use them only when required " @@ -600,25 +592,23 @@ phpdbg_help_text_t phpdbg_help_text[] = { "to compilation." }, -{"eval", -"The **eval** command takes a string expression which it evaluates and then displays. It " +{"ev", +"The **ev** command takes a string expression which it evaluates and then displays. It " "evaluates in the context of the lowest (that is the executing) frame, unless this has first " "been explicitly changed by issuing a **frame** command. " CR CR "**Examples**" CR CR -" $P eval $variable" CR -" $P E $variable" CR +" $P ev $variable" CR " Will print_r($variable) on the console, if it is defined" CR CR -" $P eval $variable = \"Hello phpdbg :)\"" CR -" $P E $variable = \"Hello phpdbg :)\"" CR +" $P ev $variable = \"Hello phpdbg :)\"" CR " Will set $variable in the current scope" CR CR -"Note that **eval** allows any valid PHP expression including assignments, function calls and " +"Note that **ev** allows any valid PHP expression including assignments, function calls and " "other write statements. This enables you to change the environment during execution, so care " "is needed here. You can even call PHP functions which have breakpoints defined. " CR CR -"Note: **eval** will always show the result, so do not prefix the code with **return**" +"Note: **ev** will always show the result, so do not prefix the code with **return**" }, {"exec", @@ -853,12 +843,11 @@ phpdbg_help_text_t phpdbg_help_text[] = { //*********** check oplog syntax }, -{"shell", +{"sh", "Direct access to shell commands saves having to switch windows/consoles" CR CR "**Examples**" CR CR -" $P shell ls /usr/src/php-src" CR -" $P - ls /usr/src/php-src" CR +" $P sh ls /usr/src/php-src" CR " Will execute ls /usr/src/php-src, displaying the output in the console" //*********** what does this mean????Note: read only commands please! }, diff --git a/phpdbg_lexer.c b/phpdbg_lexer.c index ba8980c27c..730c5fb68c 100644 --- a/phpdbg_lexer.c +++ b/phpdbg_lexer.c @@ -358,16 +358,15 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[72] = +static yyconst flex_int16_t yy_accept[67] = { 0, - 0, 0, 0, 0, 16, 12, 14, 1, 9, 9, + 12, 12, 0, 0, 16, 12, 14, 1, 9, 9, 3, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 12, 14, 9, 12, 2, 12, 12, - 12, 12, 6, 8, 12, 7, 12, 12, 12, 12, - 13, 13, 10, 12, 12, 12, 12, 8, 12, 12, - 7, 12, 12, 12, 4, 12, 12, 7, 12, 12, - 12, 8, 5, 12, 12, 12, 11, 12, 7, 8, - 0 + 4, 12, 6, 8, 12, 7, 5, 12, 12, 12, + 13, 13, 10, 12, 12, 12, 8, 12, 7, 12, + 12, 12, 12, 7, 12, 12, 12, 8, 12, 12, + 12, 11, 12, 7, 8, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -411,31 +410,29 @@ static yyconst flex_int32_t yy_meta[47] = 1, 1, 1, 1, 1, 1 } ; -static yyconst flex_int16_t yy_base[76] = +static yyconst flex_int16_t yy_base[71] = { 0, - 0, 0, 45, 47, 146, 0, 49, 202, 48, 51, - 132, 42, 41, 52, 49, 42, 50, 51, 47, 57, - 58, 0, 70, 0, 72, 86, 90, 202, 54, 79, - 89, 88, 0, 0, 93, 0, 96, 87, 90, 94, - 0, 112, 0, 96, 106, 99, 105, 0, 114, 120, - 0, 122, 127, 120, 0, 126, 123, 0, 82, 124, - 130, 0, 0, 160, 131, 137, 168, 139, 0, 0, - 202, 196, 78, 199, 64 + 0, 0, 45, 47, 148, 0, 49, 184, 48, 51, + 138, 42, 41, 52, 49, 42, 50, 51, 47, 57, + 58, 0, 70, 0, 72, 86, 90, 184, 54, 79, + 0, 80, 0, 0, 91, 0, 0, 83, 87, 91, + 0, 109, 0, 97, 103, 92, 0, 102, 0, 105, + 108, 111, 117, 0, 117, 117, 118, 0, 136, 126, + 128, 150, 132, 0, 0, 184, 178, 78, 181, 64 } ; -static yyconst flex_int16_t yy_def[76] = +static yyconst flex_int16_t yy_def[71] = { 0, - 71, 1, 72, 72, 71, 73, 71, 71, 73, 73, - 71, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 74, 74, 73, 71, 73, 73, 71, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 74, 74, 27, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 75, 73, 73, 75, 73, 73, 73, - 0, 71, 71, 71, 71 + 66, 1, 67, 67, 66, 68, 66, 66, 68, 68, + 66, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 69, 69, 68, 66, 68, 68, 66, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 69, 69, 27, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 70, 68, + 68, 70, 68, 68, 68, 0, 66, 66, 66, 66 } ; -static yyconst flex_int16_t yy_nxt[249] = +static yyconst flex_int16_t yy_nxt[231] = { 0, 6, 7, 7, 8, 9, 10, 9, 11, 6, 6, 6, 12, 13, 14, 6, 6, 15, 6, 16, 17, @@ -443,30 +440,28 @@ static yyconst flex_int16_t yy_nxt[249] = 12, 13, 14, 6, 15, 6, 16, 17, 6, 18, 19, 6, 6, 6, 20, 21, 23, 7, 23, 7, 25, 25, 26, 26, 26, 26, 26, 26, 29, 30, - 32, 34, 33, 35, 67, 31, 37, 38, 36, 39, + 32, 34, 33, 35, 62, 31, 37, 38, 36, 39, 40, 42, 25, 25, 25, 44, 29, 30, 24, 34, 32, 33, 35, 31, 37, 38, 36, 45, 39, 40, 26, 26, 26, 44, 27, 43, 43, 46, 43, 43, - 43, 43, 43, 43, 53, 47, 48, 45, 49, 64, - 50, 51, 52, 42, 25, 54, 55, 46, 43, 43, - 43, 43, 43, 47, 53, 48, 56, 49, 50, 51, - 52, 57, 58, 59, 55, 54, 60, 61, 62, 28, - 63, 65, 66, 68, 56, 71, 71, 71, 69, 57, - 70, 58, 59, 71, 71, 61, 60, 62, 63, 65, - 24, 66, 68, 71, 24, 24, 24, 69, 24, 70, - 71, 71, 24, 24, 24, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 24, 71, 71, - 71, 71, 71, 71, 71, 24, 22, 22, 22, 41, - - 41, 5, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71 + 43, 43, 43, 43, 47, 51, 48, 45, 49, 50, + 42, 25, 52, 53, 54, 46, 55, 56, 43, 43, + 43, 43, 43, 47, 48, 51, 49, 50, 57, 58, + 61, 53, 52, 54, 60, 55, 24, 56, 63, 64, + 24, 24, 24, 65, 59, 28, 57, 66, 58, 61, + 24, 66, 60, 66, 24, 24, 24, 63, 64, 66, + 66, 66, 65, 24, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 66, 24, 22, 22, + 22, 41, 41, 5, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, + + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66 } ; -static yyconst flex_int16_t yy_chk[249] = +static yyconst flex_int16_t yy_chk[231] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -474,27 +469,25 @@ static yyconst flex_int16_t yy_chk[249] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 4, 4, 7, 7, 9, 9, 9, 10, 10, 10, 12, 13, - 14, 16, 15, 17, 75, 13, 18, 19, 17, 20, - 21, 23, 23, 25, 25, 29, 12, 13, 73, 16, + 14, 16, 15, 17, 70, 13, 18, 19, 17, 20, + 21, 23, 23, 25, 25, 29, 12, 13, 68, 16, 14, 15, 17, 13, 18, 19, 17, 30, 20, 21, - 26, 26, 26, 29, 10, 27, 27, 31, 27, 27, - - 27, 27, 27, 27, 44, 32, 35, 30, 37, 59, - 38, 39, 40, 42, 42, 45, 46, 31, 27, 27, - 27, 27, 27, 32, 44, 35, 47, 37, 38, 39, - 40, 49, 50, 52, 46, 45, 53, 54, 56, 11, - 57, 60, 61, 65, 47, 5, 0, 0, 66, 49, - 68, 50, 52, 0, 0, 54, 53, 56, 57, 60, - 64, 61, 65, 0, 64, 64, 64, 66, 67, 68, - 0, 0, 67, 67, 67, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, - 0, 0, 0, 0, 0, 67, 72, 72, 72, 74, - - 74, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71 + 26, 26, 26, 29, 10, 27, 27, 32, 27, 27, + + 27, 27, 27, 27, 35, 44, 38, 30, 39, 40, + 42, 42, 45, 46, 48, 32, 50, 51, 27, 27, + 27, 27, 27, 35, 38, 44, 39, 40, 52, 53, + 57, 46, 45, 48, 56, 50, 59, 51, 60, 61, + 59, 59, 59, 63, 55, 11, 52, 5, 53, 57, + 62, 0, 56, 0, 62, 62, 62, 60, 61, 0, + 0, 0, 63, 59, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 62, 67, 67, + 67, 69, 69, 66, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, + + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66 } ; /* The intent behind this definition is that it'll catch @@ -520,7 +513,7 @@ static yyconst flex_int16_t yy_chk[249] = #include <string.h> #define YY_NO_UNISTD_H 1 -#line 524 "sapi/phpdbg/phpdbg_lexer.c" +#line 517 "sapi/phpdbg/phpdbg_lexer.c" #define INITIAL 0 #define RAW 1 @@ -760,7 +753,7 @@ YY_DECL #line 42 "sapi/phpdbg/dev/phpdbg_lexer.l" -#line 764 "sapi/phpdbg/phpdbg_lexer.c" +#line 757 "sapi/phpdbg/phpdbg_lexer.c" yylval = yylval_param; @@ -815,13 +808,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 72 ) + if ( yy_current_state >= 67 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 71 ); + while ( yy_current_state != 66 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -962,7 +955,7 @@ YY_RULE_SETUP #line 104 "sapi/phpdbg/dev/phpdbg_lexer.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 966 "sapi/phpdbg/phpdbg_lexer.c" +#line 959 "sapi/phpdbg/phpdbg_lexer.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(RAW): yyterminate(); @@ -1258,7 +1251,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 72 ) + if ( yy_current_state >= 67 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1287,11 +1280,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 72 ) + if ( yy_current_state >= 67 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 71); + yy_is_jam = (yy_current_state == 66); return yy_is_jam ? 0 : yy_current_state; } diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 880e58b323..534d883d9c 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -47,7 +47,7 @@ const phpdbg_command_t phpdbg_prompt_commands[] = { PHPDBG_COMMAND_D(step, "step through execution", 's', NULL, "b"), PHPDBG_COMMAND_D(next, "continue execution", 'n', NULL, 0), PHPDBG_COMMAND_D(run, "attempt execution", 'r', NULL, 0), - PHPDBG_COMMAND_D(eval, "evaluate some code", 'E', NULL, "i"), + PHPDBG_COMMAND_D(ev, "evaluate some code", 0, NULL, "i"), PHPDBG_COMMAND_D(until, "continue past the current line", 'u', NULL, 0), PHPDBG_COMMAND_D(finish, "continue past the end of the stack", 'F', NULL, 0), PHPDBG_COMMAND_D(leave, "continue until the end of the stack", 'L', NULL, 0), @@ -62,8 +62,8 @@ const phpdbg_command_t phpdbg_prompt_commands[] = { PHPDBG_COMMAND_D(help, "show help menu", 'h', phpdbg_help_commands, "|s"), PHPDBG_COMMAND_D(set, "set phpdbg configuration", 'S', phpdbg_set_commands, "s"), PHPDBG_COMMAND_D(register,"register a function", 'R', NULL, "s"), - PHPDBG_COMMAND_D(source, "execute a phpdbginit", '.', NULL, "s"), - PHPDBG_COMMAND_D(shell, "shell a command", '-', NULL, "i"), + PHPDBG_COMMAND_D(source, "execute a phpdbginit", '-', NULL, "s"), + PHPDBG_COMMAND_D(sh, "shell a command", 0, NULL, "i"), PHPDBG_COMMAND_D(quit, "exit phpdbg", 'q', NULL, 0), PHPDBG_END_COMMAND }; /* }}} */ @@ -77,13 +77,17 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ * if (stack->type == STACK_PARAM) { name = stack->next; + if (!name || name->type != STR_PARAM) { + return FAILURE; + } + if (zend_hash_exists( - &PHPDBG_G(registered), name->str, name->len+1)) { + &PHPDBG_G(registered), name->str, name->len+1)) { zval fname, *fretval; zend_fcall_info fci; - ZVAL_STRINGL(&fname, name->str, name->len, 1); + ZVAL_STRINGL(&fname, name->str, name->len+1, 1); memset(&fci, 0, sizeof(zend_fcall_info)); @@ -640,42 +644,36 @@ out: return SUCCESS; } /* }}} */ -PHPDBG_COMMAND(eval) /* {{{ */ +PHPDBG_COMMAND(ev) /* {{{ */ { - switch (param->type) { - case EVAL_PARAM: { - zend_bool stepping = ((PHPDBG_G(flags) & PHPDBG_IS_STEPPING)==PHPDBG_IS_STEPPING); - zval retval; - - if (!(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { - PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING; - } - - /* disable stepping while eval() in progress */ - PHPDBG_G(flags) |= PHPDBG_IN_EVAL; - zend_try { - if (zend_eval_stringl(param->str, param->len, - &retval, "eval()'d code" TSRMLS_CC) == SUCCESS) { - zend_print_zval_r( - &retval, 0 TSRMLS_CC); - phpdbg_writeln(EMPTY); - zval_dtor(&retval); - } - } zend_end_try(); - PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL; + zend_bool stepping = ((PHPDBG_G(flags) & PHPDBG_IS_STEPPING)==PHPDBG_IS_STEPPING); + zval retval; - /* switch stepping back on */ - if (stepping && - !(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { - PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; - } + if (!(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { + PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING; + } - CG(unclean_shutdown) = 0; - } break; + /* disable stepping while eval() in progress */ + PHPDBG_G(flags) |= PHPDBG_IN_EVAL; + zend_try { + if (zend_eval_stringl(param->str, param->len, + &retval, "eval()'d code" TSRMLS_CC) == SUCCESS) { + zend_print_zval_r( + &retval, 0 TSRMLS_CC); + phpdbg_writeln(EMPTY); + zval_dtor(&retval); + } + } zend_end_try(); + PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL; - phpdbg_default_switch_case(); + /* switch stepping back on */ + if (stepping && + !(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) { + PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; } + CG(unclean_shutdown) = 0; + return SUCCESS; } /* }}} */ @@ -800,23 +798,17 @@ PHPDBG_COMMAND(break) /* {{{ */ return SUCCESS; } /* }}} */ -PHPDBG_COMMAND(shell) /* {{{ */ +PHPDBG_COMMAND(sh) /* {{{ */ { - /* don't allow this to loop, ever ... */ - switch (param->type) { - case SHELL_PARAM: { - FILE *fd = NULL; - if ((fd=VCWD_POPEN((char*)param->str, "w"))) { - /* do something perhaps ?? do we want input ?? */ - fclose(fd); - } else { - phpdbg_error( - "Failed to execute %s", param->str); - } - } break; - - phpdbg_default_switch_case(); + FILE *fd = NULL; + if ((fd=VCWD_POPEN((char*)param->str, "w"))) { + /* do something perhaps ?? do we want input ?? */ + fclose(fd); + } else { + phpdbg_error( + "Failed to execute %s", param->str); } + return SUCCESS; } /* }}} */ diff --git a/phpdbg_prompt.h b/phpdbg_prompt.h index d92623d409..5590dd4121 100644 --- a/phpdbg_prompt.h +++ b/phpdbg_prompt.h @@ -34,7 +34,7 @@ PHPDBG_COMMAND(compile); PHPDBG_COMMAND(step); PHPDBG_COMMAND(next); PHPDBG_COMMAND(run); -PHPDBG_COMMAND(eval); +PHPDBG_COMMAND(ev); PHPDBG_COMMAND(until); PHPDBG_COMMAND(finish); PHPDBG_COMMAND(leave); @@ -47,7 +47,7 @@ PHPDBG_COMMAND(info); PHPDBG_COMMAND(clean); PHPDBG_COMMAND(clear); PHPDBG_COMMAND(help); -PHPDBG_COMMAND(shell); +PHPDBG_COMMAND(sh); PHPDBG_COMMAND(set); PHPDBG_COMMAND(source); PHPDBG_COMMAND(register); |