Kcachegrind 的输出令人困惑

发布于 2024-12-14 18:51:40 字数 3136 浏览 2 评论 0原文

在此处输入链接说明

您好, 我正在使用 Kcachegrind 分析我的 C 代码。但我对调用图的输出树形图视图感到困惑(请参阅上面提到的链接)。我编译了代码: valgrind --tool=callgraph ./Program_name 然后 kcachegrind callgrind.out.8389。我有以下问题:

  1. 在 main() 函数上方,您将看到“main() 下方”和 0x08048bb0 函数。这些是什么?是不是因为编译器/操作系统没有加载程序映像,直接跳转到main()。我读过,在调用 main() 之前,进程会执行大量代码来“清理执行空间”。这是原因吗?

  2. 在树的下部,您还会看到很多带有十六进制数字而不是名称的函数。这是为什么?

  3. 这些十六进制数是这些函数的代码段的绝对地址(即不是偏移量)还是虚拟地址(或符号)? ?

  4. 我已经使用 -g 选项在 Ubuntu 10.10 中编译了我的程序。这些十六进制数字与缺少“调试信息”有关吗?

  5. 我尝试使用“nm program_name”来弄清楚发生了什么?对于上面附加的调用图,我有以下输出:

root@xTR:/home/ahuq/system/client/xTR# nm UDPClientProject 
0804af14d_动态
第0804章
08049b4c R_IO_stdin_used
         w _Jv_RegisterClasses
0804af04d__CTOR_END__
0804af00d__CTOR_列表__
第0804章
0804af08d__DTOR_列表__
08049ebc r __FRAME_END__
0804af10d__JCR_END__
0804af10d__JCR_列表__
第0804章
         U__cxa_atexit@@GLIBC_2.1.3
0804b098 D __数据_开始
08049b00t__do_global_ctors_aux
08048c30t__do_global_dtors_aux
0804b09c d __dso_句柄
08048be0 T__gmon_start__
08049abaT__i686.get_pc_thunk.bx
正文 正文_第0804章
正文 正文_第0804章
08049a50T__libc_csu_fini
08049a60T__libc_csu_init
         U __libc_start_main@@GLIBC_2.0
         U__monstartup@@GLIBC_2.0
         U__stack_chk_fail@@GLIBC_2.4
0804b0a0A_edata
0804b0c4A_结束
08049b2c T_fini
08049b48 R_fp_hw
0804890c T_init
         你_mcleanup@@GLIBC_2.0
08048bb0 T _开始
080490aa T access_file_insert_data
         U报警@@GLIBC_2.0
0804922d T 附加
08049ac0 T 退出
         Ubzero@@GLIBC_2.0
0804b0a4 b 称为.3477
         U calloc@@GLIBC_2.0
         U ceil@@GLIBC_2.0
08049517 T client_timeout_signal_handle
0804b0a8 b 已完成.7065
0804b098 W 数据开始
080496e5 T 删除查询
080494cc T显示屏
0804b0ac b dtor_idx.7067
0804b0b4 B 错误
08049658 错误消息
08049b48 电子文本
         U 退出@@GLIBC_2.0
         U fclose@@GLIBC_2.1
         U fgets@@GLIBC_2.0
         U fopen@@GLIBC_2.1
         u fprintf@@GLIBC_2.0
08048c90 t 框架_虚拟
0804953a T get_map_notify_packet
         U htons@@GLIBC_2.0
         U inet_pton@@GLIBC_2.0
08049733 T插入查询
08048cb4 T主
         u malloc@@GLIBC_2.0
080495c6 Tmap_notify_packet_initialization
08048f3c T 映射_注册_数据包_初始化
         Umcount@@GLIBC_2.0
         u memcpy@@GLIBC_2.0
         U memset@@GLIBC_2.0
         u mysql_close@@libmysqlclient_16
         u mysql_errno@@libmysqlclient_16
         u mysql_error@@libmysqlclient_16
         u mysql_init@@libmysqlclient_16
         u mysql_query@@libmysqlclient_16
         u mysql_real_connect@@libmysqlclient_16
         u mysql_sqlstate@@libmysqlclient_16
0804b0c0 B 映射数
         错误@@GLIBC_2.0
0804b0b0 B位置
         u printf@@GLIBC_2.0
         你把@@GLIBC_2.0
         U recvfrom@@GLIBC_2.0
         你发送至@@GLIBC_2.0
         U信号@@GLIBC_2.0
         U插座@@GLIBC_2.0
0804b0a0 B stderr@@GLIBC_2.0
         u strcat@@GLIBC_2.0
         U strcpy@@GLIBC_2.0
         U strlen@@GLIBC_2.0
         你strtok@@GLIBC_2.0
08049781 T tcp_server_access_main
0804b0b8B udp_cli_program_cycle
0804b0bc B xx1
  1. 我没有看到“nm”输出中存在的调用图中的十六进制地址。我很困惑。

请帮我。

再见。

enter link description here

Hi,
I am profiling my C code with Kcachegrind. But I am confused with the output tree-map view of the call graph (see the above mentioned link). I have compiled the code: valgrind --tool=callgraph ./Program_name and then kcachegrind callgrind.out.8389. I have the following questions:

  1. Above the main() function, u will see a "below main()" and 0x08048bb0 functions. What r these? Is it because the compiler/OS doesn't load the program image and jumps to main() directly. I have read that, before calling main(), a process executes a bulk of code to “clean up the room for execution”. Is this the reason?

  2. In the lower part of the tree, u will also see a lot of functions with hexadecimal numbers instead of names. Why is this?

  3. Are these hexadecimal numbers absolute addresses (i.e. not offset) or virtual addresses (or Symbol) of the code section of these functions? or not?

  4. I have compiled my program in Ubuntu 10.10 using the -g option. Do these hexadecimal numbers have something to do with the absence of "debugging information"?

  5. I have tried to use "nm program_name" to figure out whats happening? For the above attached call graph, I have the following output:

