[LLVMbugs] [Bug 7365] New: addr2line/gdb fail to show line information and source code
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Jun 12 14:10:29 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=7365
Summary: addr2line/gdb fail to show line information and source
code
Product: clang
Version: 2.7
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: luca.barbieri at gmail.com
CC: llvmbugs at cs.uiuc.edu
clang with -g -O0 seems to either produce wrong debug information, or trigger a
bug in binutils/libbfd (assuming my system isn't somehow broken).
Note that it seems to only trigger in some cases: removing the infinite loop in
main makes things work.
This also happens on larger programs and using gdb.
Changing binutils and clang versions did not seem to help.
Any ideas on where the problem is?
$ cat test.c
int main(int argc, char** argv)
{
for(;;) {}
return 0;
}
$ gcc -g -O0 test.c
$ nm a.out|grep 'main$'
080483b4 T main
$ addr2line 080483b4
/home/lb/pers/src/misc/test.c:2
$ clang -g -O0 test.c
$ nm a.out|grep 'main$'
080483c0 T main
$ addr2line 080483c0
??:0
$ uname -a
Linux lb-linux 2.6.34-lb #15 SMP Mon May 31 17:47:02 CEST 2010 i686 GNU/Linux
$ clang -v
clang version 1.1 (branches/release_27)
Target: i386-pc-linux-gnu
Thread model: posix
$ addr2line -v
GNU addr2line (GNU Binutils for Ubuntu) 2.20.1-system.20100303
Copyright 2009 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
$ clang -emit-llvm -S -g -O0 test.c && cat test.s
; ModuleID = 'test.c'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i386-pc-linux-gnu"
define i32 @main(i32 %argc, i8** %argv) nounwind {
%1 = alloca i32, align 4 ; <i32*> [#uses=2]
%2 = alloca i32, align 4 ; <i32*> [#uses=1]
%3 = alloca i8**, align 4 ; <i8***> [#uses=1]
store i32 0, i32* %1
store i32 %argc, i32* %2
call void @llvm.dbg.declare(metadata !{i32* %2}, metadata !0), !dbg !6
store i8** %argv, i8*** %3
call void @llvm.dbg.declare(metadata !{i8*** %3}, metadata !7), !dbg !11
br label %4, !dbg !12
; <label>:4 ; preds = %4, %0
br label %4, !dbg !12
; No predecessors!
%6 = load i32* %1, !dbg !14 ; <i32> [#uses=1]
ret i32 %6, !dbg !14
}
declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
!0 = metadata !{i32 459009, metadata !1, metadata !"argc", metadata !2, i32 1,
metadata !5} ; [ DW_TAG_arg_variable ]
!1 = metadata !{i32 458798, i32 0, metadata !2, metadata !"main", metadata
!"main", metadata !"main", metadata !2, i32 2, metadata !3, i1 false, i1 true,
i32 0, i32 0, null, i1 false} ; [ DW_TAG_subprogram ]
!2 = metadata !{i32 458769, i32 0, i32 12, metadata !"test.c", metadata
!"/home/lb/pers/src/misc", metadata !"clang 1.1", i1 true, i1 false, metadata
!"", i32 0} ; [ DW_TAG_compile_unit ]
!3 = metadata !{i32 458773, metadata !2, metadata !"", null, i32 0, i64 0, i64
0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ]
!4 = metadata !{metadata !5}
!5 = metadata !{i32 458788, metadata !2, metadata !"int", metadata !2, i32 0,
i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
!6 = metadata !{i32 1, i32 14, metadata !1, null}
!7 = metadata !{i32 459009, metadata !1, metadata !"argv", metadata !2, i32 1,
metadata !8} ; [ DW_TAG_arg_variable ]
!8 = metadata !{i32 458767, metadata !2, metadata !"", null, i32 0, i64 32, i64
32, i64 0, i32 0, metadata !9} ; [ DW_TAG_pointer_type ]
!9 = metadata !{i32 458767, metadata !2, metadata !"", null, i32 0, i64 32, i64
32, i64 0, i32 0, metadata !10} ; [ DW_TAG_pointer_type ]
!10 = metadata !{i32 458788, metadata !2, metadata !"char", metadata !2, i32 0,
i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ]
!11 = metadata !{i32 1, i32 27, metadata !1, null}
!12 = metadata !{i32 3, i32 2, metadata !13, null}
!13 = metadata !{i32 458763, metadata !1, i32 2, i32 1} ; [
DW_TAG_lexical_block ]
!14 = metadata !{i32 5, i32 1, metadata !1, null}
$ clang -S -g -O0 test.c && cat test.s
.file "test.c"
.section .debug_frame,"", at progbits
.Lsection_debug_frame:
.section .debug_info,"", at progbits
.Lsection_info:
.section .debug_abbrev,"", at progbits
.Lsection_abbrev:
.section .debug_aranges,"", at progbits
.Lsection_aranges:
.section .debug_macinfo,"", at progbits
.Lsection_macinfo:
.section .debug_line,"", at progbits
.Lsection_line:
.section .debug_loc,"", at progbits
.Lsection_loc:
.section .debug_pubnames,"", at progbits
.Lsection_pubnames:
.section .debug_pubtypes,"", at progbits
.Lsection_pubtypes:
.section .debug_str,"", at progbits
.Lsection_str:
.section .debug_ranges,"", at progbits
.Lsection_ranges:
.text
.Ltext_begin:
.data
.Ldata_begin:
.text
.globl main
.align 16, 0x90
.type main, at function
main:
pushl %ebp
.Llabel1:
movl %esp, %ebp
.Llabel2:
subl $12, %esp
.Llabel3:
movl 8(%ebp), %eax
movl 12(%ebp), %ecx
movl $0, -4(%ebp)
movl %eax, -8(%ebp)
movl %ecx, -12(%ebp)
.LBB1_1:
jmp .LBB1_1
.size main, .-main
.Ltext_end:
.data
.Ldata_end:
.text
.Lsection_end1:
.section .debug_frame,"", at progbits
.Ldebug_frame_common:
.set .Lset1dbg,.Ldebug_frame_common_end-.Ldebug_frame_common_begin
.long .Lset1dbg
.Ldebug_frame_common_begin:
.long 4294967295
.byte 1
.byte 0
.uleb128 1
.sleb128 -4
.byte 8
.byte 12
.uleb128 4
.uleb128 4
.byte 136
.uleb128 1
.align 4
.Ldebug_frame_common_end:
.section .debug_info,"", at progbits
.Linfo_begin1:
.long 83
.short 2
.set .Lset2dbg,.Labbrev_begin
.long .Lset2dbg
.byte 4
.uleb128 1
.set .Lset3dbg,.Lsection_line
.long .Lset3dbg
.ascii "clang 1.1"
.byte 0
.byte 12
.ascii "test.c"
.byte 0
.ascii "/home/lb/pers/src/misc"
.byte 0
.uleb128 2
.byte 5
.ascii "int"
.byte 0
.byte 4
.uleb128 3
.ascii "main"
.byte 0
.ascii "main"
.byte 0
.byte 1
.byte 2
.byte 1
.long 57
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.Linfo_end1:
.section .debug_abbrev,"", at progbits
.Labbrev_begin:
.uleb128 1
.uleb128 17
.uleb128 1
.uleb128 16
.uleb128 6
.uleb128 37
.uleb128 8
.uleb128 19
.uleb128 11
.uleb128 3
.uleb128 8
.uleb128 27
.uleb128 8
.uleb128 0
.uleb128 0
.uleb128 2
.uleb128 36
.uleb128 0
.uleb128 62
.uleb128 11
.uleb128 3
.uleb128 8
.uleb128 11
.uleb128 11
.uleb128 0
.uleb128 0
.uleb128 3
.uleb128 46
.uleb128 0
.uleb128 3
.uleb128 8
.uleb128 8199
.uleb128 8
.uleb128 58
.uleb128 11
.uleb128 59
.uleb128 11
.uleb128 39
.uleb128 12
.uleb128 73
.uleb128 19
.uleb128 0
.uleb128 0
.uleb128 0
.Labbrev_end:
.section .debug_line,"", at progbits
.set .Lset4dbg,.Lline_end-.Lline_begin
.long .Lset4dbg
.Lline_begin:
.short 2
.set .Lset5dbg,.Lline_prolog_end-.Lline_prolog_begin
.long .Lset5dbg
.Lline_prolog_begin:
.byte 1
.byte 1
.byte 246
.byte 245
.byte 10
.byte 0
.byte 1
.byte 1
.byte 1
.byte 1
.byte 0
.byte 0
.byte 0
.byte 1
.asciz "/home/lb/pers/src/misc"
.byte 0
.asciz "test.c"
.uleb128 1
.uleb128 0
.uleb128 0
.byte 0
.Lline_prolog_end:
.byte 0
.byte 5
.byte 2
.long .Lsection_end1
.byte 0
.byte 1
.byte 1
.Lline_end:
.section .debug_pubnames,"", at progbits
.set .Lset6dbg,.Lpubnames_end1-.Lpubnames_begin1
.long .Lset6dbg
.Lpubnames_begin1:
.short 2
.set .Lset7dbg,.Linfo_begin1
.long .Lset7dbg
.set .Lset8dbg,.Linfo_end1-.Linfo_begin1
.long .Lset8dbg
.long 64
.asciz "main"
.long 0
.Lpubnames_end1:
.section .debug_pubtypes,"", at progbits
.set .Lset9dbg,.Lpubtypes_end1-.Lpubtypes_begin1
.long .Lset9dbg
.Lpubtypes_begin1:
.short 2
.set .Lset10dbg,.Linfo_begin1
.long .Lset10dbg
.set .Lset11dbg,.Linfo_end1-.Linfo_begin1
.long .Lset11dbg
.long 0
.Lpubtypes_end1:
.section .debug_loc,"", at progbits
.section .debug_aranges,"", at progbits
.section .debug_ranges,"", at progbits
.section .debug_macinfo,"", at progbits
.section .note.GNU-stack,"", at progbits
$ readelf --debug-dump a.out
Contents of the .debug_pubnames section:
Length: 23
Version: 2
Offset into .debug_info section: 0x0
Size of area in .debug_info section: 87
Offset Name
40 main
Contents of the .debug_info section:
Compilation Unit @ offset 0x0:
Length: 0x53 (32-bit)
Version: 2
Abbrev Offset: 0
Pointer Size: 4
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
< c> DW_AT_stmt_list : 0x0
<10> DW_AT_producer : clang 1.1
<1a> DW_AT_language : 12 (ANSI C99)
<1b> DW_AT_name : test.c
<22> DW_AT_comp_dir : /home/lb/pers/src/misc
<1><39>: Abbrev Number: 2 (DW_TAG_base_type)
<3a> DW_AT_encoding : 5 (signed)
<3b> DW_AT_name : int
<3f> DW_AT_byte_size : 4
<1><40>: Abbrev Number: 3 (DW_TAG_subprogram)
<41> DW_AT_name : main
<46> DW_AT_MIPS_linkage_name: main
<4b> DW_AT_decl_file : 1
<4c> DW_AT_decl_line : 2
<4d> DW_AT_prototyped : 1
<4e> DW_AT_type : <0x39>
Contents of the .debug_abbrev section:
Number TAG
1 DW_TAG_compile_unit [has children]
DW_AT_stmt_list DW_FORM_data4
DW_AT_producer DW_FORM_string
DW_AT_language DW_FORM_data1
DW_AT_name DW_FORM_string
DW_AT_comp_dir DW_FORM_string
2 DW_TAG_base_type [no children]
DW_AT_encoding DW_FORM_data1
DW_AT_name DW_FORM_string
DW_AT_byte_size DW_FORM_data1
3 DW_TAG_subprogram [no children]
DW_AT_name DW_FORM_string
DW_AT_MIPS_linkage_name DW_FORM_string
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
Raw dump of debug contents of section .debug_line:
Offset: 0x0
Length: 65
DWARF Version: 2
Prologue Length: 49
Minimum Instruction Length: 1
Initial value of 'is_stmt': 1
Line Base: -10
Line Range: 245
Opcode Base: 10
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
The Directory Table:
/home/lb/pers/src/misc
The File Name Table:
Entry Dir Time Size Name
1 1 0 0 test.c
Line Number Statements:
Extended opcode 2: set Address to 0x80483db
Extended opcode 1: End of Sequence
Offset: 0x45
Length: 68
DWARF Version: 2
Prologue Length: 39
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:
/tmp
The File Name Table:
Entry Dir Time Size Name
1 1 0 0 cc-g9lJBF.s
Line Number Statements:
Extended opcode 2: set Address to 0x80483c0
Advance Line by 32 to 33
Copy
Special opcode 21: advance Address by 1 to 0x80483c1 and Line by 2 to 35
Special opcode 35: advance Address by 2 to 0x80483c3 and Line by 2 to 37
Special opcode 49: advance Address by 3 to 0x80483c6 and Line by 2 to 39
Special opcode 48: advance Address by 3 to 0x80483c9 and Line by 1 to 40
Special opcode 48: advance Address by 3 to 0x80483cc and Line by 1 to 41
Special opcode 104: advance Address by 7 to 0x80483d3 and Line by 1 to 42
Special opcode 48: advance Address by 3 to 0x80483d6 and Line by 1 to 43
Special opcode 49: advance Address by 3 to 0x80483d9 and Line by 2 to 45
Advance PC by 2 to 0x80483db
Extended opcode 1: End of Sequence
Contents of the .debug_frame section:
00000000 00000010 ffffffff CIE
Version: 1
Augmentation: ""
Code alignment factor: 1
Data alignment factor: -4
Return address column: 8
DW_CFA_def_cfa: r4 (esp) ofs 4
DW_CFA_offset: r8 (eip) at cfa-4
DW_CFA_nop
DW_CFA_nop
Contents of the .debug_pubtypes section:
Length: 14
Version: 2
Offset into .debug_info section: 0x0
Size of area in .debug_info section: 87
Offset Name
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list