PHPDBG_LIST(func) /* {{{ */
{
- if (param->type == STR_PARAM) {
- i_phpdbg_list_func(
- param->str, param->len TSRMLS_CC);
- } else {
- phpdbg_error(
- "Unsupported parameter type (%s) for function", phpdbg_get_param_type(param TSRMLS_CC));
+ switch (param->type) {
+ case STR_PARAM:
+ i_phpdbg_list_func(
+ param->str, param->len TSRMLS_CC);
+ break;
+
+ phpdbg_default_switch_case();
}
return SUCCESS;
PHPDBG_LIST(method) /* {{{ */
{
- if (param->type == METHOD_PARAM) {
- zend_class_entry **ce;
+ switch (param->type) {
+ case METHOD_PARAM: {
+ zend_class_entry **ce;
- if (zend_lookup_class(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) {
- zend_function *function;
- char *lcname = zend_str_tolower_dup(
- param->method.name, strlen(param->method.name));
-
- if (zend_hash_find(&(*ce)->function_table, lcname, strlen(lcname)+1, (void**) &function) == SUCCESS) {
- phpdbg_list_function(
- function TSRMLS_CC);
+ if (zend_lookup_class(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) {
+ zend_function *function;
+ char *lcname = zend_str_tolower_dup(
+ param->method.name, strlen(param->method.name));
+
+ if (zend_hash_find(&(*ce)->function_table, lcname, strlen(lcname)+1, (void**) &function) == SUCCESS) {
+ phpdbg_list_function(
+ function TSRMLS_CC);
+ } else {
+ phpdbg_error("Could not find ::%s in %s", param->method.name, param->method.class);
+ }
+
+ efree(lcname);
} else {
- phpdbg_error("Could not find ::%s in %s", param->method.name, param->method.class);
+ phpdbg_error("Could not find the class %s", param->method.class);
}
-
- efree(lcname);
- } else {
- phpdbg_error("Could not find the class %s", param->method.class);
- }
- } else {
- phpdbg_error(
- "Unsupported parameter type (%s) for function", phpdbg_get_param_type(param TSRMLS_CC));
+ } break;
+
+ phpdbg_default_switch_case();
}
return SUCCESS;
PHPDBG_LIST(class) /* {{{ */
{
- if (param->type == STR_PARAM) {
- zend_class_entry **ce;
+ switch (param->type) {
+ case STR_PARAM: {
+ zend_class_entry **ce;
- if (zend_lookup_class(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) {
- if ((*ce)->type == ZEND_USER_CLASS) {
- if ((*ce)->info.user.filename) {
- phpdbg_list_file(
- (*ce)->info.user.filename,
- (*ce)->info.user.line_end - (*ce)->info.user.line_start + 1,
- (*ce)->info.user.line_start TSRMLS_CC
- );
+ if (zend_lookup_class(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) {
+ if ((*ce)->type == ZEND_USER_CLASS) {
+ if ((*ce)->info.user.filename) {
+ phpdbg_list_file(
+ (*ce)->info.user.filename,
+ (*ce)->info.user.line_end - (*ce)->info.user.line_start + 1,
+ (*ce)->info.user.line_start TSRMLS_CC
+ );
+ } else {
+ phpdbg_error("The source of the requested class (%s) cannot be found", (*ce)->name);
+ }
} else {
- phpdbg_error("The source of the requested class (%s) cannot be found", (*ce)->name);
+ phpdbg_error("The class requested (%s) is not user defined", (*ce)->name);
}
} else {
- phpdbg_error("The class requested (%s) is not user defined", (*ce)->name);
+ phpdbg_error("The requested class (%s) could not be found", param->str);
}
- } else {
- phpdbg_error("The requested class (%s) could not be found", param->str);
- }
- } else {
- phpdbg_error(
- "Unsupported parameter type (%s) for function", phpdbg_get_param_type(param TSRMLS_CC));
+ } break;
+
+ phpdbg_default_switch_case();
}
return SUCCESS;
phpdbg_do_list_method(param TSRMLS_CC);
break;
- default:
- phpdbg_error(
- "Unsupported parameter type (%s) for function", phpdbg_get_param_type(param TSRMLS_CC));
- break;
+ phpdbg_default_switch_case();
}
} /* }}} */
static PHPDBG_COMMAND(exec) /* {{{ */
{
- if (param->type == STR_PARAM) {
- struct stat sb;
-
- if (VCWD_STAT(param->str, &sb) != FAILURE) {
- if (sb.st_mode & S_IFREG|S_IFLNK) {
- if (PHPDBG_G(exec)) {
- phpdbg_notice("Unsetting old execution context: %s", PHPDBG_G(exec));
- efree(PHPDBG_G(exec));
- PHPDBG_G(exec) = NULL;
- }
-
- if (PHPDBG_G(ops)) {
- phpdbg_notice("Destroying compiled opcodes");
- phpdbg_clean(0 TSRMLS_CC);
- }
-
- PHPDBG_G(exec) = phpdbg_resolve_path(param->str TSRMLS_CC);
-
- if (!PHPDBG_G(exec)) {
- phpdbg_error("Cannot get real file path");
- return FAILURE;
+ switch (param->type) {
+ case STR_PARAM: {
+ struct stat sb;
+
+ if (VCWD_STAT(param->str, &sb) != FAILURE) {
+ if (sb.st_mode & S_IFREG|S_IFLNK) {
+ if (PHPDBG_G(exec)) {
+ phpdbg_notice("Unsetting old execution context: %s", PHPDBG_G(exec));
+ efree(PHPDBG_G(exec));
+ PHPDBG_G(exec) = NULL;
+ }
+
+ if (PHPDBG_G(ops)) {
+ phpdbg_notice("Destroying compiled opcodes");
+ phpdbg_clean(0 TSRMLS_CC);
+ }
+
+ PHPDBG_G(exec) = phpdbg_resolve_path(param->str TSRMLS_CC);
+
+ if (!PHPDBG_G(exec)) {
+ phpdbg_error("Cannot get real file path");
+ return FAILURE;
+ }
+
+ PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec));
+
+ phpdbg_notice("Set execution context: %s", PHPDBG_G(exec));
+
+ } else {
+ phpdbg_error("Cannot use %s as execution context, not a valid file or symlink", param->str);
}
-
- PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec));
-
- phpdbg_notice("Set execution context: %s", PHPDBG_G(exec));
-
} else {
- phpdbg_error("Cannot use %s as execution context, not a valid file or symlink", param->str);
+ phpdbg_error("Cannot stat %s, ensure the file exists", param->str);
}
- } else {
- phpdbg_error("Cannot stat %s, ensure the file exists", param->str);
- }
- } else {
- phpdbg_error("Unsupported parameter type (%s) for command", phpdbg_get_param_type(param TSRMLS_CC));
+ } break;
+
+ phpdbg_default_switch_case();
}
-
+
return SUCCESS;
} /* }}} */
static PHPDBG_COMMAND(step) /* {{{ */
{
- if (param->type == EMPTY_PARAM || param->type == NUMERIC_PARAM) {
- if (param->type == NUMERIC_PARAM && param->num) {
- PHPDBG_G(flags) |= PHPDBG_IS_STEPPING;
- } else {
- PHPDBG_G(flags) &= ~PHPDBG_IS_STEPPING;
- }
-
- phpdbg_notice("Stepping %s",
- (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ? "on" : "off");
- } else {
- phpdbg_error("Unsupported parameter type (%s) for command", phpdbg_get_param_type(param TSRMLS_CC));
- }
+ switch (param->type) {
+ case EMPTY_PARAM:
+ case NUMERIC_PARAM: {
+ if (param->type == NUMERIC_PARAM && param->num) {
+ PHPDBG_G(flags) |= PHPDBG_IS_STEPPING;
+ } else {
+ PHPDBG_G(flags) &= ~PHPDBG_IS_STEPPING;
+ }
+
+ phpdbg_notice("Stepping %s",
+ (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ? "on" : "off");
+ } break;
+
+ phpdbg_default_switch_case();
+ }
return SUCCESS;
} /* }}} */
static PHPDBG_COMMAND(eval) /* {{{ */
{
- if (param->type == STR_PARAM) {
- zend_bool stepping = (PHPDBG_G(flags) & PHPDBG_IS_STEPPING);
- zval retval;
-
- PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING;
-
- /* disable stepping while eval() in progress */
- PHPDBG_G(flags) |= PHPDBG_IN_EVAL;
- 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);
- }
- PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL;
+ switch (param->type) {
+ case STR_PARAM: {
+ zend_bool stepping = (PHPDBG_G(flags) & PHPDBG_IS_STEPPING);
+ zval retval;
+
+ PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING;
+
+ /* disable stepping while eval() in progress */
+ PHPDBG_G(flags) |= PHPDBG_IN_EVAL;
+ 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);
+ }
+ PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL;
- /* switch stepping back on */
- if (stepping) {
- PHPDBG_G(flags) |= PHPDBG_IS_STEPPING;
- }
- } else {
- phpdbg_error(
- "Unsupported parameter type (%s) for command", phpdbg_get_param_type(param TSRMLS_CC));
- return FAILURE;
+ /* switch stepping back on */
+ if (stepping) {
+ PHPDBG_G(flags) |= PHPDBG_IS_STEPPING;
+ }
+ } break;
+
+ phpdbg_default_switch_case();
}
-
+
return SUCCESS;
} /* }}} */
phpdbg_writeln(EMPTY);
zval_dtor(&zbacktrace);
-
- return SUCCESS;
} break;
-
- default: {
- phpdbg_error(
- "Unsupported parameter type (%s) for command", phpdbg_get_param_type(param TSRMLS_CC));
- return FAILURE;
- }
+
+ phpdbg_default_switch_case();
}
+
+ return SUCCESS;
} /* }}} */
static PHPDBG_COMMAND(print) /* {{{ */
phpdbg_set_breakpoint_symbol(param->str TSRMLS_CC);
break;
- default:
- phpdbg_error(
- "Unsupported parameter type (%s) for command", phpdbg_get_param_type(param TSRMLS_CC));
- return FAILURE;
+ phpdbg_default_switch_case();
}
return SUCCESS;
static PHPDBG_COMMAND(oplog) /* {{{ */
{
- if (param->type == EMPTY_PARAM ||
- ((param->type == NUMERIC_PARAM) && !param->num)) {
- if (PHPDBG_G(oplog)) {
- phpdbg_notice("Disabling oplog");
- fclose(
- PHPDBG_G(oplog));
- return SUCCESS;
- } else {
- phpdbg_error("No oplog currently open");
- return FAILURE;
- }
- } else {
- if (param->type == STR_PARAM) {
- /* open oplog */
+ switch (param->type) {
+ case EMPTY_PARAM:
+ case NUMERIC_PARAM:
+ if ((param->type != NUMERIC_PARAM) || !param->num) {
+ if (PHPDBG_G(oplog)) {
+ phpdbg_notice("Disabling oplog");
+ fclose(
+ PHPDBG_G(oplog));
+ } else {
+ phpdbg_error("No oplog currently open");
+ }
+ }
+ break;
+
+ case STR_PARAM: {
+ /* open oplog */
FILE *old = PHPDBG_G(oplog);
PHPDBG_G(oplog) = fopen(param->str, "w+");
if (!PHPDBG_G(oplog)) {
phpdbg_error("Failed to open %s for oplog", param->str);
PHPDBG_G(oplog) = old;
- return FAILURE;
} else {
if (old) {
phpdbg_notice("Closing previously open oplog");
fclose(old);
}
phpdbg_notice("Successfully opened oplog %s", param->str);
-
- return SUCCESS;
}
- } else {
- phpdbg_error(
- "Unsupported parameter type (%s) for command", phpdbg_get_param_type(param TSRMLS_CC));
- return FAILURE;
- }
+ } break;
+
+ phpdbg_default_switch_case();
}
+
+ return SUCCESS;
} /* }}} */
static PHPDBG_COMMAND(help) /* {{{ */