News for hackers. Stuff that matters.
Re:Instrumentation in Go by Julio-Guerra on Tuesday May 26, 2020 @08:15AM (#23310147)
Something to note here is that everything is known and done statically in the source code. This could be addressed through metaprogramming if only the Go language had some ^^

We have similar needs at Sqreen but for security monitoring and protection reasons: we need to dynamically instrument functions at run time, while not asking any code modification to our users. To do so, we instead leverage the Go compiler to perform compile-time instrumentation that inserts hooks anywhere interesting. You can read more about this approach at https://blog.sqreen.com/dynamic-instrumentation-go/

Re:Instrumentation in Go by gobwas on Tuesday May 26, 2020 @08:21AM (#23310201)
I have read this article before and I really like the idea of doing so. I would love to read more about how you guys modified the compiler!
Re:Instrumentation in Go by Julio-Guerra on Tuesday May 26, 2020 @08:48AM (#23310432)
We haven't modified the compiler but instead plugged into it an external instrumentation tool using the compiler option `-toolexec`.

With this option, the compiler invokes every toolchain binary (compile, asm, link, etc.) through the provided program. So you can basically write a proxy program intercepting calls to `compile` to do source-code instrumentation, exactly like you would with go generate, but now automatically done during compilation on every package.

Re:Instrumentation in Go by gobwas on Tuesday May 26, 2020 @09:11AM (#23310669)
Ah, cool! Thank you so much, didn't know about this parameter :D Will try it definitely.