}
} /* }}} */
+void phpdbg_sigint_handler(int signo)
+{
+ TSRMLS_FETCH();
+ PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED;
+ phpdbg_notice("here");
+}
+
int main(int argc, char **argv) /* {{{ */
{
sapi_module_struct *phpdbg = &phpdbg_sapi_module;
long cleaning = 0;
int run = 0;
int step = 0;
-
+
#ifdef ZTS
void ***tsrm_ls;
#endif
opt = 0;
run = 0;
step = 0;
-
+
while ((opt = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
switch (opt) {
case 'r':
case 's': /* set stepping on */
step = 1;
break;
-
+
case 'E': /* stepping through eval on */
flags |= PHPDBG_IS_STEPONEVAL;
break;
phpdbg->ini_entries = ini_entries;
if (phpdbg->startup(phpdbg) == SUCCESS) {
+#ifdef ZEND_SIGNALS
+ zend_signal(SIGINT, phpdbg_sigint_handler);
+#else
+ signal(SIGINT, phpdbg_sigint_handler);
+#endif
+
zend_activate(TSRMLS_C);
#ifdef ZEND_SIGNALS
zend_try {
PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING;
phpdbg_init(
- init_file, init_file_len,
+ init_file, init_file_len,
init_file_default TSRMLS_CC);
PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING;
} zend_catch {
goto phpdbg_out;
}
} zend_end_try();
-
+
/* step from here, not through init */
if (step) {
PHPDBG_G(flags) |= PHPDBG_IS_STEPPING;
}
-
+
if (run) {
/* no need to try{}, run does it ... */
PHPDBG_COMMAND_HANDLER(run)(NULL, NULL TSRMLS_CC);
#define PHPDBG_IS_REGISTERED (1<<16)
#define PHPDBG_IS_STEPONEVAL (1<<17)
#define PHPDBG_IS_INITIALIZING (1<<18)
+#define PHPDBG_IS_SIGNALED (1<<19)
#ifndef _WIN32
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED)
phpdbg_notice("Variables: %d",
zend_hash_num_elements(&vars));
-
+
if (zend_hash_num_elements(&vars)) {
phpdbg_writeln("Address\t\tRefs\tType\t\tVariable");
for (zend_hash_internal_pointer_reset_ex(&vars, &pos);
case IS_OBJECT: phpdbg_write("(object)\t"); break;
case IS_NULL: phpdbg_write("(null)\t"); break;
}
-
+
if (Z_TYPE_PP(data) == IS_RESOURCE) {
int type;
-
+
phpdbg_writeln(
"%s$%s", Z_ISREF_PP(data) ? "&": "", var);
if (zend_list_find(Z_RESVAL_PP(data), &type)) {
return SUCCESS;
} /* }}} */
-static inline void phpdbg_print_class_name(zend_class_entry **ce TSRMLS_DC) { /* {{{ */
+static inline void phpdbg_print_class_name(zend_class_entry **ce TSRMLS_DC) /* {{{ */
+{
phpdbg_write(
"%s %s %s (%d)",
((*ce)->type == ZEND_USER_CLASS) ?
ops->line_end - ops->line_start + 1, ops->line_start, 0 TSRMLS_CC);
} /* }}} */
-void phpdbg_list_function_byname(const char *str, size_t len TSRMLS_DC)
+void phpdbg_list_function_byname(const char *str, size_t len TSRMLS_DC) /* {{{ */
{
HashTable *func_table = EG(function_table);
zend_function* fbc;
}
efree(func_name);
-}
+} /* }}} */
zend_bool stepping = (PHPDBG_G(flags) & PHPDBG_IS_STEPPING);
zval retval;
char *code = NULL;
-
+
if (!(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) {
PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING;
}
if (input && input->start) {
code = (char*) input->start;
-
+
if (memcmp(
code, "eval", sizeof("eval")-1) == SUCCESS) {
code += sizeof("eval")-1;
} else code += sizeof("E")-1;
-
+
while (code && isspace(*code)) {
code++;
}
} else phpdbg_error("Nothing to execute");
-
+
/* disable stepping while eval() in progress */
PHPDBG_G(flags) |= PHPDBG_IN_EVAL;
if (zend_eval_stringl(code, strlen(code),
case STR_PARAM: {
FILE *fd = NULL;
char * program = NULL;
-
+
/* we expect an input, I hope we get one ! */
if (input && input->start) {
program = (char*) input->start;
-
+
if (memcmp(
program, "shell", sizeof("shell")-1) == SUCCESS) {
program += sizeof("shell")-1;
} else program += sizeof("-")-1;
-
+
while (program && isspace(*program)) {
program++;
}
} else program = param->str;
-
+
if ((fd=VCWD_POPEN((char*)program, "w"))) {
/* do something perhaps ?? do we want input ?? */
fclose(fd);
} while(!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING));\
} while(0)
- /* allow conditional breakpoints and
+ /* allow conditional breakpoints and
initialization to access the vm uninterrupted */
if (PHPDBG_G(flags) & PHPDBG_IN_COND_BP|PHPDBG_IS_INITIALIZING) {
/* skip possible breakpoints */
$dbg = new phpdbg();
-$test = 1;
var_dump(
$dbg->isGreat("PHP Rocks !!"));
foreach (test() as $gen)
continue;
+
+$n = 10;
+while ($n--) {
+ sleep(1);
+}
+
echo "it works!\n";
if (isset($dump))
var_dump($_SERVER);
-function phpdbg_test_ob()
+function phpdbg_test_ob()
{
echo 'Start';
ob_start();
echo 'End';
echo $b;
}
+
+
?>