8

My C++ program is consuming a lot of CPU, and more so as it runs. I used Google Performance Tools to profile CPU usage, and this is what I got:

(pprof) top
Total: 1343 samples
    1330  99.0%  99.0%     1330  99.0% 0x0000000801dcb11c
       7   0.5%  99.6%        7   0.5% 0x0000000801dcb11e
       4   0.3%  99.9%        4   0.3% program::threadWorker
       1   0.1%  99.9%        1   0.1% 0x0000000801dcb110
       1   0.1% 100.0%        1   0.1% 0x00007fffffffffc0

However, only 1 out of the 5 processes shown here is an actual function name; the rest are addresses. How can I find out what these addresses pertain to? (Of course, I am most interested in the first address shown above)

Edit: This is how I ran the profiler:

env CPUPROFILE=prof.out ./a.out
[kill program]

pprof ./a.out prof.out

Also, I found the root cause by code inspection. But it would still be nice to have the profiler pinpoint the culprit function rather than an address.

xmoex
  • 2,602
  • 22
  • 36
jules
  • 386
  • 4
  • 13

1 Answers1

3

Is it possible you haven't specified the executable when loading the results in google-pprof?

I run it as:

$ google-pprof executable /tmp/executable.hprof --text | less

and can see the function names just fine. Or that those methods are in some shared library not in your path when you run google-pprof?

Stephen Johnson
  • 467
  • 3
  • 8
  • I edited my question to include how I ran the profiler. I found the culprit function, which is declared in the same file and not from a shared library. – jules Oct 14 '11 at 06:37
  • @Mike Dunlavey: no, I found it by code inspection because my program is rather small. – jules Oct 17 '11 at 19:06
  • @jules: You might want to [try this](http://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux/378024#378024). – Mike Dunlavey Oct 17 '11 at 20:26