X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/3e170ce000f1506b7b5d2c5c7faec85ceabb573d..94ff46dc2849db4d43eaaf144872decc522aafb4:/libsyscall/wrappers/stackshot.c diff --git a/libsyscall/wrappers/stackshot.c b/libsyscall/wrappers/stackshot.c index c5633120b..d819d3470 100644 --- a/libsyscall/wrappers/stackshot.c +++ b/libsyscall/wrappers/stackshot.c @@ -50,7 +50,7 @@ stackshot_config_create(void) 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; @@ -136,14 +136,14 @@ stackshot_capture_with_config(stackshot_config_t *stackshot_config) } 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; @@ -171,7 +171,7 @@ stackshot_config_get_stackshot_buffer(stackshot_config_t *stackshot_config) } s_config = (stackshot_config_t *) stackshot_config; - return ((void *)s_config->sc_buffer); + return (void *)s_config->sc_buffer; } /* @@ -213,6 +213,30 @@ stackshot_config_set_size_hint(stackshot_config_t *stackshot_config, uint32_t su 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