Skip to content

Commit 4e6a8ee

Browse files
committed
Breakpoints are now persistent over cleans
1 parent 2be5a1e commit 4e6a8ee

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

phpdbg.c

Lines changed: 17 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;
@@ -570,6 +571,12 @@ int main(int argc, char **argv) /* {{{ */
570571
tsrm_ls = ts_resource(0);
571572
#endif
572573

574+
bp_tmp_file = malloc(L_tmpnam);
575+
tmpnam(bp_tmp_file);
576+
if (bp_tmp_file == NULL) {
577+
phpdbg_error("Unable to create temporary file");
578+
}
579+
573580
phpdbg_main:
574581
ini_entries = NULL;
575582
ini_entries_len = 0;
@@ -772,9 +779,8 @@ int main(int argc, char **argv) /* {{{ */
772779
/* initialize from file */
773780
zend_try {
774781
PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING;
775-
phpdbg_init(
776-
init_file, init_file_len,
777-
init_file_default TSRMLS_CC);
782+
phpdbg_init(init_file, init_file_len, init_file_default TSRMLS_CC);
783+
phpdbg_try_file_init(bp_tmp_file, strlen(bp_tmp_file), 0 TSRMLS_CC);
778784
PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING;
779785
} zend_catch {
780786
PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING;
@@ -803,9 +809,14 @@ int main(int argc, char **argv) /* {{{ */
803809
phpdbg_interactive(TSRMLS_C);
804810
} zend_catch {
805811
if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) {
812+
FILE *bp_tmp_fp = fopen(bp_tmp_file, "w");
813+
phpdbg_export_breakpoints(bp_tmp_fp TSRMLS_CC);
814+
fclose(bp_tmp_fp);
806815
cleaning = 1;
807816
goto phpdbg_out;
808-
} else cleaning = 0;
817+
} else {
818+
cleaning = 0;
819+
}
809820

810821
if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) {
811822
goto phpdbg_out;
@@ -851,6 +862,8 @@ int main(int argc, char **argv) /* {{{ */
851862
goto phpdbg_main;
852863
}
853864

865+
free(bp_tmp_file);
866+
854867
#ifdef ZTS
855868
/* bugggy */
856869
/* tsrm_shutdown(); */

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)