2016-11-20 7 views
3

목표 : callgrind (및 나중에 cachegrind의 출력)를 분석 할 수 있기를 원하며 callgrind_annotate CLI를 사용할 때 의미있는 변수 이름을보고 싶습니다.명령 줄에서 OSX의 callgrind 출력에 의미있는 함수 이름을 어떻게 얻을 수 있습니까?

이전 연구 : 나는 Valgrind의 (http://valgrind.org/docs/manual/manual-core.html)에서 dsym 플래그 알고 내가 디버그 기호 OSX (LLDB not showing source code)에 작동하는 방법에 대한 이해를 믿습니다. 이 사이트에서 본 이슈에 대한 언급 중 일부는 답이 없거나 -g 플래그가 포함되지 않은 경우입니다.

이론 (... 잘못 될 수 있음) :. Valgrind의이 dsym 디렉토리의 경로를 찾기 위해 고군분투 만약 내가 궁금하네요 Valgrind의 출력에서 ​​"DYM ="라인을 바탕으로 "

어떤 데이터가 당신을 줄 수

주어진 다음의 소스 코드 : 다음 명령 줄 지침을 사용 하였다

#include <iostream> 
#include <cmath> 
bool isPrime(int x) 
{ 
     int limit = std::sqrt(x); 
     for (int i = 2; i <= limit; ++i) 
     { 
       if (x % i == 0) 
       { 
         return false; 
       } 
     } 
     return true; 
} 
int main() 
{ 
     int primeCount = 0; 
     for (int i = 0; i < 1000000; ++i) 
     { 
       if (isPrime(i)) 
       { 
         ++primeCount; 
       } 
     } 
} 

을 :

g++ -g -c badprime.cpp 
g++ badprime.o -o badprime 
nm -pa badprime 
dsymutil badprime 
valgrind --tool=callgrind --dsymutil=yes ./badprime 
callgrind_annotate --auto=yes callgrind.out.45056 badprime.cpp 

nm -pa 비트는 디버깅 맵 정보가 있는지 확인하기위한 것입니다. 또한 디버깅 정보가 있는지 확인하기 위해 dSYM 폴더에서 dwarfdump를 실행했습니다. annotate 명령의 출력으로 "badprime.cpp에 대한 정보가 수집되지 않았습니다."라는 줄로 인사합니다.

컴파일러 소개 :

Apple LLVM version 8.0.0 (clang-800.0.42.1) 
Target: x86_64-apple-darwin15.6.0 

Valgrind의 정보 :

$ valgrind --tool=callgrind --dsymutil=yes -v ./badprime 
==45056== Callgrind, a call-graph generating cache profiler 
==45056== Copyright (C) 2002-2015, and GNU GPL'd, by Josef Weidendorfer et al. 
==45056== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info 
==45056== Command: ./badprime 
==45056== 
--45056-- Valgrind options: 
--45056-- --tool=callgrind 
--45056-- --dsymutil=yes 
--45056-- -v 
--45056-- Output from sysctl({CTL_KERN,KERN_VERSION}): 
--45056-- Darwin Kernel Version 15.6.0: Thu Jun 23 18:25:34 PDT 2016; root:xnu-3248.60.10~1/RELEASE_X86_64 
--45056-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-lzcnt-rdtscp-sse3-avx-avx2-bmi 
--45056-- Page sizes: currently 4096, max supported 4096 
--45056-- Valgrind library directory: /usr/local/Cellar/valgrind/3.11.0/lib/valgrind 
==45056== For interactive control, run 'callgrind_control -h'. 
--45056-- /usr/lib/dyld (rx at 0x7fff5fc00000, rw at 0x7fff5fc38000) 
--45056-- reading syms from primary file (6 1229) 
--45056-- Scheduler: using generic scheduler lock implementation. 
==45056== embedded gdbserver: reading from /var/folders/7h/d91hqksj7bdfxp0km10b2qn40000gp/T//vgdb-pipe-from-vgdb-to-45056-by-dudett-on-??? 
==45056== embedded gdbserver: writing to /var/folders/7h/d91hqksj7bdfxp0km10b2qn40000gp/T//vgdb-pipe-to-vgdb-from-45056-by-dudett-on-??? 
==45056== embedded gdbserver: shared mem /var/folders/7h/d91hqksj7bdfxp0km10b2qn40000gp/T//vgdb-pipe-shared-mem-vgdb-45056-by-dudett-on-??? 
==45056== 
==45056== TO CONTROL THIS PROCESS USING vgdb (which you probably 
==45056== don't want to do, unless you know exactly what you're doing, 
==45056== or are doing some strange experiment): 
==45056== /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/../../bin/vgdb --pid=45056 ...command... 
==45056== 
==45056== TO DEBUG THIS PROCESS USING GDB: start GDB like this 
==45056== /path/to/gdb ./badprime 
==45056== and then give GDB the following command 
==45056== target remote | /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/../../bin/vgdb --pid=45056 
==45056== --pid is optional if only one valgrind process is running 
==45056== 
--45056-- /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_core-amd64-darwin.so (rx at 0x100002000, rw at 0x100004000) 
--45056-- reading syms from primary file (3 21) 
--45056-- dSYM= /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_core-amd64-darwin.so.dSYM/Contents/Resources/DWARF/vgpreload_core-amd64-darwin.so 

callgrind_annotate 출력 :

0,123,545,174,527,349,278,833,177,832 Valgrind의 행

valgrind-3.11.0 

초기 상세 출력 10

나는 도움이 될 수있는 모든 것에 매우 감사하게 생각합니다.

답변

1

링커 (ld) 명령 줄 옵션을 확인하십시오. -s은 모든 기호 정보를 제거하며 컴파일러에서 -g보다 우선합니다. ld 매뉴얼에서

는 :

-s 
--strip-all 
Omit all symbol information from the output file. 

ftp link

나는 당신이 연결을 위해 ld를 사용하지 않는 것으로 나타났습니다. 따라서 이것은 귀하의 문제에는 적용되지 않습니다. 그러나 나는이 문제를 경험하고 ld을 사용하는 사람들을 위해 나의 대답을 남겨 둘 것입니다.