Skip to content

Commit

Permalink
btf.go : Add LoadBTF to transparently search and load BTF file
Browse files Browse the repository at this point in the history
Signed-off-by: Tristan d'Audibert <tristan.daudibert@orange.com>
  • Loading branch information
ScriptSathi committed Jan 23, 2025
1 parent dac4d2e commit 4ef0814
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion pkg/btf/btf.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,16 @@ func GetCachedBTFFile() string {
return btfFile
}

func LoadBTF() (*btf.Spec, error) {
err := InitCachedBTF(defaults.DefaultTetragonLib, "")
if err != nil {
return nil, err
}
return NewBTF()
}

func FindBtfFuncParamFromHook(hook string, argIndex int) (*btf.FuncParam, error) {
spec, err := NewBTF()
spec, err := LoadBTF()
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/btf/btf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ func testAssertErrorOnInvalidPath(t *testing.T, spec *btf.Spec) {
}

func TestResolveBtfPath(t *testing.T) {
spec, err := NewBTF()
spec, err := LoadBTF()
failOnError(t, err)

testAssertEqualPath(t, spec)
Expand Down

0 comments on commit 4ef0814

Please sign in to comment.