mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
Merge branch 'master' of https://github.com/krakjoe/phpdbg
This commit is contained in:
parent
4e6a8eeffa
commit
02ae3f8de1
36
phpdbg.c
36
phpdbg.c
@ -78,7 +78,7 @@ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */
|
||||
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;
|
||||
} /* }}} */
|
||||
|
||||
@ -162,6 +162,7 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
|
||||
if (PHPDBG_G(prompt)[0]) {
|
||||
free(PHPDBG_G(prompt)[0]);
|
||||
}
|
||||
|
||||
if (PHPDBG_G(prompt)[1]) {
|
||||
free(PHPDBG_G(prompt)[1]);
|
||||
}
|
||||
@ -249,32 +250,32 @@ static PHP_FUNCTION(phpdbg_color)
|
||||
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);
|
||||
} /* }}} */
|
||||
|
||||
@ -565,19 +566,21 @@ int main(int argc, char **argv) /* {{{ */
|
||||
setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
|
||||
#endif
|
||||
|
||||
phpdbg_main:
|
||||
#ifdef ZTS
|
||||
tsrm_startup(1, 1, 0, NULL);
|
||||
|
||||
tsrm_ls = ts_resource(0);
|
||||
#endif
|
||||
|
||||
bp_tmp_file = malloc(L_tmpnam);
|
||||
tmpnam(bp_tmp_file);
|
||||
if (bp_tmp_file == NULL) {
|
||||
phpdbg_error("Unable to create temporary file");
|
||||
if (!cleaning) {
|
||||
bp_tmp_file = malloc(L_tmpnam);
|
||||
tmpnam(bp_tmp_file);
|
||||
if (bp_tmp_file == NULL) {
|
||||
phpdbg_error("Unable to create temporary file");
|
||||
}
|
||||
}
|
||||
|
||||
phpdbg_main:
|
||||
ini_entries = NULL;
|
||||
ini_entries_len = 0;
|
||||
ini_ignore = 0;
|
||||
@ -858,16 +861,15 @@ phpdbg_out:
|
||||
sapi_shutdown();
|
||||
}
|
||||
|
||||
#ifdef ZTS
|
||||
tsrm_shutdown();
|
||||
#endif
|
||||
|
||||
if (cleaning) {
|
||||
goto phpdbg_main;
|
||||
}
|
||||
|
||||
free(bp_tmp_file);
|
||||
|
||||
#ifdef ZTS
|
||||
/* bugggy */
|
||||
/* tsrm_shutdown(); */
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
} /* }}} */
|
||||
|
11
phpdbg.h
11
phpdbg.h
@ -112,11 +112,12 @@
|
||||
#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 */
|
||||
@ -137,7 +138,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
|
||||
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 */
|
||||
@ -151,10 +152,10 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
|
||||
|
||||
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) /* }}} */
|
||||
|
||||
|
40
phpdbg_bp.c
40
phpdbg_bp.c
@ -48,20 +48,20 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
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);
|
||||
@ -72,14 +72,14 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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)) {
|
||||
@ -106,36 +106,36 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */
|
||||
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) /* {{{ */
|
||||
@ -545,6 +545,10 @@ int phpdbg_find_conditional_breakpoint(TSRMLS_D) /* {{{ */
|
||||
|
||||
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)
|
||||
|
@ -234,7 +234,7 @@ PHPDBG_HELP(break) /* {{{ */
|
||||
phpdbg_writeln(EMPTY);
|
||||
phpdbg_writeln("\t%sbreak [address] 0x7ff68f570e08", phpdbg_get_prompt(TSRMLS_C));
|
||||
phpdbg_writeln("\t%sb [a] 0x7ff68f570e08", phpdbg_get_prompt(TSRMLS_C));
|
||||
phpdbg_writeln("\tWill break at the opline with the address provided (addresses are shown during execution)");
|
||||
phpdbg_writeln("\tWill break at the opline with the address provided");
|
||||
phpdbg_writeln(EMPTY);
|
||||
phpdbg_writeln("\t%sbreak [lineno] 200", phpdbg_get_prompt(TSRMLS_C));
|
||||
phpdbg_writeln("\t%sb [l] 200", phpdbg_get_prompt(TSRMLS_C));
|
||||
|
38
phpdbg_set.c
38
phpdbg_set.c
@ -41,16 +41,38 @@ PHPDBG_SET(prompt) /* {{{ */
|
||||
return SUCCESS;
|
||||
} /* }}} */
|
||||
|
||||
PHPDBG_SET(break) /* {{{ */
|
||||
{
|
||||
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]) {
|
||||
@ -58,16 +80,16 @@ PHPDBG_SET(color) /* {{{ */
|
||||
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);
|
||||
|
@ -27,11 +27,13 @@
|
||||
PHPDBG_SET(prompt);
|
||||
PHPDBG_SET(color);
|
||||
PHPDBG_SET(oplog);
|
||||
PHPDBG_SET(break);
|
||||
|
||||
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(break, "usage: set break <on|off>", 'b', set_break, NULL, 0),
|
||||
PHPDBG_END_COMMAND
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user