https://github.com/silversquirl/zik
Source-level static instrumentation framework for Zig
https://github.com/silversquirl/zik
instrumentation profiler tracing zig
Last synced: about 1 year ago
JSON representation
Source-level static instrumentation framework for Zig
- Host: GitHub
- URL: https://github.com/silversquirl/zik
- Owner: silversquirl
- License: mit
- Created: 2024-03-25T04:56:45.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-25T05:09:39.000Z (about 2 years ago)
- Last Synced: 2025-04-14T03:51:17.929Z (about 1 year ago)
- Topics: instrumentation, profiler, tracing, zig
- Language: Zig
- Homepage:
- Size: 14.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Zig Instrumentation Kit
A slightly cursed library for source-level static instrumentation in Zig.
This repository also includes a simple function-level profiler that outputs to the [callgrind format](https://valgrind.org/docs/manual/cl-format.html), which is readable by [KCacheGrind](https://kcachegrind.github.io/html/Home.html).
## Using the profiler
**NOTE: This is currently proof-of-concept quality. Notably, multithreaded programs will not work at all**
Build the profiler using `zig build zikprof`, then run the binary from `zig-out/bin/zikprof` with the same args you'd normally pass to `zig`. (TODO: this does not currently work with `zig build`. Stick to `zig build-exe`, `zig run`, etc)
This will copy your entire source tree, rooted at `build.zig`, into `zig-cache/tmp/zik/src`, instrument it, then run the Zig command as normal. (TODO: this should be more transparent to the user. Build output and program output should be placed in the locations one would expect from running Zig normally)
Here is an example usage:
```
zig build zikprof
cd example
../zig-out/bin/zikprof run main.zig
```
You can then open `example/zig-cache/tmp/zik/src/callgrind.out.zikprof.` in KCacheGrind to inspect the call graph.