Comments (15)
After installing llvm-symbolizer I managed to get this to work with a toy program:
$ brew install gperftools
$ rm /usr/local/bin/pprof
$ go get pprof # And add ~/go/bin to PATH
$ brew install llvm
$ ln -s /usr/local/opt/llvm/bin/llvm-symbolizer /usr/local/bin/llvm-symbolizer
$ mkdir tmp
$ cd tmp
$ echo "see example below" > main.cpp
$ clang++ -fno-pie -lprofiler -g -O0 main.cpp -o main
$ CPUPROFILE=prof.out ./main
$ pprof -weblist ".*" prof.out
This produces a nice output. -fno-pie
is definitely necessary, otherwise it doesn't work.
However when I try it on my actual project I only get this output:
_mh_execute_header
??Total: 0 200ms (flat, cum) 0.47%
I am building the project using QBS, and it seems that pprof thinks the executable is in /var/folders/hc/__somerandomstuff/T/mygreat-abe32b32
rather than its actual name mygreat_project
. I don't know much about how QBS works but I guess it is building it in that temporary directory and then moving the result. Anyone have any idea what could be going on here?
Example profileable code
I used this from rosetta code:
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <list>
bool k_prime(unsigned n, unsigned k) {
unsigned f = 0;
for (unsigned p = 2; f < k && p * p <= n; p++)
while (0 == n % p) { n /= p; f++; }
return f + (n > 1 ? 1 : 0) == k;
}
std::list<unsigned> primes(unsigned k, unsigned n) {
std::list<unsigned> list;
for (unsigned i = 2;list.size() < n;i++)
if (k_prime(i, k)) list.push_back(i);
return list;
}
int main(const int argc, const char* argv[]) {
using namespace std;
for (unsigned k = 1; k <= 20; k++) {
ostringstream os("");
const list<unsigned> l = primes(k, 10);
for (list<unsigned>::const_iterator i = l.begin(); i != l.end(); i++)
os << setw(4) << *i;
cout << "k = " << k << ':' << os.str() << endl;
}
return EXIT_SUCCESS;
}
from pprof.
pprof translates addresses to line information using either GNU addr2line or LLVM llvm-symbolizer. I see you are on a Mac, which by default doesn't have either one. You need to find a way to install one or the other (probably llvm-symbolizer).
from pprof.
Hi @rsc, thanks for the reply :) It's unfortunate that we depend on llvm-symbolizer which is not shipped on OSX and not readily available in Homebrew either. Do you know where I'm supposed to get it from? Do I have to build LLVM from source? Is it possible to use atos
which does ship with OSX instead?
from pprof.
FWIW, llvm-symbolizer is available on brew, via the llvm formula. It is not necessary to build from source.
$ brew install llvm
...
$ (brew --prefix llvm)/bin/llvm-symbolizer
-r-xr-xr-x 1 tamird admin 2.8M Mar 7 15:44 /usr/local/opt/llvm/bin/llvm-symbolizer
$
from pprof.
It should be possible to add atos support. I'll give that a stab
from pprof.
Thanks both! I hadn't even thought to look for an LLVM package in Homebrew. I now have llvm-symbolizer installed, but I'm afraid I'm still not getting symbols resolved (apart from a few that look like OpenSSL libraries):
$ /usr/local/bin/pprof --text ./_test /tmp/prof.out
Using local file ./_test.
Using local file /tmp/prof.out.
Total: 346 samples
97 28.0% 28.0% 97 28.0% 0x00007fff8b94f362
61 17.6% 45.7% 61 17.6% 0x00007fff8b94f2a2
39 11.3% 56.9% 39 11.3% 0x00007fff8b94ef12
27 7.8% 64.7% 27 7.8% 0x00007fff8b94d532
...
0 0.0% 100.0% 1 0.3% 0x5c28d1c3ffffffff
0 0.0% 100.0% 1 0.3% _EVP_DigestInit_ex
0 0.0% 100.0% 1 0.3% _HMAC
0 0.0% 100.0% 1 0.3% _HMAC_Init_ex
0 0.0% 100.0% 315 91.0% __mh_execute_header
Any ideas for what else I could try?
from pprof.
PATH=$PATH:$(brew --prefix llvm)/bin/llvm-symbolizer /usr/local/bin/pprof --text ./_test /tmp/prof.out
?
from pprof.
@tamird thanks for the suggestion, but I'm afraid that doesn't help. I have llvm-symbolizer on my PATH anyway, so adding it again makes no difference.
from pprof.
Hi, is there anymore progress? I'm still experiencing the same problem now(gperftools and standalone pprof)
from pprof.
It seems that using -Wl,-no-pie
compiler option fixes for the executable itself, but the system libraries are not fixed still.
from pprof.
I wish to report that I have this issue as well. @LukeXuan can you expand further on what you meant by the compiler option? I tried it in my CMakeslist.txt
, and it didn't work for me. Further I couldn't even find that compiler option anywhere.
I am currently on MacOS 10.12, using GCC/G++ 7 (I wanted OpenMP), standalone pprof
, and I installed binutils
for addr2line
. Note that binutils
from homebrew named its exec gaddr2line, so I symlinked it to addr2line
in /usr/local/bin
. Which is how I can call it from terminal.
I can call addr2line from terminal, and a cursory look in the Go code seems like there is provision for pprof to look for addr2line from the current $PATH. I did not have the necessary time to figure out if Go was actually able to find addr2line or not, but I don't see why not.
from pprof.
Hi, firstly I'm using llvm toolchain from homebrew(I just made sure that llvm-symbolizer
is in the PATH). The compile command is like
clang++ -std=c++1z -Og -g3 -lprofiler -Wl,-no_pie source.cpp exec
Then nearly everything works fine for me.
from pprof.
I also get the same problem, when using pprof to show profile information, I just get below result:
$pprof --text ./test cpu-test.pprof
File: test
Type: cpu
Showing nodes accounting for 23.31s, 100% of 23.31s total
flat flat% sum% cum cum%
23.31s 100% 100% 23.31s 100% [test]
while using go tool pprof
, I can get detailed profile info, like below:
File: test
Type: inuse_space
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 627.26MB, 97.76% of 641.66MB total
Dropped 68 nodes (cum <= 3.21MB)
Showing top 10 nodes out of 47
flat flat% sum% cum cum%
223.52MB 34.83% 34.83% 223.52MB 34.83% runtime.stackfree /home/test/bin/go/src/runtime/stack.go
131.03MB 20.42% 55.25% 131.03MB 20.42% runtime.mapassign /home/test/bin/go/src/runtime/hashmap.go
107.52MB 16.76% 72.01% 107.52MB 16.76% runtime.mallocinit /home/test/bin/go/src/runtime/malloc.go
from pprof.
Aha solved it! The problem was that I turned QBS's modules.cpp.positionIndependentCode
option off but that doesn't add -fno-pie
. I guess maybe it just sets it to 'auto' rather than forces it to off? Anyway with these options it finally works:
modules.cpp.linkerFlags:-lprofiler modules.cpp.driverFlags:-fno-pie modules.cpp.positionIndependentCode:false
from pprof.
This should be fixed now with the recent improvements of handling binaries on OSX. Please file specific issues if still not working.
from pprof.
Related Issues (20)
- Patch CVE for d3-color HOT 1
- make sources/sinks a different color HOT 2
- Canvas size related to initial size of a graph, should use the full space
- New flamegraph: 'hover shows details on the top' from old flame-graph missing HOT 2
- Nice to have: 'grab' cursor when dragging the graph HOT 2
- How to load debug symbols from separately installed `-dbgsym` packages? HOT 7
- don't need profile after convert HOT 1
- Pprof does not resolve symbols HOT 2
- [Help Needed] How to Accelerate `pprof -top` Command Execution for Profiling Data? HOT 2
- extended dependencies because of browser test HOT 4
- panics if profile is not found HOT 1
- The calling relationship of CPU profile results is wrong HOT 3
- New flamegraph cannot copy strings
- Unknown heap traces HOT 1
- list [-e] [-f format] [-json] [build flags] HOT 1
- list [-e] [-f format] [-json] [build flags] ...
- How to efficiently compress pprof files? HOT 1
- Add release tag HOT 1
- Symbolization seems to fail with buildID mismatch error when a profiling target application is run by invoking a linker directly HOT 1
- How to implement `/pprof/symbol` API for RelWithDebInfo ELF . HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pprof.