Reputation: 1
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:
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?
In the lower part of the tree, u will also see a lot of functions with hexadecimal numbers instead of names. Why is this?
Are these hexadecimal numbers absolute addresses (i.e. not offset) or virtual addresses (or Symbol) of the code section of these functions? or not?
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"?
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
Please help me.
Bye.
Upvotes: 0
Views: 937
Reputation: 182733
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.
Upvotes: 1