Skip to content

Commit ea64330

Browse files
committed
Put info to info and made print always output opcodes
1 parent 2ed0085 commit ea64330

File tree

2 files changed

+42
-30
lines changed

2 files changed

+42
-30
lines changed

sapi/phpdbg/phpdbg_help.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ phpdbg_help_text_t phpdbg_help_text[] = {
389389
" **-l** **-l**4000 Setup remote console ports" CR
390390
" **-a** **-a**192.168.0.3 Setup remote console bind address" CR
391391
" **-x** Enable xml output (instead of normal text output)" CR
392+
" **-h** Print the help overview" CR
392393
" **-V** Print version number" CR
393394
" **--** **--** arg1 arg2 Use to delimit phpdbg arguments and php $argv; append any $argv "
394395
"argument after it" CR CR
@@ -637,8 +638,8 @@ phpdbg_help_text_t phpdbg_help_text[] = {
637638

638639
{"frame",
639640
"The **frame** takes an optional integer argument. If omitted, then the current frame is displayed "
640-
"If specified then the current scope is set to the corresponding frame listed in a **back** trace. " "This can be used to allowing access to the variables in a higher stack frame than that currently "
641-
"being executed." CR CR
641+
"If specified then the current scope is set to the corresponding frame listed in a **back** trace. "
642+
"This can be used to allowing access to the variables in a higher stack frame than that currently being executed." CR CR
642643

643644
"**Examples**" CR CR
644645
" $P frame 2" CR
@@ -651,6 +652,7 @@ phpdbg_help_text_t phpdbg_help_text[] = {
651652

652653
{"info",
653654
"**info** commands provide quick access to various types of information about the PHP environment" CR
655+
"By default general information about environment and PHP build is shown." CR
654656
"Specific info commands are show below:" CR CR
655657

656658
" **Target** **Alias** **Purpose**" CR
@@ -738,7 +740,7 @@ phpdbg_help_text_t phpdbg_help_text[] = {
738740
},
739741

740742
{"print",
741-
"By default, print will show information about the current execution context." CR
743+
"By default, print will show the opcodes of the current execution context." CR
742744
"Other printing commands give access to instruction information." CR
743745
"Specific printers loaded are show below:" CR CR
744746

@@ -750,6 +752,8 @@ phpdbg_help_text_t phpdbg_help_text[] = {
750752
" **func** **f** print out the instructions in the specified function" CR
751753
" **stack** **s** print out the instructions in the current stack" CR CR
752754

755+
"In case passed argument does not match a specific printing command, it will treat it as function or method name and print its opcodes" CR CR
756+
753757
"**Examples**" CR CR
754758
" $P print class \\\\my\\\\class" CR
755759
" $P p c \\\\my\\\\class" CR

sapi/phpdbg/phpdbg_prompt.c

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ const phpdbg_command_t phpdbg_prompt_commands[] = {
7373
PHPDBG_COMMAND_D(until, "continue past the current line", 'u', NULL, 0, 0),
7474
PHPDBG_COMMAND_D(finish, "continue past the end of the stack", 'F', NULL, 0, 0),
7575
PHPDBG_COMMAND_D(leave, "continue until the end of the stack", 'L', NULL, 0, 0),
76-
PHPDBG_COMMAND_D(print, "print something", 'p', phpdbg_print_commands, 0, 0),
76+
PHPDBG_COMMAND_D(print, "print something", 'p', phpdbg_print_commands, "|*c", 0),
7777
PHPDBG_COMMAND_D(break, "set breakpoint", 'b', phpdbg_break_commands, "|*c", 0),
7878
PHPDBG_COMMAND_D(back, "show trace", 't', NULL, "|n", PHPDBG_ASYNC_SAFE),
7979
PHPDBG_COMMAND_D(frame, "switch to a frame", 'f', NULL, "|n", PHPDBG_ASYNC_SAFE),
80-
PHPDBG_COMMAND_D(list, "lists some code", 'l', phpdbg_list_commands, "*", PHPDBG_ASYNC_SAFE),
81-
PHPDBG_COMMAND_D(info, "displays some informations", 'i', phpdbg_info_commands, "s", PHPDBG_ASYNC_SAFE),
80+
PHPDBG_COMMAND_D(list, "lists some code", 'l', phpdbg_list_commands, "*", PHPDBG_ASYNC_SAFE),
81+
PHPDBG_COMMAND_D(info, "displays some informations", 'i', phpdbg_info_commands, "|s", PHPDBG_ASYNC_SAFE),
8282
PHPDBG_COMMAND_D(clean, "clean the execution environment", 'X', NULL, 0, 0),
8383
PHPDBG_COMMAND_D(clear, "clear breakpoints", 'C', NULL, 0, 0),
8484
PHPDBG_COMMAND_D(help, "show help menu", 'h', phpdbg_help_commands, "|s", PHPDBG_ASYNC_SAFE),
@@ -779,52 +779,60 @@ PHPDBG_COMMAND(back) /* {{{ */
779779
} /* }}} */
780780

781781
PHPDBG_COMMAND(print) /* {{{ */
782+
{
783+
if (!param || param->type == EMPTY_PARAM) {
784+
return phpdbg_do_print_exec(param);
785+
} else switch (param->type) {
786+
case STR_PARAM:
787+
return phpdbg_do_print_func(param);
788+
case METHOD_PARAM:
789+
return phpdbg_do_print_method(param);
790+
default:
791+
phpdbg_error("print", "type=\"invalidarg\"", "Invalid arguments to print, expected nothing, function name or method name");
792+
return SUCCESS;
793+
}
794+
} /* }}} */
795+
796+
PHPDBG_COMMAND(info) /* {{{ */
782797
{
783798
phpdbg_out("Execution Context Information\n\n");
784799
phpdbg_xml("<printinfo %r>");
785800
#ifdef HAVE_LIBREADLINE
786-
phpdbg_writeln("print", "readline=\"yes\"", "Readline yes");
801+
phpdbg_writeln("info", "readline=\"yes\"", "Readline yes");
787802
#else
788-
phpdbg_writeln("print", "readline=\"no\"", "Readline no");
803+
phpdbg_writeln("info", "readline=\"no\"", "Readline no");
789804
#endif
790805
#ifdef HAVE_LIBEDIT
791-
phpdbg_writeln("print", "libedit=\"yes\"", "Libedit yes");
806+
phpdbg_writeln("info", "libedit=\"yes\"", "Libedit yes");
792807
#else
793-
phpdbg_writeln("print", "libedit=\"no\"", "Libedit no");
808+
phpdbg_writeln("info", "libedit=\"no\"", "Libedit no");
794809
#endif
795810

796-
phpdbg_writeln("print", "context=\"%s\"", "Exec %s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none");
797-
phpdbg_writeln("print", "compiled=\"%s\"", "Compiled %s", PHPDBG_G(ops) ? "yes" : "no");
798-
phpdbg_writeln("print", "stepping=\"%s\"", "Stepping %s", (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ? "on" : "off");
799-
phpdbg_writeln("print", "quiet=\"%s\"", "Quietness %s", (PHPDBG_G(flags) & PHPDBG_IS_QUIET) ? "on" : "off");
800-
phpdbg_writeln("print", "oplog=\"%s\"", "Oplog %s", PHPDBG_G(oplog) ? "on" : "off");
811+
phpdbg_writeln("info", "context=\"%s\"", "Exec %s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none");
812+
phpdbg_writeln("info", "compiled=\"%s\"", "Compiled %s", PHPDBG_G(ops) ? "yes" : "no");
813+
phpdbg_writeln("info", "stepping=\"%s\"", "Stepping %s", (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ? "on" : "off");
814+
phpdbg_writeln("info", "quiet=\"%s\"", "Quietness %s", (PHPDBG_G(flags) & PHPDBG_IS_QUIET) ? "on" : "off");
815+
phpdbg_writeln("info", "oplog=\"%s\"", "Oplog %s", PHPDBG_G(oplog) ? "on" : "off");
801816

802817
if (PHPDBG_G(ops)) {
803-
phpdbg_writeln("print", "ops=\"%d\"", "Opcodes %d", PHPDBG_G(ops)->last);
804-
phpdbg_writeln("print", "vars=\"%d\"", "Variables %d", PHPDBG_G(ops)->last_var ? PHPDBG_G(ops)->last_var - 1 : 0);
818+
phpdbg_writeln("info", "ops=\"%d\"", "Opcodes %d", PHPDBG_G(ops)->last);
819+
phpdbg_writeln("info", "vars=\"%d\"", "Variables %d", PHPDBG_G(ops)->last_var ? PHPDBG_G(ops)->last_var - 1 : 0);
805820
}
806821

807-
phpdbg_writeln("print", "executing=\"%d\"", "Executing %s", PHPDBG_G(in_execution) ? "yes" : "no");
822+
phpdbg_writeln("info", "executing=\"%d\"", "Executing %s", PHPDBG_G(in_execution) ? "yes" : "no");
808823
if (PHPDBG_G(in_execution)) {
809-
phpdbg_writeln("print", "vmret=\"%d\"", "VM Return %d", PHPDBG_G(vmret));
824+
phpdbg_writeln("info", "vmret=\"%d\"", "VM Return %d", PHPDBG_G(vmret));
810825
}
811826

812-
phpdbg_writeln("print", "classes=\"%d\"", "Classes %d", zend_hash_num_elements(EG(class_table)));
813-
phpdbg_writeln("print", "functions=\"%d\"", "Functions %d", zend_hash_num_elements(EG(function_table)));
814-
phpdbg_writeln("print", "constants=\"%d\"", "Constants %d", zend_hash_num_elements(EG(zend_constants)));
815-
phpdbg_writeln("print", "includes=\"%d\"", "Included %d", zend_hash_num_elements(&EG(included_files)));
827+
phpdbg_writeln("info", "classes=\"%d\"", "Classes %d", zend_hash_num_elements(EG(class_table)));
828+
phpdbg_writeln("info", "functions=\"%d\"", "Functions %d", zend_hash_num_elements(EG(function_table)));
829+
phpdbg_writeln("info", "constants=\"%d\"", "Constants %d", zend_hash_num_elements(EG(zend_constants)));
830+
phpdbg_writeln("info", "includes=\"%d\"", "Included %d", zend_hash_num_elements(&EG(included_files)));
816831
phpdbg_xml("</printinfo>");
817832

818833
return SUCCESS;
819834
} /* }}} */
820835

821-
PHPDBG_COMMAND(info) /* {{{ */
822-
{
823-
phpdbg_error("info", "type=\"toofewargs\" expected=\"1\"", "No information command selected!");
824-
825-
return SUCCESS;
826-
} /* }}} */
827-
828836
PHPDBG_COMMAND(set) /* {{{ */
829837
{
830838
phpdbg_error("set", "type=\"toofewargs\" expected=\"1\"", "No set command selected!");

0 commit comments

Comments
 (0)