REGISTER_LONG_CONSTANT("PHPDBG_COLOR_PROMPT", PHPDBG_COLOR_PROMPT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHPDBG_COLOR_NOTICE", PHPDBG_COLOR_NOTICE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHPDBG_COLOR_ERROR", PHPDBG_COLOR_ERROR, CONST_CS|CONST_PERSISTENT);
-
+
return SUCCESS;
} /* }}} */
long element;
char *color;
zend_uint color_len;
-
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &element, &color, &color_len) == FAILURE) {
return;
}
-
+
switch (element) {
case PHPDBG_COLOR_NOTICE:
case PHPDBG_COLOR_ERROR:
case PHPDBG_COLOR_PROMPT:
phpdbg_set_color_ex(element, color, color_len TSRMLS_CC);
break;
-
+
default: zend_error(E_ERROR, "phpdbg detected an incorrect color constant");
}
} /* }}} */
/* {{{ proto void phpdbg_prompt(string prompt) */
-static PHP_FUNCTION(phpdbg_prompt)
+static PHP_FUNCTION(phpdbg_prompt)
{
char *prompt;
zend_uint prompt_len;
-
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &prompt, &prompt_len) == FAILURE) {
return;
}
-
+
phpdbg_set_prompt(prompt TSRMLS_CC);
} /* }}} */
#define PHPDBG_IS_INITIALIZING (1<<19)
#define PHPDBG_IS_SIGNALED (1<<20)
#define PHPDBG_IS_INTERACTIVE (1<<21)
+#define PHPDBG_IS_BP_ENABLED (1<<22)
#ifndef _WIN32
-# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED)
+# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED|PHPDBG_IS_BP_ENABLED)
#else
-# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET)
+# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_BP_ENABLED)
#endif /* }}} */
/* {{{ strings */
HashTable registered; /* registered */
HashTable seek; /* seek oplines */
phpdbg_frame_t frame; /* frame */
-
+
char *exec; /* file to execute */
size_t exec_len; /* size of exec */
zend_op_array *ops; /* op_array */
char *prompt[2]; /* prompt */
const phpdbg_color_t *colors[PHPDBG_COLORS]; /* colors */
-
+
phpdbg_command_t *lcmd; /* last command */
phpdbg_param_t lparam; /* last param */
-
+
zend_ulong flags; /* phpdbg flags */
ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */
{
HashPosition position;
HashTable *table = NULL;
-
+
if (PHPDBG_G(flags) & PHPDBG_HAS_FILE_BP) {
zend_llist *brakes;
table = &PHPDBG_G(bp)[PHPDBG_BREAK_FILE];
-
+
for (zend_hash_internal_pointer_reset_ex(table, &position);
zend_hash_get_current_data_ex(table, (void*) &brakes, &position) == SUCCESS;
zend_hash_move_forward_ex(table, &position)) {
-
+
zend_llist_position lposition;
phpdbg_breakfile_t *brake;
zend_ulong count = zend_llist_count(brakes);
-
+
if ((brake = zend_llist_get_first_ex(brakes, &lposition))) {
phpdbg_notice(
"Exporting file breakpoints in %s (%d)", brake->filename, count);
}
}
}
-
+
if (PHPDBG_G(flags) & PHPDBG_HAS_SYM_BP) {
phpdbg_breaksymbol_t *brake;
-
+
table = &PHPDBG_G(bp)[PHPDBG_BREAK_SYM];
-
+
phpdbg_notice("Exporting symbol breakpoints (%d)", zend_hash_num_elements(table));
-
+
for (zend_hash_internal_pointer_reset_ex(table, &position);
zend_hash_get_current_data_ex(table, (void*) &brake, &position) == SUCCESS;
zend_hash_move_forward_ex(table, &position)) {
zend_hash_move_forward_ex(class, &mposition)) {
if (!noted) {
phpdbg_notice(
- "Exporting method breakpoints in %s (%d)",
+ "Exporting method breakpoints in %s (%d)",
brake->class_name, zend_hash_num_elements(class));
noted = 1;
}
-
+
fprintf(
handle, "break %s::%s\n", brake->class_name, brake->func_name);
}
}
}
-
+
if (PHPDBG_G(flags) & PHPDBG_HAS_OPCODE_BP) {
phpdbg_breakop_t *brake;
-
+
table = &PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE];
-
+
phpdbg_notice(
"Exporting opcode breakpoints (%d)", zend_hash_num_elements(table));
-
+
for (zend_hash_internal_pointer_reset_ex(table, &position);
zend_hash_get_current_data_ex(table, (void**) &brake, &position) == SUCCESS;
zend_hash_move_forward_ex(table, &position)) {
-
+
fprintf(
- handle, "break op %s\n", brake->name);
+ handle, "break op %s\n", brake->name);
}
}
-
+
/* export other types here after resolving errors from source command */
-
+
} /* }}} */
PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRMLS_DC) /* {{{ */
int phpdbg_find_breakpoint(zend_execute_data* execute_data TSRMLS_DC) /* {{{ */
{
+ if (!(PHPDBG_G(flags) & PHPDBG_IS_BP_ENABLED)) {
+ return FAILURE;
+ }
+
/* conditions cannot be executed by eval()'d code */
if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)
&& (PHPDBG_G(flags) & PHPDBG_HAS_COND_BP)
return SUCCESS;
} /* }}} */
+PHPDBG_SET(breakpoint) /* {{{ */
+{
+ switch (param->type) {
+ case EMPTY_PARAM:
+ phpdbg_writeln("%s",
+ PHPDBG_G(flags) & PHPDBG_IS_BP_ENABLED ? "on" : "off");
+ break;
+
+ case STR_PARAM:
+ if (strncasecmp(param->str, PHPDBG_STRL("on")) == 0) {
+ PHPDBG_G(flags) |= PHPDBG_IS_BP_ENABLED;
+ } else if (strncasecmp(param->str, PHPDBG_STRL("off")) == 0) {
+ PHPDBG_G(flags) ^= PHPDBG_IS_BP_ENABLED;
+ }
+ break;
+
+ phpdbg_default_switch_case();
+ }
+
+ return SUCCESS;
+} /* }}} */
+
PHPDBG_SET(color) /* {{{ */
{
if ((param->type == STR_PARAM) && (input->argc == 3)) {
const phpdbg_color_t *color = phpdbg_get_color(
input->argv[2]->string, input->argv[2]->length TSRMLS_CC);
int element = PHPDBG_COLOR_INVALID;
-
+
if (color) {
- if (phpdbg_argv_is(1, "prompt")) {
- phpdbg_notice(
+ if (phpdbg_argv_is(1, "prompt")) {
+ phpdbg_notice(
"setting prompt color to %s (%s)", color->name, color->code);
element = PHPDBG_COLOR_PROMPT;
if (PHPDBG_G(prompt)[1]) {
PHPDBG_G(prompt)[1]=NULL;
}
} else if (phpdbg_argv_is(1, "error")) {
- phpdbg_notice(
+ phpdbg_notice(
"setting error color to %s (%s)", color->name, color->code);
element = PHPDBG_COLOR_ERROR;
-
+
} else if (phpdbg_argv_is(1, "notice")) {
- phpdbg_notice(
+ phpdbg_notice(
"setting notice color to %s (%s)", color->name, color->code);
element = PHPDBG_COLOR_NOTICE;
-
- } else goto usage;
+
+ } else goto usage;
/* set color for element */
phpdbg_set_color(element, color TSRMLS_CC);
PHPDBG_SET(prompt);
PHPDBG_SET(color);
PHPDBG_SET(oplog);
+PHPDBG_SET(breakpoint);
static const phpdbg_command_t phpdbg_set_commands[] = {
PHPDBG_COMMAND_D_EX(prompt, "usage: set prompt <string>", 'p', set_prompt, NULL, 0),
PHPDBG_COMMAND_D_EX(color, "usage: set color <element> <color>", 'c', set_color, NULL, 1),
PHPDBG_COMMAND_D_EX(oplog, "usage: set oplog <output>", 'O', set_oplog, NULL, 0),
+ PHPDBG_COMMAND_D_EX(breakpoint, "usage: set breakpoint <on|off>", 'b', set_breakpoint, NULL, 0),
PHPDBG_END_COMMAND
};