Adds a new test api.detach_state which runs a series of start/stop sessions, each testing different aspects of state preservation across detach. The test is Linux x86_64-only for now.
One set of tests restoring microarchitectural state: general-purpose registers, eflags, stack pointer, and xmm registers. Each is tested at two different points: one from the code cache and the other from DR (via selfmod code to make it very likely the thread will be in DR at detach time), since the state restore mechanism for each point differs.
Another set of tests checks that signal state (blocked signal mask and alternate stack) is properly restored after detach, again with two different points: detaching when inside a signal handler, and when not.
Fixes #3160 (closed)