gpt4 book ai didi

Cachegrind 的 cg_annotate 不显示我的源代码的注释

转载 作者:太空狗 更新时间:2023-10-29 17:22:13 27 4
gpt4 key购买 nike

我的源代码:

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

在其上构建并运行 cachegrind:

$ 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% )

最后,运行 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

为什么 没有收集到 play.c 的信息?如果我不使用调试符号构建,我希望看到这一点,但我做到了。

如果相关,这是 Debian "jessie",GCC 4.8.1 和 Valgrind 3.8.1

最佳答案

将我要注释的源文件指定为相对路径是不够的,因此以下 2 个命令都不起作用:

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

必须是绝对路径:

$ 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]

请注意,callgrind_annotate 仅在按以下方式调用时有效(当然,假设我们使用 callgrind 工具而不是 cachegrind):

$ callgrind_annotate out play.c

其他两种形式(./play.c~/projects/utils/play.c)不工作,这是一个 UX 错误。

关于Cachegrind 的 cg_annotate 不显示我的源代码的注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18944716/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com