tracy
Maybe look into using tracy, it allows you to interact with live-updating tracing profiles mark/time sections of code and log messages, I haven’t yet (but it is one of the tools I want to add eventually) and it seems like it may involve some work to get it running, but if you can get it running, I think it could be helpful for that and a lot more.
With tracy you would have to pass the data to be recorded manually, instead of magically.
zigft
I think you could use GitHub - chung-leong/zigft: Zig function transform library to create wrapper functions that replace the original functions but add logging zigft - adding-debug-output-to-a-function
scripted debugger
Another approach might be to run the program via a debugger and script it to set a breakpoint, inspect and print the variables and then continue, I think somebody in this forum wrote a post about something like that, but can’t find it right now.
in the future maybe via build system or compiler protocol?
I think it might be nice if Zig eventually had a way to automatically add tracing to some functions via some kind of build-system api or maybe by requesting it by communicating with the compiler while incremental reload is enabled.
DynamoRIO
Haven’t tested it, but it seems interesting and useful:
DynamoRIO is a system for runtime code manipulation that is efficient, transparent, and comprehensive, able to observe and manipulate every executed instruction in an unmodified application running on a stock operating system and commodity hardware.
This page explains it quite well DynamoRIO System Overview.
If somebody finds the time to try it out, let us know how it worked out!