This is a slightly reworked version of D16322, which I had reverted because it did not do what it
advertised. Differences from the previous version are:
- moved the code for cleaning up the remote working dir to a later point as it was removing the log file before we could get to it.
- specialised log downloading code for gdb-remote tests is not needed, as this will cover that use case as well.