@@ -37,6 +37,8 @@ func run(args []string) error {
37
37
return fmt .Errorf ("expect location of compressed vmlinux .BTF as argument" )
38
38
}
39
39
40
+ fmt .Println ("Running gentypes.." )
41
+
40
42
raw , err := internal .ReadAllCompressed (args [0 ])
41
43
if err != nil {
42
44
return err
@@ -127,12 +129,14 @@ import (
127
129
return consts [i ].Name < consts [j ].Name
128
130
})
129
131
132
+ var nconsts uint32
130
133
w .WriteString ("const (\n " )
131
134
for _ , c := range consts {
132
- fmt .Println ("const" , c .Name )
133
135
fmt .Fprintf (w , "\t %s = %v\n " , c .Name , c .Value )
136
+ nconsts ++
134
137
}
135
138
w .WriteString (")\n " )
139
+ fmt .Printf ("Generated %d constants\n " , nconsts )
136
140
137
141
// Typed constants (aka named enums)
138
142
enums := []struct {
@@ -161,10 +165,9 @@ import (
161
165
return enums [i ].goType < enums [j ].goType
162
166
})
163
167
168
+ var nenums uint32
164
169
enumTypes := make (map [string ]btf.Type )
165
170
for _ , o := range enums {
166
- fmt .Println ("enum" , o .goType )
167
-
168
171
var t * btf.Enum
169
172
if err := spec .TypeByName (o .cType , & t ); err != nil {
170
173
return nil , err
@@ -185,7 +188,10 @@ import (
185
188
186
189
w .WriteString (decl )
187
190
w .WriteRune ('\n' )
191
+
192
+ nenums ++
188
193
}
194
+ fmt .Printf ("Generated %d enums\n " , nenums )
189
195
190
196
// Assorted structs
191
197
@@ -249,9 +255,8 @@ import (
249
255
return structs [i ].goType < structs [j ].goType
250
256
})
251
257
258
+ var nstructs uint32
252
259
for _ , s := range structs {
253
- fmt .Println ("struct" , s .goType )
254
-
255
260
var t * btf.Struct
256
261
if err := spec .TypeByName (s .cType , & t ); err != nil {
257
262
return nil , err
@@ -260,7 +265,9 @@ import (
260
265
if err := outputPatchedStruct (gf , w , s .goType , t , s .patches ); err != nil {
261
266
return nil , fmt .Errorf ("output %q: %w" , s .goType , err )
262
267
}
268
+ nstructs ++
263
269
}
270
+ fmt .Printf ("Generated %d structs\n " , nstructs )
264
271
265
272
// Attrs
266
273
@@ -592,9 +599,8 @@ import (
592
599
return nil , fmt .Errorf ("split bpf_attr: %w" , err )
593
600
}
594
601
602
+ var nattrs uint32
595
603
for _ , s := range attrs {
596
- fmt .Println ("attr" , s .goType )
597
-
598
604
t := attrTypes [s .cType ]
599
605
if t == nil {
600
606
return nil , fmt .Errorf ("unknown attr %q" , s .cType )
@@ -611,7 +617,9 @@ import (
611
617
case retFd :
612
618
fmt .Fprintf (w , "func %s(attr *%s) (*FD, error) { fd, err := BPF(%s, unsafe.Pointer(attr), unsafe.Sizeof(*attr)); if err != nil { return nil, err }; return NewFD(int(fd)) }\n \n " , s .goType , goAttrType , s .cmd )
613
619
}
620
+ nattrs ++
614
621
}
622
+ fmt .Printf ("Generated %d attrs\n " , nattrs )
615
623
616
624
// Link info type specific
617
625
linkInfoExtraTypes := []struct {
0 commit comments