Skip to content

Commit feaec0e

Browse files
committed
2 parents 87a29a9 + b5b5bba commit feaec0e

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

phpdbg.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ int main(int argc, char **argv) /* {{{ */
552552
long cleaning = 0;
553553
int run = 0;
554554
int step = 0;
555+
char *bp_tmp_file;
555556

556557
#ifdef ZTS
557558
void ***tsrm_ls;
@@ -571,6 +572,13 @@ int main(int argc, char **argv) /* {{{ */
571572
#endif
572573

573574
phpdbg_main:
575+
if (!cleaning) {
576+
bp_tmp_file = malloc(L_tmpnam);
577+
tmpnam(bp_tmp_file);
578+
if (bp_tmp_file == NULL) {
579+
phpdbg_error("Unable to create temporary file");
580+
}
581+
}
574582
ini_entries = NULL;
575583
ini_entries_len = 0;
576584
ini_ignore = 0;
@@ -772,9 +780,8 @@ int main(int argc, char **argv) /* {{{ */
772780
/* initialize from file */
773781
zend_try {
774782
PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING;
775-
phpdbg_init(
776-
init_file, init_file_len,
777-
init_file_default TSRMLS_CC);
783+
phpdbg_init(init_file, init_file_len, init_file_default TSRMLS_CC);
784+
phpdbg_try_file_init(bp_tmp_file, strlen(bp_tmp_file), 0 TSRMLS_CC);
778785
PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING;
779786
} zend_catch {
780787
PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING;
@@ -803,9 +810,14 @@ int main(int argc, char **argv) /* {{{ */
803810
phpdbg_interactive(TSRMLS_C);
804811
} zend_catch {
805812
if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) {
813+
FILE *bp_tmp_fp = fopen(bp_tmp_file, "w");
814+
phpdbg_export_breakpoints(bp_tmp_fp TSRMLS_CC);
815+
fclose(bp_tmp_fp);
806816
cleaning = 1;
807817
goto phpdbg_out;
808-
} else cleaning = 0;
818+
} else {
819+
cleaning = 0;
820+
}
809821

810822
if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) {
811823
goto phpdbg_out;
@@ -855,6 +867,8 @@ int main(int argc, char **argv) /* {{{ */
855867
/* bugggy */
856868
/* tsrm_shutdown(); */
857869
#endif
870+
871+
free(bp_tmp_file);
858872

859873
return 0;
860874
} /* }}} */

phpdbg_prompt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
/* {{{ */
2424
void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC);
25+
void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC);
2526
int phpdbg_interactive(TSRMLS_D);
2627
int phpdbg_compile(TSRMLS_D);
2728
void phpdbg_clean(zend_bool full TSRMLS_DC); /* }}} */

0 commit comments

Comments
 (0)