+/* XXX should be static */
+void collectth_state(thread_t th_act, void *tirp);
+
+/* XXX not in a Mach header anywhere */
+kern_return_t thread_getstatus(register thread_t act, int flavor,
+ thread_state_t tstate, mach_msg_type_number_t *count);
+void task_act_iterate_wth_args(task_t, void(*)(thread_t, void *), void *);
+
+static cpu_type_t process_cpu_type(proc_t proc);
+static cpu_type_t process_cpu_subtype(proc_t proc);
+
+#ifdef SECURE_KERNEL
+__private_extern__ int do_coredump = 0; /* default: don't dump cores */
+#else
+__private_extern__ int do_coredump = 1; /* default: dump cores */
+#endif
+__private_extern__ int sugid_coredump = 0; /* default: but not SGUID binaries */
+
+
+/* cpu_type returns only the most generic indication of the current CPU. */
+/* in a core we want to know the kind of process. */
+
+static cpu_type_t
+process_cpu_type(proc_t core_proc)
+{
+ cpu_type_t what_we_think;
+#if defined (__i386__) || defined (__x86_64__)
+ if (IS_64BIT_PROCESS(core_proc)) {
+ what_we_think = CPU_TYPE_X86_64;
+ } else {
+ what_we_think = CPU_TYPE_I386;
+ }
+#endif
+ return what_we_think;
+}
+
+static cpu_type_t
+process_cpu_subtype(proc_t core_proc)
+{
+ cpu_type_t what_we_think;
+#if defined (__i386__) || defined (__x86_64__)
+ if (IS_64BIT_PROCESS(core_proc)) {
+ what_we_think = CPU_SUBTYPE_X86_64_ALL;
+ } else {
+ what_we_think = CPU_SUBTYPE_I386_ALL;
+ }
+#endif
+ return what_we_think;
+}
+
+void
+collectth_state(thread_t th_act, void *tirp)