summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ztrace.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/ztrace.h b/include/ztrace.h
new file mode 100644
index 0000000..d507809
--- /dev/null
+++ b/include/ztrace.h
@@ -0,0 +1,37 @@
+/* ztrace: what a traced program can say about itself.
+ *
+ * Link libztrace-agent.a (or libztrace-agent.so) and run the program under
+ * `ztrace run`. Run without a tracer, these do nothing.
+ *
+ * A statically linked agent sees the allocator and thread creation when the
+ * program is linked with:
+ * -Wl,--wrap=malloc,--wrap=calloc,--wrap=realloc,--wrap=free
+ * -Wl,--wrap=posix_memalign,--wrap=aligned_alloc,--wrap=memalign
+ * -Wl,--wrap=pthread_create,--wrap=fork
+ */
+#ifndef ZTRACE_H
+#define ZTRACE_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A point in the run worth a moment of the recording: a `mark` event. */
+void ztrace_mark(const char *label, uint64_t value);
+
+/* Names `len` bytes at `ptr` (a `variable` event), records them, and keeps
+ * recording what changes in them: only the bytes that changed, at each event
+ * that ends a moment. The memory must stay mapped. */
+void ztrace_watch(const void *ptr, size_t len, const char *name);
+
+/* Records `len` bytes at `ptr` as they are now, once. */
+void ztrace_snapshot(const void *ptr, size_t len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif