[Lldb-commits] [PATCH] D71487: [LLDB] Fix address computation for inline function
Johannes Altmanninger via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 19 09:02:56 PST 2019
johannes updated this revision to Diff 234736.
johannes added a comment.
- Use `addr.IsSectionOffset()` as suggested.
- Add test that links two copies of a compilation unit and makes sure that lldb only resolves it once.
The fix seems to work when linking an executable, but it does not when creating a shared object file, as demonstrated by the XFAIL test. In the DWARF of the shared object the low_pc of one copy of "foo" is set to zero, which seems to be inside a section so it is considered valid.
$ build/bin/llvm-dwarfdump build/tools/lldb/test/SymbolFile/DWARF/Output/inline-function-address-shared.test.tmp
build/tools/lldb/test/SymbolFile/DWARF/Output/inline-function-address-shared.test.tmp: file format ELF64-x86-64
.debug_info contents:
0x00000000: Compile Unit: length = 0x0000003d version = 0x0004 abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x00000041)
0x0000000b: DW_TAG_compile_unit
DW_AT_producer ("")
DW_AT_language (DW_LANG_C99)
DW_AT_name ("inline-function-address.c")
DW_AT_stmt_list (0x00000000)
DW_AT_low_pc (0x0000000000001270)
DW_AT_high_pc (0x0000000000001271)
0x00000026: DW_TAG_subprogram
DW_AT_name ("foo")
DW_AT_decl_file ("inline-function-address.h")
DW_AT_decl_line (12)
DW_AT_prototyped (true)
DW_AT_declaration (true)
DW_AT_external (true)
0x0000002d: DW_TAG_subprogram
DW_AT_low_pc (0x0000000000001270)
DW_AT_high_pc (0x0000000000001271)
DW_AT_frame_base (DW_OP_reg7 RSP)
DW_AT_specification (0x00000026 "foo")
0x00000040: NULL
0x00000041: Compile Unit: length = 0x0000003d version = 0x0004 abbr_offset = 0x0030 addr_size = 0x08 (next unit at 0x00000082)
0x0000004c: DW_TAG_compile_unit
DW_AT_producer ("")
DW_AT_language (DW_LANG_C99)
DW_AT_name ("inline-function-address.c")
DW_AT_stmt_list (0x0000003b)
DW_AT_low_pc (0x0000000000000000)
DW_AT_high_pc (0x0000000000000001)
0x00000067: DW_TAG_subprogram
DW_AT_name ("foo")
DW_AT_decl_file ("inline-function-address.h")
DW_AT_decl_line (12)
DW_AT_prototyped (true)
DW_AT_declaration (true)
DW_AT_external (true)
0x0000006e: DW_TAG_subprogram
DW_AT_low_pc (0x0000000000000000)
DW_AT_high_pc (0x0000000000000001)
DW_AT_frame_base (DW_OP_reg7 RSP)
DW_AT_specification (0x00000067 "foo")
0x00000081: NULL
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71487/new/
https://reviews.llvm.org/D71487
Files:
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll
Index: lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll
===================================================================
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll
@@ -0,0 +1,28 @@
+; REQUIRES: lld
+; RUN: llc %s -filetype=obj -o %t.o
+; RUN: ld.lld %t.o %t.o -o %t
+; "foo" is defined in both compilation units, but there should be only one meaningful debuginfo entry
+; RUN: lldb-test symbols --find=function --name=foo --function-flags=full %t | FileCheck %s
+; CHECK: Function: {{.*}} "foo"
+; CHECK-NOT: Function: {{.*}} "foo"
+
+$foo = comdat any
+define void @foo() comdat !dbg !6 {
+entry:
+ ret void
+}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !{}, imports: !{}, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "inline-function-address.h", directory: "")
+!2 = !DIFile(filename: "inline-function-address.c", directory: "")
+!3 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!4 = !DISubroutineType(types: !{})
+!5 = !DISubprogram(name: "foo", file: !1, line: 12, type: !4, flags: DIFlagPrototyped, spFlags: 0)
+!6 = distinct !DISubprogram(name: "foo", file: !1, line: 12, type: !4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !5)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!7, !8, !9}
+!llvm.ident = !{}
+!7 = !{i32 7, !"Dwarf Version", i32 4}
+!8 = !{i32 2, !"Debug Info Version", i32 3}
+!9 = !{i32 1, !"wchar_size", i32 4}
Index: lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
===================================================================
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
@@ -0,0 +1,7 @@
+# REQUIRES: lld
+; RUN: llc %S/inline-function-address.ll -filetype=obj -o %t.o
+; RUN: ld.lld %t.o %t.o -o %t -shared
+; RUN: lldb-test symbols --find=function --name=foo --function-flags=full %t | FileCheck %s
+; CHECK: Function: {{.*}} "foo"
+; CHECK-NOT: Function: {{.*}} "foo"
+; XFAIL: *
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2282,7 +2282,7 @@
addr = sc.function->GetAddressRange().GetBaseAddress();
}
- if (addr.IsValid()) {
+ if (addr.IsSectionOffset()) {
sc_list.Append(sc);
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71487.234736.patch
Type: text/x-patch
Size: 2564 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191219/6aec724e/attachment.bin>
More information about the lldb-commits
mailing list