-
Notifications
You must be signed in to change notification settings - Fork 110
Fix: Correctly instrument newproc1 for Go 1.23+ parameter counts (#13188) #216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
be77826
a988dae
0d2546c
a94ffa7
b9f5abc
141b560
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,11 @@ | |||||
|
|
||||||
| package api | ||||||
|
|
||||||
| import "path/filepath" | ||||||
| import ( | ||||||
| "path/filepath" | ||||||
| "strconv" | ||||||
| "strings" | ||||||
| ) | ||||||
|
|
||||||
| type CompileOptions struct { | ||||||
| Package string `swflag:"-p"` | ||||||
|
|
@@ -35,3 +39,39 @@ func (c *CompileOptions) IsValid() bool { | |||||
| func (c *CompileOptions) CompileBaseDir() string { | ||||||
| return filepath.Dir(filepath.Dir(c.Output)) | ||||||
| } | ||||||
|
|
||||||
| func (c *CompileOptions) CheckGoVersionGreaterOrEqual(requiredMajor, requiredMinor int) bool { | ||||||
| if c.Lang == "" { | ||||||
| return false | ||||||
| } | ||||||
| if !strings.HasPrefix(c.Lang, "go") { | ||||||
| return false | ||||||
| } | ||||||
| versionStr := strings.TrimPrefix(c.Lang, "go") | ||||||
| parts := strings.SplitN(versionStr, ".", 3) | ||||||
| if len(parts) < 2 { | ||||||
| return false | ||||||
| } | ||||||
|
|
||||||
| majorStr := parts[0] | ||||||
| currentMajor64, err := strconv.ParseInt(majorStr, 10, 64) | ||||||
| if err != nil { | ||||||
| return false | ||||||
| } | ||||||
| currentMajor := int(currentMajor64) | ||||||
|
|
||||||
| minorStr := parts[1] | ||||||
| currentMinor64, err := strconv.ParseInt(minorStr, 10, 64) | ||||||
| if err != nil { | ||||||
| return false | ||||||
| } | ||||||
| currentMinor := int(currentMinor64) | ||||||
|
|
||||||
| if currentMajor > requiredMinor { | ||||||
| return true | ||||||
| } | ||||||
| if currentMajor == requiredMajor && currentMinor >= requiredMajor { | ||||||
|
||||||
| if currentMajor == requiredMajor && currentMinor >= requiredMajor { | |
| if currentMajor == requiredMajor && currentMinor >= requiredMinor { |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -18,9 +18,6 @@ | |||||
| package runtime | ||||||
|
|
||||||
| import ( | ||||||
| "strconv" | ||||||
| "strings" | ||||||
|
|
||||||
| "github.com/dave/dst" | ||||||
| "github.com/dave/dst/dstutil" | ||||||
|
|
||||||
|
|
@@ -73,7 +70,11 @@ func (r *Instrument) FilterAndEdit(path string, curFile *dst.File, cursor *dstut | |||||
| if len(n.Type.Results.List) != 1 { | ||||||
| return false | ||||||
| } | ||||||
| if len(n.Type.Params.List) != 3 { | ||||||
| expectedParamCount := 3 | ||||||
| if r.opts.CheckGoVersionGreaterOrEqual(1, 23) { | ||||||
| expectedParamCount = 5 | ||||||
|
||||||
| expectedParamCount = 5 | |
| expectedParamCount = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison should be with requiredMajor, not requiredMinor, to correctly determine if the current major version exceeds the required major version.