Commit: 02ae3f8de1799d5ae4a6fa2cc86a34acb4767e9c
Author: Bob Weinand <bobw...@hotmail.com> Mon, 25 Nov 2013 23:45:55
+0100
Parents: 4e6a8eeffa4cdec4b75303788e676468fdf6129e
Branches: PHP-5.6
Link:
http://git.php.net/?p=php-src.git;a=commitdiff;h=02ae3f8de1799d5ae4a6fa2cc86a34acb4767e9c
Log:
Merge branch 'master' of https://github.com/krakjoe/phpdbg
Changed paths:
M phpdbg.c
M phpdbg.h
M phpdbg_bp.c
M phpdbg_help.c
M phpdbg_set.c
M phpdbg_set.h
diff --git a/phpdbg.c b/phpdbg.c
index 9215e43..275d91a 100644
--- a/phpdbg.c
+++ b/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;
} /* }}} */
diff --git a/phpdbg.h b/phpdbg.h
index 19cf0c4..6962cdb 100644
--- a/phpdbg.h
+++ b/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) /* }}} */
diff --git a/phpdbg_bp.c b/phpdbg_bp.c
index afd0be0..40a3a50 100644
--- a/phpdbg_bp.c
+++ b/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)
diff --git a/phpdbg_help.c b/phpdbg_help.c
index c9598a7..650025b 100644
--- a/phpdbg_help.c
+++ b/phpdbg_help.c
@@ -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));
diff --git a/phpdbg_set.c b/phpdbg_set.c
index b604822..f326560 100644
--- a/phpdbg_set.c
+++ b/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);
diff --git a/phpdbg_set.h b/phpdbg_set.h
index fa443ee..c3afc06 100644
--- a/phpdbg_set.h
+++ b/phpdbg_set.h
@@ -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
};
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php