expand and split the debug trace infrastructure a little

I want to re-use this in client packages as well, rather than reimplementing it in every backend. This is a little awkward (for example, parses flags relating to compilation and execution) but I think will work out better overall.
wibbles
tlm note