Revert "Revert "support debugfile switch and global script config""

This reverts commit 68603463f1d0b3de60fb952cb369ec3d54212f7b.