]> Cypherpunks repositories - gostls13.git/commitdiff
internal/trace: move maxArgs into tracev2 and validate specs
authorMichael Anthony Knyszek <mknyszek@google.com>
Sat, 1 Feb 2025 05:26:17 +0000 (05:26 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 11 Feb 2025 19:22:32 +0000 (11:22 -0800)
This change moves maxArgs to tracev2 and renames it MaxTimedEventArgs.
It also updates the tests to make sure the specs conform to this
requirement.

Change-Id: I7b0c888a4dfd83306a470a4c9b0f9e44fe2e7818
Reviewed-on: https://go-review.googlesource.com/c/go/+/646016
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

src/internal/trace/base.go
src/internal/trace/tracev2/events.go
src/internal/trace/tracev2/events_test.go

index 5e11c6f0498a66fc19181613692b242115d0635a..693dbc6fa68d1a6cfd6c0f7a09a91fa359979738 100644 (file)
@@ -16,13 +16,9 @@ import (
        "internal/trace/version"
 )
 
-// maxArgs is the maximum number of arguments for "plain" events,
-// i.e. anything that could reasonably be represented as a baseEvent.
-const maxArgs = 5
-
 // timedEventArgs is an array that is able to hold the arguments for any
 // timed event.
-type timedEventArgs [maxArgs - 1]uint64
+type timedEventArgs [tracev2.MaxTimedEventArgs - 1]uint64
 
 // baseEvent is the basic unprocessed event. This serves as a common
 // fundamental data structure across.
index c6dd162a6312a6e4d18806fd5fd127bf907059a3..2f3581ab5b7ccbc76acd6665c71e706ea0f45ae4 100644 (file)
@@ -133,6 +133,9 @@ const (
 
 const NumExperimentalEvents = MaxExperimentalEvent - MaxEvent
 
+// MaxTimedEventArgs is the maximum number of arguments for timed events.
+const MaxTimedEventArgs = 5
+
 func Specs() []EventSpec {
        return specs[:]
 }
index 1f2fbf7610a0860ff0e1a8ba08bea6c119099fec..60c4c08c34a1278acfe150fef90d9289e86aaa80 100644 (file)
@@ -38,6 +38,9 @@ func TestSpecs(t *testing.T) {
                if spec.IsStack && spec.Name != "Stack" {
                        t.Errorf("%s listed as being a stack, but is not the Stack event (unsupported)", spec.Name)
                }
+               if spec.IsTimedEvent && len(spec.Args) > tracev2.MaxTimedEventArgs {
+                       t.Errorf("%s has too many timed event args: have %d, want %d at most", spec.Name, len(spec.Args), tracev2.MaxTimedEventArgs)
+               }
                if ev.Experimental() && spec.Experiment == tracev2.NoExperiment {
                        t.Errorf("experimental event %s must have an experiment", spec.Name)
                }