+
+#if defined (__i386__) || defined(__x86_64__)
+ x86_thread_state_t state;
+ memset(&state, 0, sizeof(state));
+
+ bottom = reinterpret_cast<thread_state_t>(&state);
+ flavor = MACHINE_THREAD_STATE;
+ count = MACHINE_THREAD_STATE_COUNT;
+#elif defined(__arm__) || defined(__arm64__)
+ arm_unified_thread_state_t state;
+ memset(&state, 0, sizeof(state));
+
+ switch (info.all_image_info_format) {
+ case TASK_DYLD_ALL_IMAGE_INFO_32:
+ bottom = reinterpret_cast<thread_state_t>(&state.ts_32);
+ flavor = ARM_THREAD_STATE;
+ count = ARM_THREAD_STATE_COUNT;
+ state.ash.flavor = ARM_THREAD_STATE32;
+ break;
+ case TASK_DYLD_ALL_IMAGE_INFO_64:
+ bottom = reinterpret_cast<thread_state_t>(&state.ts_64);
+ flavor = ARM_THREAD_STATE64;
+ count = ARM_THREAD_STATE64_COUNT + 1;
+ state.ash.flavor = ARM_THREAD_STATE64;
+ break;
+ default:
+ _assert(false);
+ }
+#else
+ #error XXX: implement
+#endif
+
+ mach_msg_type_number_t read(count);
+ _krncall(thread_get_state(thread, flavor, bottom, &read));
+ _assert(read == count);