]> git.saurik.com Git - apple/xnu.git/blobdiff - libsyscall/wrappers/stackshot.c
xnu-6153.41.3.tar.gz
[apple/xnu.git] / libsyscall / wrappers / stackshot.c
index c5633120ba731f03896223f4cf726cad7029d59d..d819d34707d4e73ba36c96143a2fea7dd151adc4 100644 (file)
@@ -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