{"repo":"stevenjohnstone/go-bpf-gen","free":true,"listed":false,"github":"https://github.com/stevenjohnstone/go-bpf-gen","clone":"git clone https://github.com/stevenjohnstone/go-bpf-gen.git","description":"Generate bpftrace scripts for use with golang programs. Works around quirks in the golang runtime.","language":"Go","stars":65,"topics":["bpftrace","golang","bpf","ebpf","observability","debugging"],"license":"ISC","category":"analytics","readme_excerpt":"About Generate bpftrace programs suitable for tracing a golang program on x86-64. Why? Using bpftrace with golang isn't as straightforward as for C/C++ compiled code. See this blog post by Brendan Gregg. Problem 1: Stacks can grow and be copied uretprobes are implemented by hijacking return addresses on the stack. Golang can grow stacks and in doing so move the stack contents. This can result in golang panics when being traced. To get around this, the template generator looks for the addresses of RET instructions in the targeted function and creates uprobes for those. Problem 2: Goroutines don't map 1-1 with system threads It's not a problem for golang but it's a problem when trying to do per-thread statistics with bpftrace. A goroutine may move around system threads so we need a way to map goroutine IDs to thread IDs. Solution This program can generate bpftrace programs from templates, filling in details like the location of RET instructions, offsets of goroutine ID values in structures etc. Bundled Scripts goroutine.bt The script generated by prints a message whenever a goroutine is spawned. httpsnoop.bt The script generated by tracks outgoing HTTP requests. latency.bt The script generated by will measure the time spent in functions specified in the symbol parameters. recover.bt The script generated by will record stack traces from calls to recover() after a panic. shortread.bt The script generated by will record stack traces from calls to [ func(f os.File) Read([]byte) (in","default_branch":null,"files":null,"tree":[],"storefront":"/r/stevenjohnstone","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/stevenjohnstone/go-bpf-gen/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}