Debugging support

Supercedes https://github.com/hashdist/hashdist/pull/125