-
Notifications
You must be signed in to change notification settings - Fork 607
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
use simplified demangled symbol names in disassembly report #449
Changes from all commits
722e882
4a33a9b
0de8ff2
d681580
0153aa7
4d646c8
e71d09f
8a1a78d
4009e9c
f6a8201
15a7500
6eaec37
5987a5e
1462b2f
cecb2a5
9297b70
db747b2
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 |
---|---|---|
|
@@ -31,6 +31,7 @@ import ( | |
"github.com/google/pprof/internal/measurement" | ||
"github.com/google/pprof/internal/plugin" | ||
"github.com/google/pprof/profile" | ||
"github.com/ianlancetaylor/demangle" | ||
) | ||
|
||
// Output formats. | ||
|
@@ -432,6 +433,9 @@ func PrintAssembly(w io.Writer, rpt *Report, obj plugin.ObjTool, maxFuncs int) e | |
} | ||
} | ||
|
||
// demangle symbols by default for disassembly report | ||
options := []demangle.Option{demangle.NoParams, demangle.NoTemplateParams} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would've preferred to have a way to control this, (eg with symbolize=demangle=xxx). Sometimes having the mangled name is useful |
||
|
||
// Correlate the symbols from the binary with the profile samples. | ||
for _, s := range syms { | ||
sns := symNodes[s] | ||
|
@@ -447,7 +451,13 @@ func PrintAssembly(w io.Writer, rpt *Report, obj plugin.ObjTool, maxFuncs int) e | |
|
||
ns := annotateAssembly(insts, sns, s.base) | ||
|
||
fmt.Fprintf(w, "ROUTINE ======================== %s\n", s.sym.Name[0]) | ||
if strings.HasPrefix(s.sym.Name[0], "__Z") { | ||
// Workaround to handle double leading underscores on Mac | ||
// which are not properly handled by the demangle.Filter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we open an issue against the demangle package for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
fmt.Fprintf(w, "ROUTINE ======================== %s\n", demangle.Filter(s.sym.Name[0][1:], options...)) | ||
} else { | ||
fmt.Fprintf(w, "ROUTINE ======================== %s\n", demangle.Filter(s.sym.Name[0], options...)) | ||
} | ||
for _, name := range s.sym.Name[1:] { | ||
fmt.Fprintf(w, " AKA ======================== %s\n", name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we demangle these ones too? |
||
} | ||
|
@@ -462,7 +472,7 @@ func PrintAssembly(w io.Writer, rpt *Report, obj plugin.ObjTool, maxFuncs int) e | |
if n.function != function || n.file != file || n.line != line { | ||
function, file, line = n.function, n.file, n.line | ||
if n.function != "" { | ||
locStr = n.function + " " | ||
locStr = demangle.Filter(n.function, options...) + " " | ||
} | ||
if n.file != "" { | ||
locStr += n.file | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2019 Google Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// sample program that is used to produce some of the files in | ||
// pprof/internal/report/testdata. | ||
|
||
#include <iostream> | ||
|
||
using namespace std; | ||
int main(int argc, char** argv) { | ||
cout << "Hello World!" << endl; | ||
return 0; | ||
} |
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.
So without this disasm doesn't work on Mac at all? If that's the case perhaps we should put this on its own PR
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.
#534