2013-09-22 27 views
6

mã nguồn của tôi:Cachegrind của không hiển thị chú thích cho mã nguồn của tôi

$ cat play.c 
int main() { 
    return 0; 
} 

Xây dựng và chạy cachegrind vào nó:

$ gcc -g -Wall play.c -o play && valgrind --tool=cachegrind --cachegrind-out-file=out ./play 
==17670== Cachegrind, a cache and branch-prediction profiler 
==17670== Copyright (C) 2002-2012, and GNU GPL'd, by Nicholas Nethercote et al. 
==17670== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info 
==17670== Command: ./play 
==17670== 
--17670-- warning: L3 cache found, using its data for the L2 simulation. 
==17670== 
==17670== I refs:  97,846 
==17670== I1 misses:  697 
==17670== LLi misses:  692 
==17670== I1 miss rate: 0.71% 
==17670== LLi miss rate: 0.70% 
==17670== 
==17670== D refs:  36,490 (25,595 rd + 10,895 wr) 
==17670== D1 misses:  1,657 (1,185 rd + 472 wr) 
==17670== LLd misses:  1,503 (1,043 rd + 460 wr) 
==17670== D1 miss rate: 4.5% ( 4.6%  + 4.3% ) 
==17670== LLd miss rate: 4.1% ( 4.0%  + 4.2% ) 
==17670== 
==17670== LL refs:  2,354 (1,882 rd + 472 wr) 
==17670== LL misses:  2,195 (1,735 rd + 460 wr) 
==17670== LL miss rate:  1.6% ( 1.4%  + 4.2% ) 

Và cuối cùng, chạy cg_annotate:

$ cg_annotate out play.c 
-------------------------------------------------------------------------------- 
I1 cache:   65536 B, 64 B, 2-way associative 
D1 cache:   65536 B, 64 B, 2-way associative 
LL cache:   6291456 B, 64 B, 48-way associative 
Command:   ./play 
Data file:  out 
Events recorded: Ir I1mr ILmr Dr D1mr DLmr Dw D1mw DLmw 
Events shown:  Ir I1mr ILmr Dr D1mr DLmr Dw D1mw DLmw 
Event sort order: Ir I1mr ILmr Dr D1mr DLmr Dw D1mw DLmw 
Thresholds:  0.1 100 100 100 100 100 100 100 100 
Include dirs:  
User annotated: play.c 
Auto-annotation: off 

-------------------------------------------------------------------------------- 
    Ir I1mr ILmr  Dr D1mr DLmr  Dw D1mw DLmw 
-------------------------------------------------------------------------------- 
97,846 697 692 25,595 1,185 1,043 10,895 472 460 PROGRAM TOTALS 

-------------------------------------------------------------------------------- 
    Ir I1mr ILmr Dr D1mr DLmr Dw D1mw DLmw file:function 
