MINOR: debug: implement ha_panic()
This function dumps all existing threads using the thread dump mechanism
then aborts. This will be used by the lockup detection and by debugging
tools.
diff --git a/src/debug.c b/src/debug.c
index fce23c3..3e38bfa 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -136,6 +136,17 @@
return 1;
}
+/* dumps a state of all threads into the trash and on fd #2, then aborts. */
+void ha_panic()
+{
+ chunk_reset(&trash);
+ chunk_appendf(&trash, "Thread %u is about to kill the process.\n", tid);
+ ha_thread_dump_all_to_trash();
+ write(2, trash.area, trash.data);
+ for (;;)
+ abort();
+}
+
#ifndef USE_THREAD_DUMP
/* This function dumps all threads' state to the trash. This version is the