jwnhy updated this revision to Diff 512362.
jwnhy added a comment.

Updated the patch to remove unncessary checks and added a testcase.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147606/new/

https://reviews.llvm.org/D147606

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/test/Shell/SymbolFile/DWARF/x86/debug_empty_ranges.s

Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_empty_ranges.s
===================================================================
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_empty_ranges.s
@@ -0,0 +1,481 @@
+# Test handling of empty DWARF ranges generated by GCC
+
+# RUN: %clang --target=x86_64-pc-linux -o %t %s 
+# RUN: %lldb %t -o "b func" -o "r" -o "expression -T -- i" \
+# RUN: -o "exit" | FileCheck %s
+
+# Failing case was:
+# error: expression failed to parse:
+# error: <user expression 0>:1:1: use of undeclared identifier 'i'
+# CHECK: (int) $0 = 10
+	.file	"r.c"
+	.file 1 "r.c"
+	.text
+.Ltext0:
+	.file 0 "" "r.c"
+	.globl	main
+	.type	main, @function
+main:
+.LFB1:
+	.file 1 "r.c"
+	.loc 1 12 12
+	.cfi_startproc
+	.loc 1 12 14
+	movl	b(%rip), %eax
+.LBB5:
+.LBB6:
+	.loc 1 4 3
+.LVL0:
+	.loc 1 5 3
+	.loc 1 5 12
+.LBE6:
+	.loc 1 6 5
+	.loc 1 7 5
+.LBB7:
+	.loc 1 5 19
+	.loc 1 5 12
+.LBE7:
+	.loc 1 6 5
+	.loc 1 7 5
+.LBB8:
+	.loc 1 5 19
+	.loc 1 5 12
+.LBE8:
+	.loc 1 6 5
+	.loc 1 7 5
+.LBB9:
+	.loc 1 5 19
+	.loc 1 5 12
+.LBE9:
+	.loc 1 6 5
+	.loc 1 7 5
+.LBB10:
+	.loc 1 5 19
+	.loc 1 5 12
+.LBE10:
+	.loc 1 6 5
+	.loc 1 7 5
+.LBB11:
+	.loc 1 5 19
+	.loc 1 5 12
+.LBE11:
+	.loc 1 6 5
+	.loc 1 7 5
+.LBB12:
+	.loc 1 5 19
+	.loc 1 5 12
+.LBE12:
+	.loc 1 6 5
+	.loc 1 7 5
+.LBB13:
+	.loc 1 5 19
+	.loc 1 5 12
+.LBE13:
+	.loc 1 6 5
+	.loc 1 7 5
+.LBB14:
+	.loc 1 5 19
+	.loc 1 5 12
+.LBE14:
+	.loc 1 6 5
+	.loc 1 7 5
+.LBB15:
+	.loc 1 5 19
+	.loc 1 5 12
+.LBE15:
+	.loc 1 6 5
+	.loc 1 7 5
+.LBB16:
+	.loc 1 5 19
+	.loc 1 5 12
+	.loc 1 9 3
+	.loc 1 9 5 is_stmt 0
+	movl	$0, a(%rip)
+	.loc 1 10 3 is_stmt 1
+.LVL1:
+.LBE16:
+.LBE5:
+	.loc 1 12 26 is_stmt 0
+	movl	$0, %eax
+	ret
+	.cfi_endproc
+.LFE1:
+	.size	main, .-main
+	.globl	b
+	.bss
+	.align 4
+	.type	b, @object
+	.size	b, 4
+b:
+	.zero	4
+	.globl	a
+	.align 4
+	.type	a, @object
+	.size	a, 4
+a:
+	.zero	4
+	.text
+.Letext0:
+	.section	.debug_info,"",@progbits
+.Ldebug_info0:
+	.long	0xd9
+	.value	0x5
+	.byte	0x1
+	.byte	0x8
+	.long	.Ldebug_abbrev0
+	.uleb128 0x3
+	.long	.LASF2
+	.byte	0x1d
+	.long	.LASF0
+	.long	.LASF1
+	.quad	.Ltext0
+	.quad	.Letext0-.Ltext0
+	.long	.Ldebug_line0
+	.uleb128 0x1
+	.string	"a"
+	.byte	0x1
+	.byte	0x5
+	.long	0x41
+	.uleb128 0x9
+	.byte	0x3
+	.quad	a
+	.uleb128 0x4
+	.byte	0x4
+	.byte	0x5
+	.string	"int"
+	.uleb128 0x5
+	.long	0x41
+	.uleb128 0x1
+	.string	"b"
+	.byte	0x2
+	.byte	0xe
+	.long	0x48
+	.uleb128 0x9
+	.byte	0x3
+	.quad	b
+	.uleb128 0x6
+	.long	.LASF3
+	.byte	0x1
+	.byte	0xc
+	.byte	0x5
+	.long	0x41
+	.quad	.LFB1
+	.quad	.LFE1-.LFB1
+	.uleb128 0x1
+	.byte	0x9c
+	.long	0xb0
+	.uleb128 0x7
+	.long	0xb0
+	.quad	.LBB5
+	.quad	.LBE5-.LBB5
+	.byte	0x1
+	.byte	0xc
+	.byte	0xe
+	.uleb128 0x8
+	.long	0xbd
+	.uleb128 0x9
+	.long	.LLRL0
+	.uleb128 0xa
+	.long	0xc7
+	.long	.LLST1
+	.byte	0
+	.byte	0
+	.byte	0
+	.uleb128 0xb
+	.long	.LASF4
+	.byte	0x1
+	.byte	0x3
+	.byte	0xc
+	.long	0x41
+	.byte	0x1
+	.uleb128 0xc
+	.string	"b"
+	.byte	0x1
+	.byte	0x3
+	.byte	0x18
+	.long	0x41
+	.uleb128 0x2
+	.string	"i"
+	.byte	0x4
+	.byte	0x7
+	.long	0x41
+	.uleb128 0xd
+	.uleb128 0x2
+	.string	"c"
+	.byte	0x6
+	.byte	0x9
+	.long	0x41
+	.byte	0
+	.byte	0
+	.byte	0
+	.section	.debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+	.uleb128 0x1
+	.uleb128 0x34
+	.byte	0
+	.uleb128 0x3
+	.uleb128 0x8
+	.uleb128 0x3a
+	.uleb128 0x21
+	.sleb128 1
+	.uleb128 0x3b
+	.uleb128 0xb
+	.uleb128 0x39
+	.uleb128 0xb
+	.uleb128 0x49
+	.uleb128 0x13
+	.uleb128 0x3f
+	.uleb128 0x19
+	.uleb128 0x2
+	.uleb128 0x18
+	.byte	0
+	.byte	0
+	.uleb128 0x2
+	.uleb128 0x34
+	.byte	0
+	.uleb128 0x3
+	.uleb128 0x8
+	.uleb128 0x3a
+	.uleb128 0x21
+	.sleb128 1
+	.uleb128 0x3b
+	.uleb128 0xb
+	.uleb128 0x39
+	.uleb128 0xb
+	.uleb128 0x49
+	.uleb128 0x13
+	.byte	0
+	.byte	0
+	.uleb128 0x3
+	.uleb128 0x11
+	.byte	0x1
+	.uleb128 0x25
+	.uleb128 0xe
+	.uleb128 0x13
+	.uleb128 0xb
+	.uleb128 0x3
+	.uleb128 0x1f
+	.uleb128 0x1b
+	.uleb128 0x1f
+	.uleb128 0x11
+	.uleb128 0x1
+	.uleb128 0x12
+	.uleb128 0x7
+	.uleb128 0x10
+	.uleb128 0x17
+	.byte	0
+	.byte	0
+	.uleb128 0x4
+	.uleb128 0x24
+	.byte	0
+	.uleb128 0xb
+	.uleb128 0xb
+	.uleb128 0x3e
+	.uleb128 0xb
+	.uleb128 0x3
+	.uleb128 0x8
+	.byte	0
+	.byte	0
+	.uleb128 0x5
+	.uleb128 0x35
+	.byte	0
+	.uleb128 0x49
+	.uleb128 0x13
+	.byte	0
+	.byte	0
+	.uleb128 0x6
+	.uleb128 0x2e
+	.byte	0x1
+	.uleb128 0x3f
+	.uleb128 0x19
+	.uleb128 0x3
+	.uleb128 0xe
+	.uleb128 0x3a
+	.uleb128 0xb
+	.uleb128 0x3b
+	.uleb128 0xb
+	.uleb128 0x39
+	.uleb128 0xb
+	.uleb128 0x49
+	.uleb128 0x13
+	.uleb128 0x11
+	.uleb128 0x1
+	.uleb128 0x12
+	.uleb128 0x7
+	.uleb128 0x40
+	.uleb128 0x18
+	.uleb128 0x7a
+	.uleb128 0x19
+	.uleb128 0x1
+	.uleb128 0x13
+	.byte	0
+	.byte	0
+	.uleb128 0x7
+	.uleb128 0x1d
+	.byte	0x1
+	.uleb128 0x31
+	.uleb128 0x13
+	.uleb128 0x11
+	.uleb128 0x1
+	.uleb128 0x12
+	.uleb128 0x7
+	.uleb128 0x58
+	.uleb128 0xb
+	.uleb128 0x59
+	.uleb128 0xb
+	.uleb128 0x57
+	.uleb128 0xb
+	.byte	0
+	.byte	0
+	.uleb128 0x8
+	.uleb128 0x5
+	.byte	0
+	.uleb128 0x31
+	.uleb128 0x13
+	.byte	0
+	.byte	0
+	.uleb128 0x9
+	.uleb128 0xb
+	.byte	0x1
+	.uleb128 0x55
+	.uleb128 0x17
+	.byte	0
+	.byte	0
+	.uleb128 0xa
+	.uleb128 0x34
+	.byte	0
+	.uleb128 0x31
+	.uleb128 0x13
+	.uleb128 0x2
+	.uleb128 0x17
+	.byte	0
+	.byte	0
+	.uleb128 0xb
+	.uleb128 0x2e
+	.byte	0x1
+	.uleb128 0x3
+	.uleb128 0xe
+	.uleb128 0x3a
+	.uleb128 0xb
+	.uleb128 0x3b
+	.uleb128 0xb
+	.uleb128 0x39
+	.uleb128 0xb
+	.uleb128 0x27
+	.uleb128 0x19
+	.uleb128 0x49
+	.uleb128 0x13
+	.uleb128 0x20
+	.uleb128 0xb
+	.byte	0
+	.byte	0
+	.uleb128 0xc
+	.uleb128 0x5
+	.byte	0
+	.uleb128 0x3
+	.uleb128 0x8
+	.uleb128 0x3a
+	.uleb128 0xb
+	.uleb128 0x3b
+	.uleb128 0xb
+	.uleb128 0x39
+	.uleb128 0xb
+	.uleb128 0x49
+	.uleb128 0x13
+	.byte	0
+	.byte	0
+	.uleb128 0xd
+	.uleb128 0xb
+	.byte	0x1
+	.byte	0
+	.byte	0
+	.byte	0
+	.section	.debug_loclists,"",@progbits
+	.long	.Ldebug_loc3-.Ldebug_loc2
+.Ldebug_loc2:
+	.value	0x5
+	.byte	0x8
+	.byte	0
+	.long	0
+.Ldebug_loc0:
+.LLST1:
+	.byte	0x4
+	.uleb128 .LVL0-.Ltext0
+	.uleb128 .LVL1-.Ltext0
+	.uleb128 0x2
+	.byte	0x3a
+	.byte	0x9f
+	.byte	0
+.Ldebug_loc3:
+	.section	.debug_aranges,"",@progbits
+	.long	0x2c
+	.value	0x2
+	.long	.Ldebug_info0
+	.byte	0x8
+	.byte	0
+	.value	0
+	.value	0
+	.quad	.Ltext0
+	.quad	.Letext0-.Ltext0
+	.quad	0
+	.quad	0
+	.section	.debug_rnglists,"",@progbits
+.Ldebug_ranges0:
+	.long	.Ldebug_ranges3-.Ldebug_ranges2
+.Ldebug_ranges2:
+	.value	0x5
+	.byte	0x8
+	.byte	0
+	.long	0
+.LLRL0:
+	.byte	0x4
+	.uleb128 .LBB6-.Ltext0
+	.uleb128 .LBE6-.Ltext0
+	.byte	0x4
+	.uleb128 .LBB7-.Ltext0
+	.uleb128 .LBE7-.Ltext0
+	.byte	0x4
+	.uleb128 .LBB8-.Ltext0
+	.uleb128 .LBE8-.Ltext0
+	.byte	0x4
+	.uleb128 .LBB9-.Ltext0
+	.uleb128 .LBE9-.Ltext0
+	.byte	0x4
+	.uleb128 .LBB10-.Ltext0
+	.uleb128 .LBE10-.Ltext0
+	.byte	0x4
+	.uleb128 .LBB11-.Ltext0
+	.uleb128 .LBE11-.Ltext0
+	.byte	0x4
+	.uleb128 .LBB12-.Ltext0
+	.uleb128 .LBE12-.Ltext0
+	.byte	0x4
+	.uleb128 .LBB13-.Ltext0
+	.uleb128 .LBE13-.Ltext0
+	.byte	0x4
+	.uleb128 .LBB14-.Ltext0
+	.uleb128 .LBE14-.Ltext0
+	.byte	0x4
+	.uleb128 .LBB15-.Ltext0
+	.uleb128 .LBE15-.Ltext0
+	.byte	0x4
+	.uleb128 .LBB16-.Ltext0
+	.uleb128 .LBE16-.Ltext0
+	.byte	0
+.Ldebug_ranges3:
+	.section	.debug_line,"",@progbits
+.Ldebug_line0:
+	.section	.debug_str,"MS",@progbits,1
+.LASF4:
+	.string	"func"
+.LASF3:
+	.string	"main"
+.LASF2:
+	.string	"GNU C17 12.2.0 -mtune=generic -march=x86-64 -g -gno-as-locview-support -O1 -fPIE"
+	.section	.debug_line_str,"MS",@progbits,1
+.LASF1:
+	.string	""
+.LASF0:
+	.string	"r.c"
+	.ident	"GCC: (GNU) 12.2.0"
+	.section	.note.GNU-stack,"",@progbits
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -1065,8 +1065,9 @@
 
   DWARFRangeList ranges;
   for (const llvm::DWARFAddressRange &llvm_range : *llvm_ranges) {
-    ranges.Append(DWARFRangeList::Entry(llvm_range.LowPC,
-                                        llvm_range.HighPC - llvm_range.LowPC));
+    if (llvm_range.HighPC - llvm_range.LowPC > 0)
+      ranges.Append(DWARFRangeList::Entry(llvm_range.LowPC,
+                                          llvm_range.HighPC - llvm_range.LowPC));
   }
   return ranges;
 }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to