-------------------------------------------------------------------------------- 
22,411 13 13 7,443 157 130 3,653 1 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-lookup.c:do_lookup_x 
17,322 10 10 3,596 87 83 1,828 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-lookup.c:_dl_lookup_symbol_x 
15,697 19 19 3,594 557 543 1,927 245 238 /build/eglibc-TepTGA/eglibc-2.17/elf/../sysdeps/x86_64/dl-machine.h:_dl_relocate_object 
9,072 2 2 2,694 17 11  0 0 0 /build/eglibc-TepTGA/eglibc-2.17/string/../sysdeps/x86_64/multiarch/../strcmp.S:strcmp 
8,262 13 13 2,053 84 70 119 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/do-rel.h:_dl_relocate_object 
4,118 6 6 1,732 17 15 497 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-lookup.c:check_match.9345 
1,201 2 2 197 0 0  2 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-minimal.c:strsep 
1,149 36 36 301 1 1 138 10 10 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-load.c:_dl_map_object_from_fd 
1,139 14 14 377 14 13 158 13 13 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-version.c:_dl_check_map_versions 
1,057 31 31 223 1 1 110 2 2 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-deps.c:_dl_map_object_deps 
1,008 13 13 252 11 11 76 3 3 /build/eglibc-TepTGA/eglibc-2.17/string/../string/memcmp.c:bcmp 
    922 67 67 200 22 13 112 10 10 /build/eglibc-TepTGA/eglibc-2.17/elf/rtld.c:dl_main 
    779 2 2 201 6 0 116 2 2 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-misc.c:_dl_name_match_p 
    742 5 5 75 1 1  0 0 0 /build/eglibc-TepTGA/eglibc-2.17/string/../sysdeps/x86_64/multiarch/../rtld-strlen.S:strlen 
    727 4 4 114 10 10  0 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-cache.c:_dl_cache_libcmp 
    606 4 4 114 0 0 112 1 1 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-minimal.c:__libc_memalign 
    586 11 11 96 3 3 111 21 21 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-object.c:_dl_new_object 
    549 8 8 96 14 14 47 12 12 /build/eglibc-TepTGA/eglibc-2.17/elf/get-dynamic-info.h:_dl_map_object_from_fd 
    520 11 11 113 6 6 83 3 3 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-load.c:open_verify 
    512 10 10 19 5 4 295 37 37 /build/eglibc-TepTGA/eglibc-2.17/string/../sysdeps/x86_64/multiarch/../memset.S:memset 
    458 11 11 135 16 0 112 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-reloc.c:_dl_relocate_object 
    450 24 24 89 1 1 73 3 3 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-load.c:_dl_map_object 
    408 11 11 113 16 14 26 4 4 /build/eglibc-TepTGA/eglibc-2.17/elf/../elf/dl-sysdep.c:_dl_sysdep_start 
    377 5 5 54 2 1 39 3 3 /build/eglibc-TepTGA/eglibc-2.17/string/../sysdeps/x86_64/memcpy.S:mempcpy 
    369 5 5 59 0 0 47 6 6 /build/eglibc-TepTGA/eglibc-2.17/string/../sysdeps/x86_64/multiarch/../memcpy.S:memcpy 
    349 14 14 38 2 2 63 6 6 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-load.c:_dl_init_paths 
    344 2 2 117 25 25  2 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-environ.c:_dl_next_ld_env_entry 
    325 3 3  5 0 0 292 36 36 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-tls.c:_dl_allocate_tls_storage 
    317 16 16 49 10 10 27 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-cache.c:_dl_load_cache_lookup 
    311 14 14 105 0 0 42 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-load.c:open_path 
    270 11 11 86 5 0 33 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-fini.c:_dl_fini 
    266 11 11 46 6 6 20 7 7 /build/eglibc-TepTGA/eglibc-2.17/elf/get-dynamic-info.h:_dl_start 
    257 20 20 46 0 0 39 3 3 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-hwcaps.c:_dl_important_hwcaps 
    234 8 8 34 6 6 23 6 6 /build/eglibc-TepTGA/eglibc-2.17/elf/get-dynamic-info.h:dl_main 
    232 4 4 73 14 0 35 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-init.c:call_init 
    211 1 1 63 11 11 19 5 5 /build/eglibc-TepTGA/eglibc-2.17/elf/../sysdeps/x86_64/dl-machine.h:_dl_start 
    207 2 2 18 3 3  0 0 0 /build/eglibc-TepTGA/eglibc-2.17/string/../sysdeps/x86_64/multiarch/../strchr.S:index 
    185 5 5 72 4 4 27 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-version.c:match_symbol 
    181 7 7 49 1 0 25 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-fini.c:_dl_sort_fini 
    175 17 13 83 1 0 21 1 1 ???:??? 
    175 6 6 20 4 2 19 6 6 /build/eglibc-TepTGA/eglibc-2.17/elf/rtld.c:_dl_start 
    168 10 10 18 2 2  6 0 0 /build/eglibc-TepTGA/eglibc-2.17/string/../sysdeps/x86_64/multiarch/../cacheinfo.c:handle_amd 
    156 6 6 56 1 0 18 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/../elf/dl-runtime.c:_dl_fixup 
    146 2 2 30 5 5  0 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/do-rel.h:_dl_start 
    137 11 11 30 0 0 34 2 2 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-load.c:fillin_rpath 
    125 14 14 11 1 0 29 4 2 /build/eglibc-TepTGA/eglibc-2.17/string/../sysdeps/x86_64/multiarch/../cacheinfo.c:init_cacheinfo 
    111 3 3 36 0 0 51 5 5 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-error.c:_dl_catch_error 
    106 3 3 26 0 0 20 0 0 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-object.c:_dl_add_to_namespace_list 
    100 2 2 28 5 5 24 1 1 /build/eglibc-TepTGA/eglibc-2.17/elf/dl-lookup.c:_dl_setup_hash 

-------------------------------------------------------------------------------- 
-- User-annotated source: play.c 
-------------------------------------------------------------------------------- 
    No information has been collected for play.c 

Tại sao No information has been collected for play.c? Tôi hy vọng sẽ thấy rằng nếu tôi không xây dựng với các biểu tượng gỡ lỗi, nhưng tôi đã làm.

Trong trường hợp nó có liên quan, đây là Debian "jessie", với GCC 4.8.1 và Valgrind 3.8.1.

Trả lời

7

Nó không đủ để xác định tập tin nguồn Tôi muốn chú thích như một đường dẫn tương đối, vì vậy không ai trong số 2 lệnh sau sẽ làm việc:

$ cg_annotate out play.c 
$ cg_annotate out ./play.c 

Nó phải là một đường dẫn tuyệt đối:

$ cg_annotate out ~/projects/utils/play.c 
[snip] 
-------------------------------------------------------------------------------- 
-- User-annotated source: /home/tshepang/projects/utils/play.c 
-------------------------------------------------------------------------------- 
Ir I1mr ILmr Dr D1mr DLmr Dw D1mw DLmw 

2 0 0 0 0 0 1 0 0 int main() { 
1 0 0 0 0 0 0 0 0 return 0; 
2 0 0 2 0 0 0 0 0 } 

[snip] 

Lưu ý rằng callgrind_annotate sẽ chỉ hoạt động khi được gọi theo cách sau (giả sử, tất nhiên, chúng tôi đã chạy Valgrind với callgrind công cụ i nstead của cachegrind):

$ callgrind_annotate out play.c 

Hai hình thức khác (./play.c~/projects/utils/play.c) không có tác dụng, làm cho này lỗi một UX.

+0

Rất tiếc, tôi nhận được kết quả tương tự như khi chạy 'callgrind_annotate relative_path'. Có bất kỳ lời đề nghị khác? – Juto

+0

Hệ điều hành của tôi là Mac OS X – Juto

+0

Tôi không biết. Có thể hỏi một câu hỏi riêng? – Tshepang

Các vấn đề liên quan