While there are many globals that are not reset, we take a best-effort approach here and reset the ones that matter, allowing us to re-attach with a memtrace client and static DR.
Portions of this were initially based on https://codereview.appspot.com/13314047/ from Peter Goodman.
For DO_ONCE, an incremented counter is used.
For numerous other globals, at exit time if doing_detach is set we reset them to NULL.
For locks, we simply reset count_times_acquired but leave the deleted field as it does not matter much (part of the whole theme here: this may never be rock-solid for unusual option combinations but our goal is supporting the common case).
For drreg, with the new multi-init feature we have to zero the options at exit time.
Adds several tests by adding loops around existing start/stop tests, but stops short on burst_threads until i#2175 is fixed.
Review-URL: https://codereview.appspot.com/318520043