[engine] Support running tasks through debugger; add flags to control debug/performance monitoring modes, and make the command line munging code a little more general.