Skip to content

Commit

Permalink
Add small section in selftest
Browse files Browse the repository at this point in the history
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
  • Loading branch information
grantseltzer committed Jun 27, 2022
1 parent 5b4cbbf commit 1372cb5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion selftest/tracing/main.go
Expand Up @@ -11,6 +11,7 @@ import (
"fmt"

bpf "github.com/aquasecurity/libbpfgo"
"github.com/aquasecurity/libbpfgo/helpers"
)

func main() {
Expand All @@ -28,7 +29,22 @@ func main() {
os.Exit(-1)
}

bpfModule.ListProgramNames()
m, err := helpers.NewKernelSymbolsMap()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}

sym, err := m.GetSymbolByName("system", "__x64_sys_mmap")
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}

if sym.Address == 0 || sym.Name == "" {
fmt.Fprintln(os.Stderr, "could not find symbol to attach to")
os.Exit(-1)
}

prog, err := bpfModule.GetProgram("mmap_fentry")
if err != nil {
Expand Down

0 comments on commit 1372cb5

Please sign in to comment.