Skip to content
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

cmd/compile,debug/gosym: generics: compiler produces symbols that gosym can not parse #48032

Closed
aarzilli opened this issue Aug 28, 2021 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@aarzilli
Copy link
Contributor

The symbol names currently produced by the compiler for generic function instantiations can not be parsed by debug/gosym (or any simple parser for that matter).

For example:

func testfunction[T any](arg T) {
	fmt.Println(arg)
}

func main() {
	testfunction(3)
}

Produces the symbol main.testfunction[.shape.int] for which gosym will return:

PackageName: "main"
ReceiverName: "testfunction[.shape"
BaseName: "int]"

instead of:

PackageName: "main"
ReceiverName: ""
BaseName: "testfunction[.shape.int]"

Parsing symbol names is further complicated by generic method instantiations:

type S[T any] struct {
	x T
}

func (s *S[T]) testfunction() {
	fmt.Println(s.x)
}

Will produce the symbol main.(*S[.shape.int]).testfunction, so just looking for the first . instead of the last one doesn't work either.

Referencing issue #37762 here since its making an effort to fix a bug in this area.

@cherrymui cherrymui changed the title cmd/compile,debug/gosym: compiler produces symbols that gosym can not parse cmd/compile,debug/gosym: generics: compiler produces symbols that gosym can not parse Aug 30, 2021
@cherrymui
Copy link
Member

cc @griesemer @randall77 @danscales

@cherrymui cherrymui added the NeedsFix The path to resolution is known, but the work has not been done. label Aug 30, 2021
@cherrymui cherrymui added this to the Go1.18 milestone Aug 30, 2021
@danscales
Copy link
Contributor

@griesemer and I talked. Once some types2 change are complete that will give a better unique name for various types (in a week or two), we will discuss gosym compatibility and other issues related to naming instantiations of generic functions/methods, and come to a more formal decision on the format of names of function instantiations.

In this case, as you describe, the '.' that we are using when specifying the type args of a function instantiation is clearly confusing the current gosym code.

@gopherbot
Copy link

Change https://golang.org/cl/354689 mentions this issue: cmd/compile: adjust debug/gosym to deal with instantiated types/funcs/methods

@golang golang locked and limited conversation to collaborators Oct 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants