2017-09-12 07:05:20 +08:00
; RUN: llc -filetype=obj -o - < %s | llvm-dwarfdump -v -debug-info - | FileCheck %s
2016-01-16 09:15:32 +08:00
;
[DebugInfo] Omit location list entries with empty ranges
Summary:
This fixes PR39710. In that case we emitted a location list looking like
this:
.Ldebug_loc0:
.quad .Lfunc_begin0-.Lfunc_begin0
.quad .Lfunc_begin0-.Lfunc_begin0
.short 1 # Loc expr size
.byte 85 # DW_OP_reg5
.quad .Lfunc_begin0-.Lfunc_begin0
.quad .Lfunc_end0-.Lfunc_begin0
.short 1 # Loc expr size
.byte 85 # super-register DW_OP_reg5
.quad 0
.quad 0
As seen, the first entry's beginning and ending addresses evalute to 0,
which meant that the entry inadvertently became an "end of list" entry,
resulting in the location list ending sooner than expected.
To fix this, omit all entries with empty ranges. Location list entries
with empty ranges do not have any effect, as specified by DWARF, so we
might as well drop them:
"A location list entry (but not a base address selection or end of list
entry) whose beginning and ending addresses are equal has no effect
because the size of the range covered by such an entry is zero."
Reviewers: davide, aprantl, dblaikie
Reviewed By: aprantl
Subscribers: javed.absar, JDevlieghere, llvm-commits
Tags: #debug-info
Differential Revision: https://reviews.llvm.org/D55919
llvm-svn: 350698
2019-01-09 17:58:59 +08:00
; Checks that we're omitting the first range, as it is empty, and that we're
; emitting one that spans the rest of the function. In this case, the first
; range, which we omit, describes 8 bytes of the variable using DW_OP_litX,
; whereas the second one only describes 4 bytes, so clobbering the whole 8 byte
; fragment with the 4 bytes fragment isn't necessarily best thing to do here,
; but it is what is currently being emitted. Any change here needs to be
; intentional, so the test is very specific.
2016-01-16 09:15:32 +08:00
;
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-30 05:41:21 +08:00
; CHECK: DW_TAG_inlined_subroutine
; CHECK: DW_TAG_variable
; CHECK: DW_AT_location [DW_FORM_sec_offset] ({{.*}}
[DebugInfo] Omit location list entries with empty ranges
Summary:
This fixes PR39710. In that case we emitted a location list looking like
this:
.Ldebug_loc0:
.quad .Lfunc_begin0-.Lfunc_begin0
.quad .Lfunc_begin0-.Lfunc_begin0
.short 1 # Loc expr size
.byte 85 # DW_OP_reg5
.quad .Lfunc_begin0-.Lfunc_begin0
.quad .Lfunc_end0-.Lfunc_begin0
.short 1 # Loc expr size
.byte 85 # super-register DW_OP_reg5
.quad 0
.quad 0
As seen, the first entry's beginning and ending addresses evalute to 0,
which meant that the entry inadvertently became an "end of list" entry,
resulting in the location list ending sooner than expected.
To fix this, omit all entries with empty ranges. Location list entries
with empty ranges do not have any effect, as specified by DWARF, so we
might as well drop them:
"A location list entry (but not a base address selection or end of list
entry) whose beginning and ending addresses are equal has no effect
because the size of the range covered by such an entry is zero."
Reviewers: davide, aprantl, dblaikie
Reviewed By: aprantl
Subscribers: javed.absar, JDevlieghere, llvm-commits
Tags: #debug-info
Differential Revision: https://reviews.llvm.org/D55919
llvm-svn: 350698
2019-01-09 17:58:59 +08:00
; CHECK-NEXT: [0x00000004, 0x00000014): DW_OP_lit0, DW_OP_stack_value, DW_OP_piece 0x4)
2016-01-16 09:15:32 +08:00
; Created form the following test case (PR26163) with
; clang -cc1 -triple armv4t--freebsd11.0-gnueabi -emit-obj -debug-info-kind=standalone -O2 -x c test.c
;
; typedef unsigned int size_t;
; struct timeval {
; long long tv_sec;
; int tv_usec;
; };
2018-01-16 19:17:57 +08:00
;
2016-01-16 09:15:32 +08:00
; void *memset(void *, int, size_t);
; void foo(void);
2018-01-16 19:17:57 +08:00
;
2016-01-16 09:15:32 +08:00
; static void
; bar(int value)
; {
; struct timeval lifetime;
2018-01-16 19:17:57 +08:00
;
2016-01-16 09:15:32 +08:00
; memset(&lifetime, 0, sizeof(struct timeval));
; lifetime.tv_sec = value;
2018-01-16 19:17:57 +08:00
;
2016-01-16 09:15:32 +08:00
; foo();
; }
2018-01-16 19:17:57 +08:00
;
2016-01-16 09:15:32 +08:00
; int
; parse_config_file(void)
; {
; int value;
2018-01-16 19:17:57 +08:00
;
2016-01-16 09:15:32 +08:00
; bar(value);
; return (0);
; }
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv4t--freebsd11.0-gnueabi"
%struct.timeval = type { i64 , i32 }
declare void @llvm.dbg.declare ( metadata , metadata , metadata )
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata )
2016-01-16 09:15:32 +08:00
declare void @foo ( )
define i32 @parse_config_file ( ) !dbg !4 {
entry:
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i32 0 , metadata !15 , metadata !26 ) , !dbg !27
2016-01-16 09:15:32 +08:00
tail call void @llvm.dbg.declare ( metadata %struct.timeval * undef , metadata !16 , metadata !26 ) , !dbg !29
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i64 0 , metadata !16 , metadata !30 ) , !dbg !29
tail call void @llvm.dbg.value ( metadata i32 0 , metadata !16 , metadata !31 ) , !dbg !29
2016-01-16 09:15:32 +08:00
tail call void @foo ( ) #3 , !dbg !32
ret i32 0 , !dbg !33
}
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !22 , !23 , !24 }
!llvm.ident = ! { !25 }
2019-01-16 00:18:52 +08:00
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , file: !1 , producer: "clang version 3.9.0" , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !2 )
2016-01-16 09:15:32 +08:00
!1 = !DIFile ( filename: "<stdin>" , directory: "/home/ubuntu/bugs" )
!2 = ! { }
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
!4 = distinct !DISubprogram ( name: "parse_config_file" , scope: !5 , file: !5 , line: 22 , type: !6 , isLocal: false , isDefinition: true , scopeLine: 23 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !0 , retainedNodes: !9 )
2016-01-16 09:15:32 +08:00
!5 = !DIFile ( filename: "test.c" , directory: "/home/ubuntu/bugs" )
!6 = !DISubroutineType ( types: !7 )
!7 = ! { !8 }
!8 = !DIBasicType ( name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!9 = ! { !10 }
!10 = !DILocalVariable ( name: "value" , scope: !4 , file: !5 , line: 24 , type: !8 )
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
!11 = distinct !DISubprogram ( name: "bar" , scope: !5 , file: !5 , line: 11 , type: !12 , isLocal: true , isDefinition: true , scopeLine: 12 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !0 , retainedNodes: !14 )
2016-01-16 09:15:32 +08:00
!12 = !DISubroutineType ( types: !13 )
!13 = ! { null , !8 }
!14 = ! { !15 , !16 }
!15 = !DILocalVariable ( name: "value" , arg: 1 , scope: !11 , file: !5 , line: 11 , type: !8 )
!16 = !DILocalVariable ( name: "lifetime" , scope: !11 , file: !5 , line: 13 , type: !17 )
!17 = !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "timeval" , file: !5 , line: 2 , size: 128 , align: 64 , elements: !18 )
!18 = ! { !19 , !21 }
!19 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "tv_sec" , scope: !17 , file: !5 , line: 3 , baseType: !20 , size: 64 , align: 64 )
!20 = !DIBasicType ( name: "long long int" , size: 64 , align: 64 , encoding: D W _ A T E _ s i g n e d )
!21 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "tv_usec" , scope: !17 , file: !5 , line: 4 , baseType: !8 , size: 32 , align: 32 , offset: 64 )
!22 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!23 = ! { i32 1 , !"wchar_size" , i32 4 }
!24 = ! { i32 1 , !"min_enum_size" , i32 4 }
2019-01-16 00:18:52 +08:00
!25 = ! { !"clang version 3.9.0" }
2016-01-16 09:15:32 +08:00
!26 = !DIExpression ( )
!27 = !DILocation ( line: 11 , scope: !11 , inlinedAt: !28 )
!28 = distinct !DILocation ( line: 26 , scope: !4 )
!29 = !DILocation ( line: 13 , scope: !11 , inlinedAt: !28 )
2016-12-06 02:04:47 +08:00
!30 = !DIExpression ( D W _ O P _ L L V M _ f r a g m e n t , 0 , 64 )
!31 = !DIExpression ( D W _ O P _ L L V M _ f r a g m e n t , 0 , 32 )
2016-01-16 09:15:32 +08:00
!32 = !DILocation ( line: 18 , scope: !11 , inlinedAt: !28 )
!33 = !DILocation ( line: 27 , scope: !4 )