Skip to content

handle demangling OSX names with underscore prefix#924

Merged
aalexand merged 1 commit into
google:mainfrom
alk:osx-un-underscore
Jan 25, 2025
Merged

handle demangling OSX names with underscore prefix#924
aalexand merged 1 commit into
google:mainfrom
alk:osx-un-underscore

Conversation

@alk

@alk alk commented Jan 23, 2025

Copy link
Copy Markdown
Contributor

See discussion at #477 (comment)

// OSX has all the symbols prefixed with extra '_' so lets try
// once more without it
if strings.HasPrefix(fn.SystemName, "_") {
if demangled := demangle.Filter(fn.SystemName[1:], o...); demangled != fn.SystemName {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just pass strings.StripPrefix(fn.SystemName, "_"), ... in the demangle.Filter call above?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above? So just cut all the time no matter OS and everything? Then it won't work, since _ is usually used for mangled names for regular OS-es. And cutting it will simply break everything.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, got it.

Can we add a test that will exercise this code path?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack. Added test case.

@alk
alk force-pushed the osx-un-underscore branch from 7dd4dbb to 85c67d0 Compare January 24, 2025 01:36
@codecov-commenter

codecov-commenter commented Jan 24, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.96%. Comparing base (0ed6a68) to head (85c67d0).
Report is 62 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #924      +/-   ##
==========================================
+ Coverage   66.86%   66.96%   +0.09%     
==========================================
  Files          44       44              
  Lines        9824     9864      +40     
==========================================
+ Hits         6569     6605      +36     
- Misses       2794     2820      +26     
+ Partials      461      439      -22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alk

alk commented Jan 24, 2025

Copy link
Copy Markdown
Contributor Author

The failure looks like a flake. The failed test looks unrelated to my change. But do let me know if I am mistaken. And if there is anything I can do to help.

@aalexand

Copy link
Copy Markdown
Collaborator

The failure looks like a flake. The failed test looks unrelated to my change. But do let me know if I am mistaken. And if there is anything I can do to help.

Right, it's a known recent flaky error, I filed #925 to track it. I restarted the failed test.

@alk

alk commented Jan 25, 2025

Copy link
Copy Markdown
Contributor Author

Thanks. Test passed now. So what happens next ?

@aalexand
aalexand merged commit 7fdb3d7 into google:main Jan 25, 2025
@aalexand

Copy link
Copy Markdown
Collaborator

merged

aalexand added a commit to aalexand/pprof that referenced this pull request Apr 17, 2025
This is a follow-up to google#924. In the comparison we should compare to the
string with stripped underscore, otherwise the comparison will never be
true and we strip the underscore in cases we shouldn't. See the added
test case.

Also, while we are here, add copying demangling options that we also
missed. Hopefully we can get
ianlancetaylor/demangle#24 in and this won't be
needed.
aalexand added a commit that referenced this pull request Apr 17, 2025
This is a follow-up to #924. In the comparison we should compare to the
string with stripped underscore, otherwise the comparison will never be
true and we strip the underscore in cases we shouldn't. See the added
test case.

Also, while we are here, add copying demangling options that we also
missed. Hopefully we can get
ianlancetaylor/demangle#24 in and this won't be
needed.
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.

3 participants