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;
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 */
{
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;
} /* }}} */
{
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();