mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00
no more printf
This commit is contained in:
parent
ce78503e15
commit
a8285e3bbf
4 changed files with 73 additions and 69 deletions
2
phpdbg.c
2
phpdbg.c
|
@ -443,7 +443,7 @@ int main(int argc, char **argv) /* {{{ */
|
||||||
/* print blurb */
|
/* print blurb */
|
||||||
phpdbg_notice("Welcome to phpdbg, the interactive PHP debugger, v%s",
|
phpdbg_notice("Welcome to phpdbg, the interactive PHP debugger, v%s",
|
||||||
PHPDBG_VERSION);
|
PHPDBG_VERSION);
|
||||||
printf("[To get help using phpdbg type \"help\" and press enter\n");
|
phpdbg_writeln("To get help using phpdbg type \"help\" and press enter");
|
||||||
phpdbg_notice("Please report bugs to <%s>", PHPDBG_ISSUES);
|
phpdbg_notice("Please report bugs to <%s>", PHPDBG_ISSUES);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
20
phpdbg_bp.c
20
phpdbg_bp.c
|
@ -287,12 +287,12 @@ void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
|
||||||
phpdbg_breaksymbol_t *brake;
|
phpdbg_breaksymbol_t *brake;
|
||||||
|
|
||||||
PHPDBG_SEP_LINE(TSRMLS_C);
|
PHPDBG_SEP_LINE(TSRMLS_C);
|
||||||
printf("Function Breakpoints:\n");
|
phpdbg_writeln("Function Breakpoints:");
|
||||||
for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position);
|
for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position);
|
||||||
zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], (void**) &brake, &position) == SUCCESS;
|
zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], (void**) &brake, &position) == SUCCESS;
|
||||||
zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position)) {
|
zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position)) {
|
||||||
printf(
|
phpdbg_writeln(
|
||||||
"#%d\t\t%s\n", brake->id, brake->symbol);
|
"#%d\t\t%s", brake->id, brake->symbol);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
|
||||||
zend_ulong class_idx = 0L;
|
zend_ulong class_idx = 0L;
|
||||||
|
|
||||||
PHPDBG_SEP_LINE(TSRMLS_C);
|
PHPDBG_SEP_LINE(TSRMLS_C);
|
||||||
printf("Method Breakpoints:\n");
|
phpdbg_writeln("Method Breakpoints:");
|
||||||
for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], &position[0]);
|
for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], &position[0]);
|
||||||
zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], (void**) &class_table, &position[0]) == SUCCESS;
|
zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], (void**) &class_table, &position[0]) == SUCCESS;
|
||||||
zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], &position[0])) {
|
zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], &position[0])) {
|
||||||
|
@ -318,8 +318,8 @@ void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
|
||||||
for (zend_hash_internal_pointer_reset_ex(class_table, &position[1]);
|
for (zend_hash_internal_pointer_reset_ex(class_table, &position[1]);
|
||||||
zend_hash_get_current_data_ex(class_table, (void**)&brake, &position[1]) == SUCCESS;
|
zend_hash_get_current_data_ex(class_table, (void**)&brake, &position[1]) == SUCCESS;
|
||||||
zend_hash_move_forward_ex(class_table, &position[1])) {
|
zend_hash_move_forward_ex(class_table, &position[1])) {
|
||||||
printf(
|
phpdbg_writeln(
|
||||||
"#%d\t\t%s::%s\n", brake->id, brake->class_name, brake->func_name);
|
"#%d\t\t%s::%s", brake->id, brake->class_name, brake->func_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
|
||||||
zend_llist *points;
|
zend_llist *points;
|
||||||
|
|
||||||
PHPDBG_SEP_LINE(TSRMLS_C);
|
PHPDBG_SEP_LINE(TSRMLS_C);
|
||||||
printf("File Breakpoints:\n");
|
phpdbg_writeln("File Breakpoints:");
|
||||||
for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position);
|
for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position);
|
||||||
zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], (void**) &points, &position) == SUCCESS;
|
zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], (void**) &points, &position) == SUCCESS;
|
||||||
zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position)) {
|
zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position)) {
|
||||||
|
@ -340,7 +340,7 @@ void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
|
||||||
|
|
||||||
if ((brake = zend_llist_get_first_ex(points, &lposition))) {
|
if ((brake = zend_llist_get_first_ex(points, &lposition))) {
|
||||||
do {
|
do {
|
||||||
printf("#%d\t\t%s:%lu\n", brake->id, brake->filename, brake->line);
|
phpdbg_writeln("#%d\t\t%s:%lu", brake->id, brake->filename, brake->line);
|
||||||
} while ((brake = zend_llist_get_next_ex(points, &lposition)));
|
} while ((brake = zend_llist_get_next_ex(points, &lposition)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,11 +351,11 @@ void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
|
||||||
phpdbg_breakline_t *brake;
|
phpdbg_breakline_t *brake;
|
||||||
|
|
||||||
PHPDBG_SEP_LINE(TSRMLS_C);
|
PHPDBG_SEP_LINE(TSRMLS_C);
|
||||||
printf("Opline Breakpoints:\n");
|
phpdbg_writeln("Opline Breakpoints:");
|
||||||
for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], &position);
|
for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], &position);
|
||||||
zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (void**) &brake, &position) == SUCCESS;
|
zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (void**) &brake, &position) == SUCCESS;
|
||||||
zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], &position)) {
|
zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], &position)) {
|
||||||
printf("#%d\t\t%#lx\n", brake->id, brake->opline);
|
phpdbg_writeln("#%d\t\t%#lx", brake->id, brake->opline);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
119
phpdbg_help.c
119
phpdbg_help.c
|
@ -20,52 +20,53 @@
|
||||||
#include "phpdbg.h"
|
#include "phpdbg.h"
|
||||||
#include "phpdbg_help.h"
|
#include "phpdbg_help.h"
|
||||||
#include "phpdbg_print.h"
|
#include "phpdbg_print.h"
|
||||||
|
#include "phpdbg_utils.h"
|
||||||
|
|
||||||
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
|
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
|
||||||
|
|
||||||
PHPDBG_HELP(exec) /* {{{ */
|
PHPDBG_HELP(exec) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("Will attempt execution, if compilation has not yet taken place, it occurs now.\n");
|
phpdbg_writeln("Will attempt execution, if compilation has not yet taken place, it occurs now.");
|
||||||
printf("The execution context must be set before execution can take place\n");
|
phpdbg_writeln("The execution context must be set before execution can take place");
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
PHPDBG_HELP(step) /* {{{ */
|
PHPDBG_HELP(step) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("You can enable and disable stepping at any phpdbg prompt during execution\n");
|
phpdbg_writeln("You can enable and disable stepping at any phpdbg prompt during execution");
|
||||||
printf("For example:\n");
|
phpdbg_writeln("For example:");
|
||||||
printf("\t%sstepping 1\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
|
phpdbg_writeln("\t%sstepping 1", PROMPT);
|
||||||
printf("Will enable stepping\n");
|
phpdbg_writeln("Will enable stepping");
|
||||||
printf("While stepping is enabled you are presented with a prompt after the execution of each opcode\n");
|
phpdbg_writeln("While stepping is enabled you are presented with a prompt after the execution of each opcode");
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
PHPDBG_HELP(next) /* {{{ */
|
PHPDBG_HELP(next) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("While stepping through execution, or after a breakpoint, use the next command to step back into the vm and execute the next opcode\n");
|
phpdbg_writeln("While stepping through execution, or after a breakpoint, use the next command to step back into the vm and execute the next opcode");
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
PHPDBG_HELP(compile) /* {{{ */
|
PHPDBG_HELP(compile) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("Pre-compilation of the execution context provides the opportunity to inspect the opcodes before they are executed\n");
|
phpdbg_writeln("Pre-compilation of the execution context provides the opportunity to inspect the opcodes before they are executed");
|
||||||
printf("The execution context must be set for compilation to succeed\n");
|
phpdbg_writeln("The execution context must be set for compilation to succeed");
|
||||||
printf("If errors occur during compilation they must be resolved before execution can take place.\n");
|
phpdbg_writeln("If errors occur during compilation they must be resolved before execution can take place.");
|
||||||
printf("It is a good idea to clean the environment between each compilation with the clean command\n");
|
phpdbg_writeln("It is a good idea to clean the environment between each compilation with the clean command");
|
||||||
printf("You do not need to exit phpdbg to retry compilation\n");
|
phpdbg_writeln("You do not need to exit phpdbg to retry compilation");
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
PHPDBG_HELP(print) /* {{{ */
|
PHPDBG_HELP(print) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("By default, print will show information about the current execution environment\n");
|
phpdbg_writeln("By default, print will show information about the current execution environment");
|
||||||
printf("Specific printers loaded are show below:\n");
|
phpdbg_writeln("Specific printers loaded are show below:");
|
||||||
printf("%sCommands%s\n", PHPDBG_BOLD_LINE(TSRMLS_C), PHPDBG_END_LINE(TSRMLS_C));
|
phpdbg_notice("Commands");
|
||||||
{
|
{
|
||||||
phpdbg_command_t *print_command = phpdbg_print_commands;
|
const phpdbg_command_t *print_command = phpdbg_print_commands;
|
||||||
|
|
||||||
while (print_command && print_command->name) {
|
while (print_command && print_command->name) {
|
||||||
printf("\t%s\t%s\n", print_command->name, print_command->tip);
|
phpdbg_writeln("\t%s\t%s", print_command->name, print_command->tip);
|
||||||
++print_command;
|
++print_command;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,80 +75,82 @@ PHPDBG_HELP(print) /* {{{ */
|
||||||
|
|
||||||
PHPDBG_HELP(run) /* {{{ */
|
PHPDBG_HELP(run) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("Run the code inside the debug vm, you should have break points and variables set before running\n");
|
phpdbg_writeln("Run the code inside the debug vm, you should have break points and variables set before running");
|
||||||
printf("The execution context must not be set, but not necessarily compiled before execution occurs\n");
|
phpdbg_writeln("The execution context must not be set, but not necessarily compiled before execution occurs");
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
PHPDBG_HELP(eval) /* {{{ */
|
PHPDBG_HELP(eval) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("Access to eval() allows you to change the environment during execution, careful though !!\n");
|
phpdbg_writeln("Access to eval() allows you to change the environment during execution, careful though !!");
|
||||||
printf("Note: When using eval in phpdbg do not prefix the code with return.\n");
|
phpdbg_writeln("Note: When using eval in phpdbg do not prefix the code with return.");
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
PHPDBG_HELP(break) /* {{{ */
|
PHPDBG_HELP(break) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("Setting a breakpoint stops execution at a specific stage.\n");
|
phpdbg_writeln("Setting a breakpoint stops execution at a specific stage.");
|
||||||
printf("For example:\n");
|
phpdbg_writeln(EMPTY);
|
||||||
printf("\t%sbreak test.php:1\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
|
phpdbg_writeln("For example:");
|
||||||
printf("Will break execution on line 1 of test.php\n");
|
phpdbg_writeln("\t%sbreak test.php:1", PROMPT);
|
||||||
printf("\t%sbreak my_function\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
|
phpdbg_writeln("Will break execution on line 1 of test.php");
|
||||||
printf("Will break execution on entry to my_function\n");
|
phpdbg_writeln("\t%sbreak my_function", PROMPT);
|
||||||
printf("\t%sbreak \\my\\class::method\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
|
phpdbg_writeln("Will break execution on entry to my_function");
|
||||||
printf("Will break execution on entry to \\my\\class::method\n");
|
phpdbg_writeln("\t%sbreak \\my\\class::method", PROMPT);
|
||||||
printf("\t%sbreak 0x7ff68f570e08\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
|
phpdbg_writeln("Will break execution on entry to \\my\\class::method");
|
||||||
printf("Will break at the opline with the address provided (addresses are shown during execution)\n");
|
phpdbg_writeln("\t%sbreak 0x7ff68f570e08", PROMPT);
|
||||||
printf("\t%sbreak 200\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
|
phpdbg_writeln("Will break at the opline with the address provided (addresses are shown during execution)");
|
||||||
printf("Will break at line 200 of the currently executing file\n");
|
phpdbg_writeln("\t%sbreak 200", PROMPT);
|
||||||
printf("It is important to note, an address is only valid for the current compiled representation of the script\n");
|
phpdbg_writeln("Will break at line 200 of the currently executing file");
|
||||||
printf("If you have to clean the environment and recompile then your opline break points will be invalid\n");
|
phpdbg_writeln(EMPTY);
|
||||||
|
phpdbg_writeln("It is important to note, an address is only valid for the current compiled representation of the script");
|
||||||
|
phpdbg_writeln("If you have to clean the environment and recompile then your opline break points will be invalid");
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
PHPDBG_HELP(clean) /* {{{ */
|
PHPDBG_HELP(clean) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("While debugging you may experience errors because of attempts to redeclare classes, constants or functions.\n");
|
phpdbg_writeln("While debugging you may experience errors because of attempts to redeclare classes, constants or functions.");
|
||||||
printf("Cleaning the environment cleans these tables, so that files can be recompiled without exiting phpdbg.\n");
|
phpdbg_writeln("Cleaning the environment cleans these tables, so that files can be recompiled without exiting phpdbg.");
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
PHPDBG_HELP(clear) /* {{{ */
|
PHPDBG_HELP(clear) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("Clearing breakpoints means you can once again run code without interruption\n");
|
phpdbg_writeln("Clearing breakpoints means you can once again run code without interruption");
|
||||||
printf("Careful though, all breakpoints are lost; be sure debugging is complete before clearing\n");
|
phpdbg_writeln("Careful though, all breakpoints are lost; be sure debugging is complete before clearing");
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
PHPDBG_HELP(quiet) /* {{{ */
|
PHPDBG_HELP(quiet) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("Setting quietness on will stop the OPLINE output during execution\n");
|
phpdbg_writeln("Setting quietness on will stop the OPLINE output during execution");
|
||||||
printf("For example:\n");
|
phpdbg_writeln("For example:");
|
||||||
printf("\t%squiet 1\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
|
phpdbg_writeln("\t%squiet 1", PROMPT);
|
||||||
printf("Will silence OPLINE output, while\n");
|
phpdbg_writeln("Will silence OPLINE output, while");
|
||||||
printf("\t%squiet 0\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
|
phpdbg_writeln("\t%squiet 0", PROMPT);
|
||||||
printf("Will enable OPLINE output again\n");
|
phpdbg_writeln("Will enable OPLINE output again");
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
PHPDBG_HELP(back) /* {{{ */
|
PHPDBG_HELP(back) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("The backtrace is gathered with the default debug_backtrace functionality.\n");
|
phpdbg_writeln("The backtrace is gathered with the default debug_backtrace functionality.");
|
||||||
printf("You can set the limit on the trace, for example:\n");
|
phpdbg_writeln("You can set the limit on the trace, for example:");
|
||||||
printf("\t%sback 5\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
|
phpdbg_writeln("\t%sback 5", PROMPT);
|
||||||
printf("Will limit the number of frames to 5, the default is no limit\n");
|
phpdbg_writeln("Will limit the number of frames to 5, the default is no limit");
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
PHPDBG_HELP(list) /* {{{ */
|
PHPDBG_HELP(list) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("The list command displays N line from current context file.\n");
|
phpdbg_writeln("The list command displays N line from current context file.");
|
||||||
printf("\t%slist 2\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
|
phpdbg_writeln("\t%slist 2", PROMPT);
|
||||||
printf("Will print next 2 lines from the current file\n");
|
phpdbg_writeln("Will print next 2 lines from the current file");
|
||||||
printf("\t%slist func\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
|
phpdbg_writeln("\t%slist func", PROMPT);
|
||||||
printf("Will print the source of the global function \"func\"\n");
|
phpdbg_writeln("Will print the source of the global function \"func\"");
|
||||||
printf("\t%slist .mine\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
|
phpdbg_writeln("\t%slist .mine", PROMPT);
|
||||||
printf("Will print the source of the class method \"mine\"\n");
|
phpdbg_writeln("Will print the source of the class method \"mine\"");
|
||||||
printf("Note: before listing functions you must have a populated function table, try compile !!\n");
|
phpdbg_writeln("Note: before listing functions you must have a populated function table, try compile !!");
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "phpdbg.h"
|
#include "phpdbg.h"
|
||||||
#include "phpdbg_list.h"
|
#include "phpdbg_list.h"
|
||||||
|
#include "phpdbg_utils.h"
|
||||||
|
|
||||||
void phpdbg_list_file(const char *filename, long count, long offset TSRMLS_DC) /* {{{ */
|
void phpdbg_list_file(const char *filename, long count, long offset TSRMLS_DC) /* {{{ */
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue