最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do I profile c++ code on macOS sequoia using pprof and gperftools - Stack Overflow

programmeradmin1浏览0评论

I'm trying to profile my c++ code on macOS using gperftools and pprof. I have installed gperftools and I am able to successfully run g++ test.cpp -o test -lprofiler and CPUPROFILE=~/prof.out ./test. But when I try to run pprof -text test ~/prof.out, I'm getting the following error:

Using local file test.
Using local file /Users/<username>/prof.out.
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libcharset.1.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libcharset.1.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libcharset.1.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libcharset.1.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libcharset.1.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libiconv.2.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libiconv.2.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libiconv.2.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libiconv.2.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libiconv.2.dylib (No such file or directory)
.
.

and a lot other .dylib files as well.

I've tried reinstalling Xcode command line tools, but still doesn't work. Can't seem to find any related issue. Any help would be appreciated.

I'm trying to profile my c++ code on macOS using gperftools and pprof. I have installed gperftools and I am able to successfully run g++ test.cpp -o test -lprofiler and CPUPROFILE=~/prof.out ./test. But when I try to run pprof -text test ~/prof.out, I'm getting the following error:

Using local file test.
Using local file /Users/<username>/prof.out.
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libcharset.1.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libcharset.1.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libcharset.1.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libcharset.1.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libcharset.1.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libiconv.2.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libiconv.2.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libiconv.2.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libiconv.2.dylib (No such file or directory)
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /usr/lib/libiconv.2.dylib (No such file or directory)
.
.

and a lot other .dylib files as well.

I've tried reinstalling Xcode command line tools, but still doesn't work. Can't seem to find any related issue. Any help would be appreciated.

Share Improve this question edited Mar 16 at 1:00 Harith Laxman asked Mar 16 at 0:44 Harith LaxmanHarith Laxman 791 silver badge4 bronze badges 1
  • Please use a code block for posting text outputs of tools. – 3CxEZiVlQ Commented Mar 16 at 0:52
Add a comment  | 

1 Answer 1

Reset to default 1

So, first, use pprof tool from github/google/pprof. It is much better.

Second, those "missing" dylibs are actually missing. Kinda. OSX now has some sort of linker cache or something and a number of system libraries are there. So pprof won't be able to symbolize addresses inside those. But in many cases it is harmless. New pprof will still plot something like [libiconv.2.dylib] in place of actual functions if you have them in profile.

发布评论

评论列表(0)

  1. 暂无评论