When reading dwarf debug info callgrind only seams to output the leaf names for the source files. This requires explicit specification of the source location in kcachegrind which is very tedious on complex programs. This works correctly when using stabs debug info. Reproduced with gcc-3.3, gcc-4.0 and gcc-4.1 (from debian packages) stamper:/tmp> gcc-4.0 -O2 -o foodwarf -g bar/foo.c stamper:/tmp> gcc-4.0 -O2 -o foostabs -gstabs bar/foo.c stamper:/tmp> valgrind --tool=callgrind ./foodwarf ==8423== Callgrind, a call-graph generating cache profiler. ==8423== Copyright (C) 2002-2006, and GNU GPL'd, by Josef Weidendorfer et al. ==8423== Using LibVEX rev 1606, a library for dynamic binary translation. ==8423== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP. ==8423== Using valgrind-3.2.0-Debian, a dynamic binary instrumentation framework. ==8423== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al. ==8423== For more details, rerun with: -v ==8423== ==8423== For interactive control, run 'callgrind_control -h'. ==8423== ==8423== Events : Ir ==8423== Collected : 138177 ==8423== ==8423== I refs: 138,177 stamper:/tmp> valgrind --tool=callgrind ./foostabs ==8438== Callgrind, a call-graph generating cache profiler. ==8438== Copyright (C) 2002-2006, and GNU GPL'd, by Josef Weidendorfer et al. ==8438== Using LibVEX rev 1606, a library for dynamic binary translation. ==8438== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP. ==8438== Using valgrind-3.2.0-Debian, a dynamic binary instrumentation framework. ==8438== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al. ==8438== For more details, rerun with: -v ==8438== ==8438== For interactive control, run 'callgrind_control -h'. ==8438== ==8438== Events : Ir ==8438== Collected : 138177 ==8438== ==8438== I refs: 138,177 stamper:/tmp> egrep '^(fl.*foo|cmd)' callgrind.out.* callgrind.out.8423:cmd: ./foodwarf callgrind.out.8423:fl=(7) foo.c callgrind.out.8438:cmd: ./foostabs callgrind.out.8438:fl=(7) bar/foo.c Just to show it can be done objdump -S foodwarf foodwarf: file format elf32-i386 ... 08048330 <main>: #include <stdlib.h> int main(int argc, char **argv) { 8048330: 55 push %ebp 8048331: 89 e5 mov %esp,%ebp 8048333: 53 push %ebx 8048334: 83 ec 04 sub $0x4,%esp argc += (int)argv[0]; 8048337: 8b 45 0c mov 0xc(%ebp),%eax 804833a: 83 e4 f0 and $0xfffffff0,%esp 804833d: 8b 55 08 mov 0x8(%ebp),%edx 8048340: 83 ec 10 sub $0x10,%esp 8048343: 8b 08 mov (%eax),%ecx 8048345: 89 c8 mov %ecx,%eax 8048347: 01 d0 add %edx,%eax argc += (int)argv[0]/2; 8048349: 89 ca mov %ecx,%edx 804834b: c1 ea 1f shr $0x1f,%edx 804834e: 01 ca add %ecx,%edx 8048350: d1 fa sar %edx 8048352: 8d 1c 10 lea (%eax,%edx,1),%ebx 8048355: 89 c8 mov %ecx,%eax 8048357: ba 56 55 55 55 mov $0x55555556,%edx 804835c: f7 ea imul %edx 804835e: c1 f9 1f sar $0x1f,%ecx 8048361: 29 ca sub %ecx,%edx 8048363: 8d 04 13 lea (%ebx,%edx,1),%eax argc += (int)argv[0]/3; return argc; } stamper:/tmp> readelf --debug-dump foodwarf The section .debug_aranges contains: Length: 28 Version: 2 Offset into .debug_info: 0 Pointer Size: 4 Segment Size: 0 Address Length 08048280 34 00000000 0 Length: 44 Version: 2 Offset into .debug_info: 114 Pointer Size: 4 Segment Size: 0 Address Length 08048484 17 08048234 11 080482a4 36 00000000 0 Length: 28 Version: 2 Offset into .debug_info: 1b6 Pointer Size: 4 Segment Size: 0 Address Length 08048330 59 00000000 0 Length: 36 Version: 2 Offset into .debug_info: 274 Pointer Size: 4 Segment Size: 0 Address Length 0804849a 4 08048249 2 00000000 0 Contents of the .debug_pubnames section: Length: 33 Version: 2 Offset into .debug_info section: 131 Size of area in .debug_info section: 145 Offset Name 121 _IO_stdin_used Length: 23 Version: 2 Offset into .debug_info section: 438 Size of area in .debug_info section: 190 Offset Name 127 main The section .debug_info contains: Compilation Unit @ offset 0x0: Length: 127 Version: 2 Abbrev Offset: 0 Pointer Size: 4 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit) DW_AT_stmt_list : 0 DW_AT_low_pc : 0x8048280 DW_AT_high_pc : 0x80482a2 DW_AT_name : ../sysdeps/i386/elf/start.S DW_AT_comp_dir : /home/aurel32/tmp/i386/glibc-2.3.6/build-tree/glibc-2.3.6/csu DW_AT_producer : GNU AS 2.16.91 DW_AT_language : 32769 (MIPS assembler) Compilation Unit @ offset 0x83: Length: 141 Version: 2 Abbrev Offset: 20 Pointer Size: 4 <0><8e>: Abbrev Number: 1 (DW_TAG_compile_unit) DW_AT_stmt_list : 0x5b DW_AT_high_pc : 0x80482a4 DW_AT_low_pc : 0x80482a4 DW_AT_producer : (indirect string, offset: 0x0): GNU C 4.0.4 20060507 (prerelease) (Debian 4.0.3-3) DW_AT_language : 1 (ANSI C) DW_AT_name : (indirect string, offset: 0x33): init.c DW_AT_comp_dir : (indirect string, offset: 0x8a): /home/aurel32/tmp/i386/glibc-2.3.6/build-tree/glibc-2.3.6/csu <1><a8>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x6a): unsigned int DW_AT_byte_size : 4 DW_AT_encoding : 7 (unsigned) <1><af>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x52): unsigned char DW_AT_byte_size : 1 DW_AT_encoding : 8 (unsigned char) <1><b6>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x77): short unsigned int DW_AT_byte_size : 2 DW_AT_encoding : 7 (unsigned) <1><bd>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x65): long unsigned int DW_AT_byte_size : 4 DW_AT_encoding : 7 (unsigned) <1><c4>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x54): signed char DW_AT_byte_size : 1 DW_AT_encoding : 6 (signed char) <1><cb>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x3a): short int DW_AT_byte_size : 2 DW_AT_encoding : 5 (signed) <1><d2>: Abbrev Number: 3 (DW_TAG_base_type) DW_AT_name : int DW_AT_byte_size : 4 DW_AT_encoding : 5 (signed) <1><d9>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x44): long long int DW_AT_byte_size : 8 DW_AT_encoding : 5 (signed) <1><e0>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x60): long long unsigned int DW_AT_byte_size : 8 DW_AT_encoding : 7 (unsigned) <1><e7>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x49): long int DW_AT_byte_size : 4 DW_AT_encoding : 5 (signed) <1><ee>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x6a): unsigned int DW_AT_byte_size : 4 DW_AT_encoding : 7 (unsigned) <1><f5>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x5b): char DW_AT_byte_size : 1 DW_AT_encoding : 6 (signed char) <1><fc>: Abbrev Number: 4 (DW_TAG_variable) DW_AT_name : (indirect string, offset: 0xc8): _IO_stdin_used DW_AT_decl_file : 1 DW_AT_decl_line : 25 DW_AT_type : <10e> DW_AT_external : 1 DW_AT_location : 5 byte block: 3 a4 84 4 8 (DW_OP_addr: 80484a4) <1><10e>: Abbrev Number: 5 (DW_TAG_const_type) DW_AT_type : <d2> Compilation Unit @ offset 0x114: Length: 158 Version: 2 Abbrev Offset: 86 Pointer Size: 4 <0><11f>: Abbrev Number: 1 (DW_TAG_compile_unit) DW_AT_stmt_list : 0x82 DW_AT_name : /home/aurel32/tmp/i386/glibc-2.3.6/build-tree/i386-libc/csu/crti.S DW_AT_comp_dir : /home/aurel32/tmp/i386/glibc-2.3.6/build-tree/glibc-2.3.6/csu DW_AT_producer : GNU AS 2.16.91 DW_AT_language : 32769 (MIPS assembler) Compilation Unit @ offset 0x1b6: Length: 186 Version: 2 Abbrev Offset: 102 Pointer Size: 4 <0><1c1>: Abbrev Number: 1 (DW_TAG_compile_unit) DW_AT_stmt_list : 0x129 DW_AT_high_pc : 0x804836b DW_AT_low_pc : 0x8048330 DW_AT_producer : (indirect string, offset: 0x0): GNU C 4.0.4 20060507 (prerelease) (Debian 4.0.3-3) DW_AT_language : 1 (ANSI C) DW_AT_name : (indirect string, offset: 0xe6): bar/foo.c DW_AT_comp_dir : (indirect string, offset: 0xf0): /tmp <1><1db>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x6a): unsigned int DW_AT_byte_size : 4 DW_AT_encoding : 7 (unsigned) <1><1e2>: Abbrev Number: 3 (DW_TAG_base_type) DW_AT_name : int DW_AT_byte_size : 4 DW_AT_encoding : 5 (signed) <1><1e9>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x49): long int DW_AT_byte_size : 4 DW_AT_encoding : 5 (signed) <1><1f0>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x52): unsigned char DW_AT_byte_size : 1 DW_AT_encoding : 8 (unsigned char) <1><1f7>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x77): short unsigned int DW_AT_byte_size : 2 DW_AT_encoding : 7 (unsigned) <1><1fe>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x65): long unsigned int DW_AT_byte_size : 4 DW_AT_encoding : 7 (unsigned) <1><205>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x54): signed char DW_AT_byte_size : 1 DW_AT_encoding : 6 (signed char) <1><20c>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x3a): short int DW_AT_byte_size : 2 DW_AT_encoding : 5 (signed) <1><213>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x44): long long int DW_AT_byte_size : 8 DW_AT_encoding : 5 (signed) <1><21a>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x60): long long unsigned int DW_AT_byte_size : 8 DW_AT_encoding : 7 (unsigned) <1><221>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x6a): unsigned int DW_AT_byte_size : 4 DW_AT_encoding : 7 (unsigned) <1><228>: Abbrev Number: 4 (DW_TAG_pointer_type) DW_AT_byte_size : 4 DW_AT_type : <22e> <1><22e>: Abbrev Number: 2 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x5b): char DW_AT_byte_size : 1 DW_AT_encoding : 6 (signed char) <1><235>: Abbrev Number: 5 (DW_TAG_subprogram) DW_AT_sibling : <26d> DW_AT_external : 1 DW_AT_name : (indirect string, offset: 0xd7): main DW_AT_decl_file : 1 DW_AT_decl_line : 4 DW_AT_prototyped : 1 DW_AT_type : <1e2> DW_AT_low_pc : 0x8048330 DW_AT_high_pc : 0x804836b DW_AT_frame_base : 1 byte block: 55 (DW_OP_reg5) <2><250>: Abbrev Number: 6 (DW_TAG_formal_parameter) DW_AT_name : (indirect string, offset: 0xdc): argc DW_AT_decl_file : 1 DW_AT_decl_line : 3 DW_AT_type : <1e2> DW_AT_location : 0 (location list) <2><25f>: Abbrev Number: 7 (DW_TAG_formal_parameter) DW_AT_name : (indirect string, offset: 0xe1): argv DW_AT_decl_file : 1 DW_AT_decl_line : 3 DW_AT_type : <26d> DW_AT_location : 1 byte block: 50 (DW_OP_reg0) <1><26d>: Abbrev Number: 4 (DW_TAG_pointer_type) DW_AT_byte_size : 4 DW_AT_type : <228> Compilation Unit @ offset 0x274: Length: 158 Version: 2 Abbrev Offset: 208 Pointer Size: 4 <0><27f>: Abbrev Number: 1 (DW_TAG_compile_unit) DW_AT_stmt_list : 0x168 DW_AT_name : /home/aurel32/tmp/i386/glibc-2.3.6/build-tree/i386-libc/csu/crtn.S DW_AT_comp_dir : /home/aurel32/tmp/i386/glibc-2.3.6/build-tree/glibc-2.3.6/csu DW_AT_producer : GNU AS 2.16.91 DW_AT_language : 32769 (MIPS assembler) Contents of the .debug_abbrev section: Number TAG 1 DW_TAG_compile_unit [no children] DW_AT_stmt_list DW_FORM_data4 DW_AT_low_pc DW_FORM_addr DW_AT_high_pc DW_FORM_addr DW_AT_name DW_FORM_string DW_AT_comp_dir DW_FORM_string DW_AT_producer DW_FORM_string DW_AT_language DW_FORM_data2 Number TAG 1 DW_TAG_compile_unit [has children] DW_AT_stmt_list DW_FORM_data4 DW_AT_high_pc DW_FORM_addr DW_AT_low_pc DW_FORM_addr DW_AT_producer DW_FORM_strp DW_AT_language DW_FORM_data1 DW_AT_name DW_FORM_strp DW_AT_comp_dir DW_FORM_strp 2 DW_TAG_base_type [no children] DW_AT_name DW_FORM_strp DW_AT_byte_size DW_FORM_data1 DW_AT_encoding DW_FORM_data1 3 DW_TAG_base_type [no children] DW_AT_name DW_FORM_string DW_AT_byte_size DW_FORM_data1 DW_AT_encoding DW_FORM_data1 4 DW_TAG_variable [no children] DW_AT_name DW_FORM_strp DW_AT_decl_file DW_FORM_data1 DW_AT_decl_line DW_FORM_data1 DW_AT_type DW_FORM_ref4 DW_AT_external DW_FORM_flag DW_AT_location DW_FORM_block1 5 DW_TAG_const_type [no children] DW_AT_type DW_FORM_ref4 Number TAG 1 DW_TAG_compile_unit [no children] DW_AT_stmt_list DW_FORM_data4 DW_AT_name DW_FORM_string DW_AT_comp_dir DW_FORM_string DW_AT_producer DW_FORM_string DW_AT_language DW_FORM_data2 Number TAG 1 DW_TAG_compile_unit [has children] DW_AT_stmt_list DW_FORM_data4 DW_AT_high_pc DW_FORM_addr DW_AT_low_pc DW_FORM_addr DW_AT_producer DW_FORM_strp DW_AT_language DW_FORM_data1 DW_AT_name DW_FORM_strp DW_AT_comp_dir DW_FORM_strp 2 DW_TAG_base_type [no children] DW_AT_name DW_FORM_strp DW_AT_byte_size DW_FORM_data1 DW_AT_encoding DW_FORM_data1 3 DW_TAG_base_type [no children] DW_AT_name DW_FORM_string DW_AT_byte_size DW_FORM_data1 DW_AT_encoding DW_FORM_data1 4 DW_TAG_pointer_type [no children] DW_AT_byte_size DW_FORM_data1 DW_AT_type DW_FORM_ref4 5 DW_TAG_subprogram [has children] DW_AT_sibling DW_FORM_ref4 DW_AT_external DW_FORM_flag DW_AT_name DW_FORM_strp DW_AT_decl_file DW_FORM_data1 DW_AT_decl_line DW_FORM_data1 DW_AT_prototyped DW_FORM_flag DW_AT_type DW_FORM_ref4 DW_AT_low_pc DW_FORM_addr DW_AT_high_pc DW_FORM_addr DW_AT_frame_base DW_FORM_block1 6 DW_TAG_formal_parameter [no children] DW_AT_name DW_FORM_strp DW_AT_decl_file DW_FORM_data1 DW_AT_decl_line DW_FORM_data1 DW_AT_type DW_FORM_ref4 DW_AT_location DW_FORM_data4 7 DW_TAG_formal_parameter [no children] DW_AT_name DW_FORM_strp DW_AT_decl_file DW_FORM_data1 DW_AT_decl_line DW_FORM_data1 DW_AT_type DW_FORM_ref4 DW_AT_location DW_FORM_block1 Number TAG 1 DW_TAG_compile_unit [no children] DW_AT_stmt_list DW_FORM_data4 DW_AT_name DW_FORM_string DW_AT_comp_dir DW_FORM_string DW_AT_producer DW_FORM_string DW_AT_language DW_FORM_data2 Dump of debug contents of section .debug_line: Length: 87 DWARF Version: 2 Prologue Length: 50 Minimum Instruction Length: 1 Initial value of 'is_stmt': 1 Line Base: -5 Line Range: 14 Opcode Base: 13 Opcodes: Opcode 1 has 0 args Opcode 2 has 1 args Opcode 3 has 1 args Opcode 4 has 1 args Opcode 5 has 1 args Opcode 6 has 0 args Opcode 7 has 0 args Opcode 8 has 0 args Opcode 9 has 1 args Opcode 10 has 0 args Opcode 11 has 0 args Opcode 12 has 1 args The Directory Table: ../sysdeps/i386/elf The File Name Table: Entry Dir Time Size Name 1 1 0 0 start.S Line Number Statements: Extended opcode 2: set Address to 0x8048280 Advance Line by 64 to 65 Copy Special opcode 38: advance Address by 2 to 0x8048282 and Line by 5 to 70 Special opcode 20: advance Address by 1 to 0x8048283 and Line by 1 to 71 Special opcode 39: advance Address by 2 to 0x8048285 and Line by 6 to 77 Special opcode 48: advance Address by 3 to 0x8048288 and Line by 1 to 78 Special opcode 24: advance Address by 1 to 0x8048289 and Line by 5 to 83 Special opcode 21: advance Address by 1 to 0x804828a and Line by 2 to 85 Advance Line by 24 to 109 Special opcode 19: advance Address by 1 to 0x804828b and Line by 0 to 109 Special opcode 76: advance Address by 5 to 0x8048290 and Line by 1 to 110 Special opcode 77: advance Address by 5 to 0x8048295 and Line by 2 to 112 Special opcode 20: advance Address by 1 to 0x8048296 and Line by 1 to 113 Special opcode 21: advance Address by 1 to 0x8048297 and Line by 2 to 115 Special opcode 79: advance Address by 5 to 0x804829c and Line by 4 to 119 Special opcode 78: advance Address by 5 to 0x80482a1 and Line by 3 to 122 Advance PC by 1 to 0x80482a2 Extended opcode 1: End of Sequence Length: 35 DWARF Version: 2 Prologue Length: 29 Minimum Instruction Length: 1 Initial value of 'is_stmt': 1 Line Base: -5 Line Range: 14 Opcode Base: 13 Opcodes: Opcode 1 has 0 args Opcode 2 has 1 args Opcode 3 has 1 args Opcode 4 has 1 args Opcode 5 has 1 args Opcode 6 has 0 args Opcode 7 has 0 args Opcode 8 has 0 args Opcode 9 has 1 args Opcode 10 has 0 args Opcode 11 has 0 args Opcode 12 has 1 args The Directory Table is empty. The File Name Table: Entry Dir Time Size Name 1 0 0 0 init.c Line Number Statements: Length: 163 DWARF Version: 2 Prologue Length: 89 Minimum Instruction Length: 1 Initial value of 'is_stmt': 1 Line Base: -5 Line Range: 14 Opcode Base: 13 Opcodes: Opcode 1 has 0 args Opcode 2 has 1 args Opcode 3 has 1 args Opcode 4 has 1 args Opcode 5 has 1 args Opcode 6 has 0 args Opcode 7 has 0 args Opcode 8 has 0 args Opcode 9 has 1 args Opcode 10 has 0 args Opcode 11 has 0 args Opcode 12 has 1 args The Directory Table: /home/aurel32/tmp/i386/glibc-2.3.6/build-tree/i386-libc/csu The File Name Table: Entry Dir Time Size Name 1 1 0 0 crti.S Line Number Statements: Extended opcode 2: set Address to 0x8048484 Advance Line by 51 to 52 Copy Special opcode 20: advance Address by 1 to 0x8048485 and Line by 1 to 53 Special opcode 34: advance Address by 2 to 0x8048487 and Line by 1 to 54 Special opcode 20: advance Address by 1 to 0x8048488 and Line by 1 to 55 Special opcode 20: advance Address by 1 to 0x8048489 and Line by 1 to 56 Special opcode 77: advance Address by 5 to 0x804848e and Line by 2 to 58 Special opcode 20: advance Address by 1 to 0x804848f and Line by 1 to 59 Advance PC by 6 to 0x8048495 Extended opcode 1: End of Sequence Extended opcode 2: set Address to 0x8048234 Advance Line by 35 to 36 Copy Special opcode 20: advance Address by 1 to 0x8048235 and Line by 1 to 37 Special opcode 34: advance Address by 2 to 0x8048237 and Line by 1 to 38 Special opcode 48: advance Address by 3 to 0x804823a and Line by 1 to 39 Advance PC by 5 to 0x804823f Extended opcode 1: End of Sequence Extended opcode 2: set Address to 0x80482a4 Advance Line by 11 to 12 Copy Special opcode 20: advance Address by 1 to 0x80482a5 and Line by 1 to 13 Special opcode 34: advance Address by 2 to 0x80482a7 and Line by 1 to 14 Special opcode 20: advance Address by 1 to 0x80482a8 and Line by 1 to 15 Special opcode 20: advance Address by 1 to 0x80482a9 and Line by 1 to 16 Special opcode 77: advance Address by 5 to 0x80482ae and Line by 2 to 18 Special opcode 20: advance Address by 1 to 0x80482af and Line by 1 to 19 Special opcode 90: advance Address by 6 to 0x80482b5 and Line by 1 to 20 Special opcode 90: advance Address by 6 to 0x80482bb and Line by 1 to 21 Special opcode 34: advance Address by 2 to 0x80482bd and Line by 1 to 22 Special opcode 34: advance Address by 2 to 0x80482bf and Line by 1 to 23 Special opcode 77: advance Address by 5 to 0x80482c4 and Line by 2 to 25 Special opcode 20: advance Address by 1 to 0x80482c5 and Line by 1 to 26 Special opcode 20: advance Address by 1 to 0x80482c6 and Line by 1 to 27 Special opcode 20: advance Address by 1 to 0x80482c7 and Line by 1 to 28 Advance PC by 1 to 0x80482c8 Extended opcode 1: End of Sequence Length: 59 DWARF Version: 2 Prologue Length: 32 Minimum Instruction Length: 1 Initial value of 'is_stmt': 1 Line Base: -5 Line Range: 14 Opcode Base: 13 Opcodes: Opcode 1 has 0 args Opcode 2 has 1 args Opcode 3 has 1 args Opcode 4 has 1 args Opcode 5 has 1 args Opcode 6 has 0 args Opcode 7 has 0 args Opcode 8 has 0 args Opcode 9 has 1 args Opcode 10 has 0 args Opcode 11 has 0 args Opcode 12 has 1 args The Directory Table: bar The File Name Table: Entry Dir Time Size Name 1 1 0 0 foo.c Line Number Statements: Extended opcode 2: set Address to 0x8048330 Special opcode 8: advance Address by 0 to 0x8048330 and Line by 3 to 4 Special opcode 104: advance Address by 7 to 0x8048337 and Line by 1 to 5 Special opcode 46: advance Address by 3 to 0x804833a and Line by -1 to 4 Special opcode 48: advance Address by 3 to 0x804833d and Line by 1 to 5 Special opcode 46: advance Address by 3 to 0x8048340 and Line by -1 to 4 Special opcode 48: advance Address by 3 to 0x8048343 and Line by 1 to 5 Special opcode 90: advance Address by 6 to 0x8048349 and Line by 1 to 6 Advance PC by constant 17 to 0x804835a Special opcode 176: advance Address by 12 to 0x8048366 and Line by 3 to 9 Advance PC by 5 to 0x804836b Extended opcode 1: End of Sequence Length: 129 DWARF Version: 2 Prologue Length: 89 Minimum Instruction Length: 1 Initial value of 'is_stmt': 1 Line Base: -5 Line Range: 14 Opcode Base: 13 Opcodes: Opcode 1 has 0 args Opcode 2 has 1 args Opcode 3 has 1 args Opcode 4 has 1 args Opcode 5 has 1 args Opcode 6 has 0 args Opcode 7 has 0 args Opcode 8 has 0 args Opcode 9 has 1 args Opcode 10 has 0 args Opcode 11 has 0 args Opcode 12 has 1 args The Directory Table: /home/aurel32/tmp/i386/glibc-2.3.6/build-tree/i386-libc/csu The File Name Table: Entry Dir Time Size Name 1 1 0 0 crtn.S Line Number Statements: Extended opcode 2: set Address to 0x804849a Advance Line by 18 to 19 Copy Special opcode 20: advance Address by 1 to 0x804849b and Line by 1 to 20 Special opcode 20: advance Address by 1 to 0x804849c and Line by 1 to 21 Special opcode 20: advance Address by 1 to 0x804849d and Line by 1 to 22 Advance PC by 1 to 0x804849e Extended opcode 1: End of Sequence Extended opcode 2: set Address to 0x8048249 Advance Line by 9 to 10 Copy Special opcode 20: advance Address by 1 to 0x804824a and Line by 1 to 11 Advance PC by 1 to 0x804824b Extended opcode 1: End of Sequence The section .debug_frame contains: 00000000 00000010 ffffffff CIE Version: 1 Augmentation: "" Code alignment factor: 1 Data alignment factor: -4 Return address column: 8 DW_CFA_def_cfa: r4 ofs 4 DW_CFA_offset: r8 at cfa-4 DW_CFA_nop DW_CFA_nop 00000014 00000018 00000000 FDE cie=00000000 pc=08048330..0804836b DW_CFA_advance_loc: 1 to 08048331 DW_CFA_def_cfa_offset: 8 DW_CFA_offset: r5 at cfa-8 DW_CFA_advance_loc: 2 to 08048333 DW_CFA_def_cfa_reg: r5 DW_CFA_advance_loc: 4 to 08048337 DW_CFA_offset: r3 at cfa-12 DW_CFA_nop Contents of the .debug_str section: 0x00000000 474e5520 4320342e 302e3420 32303036 GNU C 4.0.4 2006 0x00000010 30353037 20287072 6572656c 65617365 0507 (prerelease 0x00000020 29202844 65626961 6e20342e 302e332d ) (Debian 4.0.3- 0x00000030 33290069 6e69742e 63007368 6f727420 3).init.c.short 0x00000040 696e7400 6c6f6e67 206c6f6e 6720696e int.long long in 0x00000050 7400756e 7369676e 65642063 68617200 t.unsigned char. 0x00000060 6c6f6e67 206c6f6e 6720756e 7369676e long long unsign 0x00000070 65642069 6e740073 686f7274 20756e73 ed int.short uns 0x00000080 69676e65 6420696e 74002f68 6f6d652f igned int./home/ 0x00000090 61757265 6c33322f 746d702f 69333836 aurel32/tmp/i386 0x000000a0 2f676c69 62632d32 2e332e36 2f627569 /glibc-2.3.6/bui 0x000000b0 6c642d74 7265652f 676c6962 632d322e ld-tree/glibc-2. 0x000000c0 332e362f 63737500 5f494f5f 73746469 3.6/csu._IO_stdi 0x000000d0 6e5f7573 6564006d 61696e00 61726763 n_used.main.argc 0x000000e0 00617267 76006261 722f666f 6f2e6300 .argv.bar/foo.c. 0x000000f0 2f746d70 00 /tmp. Contents of the .debug_loc section: Offset Begin End Expression 00000000 08048330 08048347 (DW_OP_fbreg: 8) 00000000 08048347 08048355 (DW_OP_reg0) 00000000 08048355 08048357 (DW_OP_reg3) 00000000 <End of list> stamper:/tmp>
Thanks for the report. However, as callgrind just uses the information it gets from Valgrind, the report probably should be attached to Valgrind core. Do eg. memcheck (provoked) errors show the same problem? Perhaps a workaround: when all source files are unique, it is enough to specify one base directory, as kcachegrind will search recursivly in all subdirectories.
Yes... valgrind seems to have the same difference (I did this before but then it I thought always showed short names. I must have done something wrong in testing it then). dwarf: ==2743== 1 errors in context 1 of 1: ==2743== Invalid write of size 1 ==2743== at 0x80483EF: main (foo.c:15) ==2743== Address 0x417102D is 2 bytes after a block of size 3 free'd ==2743== at 0x401D139: free (vg_replace_malloc.c:233) ==2743== by 0x80483E2: main (foo.c:14) stabs: ==2711== 1 errors in context 1 of 1: ==2711== Invalid write of size 1 ==2711== at 0x80483EF: main (bar/foo.c:15) ==2711== Address 0x417102D is 2 bytes after a block of size 3 free'd ==2711== at 0x401D139: free (vg_replace_malloc.c:233) ==2711== by 0x80483E2: main (bar/foo.c:14)
With regards to workaround: Thanks, I didn't know about the recursive thing. Sadly our source configuration mechanism leads to a lot files with indentical leaf names (although I would hope it problem is minor for those modules where the time is actually spent). Perhaps more problem is that the tree is BIG and so searching for every file without any structure is going to take a while. I'll give it a try.
The OpenOffice developers sent a similar complaint: their source tree has so many files that just giving a file name without directory name is sometimes ambiguous. Maybe we should add a --full-pathnames=no|yes option. IIRC the directory names are read from the debuginfo already, since --xml=yes prints them. So it should be easy to do.
I think this was fixed in r6850 (2007-09-17!) when directory info was added to Callgrind's output files. Josef, can you confirm that fixes the problem? It won't address the broader problem mentioned by Julian in comment 4, but that should be a separate bug if we are to follow it up.
Yes: ================================== > cat foo/my.c main() {} > gcc -o mydwarf -g foo/my.c > valgrind --tool=callgrind ./mydwarf ... > egrep '^cfi.*my' callgrind.out.* cfi=(8) /home/weidendo/tmp/callgrind-bug133679/foo/my.c ================================== KCachegrind first checks a given absolute path before falling back to starting recursive search from configured source top directories. So, it works.