phpdbg_writeln("Examples:");
phpdbg_writeln("\t%sprint class \\my\\class", PROMPT);
phpdbg_writeln("Will print information about \\my\\class, including the instructions for every method and their address");
+ phpdbg_writeln("\t%sprint method \\my\\class::method", PROMPT);
+ phpdbg_writeln("Will print the instructions for \\my\\class::method");
phpdbg_writeln("\t%sprint func .getSomething", PROMPT);
phpdbg_writeln("Will print the instructions for the method getSomething in the currently active scope");
+ phpdbg_writeln("\t%sprint func my_function", PROMPT);
+ phpdbg_writeln("Will print the instructions for the global function my_function");
phpdbg_writeln("\t%sprint opline", PROMPT);
phpdbg_writeln("Will print the instruction for the current opline");
phpdbg_writeln(EMPTY);
} else {
phpdbg_error("The method %s could not be found", func_name);
}
+ } else {
+ phpdbg_error("Failed to find the requested class %s", class_name);
}
efree(class_name);
static PHPDBG_COMMAND(print) /* {{{ */
{
if (expr && expr_len > 0L) {
- if (phpdbg_print_commands &&
- phpdbg_do_cmd(phpdbg_print_commands, (char*)expr, expr_len TSRMLS_CC) == FAILURE) {
+ if (phpdbg_do_cmd(phpdbg_print_commands, (char*)expr, expr_len TSRMLS_CC) == FAILURE) {
phpdbg_error("Failed to find print command %s", expr);
}
return SUCCESS;
/* ensure string is null terminated */
cmd[cmd_len] = '\0';
- if (cmd && cmd_len > 0L) {
+ if (*cmd && cmd_len > 0L) {
#ifdef HAVE_LIBREADLINE
add_history(cmd);
#endif
return 1;
} /* }}} */
-void phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */
+int phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */
{
+ int rc = 0;
char *buffer = NULL;
va_list args;
switch (type) {
case ERROR:
- printf("%s%s%s\n",
- ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;31m[" : "["),
- buffer,
- ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]"));
+ rc = printf("%s%s%s\n",
+ ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;31m[" : "["),
+ buffer,
+ ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]"));
break;
case NOTICE:
- printf("%s%s%s\n",
- ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;64m[" : "["),
- buffer,
- ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]"));
+ rc = printf("%s%s%s\n",
+ ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;64m[" : "["),
+ buffer,
+ ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]"));
break;
case WRITELN: {
if (buffer) {
- printf("%s%s%s\n",
- ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[37m" : ""),
- buffer,
- ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : ""));
+ rc = printf("%s%s%s\n",
+ ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[37m" : ""),
+ buffer,
+ ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : ""));
} else {
- printf("\n");
+ rc = printf("\n");
}
} break;
case WRITE: if (buffer) {
- printf("%s%s%s",
- ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[37m" : ""),
- buffer,
- ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : ""));
+ rc = printf("%s%s%s",
+ ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[37m" : ""),
+ buffer,
+ ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : ""));
} break;
}
if (buffer) {
efree(buffer);
}
+
+ return rc;
} /* }}} */
WRITE
};
-void phpdbg_print(int TSRMLS_DC, const char*, ...);
+int phpdbg_print(int TSRMLS_DC, const char*, ...);
#define phpdbg_error(fmt, ...) phpdbg_print(ERROR TSRMLS_CC, fmt, ##__VA_ARGS__)
#define phpdbg_notice(fmt, ...) phpdbg_print(NOTICE TSRMLS_CC, fmt, ##__VA_ARGS__)