From 421e1cbedb47cb499201512defc2baf79d7b87f7 Mon Sep 17 00:00:00 2001 From: Pimyn Girgis Date: Tue, 6 Aug 2024 14:10:45 +0000 Subject: pkg/mgrconfig, prog, tools: allow automatically generated or manually written descriptions or both Add "Auto" type and allow to choose descriptions mode in configurations. Defaults to using manual only. --- pkg/compiler/gen.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'pkg/compiler') diff --git a/pkg/compiler/gen.go b/pkg/compiler/gen.go index 1fcf8dcac..891cd1644 100644 --- a/pkg/compiler/gen.go +++ b/pkg/compiler/gen.go @@ -78,7 +78,7 @@ func (comp *compiler) collectCallArgSizes() map[string][]uint64 { comp.error(arg.Pos, "%v arg %v is larger than pointer size", n.Name.Name, arg.Name.Name) continue } - argID := fmt.Sprintf("%v|%v", n.CallName, i) + argID := fmt.Sprintf("%v|%v", getCallName(n), i) if _, ok := argPos[argID]; !ok { argSizes[i] = typ.Size() argPos[argID] = arg.Pos @@ -90,17 +90,26 @@ func (comp *compiler) collectCallArgSizes() map[string][]uint64 { continue } } - callArgSizes[n.CallName] = argSizes + callArgSizes[getCallName(n)] = argSizes } return callArgSizes } +func getCallName(n *ast.Call) string { + for _, attr := range n.Attrs { + if attr.Ident == "automatic" { + return n.Name.Name + } + } + return n.CallName +} + func (comp *compiler) genSyscalls() []*prog.Syscall { callArgSizes := comp.collectCallArgSizes() var calls []*prog.Syscall for _, decl := range comp.desc.Nodes { if n, ok := decl.(*ast.Call); ok && n.NR != ^uint64(0) { - calls = append(calls, comp.genSyscall(n, callArgSizes[n.CallName])) + calls = append(calls, comp.genSyscall(n, callArgSizes[getCallName(n)])) } } // We assign SquashableElem here rather than during pointer type generation -- cgit mrf-deployment