root@xTR:/home/ahuq/system/client/xTR# nm UDPClientProject 
0804af14 d _DYNAMIC
0804aff4 d _GLOBAL_OFFSET_TABLE_
08049b4c R _IO_stdin_used
         w _Jv_RegisterClasses
0804af04 d __CTOR_END__
0804af00 d __CTOR_LIST__
0804af0c D __DTOR_END__
0804af08 d __DTOR_LIST__
08049ebc r __FRAME_END__
0804af10 d __JCR_END__
0804af10 d __JCR_LIST__
0804b0a0 A __bss_start
         U __cxa_atexit@@GLIBC_2.1.3
0804b098 D __data_start
08049b00 t __do_global_ctors_aux
08048c30 t __do_global_dtors_aux
0804b09c d __dso_handle
08048be0 T __gmon_start__
08049aba T __i686.get_pc_thunk.bx
0804af00 d __init_array_end
0804af00 d __init_array_start
08049a50 T __libc_csu_fini
08049a60 T __libc_csu_init
         U __libc_start_main@@GLIBC_2.0
         U __monstartup@@GLIBC_2.0
         U __stack_chk_fail@@GLIBC_2.4
0804b0a0 A _edata
0804b0c4 A _end
08049b2c T _fini
08049b48 R _fp_hw
0804890c T _init
         U _mcleanup@@GLIBC_2.0
08048bb0 T _start
080490aa T access_file_insert_data
         U alarm@@GLIBC_2.0
0804922d T append
08049ac0 T atexit
         U bzero@@GLIBC_2.0
0804b0a4 b called.3477
         U calloc@@GLIBC_2.0
         U ceil@@GLIBC_2.0
08049517 T client_timeout_signal_handle
0804b0a8 b completed.7065
0804b098 W data_start
080496e5 T delete_query
080494cc T display
0804b0ac b dtor_idx.7067
0804b0b4 B err
08049658 T err_message
08049b48 A etext
         U exit@@GLIBC_2.0
         U fclose@@GLIBC_2.1
         U fgets@@GLIBC_2.0
         U fopen@@GLIBC_2.1
         U fprintf@@GLIBC_2.0
08048c90 t frame_dummy
0804953a T get_map_notify_packet
         U htons@@GLIBC_2.0
         U inet_pton@@GLIBC_2.0
08049733 T insert_query
08048cb4 T main
         U malloc@@GLIBC_2.0
080495c6 T map_notify_packet_initialization
08048f3c T map_register_packet_initialization
         U mcount@@GLIBC_2.0
         U memcpy@@GLIBC_2.0
         U memset@@GLIBC_2.0
         U mysql_close@@libmysqlclient_16
         U mysql_errno@@libmysqlclient_16
         U mysql_error@@libmysqlclient_16
         U mysql_init@@libmysqlclient_16
         U mysql_query@@libmysqlclient_16
         U mysql_real_connect@@libmysqlclient_16
         U mysql_sqlstate@@libmysqlclient_16
0804b0c0 B num_of_mapping
         U perror@@GLIBC_2.0
0804b0b0 B position
         U printf@@GLIBC_2.0
         U puts@@GLIBC_2.0
         U recvfrom@@GLIBC_2.0
         U sendto@@GLIBC_2.0
         U signal@@GLIBC_2.0
         U socket@@GLIBC_2.0
0804b0a0 B stderr@@GLIBC_2.0
         U strcat@@GLIBC_2.0
         U strcpy@@GLIBC_2.0
         U strlen@@GLIBC_2.0
         U strtok@@GLIBC_2.0
08049781 T tcp_server_access_main
0804b0b8 B udp_cli_program_cycle
0804b0bc B xx1
  1. I am not seeing the Hexadecimal addresses from the call graph present in the "nm" ouput. I am confused.

Please help me.

Bye.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぶ宁プ宁ぶ 2024-12-21 18:51:41

main 上面的节点对应于调用 main 并从中返回的代码。这是初始化全局变量和清理的代码。

使用十六进制数字而不是名称的函数对应于调试信息或堆栈信息不可用的位置。如果您注意到的话,它们通常位于图书馆内部或图书馆之间。地址是绝对的虚拟地址。您不会在程序中找到它们,因为它们要么位于没有调试信息的动态加载库中,要么它们被重新定位,要么位于程序中未使用调试符号编译的部分(例如来自静态库)。如果它们那么容易找到,那么系统就会自动为您找到它们。

无论如何,它们仅占总消费量的 12% 左右。它们位于 SQL 代码和 XML 代码之间。

Nodes above main correspond to the code that calls main and returns from it. This is the code that initializes globals and cleans up.

The functions with hexadecimal numbers instead of names correspond to places where debug information or stack information was not available. If you notice, they're typically inside or between libraries. The addresses are absolute, virtual addresses. You won't find them in your program because either they're in dynamically-loaded libraries with no debug information, they were relocated, or they're in parts of your program that weren't compiled with debug symbols (such as code from static libraries). If they were that easy to find, they would have been found for you automatically.

In any event, they only account for about 12% of the consumption, total. They're between the SQL code and the XML code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文