+struct side_statedump_request_handle *side_statedump_request_notification_register(void (*statedump_cb)(void))
+{
+ struct side_statedump_request_handle *handle;
+
+ if (finalized)
+ return NULL;
+ if (!initialized)
+ side_init();
+ /*
+ * The statedump request notification should not be registered
+ * from a notification callback.
+ */
+ assert(filter_key == NULL);
+ handle = (struct side_statedump_request_handle *)
+ calloc(1, sizeof(struct side_statedump_request_handle));
+ if (!handle)
+ return NULL;
+ pthread_mutex_lock(&side_lock);
+ handle->cb = statedump_cb;
+ side_list_insert_node_tail(&side_statedump_list, &handle->node);
+ /* Invoke callback for all tracers. */
+ statedump_cb();
+ pthread_mutex_unlock(&side_lock);
+ return handle;
+}
+
+void side_statedump_request_notification_unregister(struct side_statedump_request_handle *handle)
+{
+ if (finalized)
+ return;
+ if (!initialized)
+ side_init();
+ assert(filter_key == NULL);
+ pthread_mutex_lock(&side_lock);
+ side_list_remove_node(&handle->node);
+ pthread_mutex_unlock(&side_lock);
+ free(handle);
+}
+
+void side_tracer_statedump_request(void *key)
+{
+ struct side_statedump_request_handle *handle;
+
+ /* Invoke the state dump callback specifically for the tracer key. */
+ filter_key = key;
+ pthread_mutex_lock(&side_lock);
+ side_list_for_each_entry(handle, &side_statedump_list, node)
+ handle->cb();
+ pthread_mutex_unlock(&side_lock);
+ filter_key = NULL;
+}
+