implements: ignore some C package calls that are just noise

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2021-09-13 16:24:37 -04:00 committed by mergify[bot]
parent 18a134b535
commit 2ebd4bc1d5
1 changed files with 25 additions and 1 deletions

View File

@ -12,6 +12,26 @@ import (
"strings" "strings"
) )
// ignoreCCalls is a map of calls from "C" that we know we can just ignore.
// ignoring this stuff makes the number of tracked entries smaller, fewer logs,
// and less stuff to iterate over in other code.
var ignoreCCalls = map[string]bool{
// some special cgo calls
"CString": true,
"CBytes": true,
"GoString": true,
"GoBytes": true,
// common utility functions
"free": true,
// common types
"int": true,
"int64_t": true,
"uint64_t": true,
"size_t": true,
"ssize_t": true,
"uintptr_t": true,
}
type goFunction struct { type goFunction struct {
shortName string shortName string
fullName string fullName string
@ -89,7 +109,11 @@ func (v *visitor) checkCalled(s *ast.SelectorExpr) {
return return
} }
if "C" == ident.String() { if "C" == ident.String() {
v.callMap[s.Sel.String()] = v.currentFunc cname := s.Sel.String()
if ignoreCCalls[cname] {
return
}
v.callMap[cname] = v.currentFunc
logger.Printf("updated %s in call map\n", s.Sel.String()) logger.Printf("updated %s in call map\n", s.Sel.String())
} }
} }