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

Improve handling of Go symbols with type parameters #717

Merged
merged 3 commits into from
Jul 29, 2022

Conversation

prattmic
Copy link
Member

This PR fixes two issues:

  1. Demangle detects Go symbols with type parameters as C++ symbols and strips out parentheses (e.g., main.(*Foo[...]).Method -> main..Method.
  2. Dot conversion replaces . with newlines, converting [...] -> [\n\n\n].

See individual commit messages for more details.

Fixes #705

For the curious: `bar(int (*) [5])` is a pointer to an array of
length 5:

	typedef int IntArray[5];
	int bar(IntArray* arr);

For google#705.
@codecov-commenter
Copy link

codecov-commenter commented Jul 28, 2022

Codecov Report

Merging #717 (4a542c6) into main (c488b8f) will increase coverage by 0.51%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #717      +/-   ##
==========================================
+ Coverage   63.70%   64.21%   +0.51%     
==========================================
  Files          41       41              
  Lines        6489     6495       +6     
==========================================
+ Hits         4134     4171      +37     
+ Misses       1913     1881      -32     
- Partials      442      443       +1     
Impacted Files Coverage Δ
...github.com/google/pprof/internal/graph/dotgraph.go 90.32% <0.00%> (+0.04%) ⬆️
...com/google/pprof/internal/symbolizer/symbolizer.go 55.11% <0.00%> (+19.44%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us.

Go symbols with type parameters are reported in Go pprof profiles as
something like `main.Set[...]`.

Today, multilinePrintableName mishandles this by replacing each with a
newline, resulting in a very strange looking node.

Instead, replace ... with a unicode ellipsis so that it isn't replaced
with a newline just below.

Note that the full symbol name (which is reported by tools like perf) is
something like `[go.shape.string_0,go.shape.int_1]`. This case is still
not handled very well, but we likely want to strip this out anyways in
ShortenFunctionName or demangling as future work.

Fixes google#705.
@aalexand aalexand merged commit a41b82a into google:main Jul 29, 2022
gopherbot pushed a commit to golang/go that referenced this pull request Aug 9, 2022
…bol names

Updates github.com/google/pprof to bring in the commit from
google/pprof#717 which fixes mangled
symbol names for type parameters.

Fixes #54105

Change-Id: I01af9f780aba3338b960a03b30906a23642e4448
Reviewed-on: https://go-review.googlesource.com/c/go/+/420234
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Than McIntosh <thanm@google.com>
jproberts pushed a commit to jproberts/go that referenced this pull request Aug 10, 2022
…bol names

Updates github.com/google/pprof to bring in the commit from
google/pprof#717 which fixes mangled
symbol names for type parameters.

Fixes golang#54105

Change-Id: I01af9f780aba3338b960a03b30906a23642e4448
Reviewed-on: https://go-review.googlesource.com/c/go/+/420234
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Than McIntosh <thanm@google.com>
gopherbot pushed a commit to golang/go that referenced this pull request Aug 19, 2022
…ngled type parameter symbol names

Updates github.com/google/pprof to bring in the commit from
google/pprof#717 which fixes mangled
symbol names for type parameters.

For #54105
Fixes #54420

Change-Id: I01af9f780aba3338b960a03b30906a23642e4448
Reviewed-on: https://go-review.googlesource.com/c/go/+/420234
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Than McIntosh <thanm@google.com>
(cherry picked from commit cd9cd92)
Reviewed-on: https://go-review.googlesource.com/c/go/+/423356
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
bradfitz pushed a commit to tailscale/go that referenced this pull request Sep 8, 2022
…ngled type parameter symbol names

Updates github.com/google/pprof to bring in the commit from
google/pprof#717 which fixes mangled
symbol names for type parameters.

For golang#54105
Fixes golang#54420

Change-Id: I01af9f780aba3338b960a03b30906a23642e4448
Reviewed-on: https://go-review.googlesource.com/c/go/+/420234
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Than McIntosh <thanm@google.com>
(cherry picked from commit cd9cd92)
Reviewed-on: https://go-review.googlesource.com/c/go/+/423356
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pprof: symbolize mishandles the names of methods of parameterized Go types
3 participants