s_config->sc_pid = -1;
s_config->sc_flags = 0;
- s_config->sc_since_timestamp = 0;
+ s_config->sc_delta_timestamp = 0;
s_config->sc_buffer = 0;
s_config->sc_size = 0;
}
s_config = (stackshot_config_t *) stackshot_config;
- if (s_config->sc_buffer != 0) {
+ if (s_config->sc_buffer != 0) {
return EINVAL;
}
- s_config->sc_out_buffer_addr = &s_config->sc_buffer;
- s_config->sc_out_size_addr = &s_config->sc_size;
- ret = __stack_snapshot_with_config(STACKSHOT_CONFIG_TYPE, s_config, sizeof(stackshot_config_t));
-
+ s_config->sc_out_buffer_addr = (uintptr_t)&s_config->sc_buffer;
+ s_config->sc_out_size_addr = (uintptr_t)&s_config->sc_size;
+ ret = __stack_snapshot_with_config(STACKSHOT_CONFIG_TYPE, (uintptr_t)s_config, sizeof(stackshot_config_t));
+
if (ret != 0) {
ret = errno;
s_config->sc_buffer = 0;
}
s_config = (stackshot_config_t *) stackshot_config;
- return ((void *)s_config->sc_buffer);
+ return (void *)s_config->sc_buffer;
}
/*
return 0;
}
+/*
+ * stackshot_config_set_delta_timestamp: set the timestamp to use as the basis for the delta stackshot
+ *
+ * This timestamp will be used along with STACKSHOT_COLLECT_DELTA_SNAPSHOT flag to collect delta stackshots
+ *
+ * Inputs: stackshot_config - a pointer to a stackshot_config_t
+ * delta_timestamp - timestamp in MachAbsoluteTime units to be used as the basis for a delta stackshot
+ *
+ * Outputs: -1 if the passed stackshot config is NULL or there is existing stackshot buffer set.
+ * 0 on success
+ */
+int
+stackshot_config_set_delta_timestamp(stackshot_config_t *stackshot_config, uint64_t delta_timestamp)
+{
+ if (stackshot_config == NULL || (void *)stackshot_config->sc_buffer != NULL) {
+ return -1;
+ }
+
+ stackshot_config->sc_delta_timestamp = delta_timestamp;
+
+ return 0;
+}
+
+
/*
* stackshot_config_dealloc_buffer: dealloc the stackshot buffer and reset the size so that a
* stackshot_config_t can be used again