Skip to content

Instantly share code, notes, and snippets.

View grantseltzer's full-sized avatar

grantseltzer grantseltzer

View GitHub Profile
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
char LICENSE[] SEC("license") = "GPL";
struct process_info {
int pid;
char comm[100];
};
@grantseltzer
grantseltzer / go_template_unit_test.go
Created February 2, 2021 20:44
Scaffolding for pretty much every go unit tests
package main
import "testing"
func TestXXX(t *testing.T) {
testCases := []struct {
testName string
}{
{
package main
import (
"debug/dwarf"
"debug/elf"
"fmt"
"io"
"log"
"os"
)
package main
import (
"debug/dwarf"
"debug/elf"
"fmt"
"io"
"log"
"os"
)
@grantseltzer
grantseltzer / main.go
Created October 6, 2020 15:21
Using Go BCC for instrumenting tail calls
package main
import (
"io/ioutil"
"log"
"time"
"github.com/iovisor/gobpf/bcc"
)
package main
//go:noinline
func parseMe(a int, b bool, c float32) {
// some code
}
func main() {
parseMe(1, true, 96.69)
package main
//go:noinline
func simpleFunction(x int) {
// some code
}
func main() {
simpleFunction(99)
}
@grantseltzer
grantseltzer / keybase.md
Last active March 14, 2020 00:37
keybase.md

Keybase proof

I hereby claim:

  • I am grantseltzer on github.
  • I am grantseltzer (https://keybase.io/grantseltzer) on keybase.
  • I have a public key ASAHcxmnVSLzcZ4MWTGettrpMzUkzvHSzC52uuB3xS_Pggo

To claim this, I am signing this object:

[
{
"functionName": "main.test_single_byte",
"args": [
{
"type": "BYTE",
"value": "dec=97\tchar='a'"
}
],
"procInfo": {
package main
import (
"fmt"
"log"
"os"
"os/signal"
"github.com/iovisor/gobpf/bcc"
)