com php-src: add source export functionality, only files working, buggy source: phpdbg_bp.c phpdbg_bp.h phpdbg_help.c phpdbg_prompt.c
| From: | Bob Weinand | Date: | Mon, 25 Nov 2013 17:41:09 +0000 |
| Subject: | com php-src: add source export functionality, only files working, buggy source: phpdbg_bp.c phpdbg_bp.h phpdbg_help.c phpdbg_prompt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74599@lists.php.net to get a copy of this message | ||
Commit: a947c890a03ce5a6f6065ce17823b0678f2c7b8c
Author: krakjoe <joe.watkins@live.co.uk> Mon, 25 Nov 2013 17:41:09 +0000
Parents: 3d6a4cbc634db0e056f92cb3c9f7eedbd93da209
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a947c890a03ce5a6f6065ce17823b0678f2c7b8c
Log:
add source export functionality, only files working, buggy source
Changed paths:
M phpdbg_bp.c
M phpdbg_bp.h
M phpdbg_help.c
M phpdbg_prompt.c
Diff:
diff --git a/phpdbg_bp.c b/phpdbg_bp.c
index 2547e39..d045255 100644
--- a/phpdbg_bp.c
+++ b/phpdbg_bp.c
@@ -44,6 +44,40 @@ static void phpdbg_class_breaks_dtor(void *data) /* {{{ */
efree((char*)bp->func_name);
} /* }}} */
+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);
+
+ fprintf(handle, "# Breakpoints in %s (%d)\n", brake->filename, count);
+ do {
+ fprintf(handle, "break file %s:%lu\n", brake->filename, brake->line);
+ } while ((brake = zend_llist_get_next_ex(brakes, &lposition)));
+ }
+ }
+ }
+
+ /* 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) /* {{{ */
{
struct stat sb;
diff --git a/phpdbg_bp.h b/phpdbg_bp.h
index 661962c..8b1a0f0 100644
--- a/phpdbg_bp.h
+++ b/phpdbg_bp.h
@@ -99,4 +99,6 @@ PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC);
PHPDBG_API void phpdbg_clear_breakpoints(TSRMLS_D);
PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC);
+PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC);
+
#endif /* PHPDBG_BP_H */
diff --git a/phpdbg_help.c b/phpdbg_help.c
index fe621fb..2dc4577 100644
--- a/phpdbg_help.c
+++ b/phpdbg_help.c
@@ -505,11 +505,15 @@ PHPDBG_HELP(source) /* {{{ */
{
phpdbg_help_header();
phpdbg_writeln("Sourcing a phpdbginit during your debugging session might save some
time");
+ phpdbg_writeln("The source command can also be used to export breakpoints to a phpdbginit
file");
phpdbg_writeln(EMPTY);
phpdbg_notice("Examples");
- phpdbg_writeln("\t%ssource /my/phpdbginit", PROMPT);
- phpdbg_writeln("\t%s. /my/phpdbginit", PROMPT);
- phpdbg_writeln("\tWill execute the init file at /my/phpdbginit");
+ phpdbg_writeln("\t%ssource /my/init", PROMPT);
+ phpdbg_writeln("\t%s. /my/init", PROMPT);
+ phpdbg_writeln("\tWill execute the phpdbginit file at /my/init");
+ phpdbg_writeln("\t%ssource export /my/init", PROMPT);
+ phpdbg_writeln("\t%s. export /my/init", PROMPT);
+ phpdbg_writeln("\tWill export breakpoints to /my/init in phpdbginit file format");
phpdbg_help_footer();
return SUCCESS;
} /* }}} */
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index 12c85d6..84b1838 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -853,7 +853,23 @@ PHPDBG_COMMAND(source) /* {{{ */
{
switch (param->type) {
case STR_PARAM: {
- phpdbg_init(param->str, param->len, 0 TSRMLS_CC);
+ if (input->argc > 2) {
+ if (phpdbg_argv_is(1, "export")) {
+ FILE *h = VCWD_FOPEN(input->argv[2]->string, "w+");
+ if (h) {
+ phpdbg_export_breakpoints(h TSRMLS_CC);
+ fclose(h);
+ } else phpdbg_error("Failed to open %s", input->argv[1]->string);
+ } else {
+ phpdbg_error(
+ "Incorrect usage of source command, see help");
+ }
+ } else {
+ struct stat sb;
+ if (VCWD_STAT(param->str, &sb) != -1) {
+ phpdbg_init(param->str, param->len, 0 TSRMLS_CC);
+ } else phpdbg_error("Cannot stat %s", param->str);
+ }
} break;
phpdbg_default_switch_case();