mirror of
https://github.com/php/php-src.git
synced 2026-03-29 19:52:20 +02:00
- Removed name member to opline breakpoints
This commit is contained in:
51
phpdbg.c
51
phpdbg.c
@@ -58,11 +58,6 @@ static void php_phpdbg_destroy_bp_symbol(void *brake) /* {{{ */
|
||||
efree((char*)((phpdbg_breaksymbol_t*)brake)->symbol);
|
||||
} /* }}} */
|
||||
|
||||
static void php_phpdbg_destroy_bp_opline(void *brake) /* {{{ */
|
||||
{
|
||||
free((char*)((phpdbg_breakline_t*)brake)->name);
|
||||
} /* }}} */
|
||||
|
||||
static void php_phpdbg_destroy_bp_methods(void *brake) /* {{{ */
|
||||
{
|
||||
zend_hash_destroy((HashTable*)brake);
|
||||
@@ -72,9 +67,9 @@ 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_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_OPLINE], 8, NULL, NULL, 0);
|
||||
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 8, NULL, php_phpdbg_destroy_bp_methods, 0);
|
||||
|
||||
|
||||
return SUCCESS;
|
||||
} /* }}} */
|
||||
|
||||
@@ -84,7 +79,7 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
|
||||
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));
|
||||
}
|
||||
@@ -97,12 +92,12 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
|
||||
} /* }}} */
|
||||
|
||||
/* {{{ proto void phpdbg_break(void)
|
||||
instructs phpdbg to insert a breakpoint at the next opcode */
|
||||
instructs phpdbg to insert a breakpoint at the next opcode */
|
||||
static PHP_FUNCTION(phpdbg_break)
|
||||
{
|
||||
if (EG(current_execute_data) && EG(active_op_array)) {
|
||||
zend_ulong opline_num = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes);
|
||||
|
||||
|
||||
phpdbg_set_breakpoint_opline_ex(
|
||||
&EG(active_op_array)->opcodes[opline_num+1] TSRMLS_CC);
|
||||
}
|
||||
@@ -206,7 +201,7 @@ static void php_sapi_phpdbg_register_vars(zval *track_vars_array TSRMLS_DC) /* {
|
||||
if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_NAME", &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) {
|
||||
php_register_variable("SCRIPT_NAME", PHPDBG_G(exec), track_vars_array TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_FILENAME", &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) {
|
||||
php_register_variable("SCRIPT_FILENAME", PHPDBG_G(exec), track_vars_array TSRMLS_CC);
|
||||
}
|
||||
@@ -214,7 +209,7 @@ static void php_sapi_phpdbg_register_vars(zval *track_vars_array TSRMLS_DC) /* {
|
||||
php_register_variable("PATH_TRANSLATED", PHPDBG_G(exec), track_vars_array TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* any old docroot will doo */
|
||||
len = 0U;
|
||||
if (sapi_module.input_filter(PARSE_SERVER, "DOCUMENT_ROOT", &docroot, len, &len TSRMLS_CC)) {
|
||||
@@ -302,7 +297,7 @@ int main(int argc, char *argv[]) /* {{{ */
|
||||
char *php_optarg = NULL;
|
||||
int php_optind = 1;
|
||||
int opt;
|
||||
|
||||
|
||||
#ifdef ZTS
|
||||
void ***tsrm_ls;
|
||||
#endif
|
||||
@@ -319,7 +314,7 @@ int main(int argc, char *argv[]) /* {{{ */
|
||||
|
||||
tsrm_ls = ts_resource(0);
|
||||
#endif
|
||||
|
||||
|
||||
while ((opt = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
@@ -363,7 +358,7 @@ int main(int argc, char *argv[]) /* {{{ */
|
||||
case 'z':
|
||||
zend_load_extension(php_optarg);
|
||||
break;
|
||||
|
||||
|
||||
case 'e': /* set execution context */
|
||||
exec_len = strlen(php_optarg);
|
||||
if (exec_len) {
|
||||
@@ -374,11 +369,11 @@ int main(int argc, char *argv[]) /* {{{ */
|
||||
case 'v': /* set quietness off */
|
||||
flags &= ~PHPDBG_IS_QUIET;
|
||||
break;
|
||||
|
||||
|
||||
case 's': /* set stepping on */
|
||||
flags |= PHPDBG_IS_STEPPING;
|
||||
break;
|
||||
|
||||
|
||||
case 'b': /* set colours off */
|
||||
flags &= ~PHPDBG_IS_COLOURED;
|
||||
break;
|
||||
@@ -394,7 +389,7 @@ int main(int argc, char *argv[]) /* {{{ */
|
||||
phpdbg->executable_location = argv[0];
|
||||
phpdbg->phpinfo_as_text = 1;
|
||||
phpdbg->php_ini_ignore = 0;
|
||||
|
||||
|
||||
if (ini_entries) {
|
||||
ini_entries = realloc(ini_entries, ini_entries_len + sizeof(phpdbg_ini_hardcoded));
|
||||
memmove(ini_entries + sizeof(phpdbg_ini_hardcoded) - 2, ini_entries, ini_entries_len + 1);
|
||||
@@ -404,9 +399,9 @@ int main(int argc, char *argv[]) /* {{{ */
|
||||
memcpy(ini_entries, phpdbg_ini_hardcoded, sizeof(phpdbg_ini_hardcoded));
|
||||
}
|
||||
ini_entries_len += sizeof(phpdbg_ini_hardcoded) - 2;
|
||||
|
||||
|
||||
phpdbg->ini_entries = ini_entries;
|
||||
|
||||
|
||||
if (phpdbg->startup(phpdbg) == SUCCESS) {
|
||||
zend_activate(TSRMLS_C);
|
||||
|
||||
@@ -421,35 +416,35 @@ int main(int argc, char *argv[]) /* {{{ */
|
||||
if (exec) { /* set execution context */
|
||||
PHPDBG_G(exec) = estrndup(exec, exec_len);
|
||||
PHPDBG_G(exec_len) = exec_len;
|
||||
|
||||
|
||||
free(exec);
|
||||
}
|
||||
|
||||
|
||||
/* set flags from command line */
|
||||
PHPDBG_G(flags) = flags;
|
||||
|
||||
|
||||
zend_try {
|
||||
zend_activate_modules(TSRMLS_C);
|
||||
} zend_end_try();
|
||||
|
||||
|
||||
/* print blurb */
|
||||
printf(
|
||||
"%sWelcome to phpdbg, the interactive PHP debugger, v%s%s\n",
|
||||
"%sWelcome to phpdbg, the interactive PHP debugger, v%s%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C), PHPDBG_VERSION, PHPDBG_END_LINE(TSRMLS_C));
|
||||
printf(
|
||||
"[To get help using phpdbg type \"help\" and press enter\n");
|
||||
printf(
|
||||
"%sPlease report bugs to <%s>%s\n",
|
||||
"%sPlease report bugs to <%s>%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C), PHPDBG_ISSUES, PHPDBG_END_LINE(TSRMLS_C));
|
||||
|
||||
do {
|
||||
zend_try {
|
||||
phpdbg_interactive(TSRMLS_C);
|
||||
} zend_catch {
|
||||
|
||||
|
||||
} zend_end_try();
|
||||
} while(!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING));
|
||||
|
||||
|
||||
if (ini_entries) {
|
||||
free(ini_entries);
|
||||
}
|
||||
|
||||
63
phpdbg_bp.c
63
phpdbg_bp.c
@@ -68,8 +68,8 @@ void phpdbg_set_breakpoint_file(const char *path, long line_num TSRMLS_DC) /* {{
|
||||
zend_llist_add_element(break_files_ptr, &new_break);
|
||||
|
||||
printf(
|
||||
"%sBreakpoint #%d added at %s:%ld%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
"%sBreakpoint #%d added at %s:%ld%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
new_break.id, new_break.filename, new_break.line,
|
||||
PHPDBG_END_LINE(TSRMLS_C));
|
||||
} /* }}} */
|
||||
@@ -90,13 +90,13 @@ void phpdbg_set_breakpoint_symbol(const char *name TSRMLS_DC) /* {{{ */
|
||||
name_len, &new_break, sizeof(phpdbg_breaksymbol_t), NULL);
|
||||
|
||||
printf(
|
||||
"%sBreakpoint #%d added at %s%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
"%sBreakpoint #%d added at %s%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
new_break.id, new_break.symbol,
|
||||
PHPDBG_END_LINE(TSRMLS_C));
|
||||
} else {
|
||||
printf(
|
||||
"%sBreakpoint exists at %s%s\n",
|
||||
"%sBreakpoint exists at %s%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C), name, PHPDBG_END_LINE(TSRMLS_C));
|
||||
}
|
||||
} /* }}} */
|
||||
@@ -112,8 +112,8 @@ void phpdbg_set_breakpoint_method(const char* class_name,
|
||||
zend_hash_init(
|
||||
&class_breaks, 8, NULL, phpdbg_class_breaks_dtor, 0);
|
||||
zend_hash_update(
|
||||
&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD],
|
||||
class_name, class_len,
|
||||
&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD],
|
||||
class_name, class_len,
|
||||
(void**)&class_breaks, sizeof(HashTable), (void**)&class_table);
|
||||
}
|
||||
|
||||
@@ -130,42 +130,40 @@ void phpdbg_set_breakpoint_method(const char* class_name,
|
||||
|
||||
zend_hash_update(class_table, func_name, func_len, &new_break, sizeof(phpdbg_breakmethod_t), NULL);
|
||||
printf(
|
||||
"%sBreakpoint #%d added at %s::%s%s\n",
|
||||
"%sBreakpoint #%d added at %s::%s%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
new_break.id, class_name, func_name,
|
||||
PHPDBG_END_LINE(TSRMLS_C));
|
||||
} else {
|
||||
printf(
|
||||
"%sBreakpoint exists at %s::%s%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
class_name, func_name,
|
||||
"%sBreakpoint exists at %s::%s%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
class_name, func_name,
|
||||
PHPDBG_END_LINE(TSRMLS_C));
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
void phpdbg_set_breakpoint_opline(const char *name TSRMLS_DC) /* {{{ */
|
||||
void phpdbg_set_breakpoint_opline(zend_ulong opline TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zend_ulong opline = strtoul(name, 0, 16);
|
||||
|
||||
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.name = strdup(name);
|
||||
new_break.name = NULL;
|
||||
new_break.opline = opline;
|
||||
new_break.id = PHPDBG_G(bp_count)++;
|
||||
|
||||
zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], opline, &new_break, sizeof(phpdbg_breakline_t), NULL);
|
||||
|
||||
printf("%sBreakpoint #%d added at %s%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
new_break.id, new_break.name,
|
||||
printf("%sBreakpoint #%d added at %#lx%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
new_break.id, new_break.opline,
|
||||
PHPDBG_END_LINE(TSRMLS_C));
|
||||
} else {
|
||||
printf(
|
||||
"%sBreakpoint exists at %s%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C), name, PHPDBG_END_LINE(TSRMLS_C));
|
||||
"%sBreakpoint exists at %#lx%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C), opline, PHPDBG_END_LINE(TSRMLS_C));
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
@@ -176,18 +174,15 @@ void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline TSRMLS_DC) /* {{
|
||||
|
||||
PHPDBG_G(flags) |= PHPDBG_HAS_OPLINE_BP;
|
||||
|
||||
asprintf(
|
||||
(char**)&new_break.name, "%p", (zend_op*) opline);
|
||||
|
||||
new_break.opline = (zend_ulong) opline;
|
||||
new_break.id = PHPDBG_G(bp_count)++;
|
||||
|
||||
zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (zend_ulong) opline, &new_break, sizeof(phpdbg_breakline_t), NULL);
|
||||
|
||||
printf(
|
||||
"%sBreakpoint #%d added at %p%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
new_break.id, (zend_op*) new_break.opline,
|
||||
"%sBreakpoint #%d added at %#lx%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
new_break.id, new_break.opline,
|
||||
PHPDBG_END_LINE(TSRMLS_C));
|
||||
}
|
||||
} /* }}} */
|
||||
@@ -207,8 +202,8 @@ int phpdbg_find_breakpoint_file(zend_op_array *op_array TSRMLS_DC) /* {{{ */
|
||||
const phpdbg_breakfile_t *bp = (phpdbg_breakfile_t*)le->data;
|
||||
|
||||
if (bp->line == (*EG(opline_ptr))->lineno) {
|
||||
printf("%sBreakpoint #%d at %s:%ld%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
printf("%sBreakpoint #%d at %s:%ld%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
bp->id, bp->filename, bp->line,
|
||||
PHPDBG_END_LINE(TSRMLS_C));
|
||||
return SUCCESS;
|
||||
@@ -244,7 +239,7 @@ int phpdbg_find_breakpoint_symbol(zend_function *fbc TSRMLS_DC) /* {{{ */
|
||||
|
||||
if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], fname, strlen(fname),
|
||||
(void**)&bp) == SUCCESS) {
|
||||
printf("%sBreakpoint #%d in %s() at %s:%u%s\n",
|
||||
printf("%sBreakpoint #%d in %s() at %s:%u%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
bp->id, bp->symbol,
|
||||
zend_get_executed_filename(TSRMLS_C),
|
||||
@@ -261,7 +256,7 @@ int phpdbg_find_breakpoint_method(zend_op_array *ops TSRMLS_DC) /* {{{ */
|
||||
HashTable *class_table;
|
||||
phpdbg_breakmethod_t *bp;
|
||||
|
||||
if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 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,
|
||||
@@ -269,7 +264,7 @@ int phpdbg_find_breakpoint_method(zend_op_array *ops TSRMLS_DC) /* {{{ */
|
||||
strlen(ops->function_name), (void**)&bp) == SUCCESS) {
|
||||
|
||||
printf(
|
||||
"%sBreakpoint #%d in %s::%s() at %s:%u%s\n",
|
||||
"%sBreakpoint #%d in %s::%s() at %s:%u%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
bp->id, bp->class_name, bp->func_name,
|
||||
zend_get_executed_filename(TSRMLS_C),
|
||||
@@ -288,9 +283,9 @@ int phpdbg_find_breakpoint_opline(phpdbg_opline_ptr_t opline TSRMLS_DC) /* {{{ *
|
||||
|
||||
if (zend_hash_index_find(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (zend_ulong) opline,
|
||||
(void**)&bp) == SUCCESS) {
|
||||
printf("%sBreakpoint #%d in %s at %s:%u%s\n",
|
||||
printf("%sBreakpoint #%d in %#lx at %s:%u%s\n",
|
||||
PHPDBG_BOLD_LINE(TSRMLS_C),
|
||||
bp->id, bp->name,
|
||||
bp->id, bp->opline,
|
||||
zend_get_executed_filename(TSRMLS_C),
|
||||
zend_get_executed_lineno(TSRMLS_C),
|
||||
PHPDBG_END_LINE(TSRMLS_C));
|
||||
@@ -307,7 +302,7 @@ void phpdbg_clear_breakpoints(TSRMLS_D) /* {{{ */
|
||||
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_BP_MASK;
|
||||
|
||||
PHPDBG_G(bp_count) = 0;
|
||||
|
||||
@@ -63,7 +63,7 @@ typedef struct _phpdbg_breakline_t {
|
||||
void phpdbg_set_breakpoint_file(const char*, long TSRMLS_DC);
|
||||
void phpdbg_set_breakpoint_symbol(const char* TSRMLS_DC);
|
||||
void phpdbg_set_breakpoint_method(const char*, size_t, const char*, size_t TSRMLS_DC);
|
||||
void phpdbg_set_breakpoint_opline(const char* TSRMLS_DC);
|
||||
void phpdbg_set_breakpoint_opline(zend_ulong TSRMLS_DC);
|
||||
void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t TSRMLS_DC);
|
||||
|
||||
int phpdbg_find_breakpoint_file(zend_op_array* TSRMLS_DC);
|
||||
|
||||
@@ -383,7 +383,9 @@ static PHPDBG_COMMAND(break) /* {{{ */
|
||||
}
|
||||
} else {
|
||||
if (phpdbg_is_addr(expr)) {
|
||||
phpdbg_set_breakpoint_opline(expr TSRMLS_CC);
|
||||
zend_ulong opline = strtoul(expr, 0, 16);
|
||||
|
||||
phpdbg_set_breakpoint_opline(opline TSRMLS_CC);
|
||||
} else if (phpdbg_is_numeric(expr)) {
|
||||
const char *filename = zend_get_executed_filename(TSRMLS_C);
|
||||
long line_num = strtol(expr, NULL, 0);
|
||||
|
||||
Reference in New Issue
Block a user