static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */
{
- zend_hash_init(&PHPDBG_G(bp_files), 8, NULL, php_phpdbg_destroy_bp_file, 0);
- zend_hash_init(&PHPDBG_G(bp_symbols), 8, NULL, php_phpdbg_destroy_bp_symbol, 0);
- zend_hash_init(&PHPDBG_G(bp_oplines), 8, NULL, php_phpdbg_destroy_bp_opline, 0);
- zend_hash_init(&PHPDBG_G(bp_methods), 8, NULL, php_phpdbg_destroy_bp_methods, 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_OPLINE], 8, NULL, php_phpdbg_destroy_bp_opline, 0);
+ zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 8, NULL, php_phpdbg_destroy_bp_methods, 0);
return SUCCESS;
} /* }}} */
static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
{
- zend_hash_destroy(&PHPDBG_G(bp_files));
- zend_hash_destroy(&PHPDBG_G(bp_symbols));
- zend_hash_destroy(&PHPDBG_G(bp_oplines));
- zend_hash_destroy(&PHPDBG_G(bp_methods));
+ zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]);
+ zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]);
+ zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]);
+ zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]);
if (PHPDBG_G(exec)) {
efree(PHPDBG_G(exec));
instructs phpdbg to clear breakpoints */
static PHP_FUNCTION(phpdbg_clear)
{
- zend_hash_clean(&PHPDBG_G(bp_files));
- zend_hash_clean(&PHPDBG_G(bp_symbols));
- zend_hash_clean(&PHPDBG_G(bp_oplines));
- zend_hash_clean(&PHPDBG_G(bp_methods));
+ zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]);
+ zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]);
+ zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]);
+ zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]);
} /* }}} */
zend_function_entry phpdbg_user_functions[] = {
#define PHPDBG_NEXT 2
+/* {{{ tables */
+#define PHPDBG_BREAK_FILE 0
+#define PHPDBG_BREAK_SYM 1
+#define PHPDBG_BREAK_OPLINE 2
+#define PHPDBG_BREAK_METHOD 3
+#define PHPDBG_BREAK_TABLES 4 /* }}} */
+
/* {{{ flags */
#define PHPDBG_HAS_FILE_BP 0x00000001
#define PHPDBG_HAS_SYM_BP 0x00000010
typedef struct _phpdbg_command_t phpdbg_command_t;
ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
- HashTable bp_files; /* file breakpoints */
- HashTable bp_symbols; /* symbol breakpoints */
- HashTable bp_oplines; /* opline breakpoints */
- HashTable bp_methods; /* method breakpoints */
- char *exec; /* file to execute */
- size_t exec_len; /* size of exec */
- zend_op_array *ops; /* op_array */
- zval *retval; /* return value */
- int bp_count; /* breakpoint count */
- int vmret; /* return from last opcode handler execution */
- phpdbg_command_t *last; /* last command */
- const char *last_params; /* last expression */
- size_t last_params_len; /* last expression length */
- zend_ulong flags; /* phpdbg flags */
+ HashTable bp[PHPDBG_BREAK_TABLES]; /* break points */
+ char *exec; /* file to execute */
+ size_t exec_len; /* size of exec */
+ zend_op_array *ops; /* op_array */
+ zval *retval; /* return value */
+ int bp_count; /* breakpoint count */
+ int vmret; /* return from last opcode handler execution */
+ phpdbg_command_t *last; /* last command */
+ const char *last_params; /* last expression */
+ size_t last_params_len; /* last expression length */
+ zend_ulong flags; /* phpdbg flags */
ZEND_END_MODULE_GLOBALS(phpdbg)
#endif /* PHPDBG_H */
PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP;
- if (zend_hash_find(&PHPDBG_G(bp_files),
+ if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE],
new_break.filename, path_len, (void**)&break_files_ptr) == FAILURE) {
zend_llist break_files;
zend_llist_init(&break_files, sizeof(phpdbg_breakfile_t),
phpdbg_llist_breakfile_dtor, 0);
- zend_hash_update(&PHPDBG_G(bp_files),
+ zend_hash_update(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE],
new_break.filename, path_len, &break_files, sizeof(zend_llist),
(void**)&break_files_ptr);
}
{
size_t name_len = strlen(name);
- if (!zend_hash_exists(&PHPDBG_G(bp_symbols), name, name_len)) {
+ if (!zend_hash_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], name, name_len)) {
phpdbg_breaksymbol_t new_break;
PHPDBG_G(flags) |= PHPDBG_HAS_SYM_BP;
new_break.symbol = estrndup(name, name_len + 1);
new_break.id = PHPDBG_G(bp_count)++;
- zend_hash_update(&PHPDBG_G(bp_symbols), new_break.symbol,
+ zend_hash_update(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], new_break.symbol,
name_len, &new_break, sizeof(phpdbg_breaksymbol_t), NULL);
printf("[Breakpoint #%d added at %s]\n", new_break.id, new_break.symbol);
{
HashTable class_breaks, *class_table;
- if (zend_hash_find(&PHPDBG_G(bp_methods), class_name, class_len, (void**)&class_table) != SUCCESS) {
+ if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], class_name, class_len, (void**)&class_table) != SUCCESS) {
zend_hash_init(
&class_breaks, 8, NULL, phpdbg_class_breaks_dtor, 0);
zend_hash_update(
- &PHPDBG_G(bp_methods),
+ &PHPDBG_G(bp)[PHPDBG_BREAK_METHOD],
class_name, class_len,
(void**)&class_breaks, sizeof(HashTable), (void**)&class_table);
}
{
zend_ulong opline = strtoul(name, 0, 16);
- if (!zend_hash_index_exists(&PHPDBG_G(bp_oplines), opline)) {
+ if (!zend_hash_index_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], opline)) {
phpdbg_breakline_t new_break;
PHPDBG_G(flags) |= PHPDBG_HAS_OPLINE_BP;
new_break.opline = opline;
new_break.id = PHPDBG_G(bp_count)++;
- zend_hash_index_update(&PHPDBG_G(bp_oplines), opline, &new_break, sizeof(phpdbg_breakline_t), NULL);
+ zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], opline, &new_break, sizeof(phpdbg_breakline_t), NULL);
printf("[Breakpoint #%d added at %s]\n", new_break.id, new_break.name);
} else {
void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline TSRMLS_DC) /* {{{ */
{
- if (!zend_hash_index_exists(&PHPDBG_G(bp_oplines), (zend_ulong) opline)) {
+ if (!zend_hash_index_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (zend_ulong) opline)) {
phpdbg_breakline_t new_break;
PHPDBG_G(flags) |= PHPDBG_HAS_OPLINE_BP;
new_break.opline = (zend_ulong) opline;
new_break.id = PHPDBG_G(bp_count)++;
- zend_hash_index_update(&PHPDBG_G(bp_oplines), (zend_ulong) opline, &new_break, sizeof(phpdbg_breakline_t), NULL);
+ zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (zend_ulong) opline, &new_break, sizeof(phpdbg_breakline_t), NULL);
printf("[Breakpoint #%d added at %p]\n", new_break.id, (zend_op*) new_break.opline);
}
zend_llist *break_list;
zend_llist_element *le;
- if (zend_hash_find(&PHPDBG_G(bp_files), op_array->filename, name_len,
+ if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], op_array->filename, name_len,
(void**)&break_list) == FAILURE) {
return FAILURE;
}
fname = "main";
}
- if (zend_hash_find(&PHPDBG_G(bp_symbols), fname, strlen(fname),
+ if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], fname, strlen(fname),
(void**)&bp) == SUCCESS) {
printf("[Breakpoint #%d in %s() at %s:%u]\n", bp->id, bp->symbol,
zend_get_executed_filename(TSRMLS_C),
HashTable *class_table;
phpdbg_breakmethod_t *bp;
- if (zend_hash_find(&PHPDBG_G(bp_methods), ops->scope->name, ops->scope->name_length,
+ if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], ops->scope->name, ops->scope->name_length,
(void**)&class_table) == SUCCESS) {
if (zend_hash_find(
class_table,
{
phpdbg_breakline_t *bp;
- if (zend_hash_index_find(&PHPDBG_G(bp_oplines), (zend_ulong) opline,
+ if (zend_hash_index_find(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (zend_ulong) opline,
(void**)&bp) == SUCCESS) {
printf("[Breakpoint #%d in %s at %s:%u]\n", bp->id, bp->name,
zend_get_executed_filename(TSRMLS_C),
void phpdbg_clear_breakpoints(TSRMLS_D) /* {{{ */
{
- zend_hash_clean(&PHPDBG_G(bp_files));
- zend_hash_clean(&PHPDBG_G(bp_symbols));
- zend_hash_clean(&PHPDBG_G(bp_oplines));
- zend_hash_clean(&PHPDBG_G(bp_methods));
+ zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]);
+ zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]);
+ zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]);
+ zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]);
PHPDBG_G(flags) &= ~(PHPDBG_HAS_FILE_BP|PHPDBG_HAS_SYM_BP|PHPDBG_HAS_METHOD_BP|PHPDBG_HAS_OPLINE_BP);
PHPDBG_G(bp_count) = 0;
printf("--------------------------------------\n");
printf("File Break Point Information:\n");
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp_files), &position);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp_files), (void**) &points, &position) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp_files), &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_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position)) {
zend_llist_position lposition;
phpdbg_breakfile_t *brake;
printf("--------------------------------------\n");
printf("Symbol Break Point Information:\n");
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp_symbols), &position);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp_symbols), (void**) &points, &position) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp_symbols), &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**) &points, &position) == SUCCESS;
+ zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position)) {
zend_llist_position lposition;
phpdbg_breaksymbol_t *brake;
printf("--------------------------------------\n");
printf("Opline Break Point Information:\n");
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp_oplines), &position);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp_oplines), (void**) &brake, &position) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp_oplines), &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_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], &position)) {
printf("#%d\t%s\n", brake->id, brake->name);
}
}
printf("[\tFunctions: %d]\n", zend_hash_num_elements(EG(function_table)));
printf("[\tConstants: %d]\n", zend_hash_num_elements(EG(zend_constants)));
printf("[\tIncluded: %d]\n", zend_hash_num_elements(&EG(included_files)));
-
+
+ /* this is implicitly required */
+ if (PHPDBG_G(ops)) {
+ destroy_op_array(
+ PHPDBG_G(ops) TSRMLS_CC);
+ efree(PHPDBG_G(ops));
+ PHPDBG_G(ops) = NULL;
+ }
+
zend_hash_reverse_apply(EG(function_table), (apply_func_t) clean_non_persistent_function_full TSRMLS_CC);
zend_hash_reverse_apply(EG(class_table), (apply_func_t) clean_non_persistent_class_full TSRMLS_CC);
zend_hash_reverse_apply(EG(zend_constants), (apply_func_t) clean_non_persistent_constant_full TSRMLS_CC);
static PHPDBG_COMMAND(clear) /* {{{ */
{
printf("[Clearing Breakpoints:]\n");
- printf("[\tFile\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp_files)));
- printf("[\tSymbols\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp_symbols)));
- printf("[\tOplines\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp_oplines)));
- printf("[\tMethods\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp_methods)));
+ printf("[\tFile\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]));
+ printf("[\tSymbols\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]));
+ printf("[\tOplines\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]));
+ printf("[\tMethods\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]));
phpdbg_clear_breakpoints(TSRMLS_C);