return SUCCESS;
} /* }}} */
-static void php_phpdbg_destroy_bp_file(void *brake) /* {{{ */
+static void php_phpdbg_destroy_bp_file(zval *brake) /* {{{ */
{
- zend_hash_destroy((HashTable*)brake);
+ zend_hash_destroy((HashTable*)Z_PTR_P(brake));
} /* }}} */
-static void php_phpdbg_destroy_bp_symbol(void *brake) /* {{{ */
+static void php_phpdbg_destroy_bp_symbol(zval *brake) /* {{{ */
{
- efree((char*)((phpdbg_breaksymbol_t*)brake)->symbol);
+ efree((char*)((phpdbg_breaksymbol_t*)Z_PTR_P(brake))->symbol);
} /* }}} */
-static void php_phpdbg_destroy_bp_opcode(void *brake) /* {{{ */
+static void php_phpdbg_destroy_bp_opcode(zval *brake) /* {{{ */
{
- efree((char*)((phpdbg_breakop_t*)brake)->name);
+ efree((char*)((phpdbg_breakop_t*)Z_PTR_P(brake))->name);
} /* }}} */
-
-static void php_phpdbg_destroy_bp_methods(void *brake) /* {{{ */
+static void php_phpdbg_destroy_bp_methods(zval *brake) /* {{{ */
{
- zend_hash_destroy((HashTable*)brake);
+ zend_hash_destroy((HashTable*)Z_PTR_P(brake));
} /* }}} */
-static void php_phpdbg_destroy_bp_condition(void *data) /* {{{ */
+static void php_phpdbg_destroy_bp_condition(zval *data) /* {{{ */
{
- phpdbg_breakcond_t *brake = (phpdbg_breakcond_t*) data;
+ phpdbg_breakcond_t *brake = (phpdbg_breakcond_t*)Z_PTR_P(data);
if (brake) {
if (brake->ops) {
}
} /* }}} */
-static void php_phpdbg_destroy_registered(void *data) /* {{{ */
+static void php_phpdbg_destroy_registered(zval *data) /* {{{ */
{
- zend_function *function = (zend_function*) data;
+ zend_function *function = (zend_function*)Z_PTR_P(data);
TSRMLS_FETCH();
destroy_zend_function(
static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */
{
- zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0);
+ zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0);
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], 8, NULL, php_phpdbg_destroy_bp_symbol, 0);
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0);
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0);
if (VCWD_STAT(exec, &sb) != FAILURE) {
if (sb.st_mode & (S_IFREG|S_IFLNK)) {
if (PHPDBG_G(exec)) {
- ZVAL_STRINGL(return_value, PHPDBG_G(exec), PHPDBG_G(exec_len), 1);
+ ZVAL_STRINGL(return_value, PHPDBG_G(exec), PHPDBG_G(exec_len));
efree(PHPDBG_G(exec));
result = 0;
}
/* overwriteable ini defaults must be set in phpdbg_ini_defaults() */
#define INI_DEFAULT(name, value) \
Z_SET_REFCOUNT(tmp, 0); \
- Z_UNSET_ISREF(tmp); \
- ZVAL_STRINGL(&tmp, zend_strndup(value, sizeof(value)-1), sizeof(value)-1, 0); \
- zend_hash_update(configuration_hash, name, sizeof(name), &tmp, sizeof(zval), NULL);
+ ZVAL_STRINGL(&tmp, value, sizeof(value) - 1); \
+ zend_hash_str_update(configuration_hash, name, sizeof(name) - 1, &tmp);
void phpdbg_ini_defaults(HashTable *configuration_hash) /* {{{ */
{
char *exec; /* file to execute */
size_t exec_len; /* size of exec */
zend_op_array *ops; /* op_array */
- zval *retval; /* return value */
+ zval retval; /* return value */
int bp_count; /* breakpoint count */
int vmret; /* return from last opcode handler execution */
phpdbg_writeln("Note: arguments passed as strings, return (if present) print_r'd on console");
if (zend_hash_num_elements(&PHPDBG_G(registered))) {
HashPosition position;
- char *name = NULL;
- zend_uint name_len = 0;
+ zend_string *name;
phpdbg_notice("Registered Functions (%d)", zend_hash_num_elements(&PHPDBG_G(registered)));
for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(registered), &position);
- zend_hash_get_current_key_ex(&PHPDBG_G(registered), &name, &name_len, NULL, 1, &position) == HASH_KEY_IS_STRING;
+ zend_hash_get_current_key_ex(&PHPDBG_G(registered), &name, NULL, 1, &position) == HASH_KEY_IS_STRING;
zend_hash_move_forward_ex(&PHPDBG_G(registered), &position)) {
- phpdbg_writeln("|-------> %s", name);
- efree(name);
+ phpdbg_writeln("|-------> %s", name->val);
+ STR_RELEASE(name);
}
}
if (method->common.scope) {
phpdbg_writeln("\tL%d-%d %s::%s() %s",
op_array->line_start, op_array->line_end,
- method->common.scope->name,
- method->common.function_name,
- op_array->filename ? op_array->filename : "unknown");
+ method->common.scope->name->val,
+ method->common.function_name->val,
+ op_array->filename ? op_array->filename->val : "unknown");
} else {
phpdbg_writeln("\tL%d-%d %s() %s",
method->common.function_name ? op_array->line_start : 0,
method->common.function_name ? op_array->line_end : 0,
- method->common.function_name ? method->common.function_name : "{main}",
- op_array->filename ? op_array->filename : "unknown");
+ method->common.function_name ? method->common.function_name->val : "{main}",
+ op_array->filename ? op_array->filename->val : "unknown");
}
zend_hash_init(&vars, op_array->last, NULL, NULL, 0);
default: {
if (method->common.scope) {
- phpdbg_writeln("\tInternal %s::%s()", method->common.scope->name, method->common.function_name);
+ phpdbg_writeln("\tInternal %s::%s()", method->common.scope->name->val, method->common.function_name->val);
} else {
- phpdbg_writeln("\tInternal %s()", method->common.function_name);
+ phpdbg_writeln("\tInternal %s()", method->common.function_name->val);
}
}
}
if (EG(in_execution) && ops) {
if (ops->function_name) {
if (ops->scope) {
- phpdbg_notice("Stack in %s::%s()", ops->scope->name, ops->function_name);
+ phpdbg_notice("Stack in %s::%s()", ops->scope->name->val, ops->function_name->val);
} else {
- phpdbg_notice("Stack in %s()", ops->function_name);
+ phpdbg_notice("Stack in %s()", ops->function_name->val);
}
} else {
if (ops->filename) {
- phpdbg_notice("Stack in %s", ops->filename);
+ phpdbg_notice("Stack in %s", ops->filename->val);
} else {
phpdbg_notice("Stack @ %p", ops);
}
PHPDBG_PRINT(class) /* {{{ */
{
- zend_class_entry **ce;
+ zend_class_entry *ce;
switch (param->type) {
case STR_PARAM: {
- if (zend_lookup_class(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) {
+ zval tmp; /* param->str need to be zend_string later */
+ ZVAL_STRINGL(&tmp, param->str, param->len);
+ if ((ce = zend_lookup_class(Z_STR(tmp) TSRMLS_CC)) != NULL) {
+ zval_ptr_dtor(&tmp);
phpdbg_notice("%s %s: %s",
- ((*ce)->type == ZEND_USER_CLASS) ?
+ (ce->type == ZEND_USER_CLASS) ?
"User" : "Internal",
- ((*ce)->ce_flags & ZEND_ACC_INTERFACE) ?
+ (ce->ce_flags & ZEND_ACC_INTERFACE) ?
"Interface" :
- ((*ce)->ce_flags & ZEND_ACC_ABSTRACT) ?
+ (ce->ce_flags & ZEND_ACC_ABSTRACT) ?
"Abstract Class" :
"Class",
- (*ce)->name);
+ *ce->name->val);
- phpdbg_writeln("Methods (%d):", zend_hash_num_elements(&(*ce)->function_table));
- if (zend_hash_num_elements(&(*ce)->function_table)) {
+ phpdbg_writeln("Methods (%d):", zend_hash_num_elements(&ce->function_table));
+ if (zend_hash_num_elements(&ce->function_table)) {
HashPosition position;
zend_function *method;
- for (zend_hash_internal_pointer_reset_ex(&(*ce)->function_table, &position);
- zend_hash_get_current_data_ex(&(*ce)->function_table, (void**) &method, &position) == SUCCESS;
- zend_hash_move_forward_ex(&(*ce)->function_table, &position)) {
+ for (zend_hash_internal_pointer_reset_ex(&ce->function_table, &position);
+ (method = zend_hash_get_current_data_ptr_ex(&ce->function_table, &position)) != NULL;
+ zend_hash_move_forward_ex(&ce->function_table, &position)) {
phpdbg_print_function_helper(method TSRMLS_CC);
}
}
} else {
phpdbg_error("The class %s could not be found", param->str);
+ zval_ptr_dtor(&tmp);
}
} break;
{
switch (param->type) {
case METHOD_PARAM: {
- zend_class_entry **ce;
+ zend_class_entry *ce;
+ zval tmp;
- if (zend_lookup_class(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) {
+ ZVAL_STRING(&tmp, param->method.class);
+ if ((ce = zend_lookup_class(Z_STR(tmp) TSRMLS_CC)) != NULL) {
zend_function *fbc;
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**)&fbc) == SUCCESS) {
+ zval_ptr_dtor(&tmp);
+
+ if ((fbc = zend_hash_str_find_ptr(&ce->function_table, lcname, strlen(lcname))) != NULL) {
phpdbg_notice("%s Method %s",
(fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal",
fbc->common.function_name);
efree(lcname);
} else {
+ zval_ptr_dtor(&tmp);
phpdbg_error("The class %s could not be found", param->method.class);
}
} break;
lcname = zend_str_tolower_dup(func_name, func_name_len);
- if (zend_hash_find(func_table, lcname, strlen(lcname)+1, (void**)&fbc) == SUCCESS) {
+ if ((fbc = zend_hash_str_find_ptr(func_table, lcname, strlen(lcname))) != NULL) {
phpdbg_notice("%s %s %s",
(fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal",
(fbc->common.scope) ? "Method" : "Function",
- fbc->common.function_name);
+ fbc->common.function_name->val);
phpdbg_print_function_helper(fbc TSRMLS_CC);
} else {
{
phpdbg_input_t *function = input->argv[0];
- if (zend_hash_exists(
- &PHPDBG_G(registered), function->string, function->length+1)) {
+ if (zend_hash_str_exists(
+ &PHPDBG_G(registered), function->string, function->length)) {
- zval fname, *fretval;
+ zval fretval;
zend_fcall_info fci;
- ZVAL_STRINGL(&fname, function->string, function->length, 1);
-
memset(&fci, 0, sizeof(zend_fcall_info));
fci.size = sizeof(zend_fcall_info);
fci.function_table = &PHPDBG_G(registered);
- fci.function_name = &fname;
+ ZVAL_STRINGL(&fci.function_name, function->string, function->length);
fci.symbol_table = EG(active_symbol_table);
fci.object_ptr = NULL;
- fci.retval_ptr_ptr = &fretval;
+ fci.retval = &fretval;
fci.no_separation = 1;
if (input->argc > 1) {
zend_call_function(&fci, NULL TSRMLS_CC);
- if (fretval) {
+ if (!ZVAL_IS_UNDEF(&fretval)) {
zend_print_zval_r(
- fretval, 0 TSRMLS_CC);
+ &fretval, 0 TSRMLS_CC);
phpdbg_writeln(EMPTY);
}
- zval_dtor(&fname);
+ zval_ptr_dtor(&fci.function_name);
return SUCCESS;
}
for (next = self; next < EG(active_op_array)->last; next++) {
if (EG(active_op_array)->opcodes[next].lineno != opline->lineno) {
- zend_hash_index_update(
+ zend_hash_index_update_mem(
&PHPDBG_G(seek),
(zend_ulong) &EG(active_op_array)->opcodes[next],
- &EG(active_op_array)->opcodes[next],
- sizeof(zend_op), NULL);
+ (void *)&EG(active_op_array)->opcodes[next],
+ sizeof(zend_op));
break;
}
}
#ifdef ZEND_YIELD
case ZEND_YIELD:
#endif
- zend_hash_index_update(
+ zend_hash_index_update_mem(
&PHPDBG_G(seek),
(zend_ulong) &EG(active_op_array)->opcodes[next],
- &EG(active_op_array)->opcodes[next],
- sizeof(zend_op), NULL);
+ (void *)&EG(active_op_array)->opcodes[next],
+ sizeof(zend_op));
break;
}
}
#ifdef ZEND_YIELD
case ZEND_YIELD:
#endif
- zend_hash_index_update(
+ zend_hash_index_update_mem(
&PHPDBG_G(seek),
(zend_ulong) &EG(active_op_array)->opcodes[next],
- &EG(active_op_array)->opcodes[next],
- sizeof(zend_op), NULL);
+ (void *)&EG(active_op_array)->opcodes[next],
+ sizeof(zend_op));
break;
}
}
{
zend_fcall_info fci;
- zval fname,
- *trace,
+ zval trace,
exception;
/* get filename and linenumber before unsetting exception */
zend_uint lineno = zend_get_executed_lineno(TSRMLS_C);
/* copy exception */
- exception = *EG(exception);
- zval_copy_ctor(&exception);
+ ZVAL_OBJ(&exception, EG(exception));
EG(exception) = NULL;
phpdbg_error(
"Uncaught %s!",
- Z_OBJCE(exception)->name);
+ Z_OBJCE(exception)->name->val);
/* call __toString */
- ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring")-1, 1);
fci.size = sizeof(fci);
fci.function_table = &Z_OBJCE(exception)->function_table;
- fci.function_name = &fname;
+ ZVAL_STRINGL(&fci.function_name, "__tostring", sizeof("__tostring") - 1);
fci.symbol_table = NULL;
fci.object_ptr = &exception;
- fci.retval_ptr_ptr = &trace;
+ fci.retval = &trace;
fci.param_count = 0;
fci.params = NULL;
fci.no_separation = 1;
zend_call_function(&fci, NULL TSRMLS_CC);
- if (trace) {
+ if (!ZVAL_IS_UNDEF(&trace) && Z_TYPE(trace) == IS_STRING) {
phpdbg_writeln(
- "Uncaught %s", Z_STRVAL_P(trace));
+ "Uncaught %s", Z_STRVAL(trace));
/* remember to dtor trace */
zval_ptr_dtor(&trace);
}
+ zval_ptr_dtor(&trace);
/* output useful information about address */
phpdbg_writeln(
"Stacked entered at %p in %s on line %u",
EG(active_op_array)->opcodes, filename, lineno);
- zval_dtor(&fname);
zval_dtor(&exception);
} /* }}} */
if (PHPDBG_G(ops) || PHPDBG_G(exec)) {
zend_op **orig_opline = EG(opline_ptr);
zend_op_array *orig_op_array = EG(active_op_array);
- zval **orig_retval_ptr = EG(return_value_ptr_ptr);
zend_bool restore = 1;
if (!PHPDBG_G(ops)) {
}
EG(active_op_array) = PHPDBG_G(ops);
- EG(return_value_ptr_ptr) = &PHPDBG_G(retval);
if (!EG(active_symbol_table)) {
zend_rebuild_symbol_table(TSRMLS_C);
}
zend_try {
php_output_activate(TSRMLS_C);
PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE;
- zend_execute(EG(active_op_array) TSRMLS_CC);
+ zend_execute(EG(active_op_array), &PHPDBG_G(retval) TSRMLS_CC);
PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE;
php_output_deactivate(TSRMLS_C);
} zend_catch {
EG(active_op_array) = orig_op_array;
EG(opline_ptr) = orig_opline;
- EG(return_value_ptr_ptr) = orig_retval_ptr;
if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
phpdbg_error("Caught exit/error from VM");
EG(active_op_array) = orig_op_array;
EG(opline_ptr) = orig_opline;
- EG(return_value_ptr_ptr) = orig_retval_ptr;
}
} else {
phpdbg_error("Nothing to execute!");
char *lcname = zend_str_tolower_dup(param->str, param->len);
size_t lcname_len = strlen(lcname);
- if (!zend_hash_exists(&PHPDBG_G(registered), lcname, lcname_len+1)) {
- if (zend_hash_find(EG(function_table), lcname, lcname_len+1, (void**) &function) == SUCCESS) {
- zend_hash_update(
- &PHPDBG_G(registered), lcname, lcname_len+1, (void*)&function, sizeof(zend_function), NULL);
+ if (!zend_hash_str_exists(&PHPDBG_G(registered), lcname, lcname_len)) {
+ if ((function = zend_hash_str_find_ptr(EG(function_table), lcname, lcname_len)) != NULL) {
+ zend_hash_str_update_mem(
+ &PHPDBG_G(registered), lcname, lcname_len, function, sizeof(zend_function));
function_add_ref(function);
phpdbg_notice(
}
} /* }}} */
-static inline zend_execute_data *phpdbg_create_execute_data(zend_op_array *op_array, zend_bool nested TSRMLS_DC) /* {{{ */
+static inline zend_execute_data *phpdbg_create_execute_data(zend_op_array *op_array, zval *return_value, zend_bool nested TSRMLS_DC) /* {{{ */
{
#if PHP_VERSION_ID >= 50500
- return zend_create_execute_data_from_op_array(op_array, nested TSRMLS_CC);
+ return zend_create_execute_data_from_op_array(op_array, return_value, nested TSRMLS_CC);
#else
#undef EX
} /* }}} */
#if PHP_VERSION_ID >= 50500
-void phpdbg_execute_ex(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */
+void phpdbg_execute_ex(zend_execute_data *execute_data, zval *return_value TSRMLS_DC) /* {{{ */
{
#else
void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC) /* {{{ */
#if PHP_VERSION_ID >= 50500
if (0) {
zend_vm_enter:
- execute_data = phpdbg_create_execute_data(EG(active_op_array), 1 TSRMLS_CC);
+ execute_data = phpdbg_create_execute_data(EG(active_op_array), return_value, 1 TSRMLS_CC);
}
zend_hash_init(&vars, EG(active_op_array)->last, NULL, NULL, 0);
#else
/* {{{ */
#if PHP_VERSION_ID >= 50500
-void phpdbg_execute_ex(zend_execute_data *execute_data TSRMLS_DC);
+void phpdbg_execute_ex(zend_execute_data *execute_data, zval *return_value TSRMLS_DC);
#else
void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC);
#endif /* }}} */