Author: labath
Date: Tue May 29 01:16:22 2018
New Revision: 333398

URL: http://llvm.org/viewvc/llvm-project?rev=333398&view=rev
Log:
ManualDWARFIndex: Treat DW_TAG_subprogram and DW_TAG_inlined_subroutine the 
same way

Summary:
We were treating subprograms and inlined subroutines differently when
building the index. The difference was in which indexes were individual
tags inserted (subprograms went to all indexes, where as inlined
subroutines only into the basename and full name indexes).

This seems like an error, because an inlined subroutine can still
represent an C++ or an ObjC method. I don't see anything in the
subprogram branch which should not apply to an inlined subroutine, so I
propose to just treat them identically. This makes searching for an
inlined method behave the same way as for the apple index.

I write an assembly-based test because I did not want to depend on
particular clang inlining behavior (and because I wanted to see how hard
would it be).

Reviewers: clayborg, JDevlieghere

Subscribers: eraman, lldb-commits

Differential Revision: https://reviews.llvm.org/D47368

Added:
    lldb/trunk/lit/SymbolFile/DWARF/find-inline-method.s
Modified:
    lldb/trunk/lit/SymbolFile/DWARF/lit.local.cfg
    lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp

Added: lldb/trunk/lit/SymbolFile/DWARF/find-inline-method.s
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/find-inline-method.s?rev=333398&view=auto
==============================================================================
--- lldb/trunk/lit/SymbolFile/DWARF/find-inline-method.s (added)
+++ lldb/trunk/lit/SymbolFile/DWARF/find-inline-method.s Tue May 29 01:16:22 
2018
@@ -0,0 +1,152 @@
+# REQUIRES: lld
+
+# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: lldb-test symbols --find=function --name=inl --function-flags=method %t 
\
+# RUN:   | FileCheck %s
+
+# CHECK: Function: {{.*}} mangled = "_Z8externali"
+# CHECK: Blocks: {{.*}} range = [0x00201000-0x00201002)
+# CHECK-NEXT: range = [0x00201000-0x00201002), name = "inl", mangled = 
_ZN1S3inlEi
+
+
+# Generated via:
+#   clang -O2 -g -S
+
+# from file:
+#   int forward(int);
+#   struct S {
+#     static int inl(int a) { return forward(a); }
+#   };
+#   int external(int a) { return S::inl(a); }
+
+# and then simplified.
+
+       .text
+_Z8externali:
+.Lfunc_begin0:
+       jmp     _Z7forwardi
+.Lfunc_end0:
+
+.globl _start
+_start:
+_Z7forwardi:
+        ret
+
+       .section        .debug_str,"MS",@progbits,1
+.Linfo_string0:
+       .asciz  "clang version 7.0.0 (trunk 332830) (llvm/trunk 332835) with 
manual modifications"
+.Linfo_string3:
+       .asciz  "_ZN1S3inlEi"
+.Linfo_string4:
+       .asciz  "inl"
+.Linfo_string6:
+       .asciz  "S"
+.Linfo_string8:
+       .asciz  "_Z8externali"
+.Linfo_string9:
+       .asciz  "external"
+       .section        .debug_abbrev,"",@progbits
+       .byte   1                       # Abbreviation Code
+       .byte   17                      # DW_TAG_compile_unit
+       .byte   1                       # DW_CHILDREN_yes
+       .byte   37                      # DW_AT_producer
+       .byte   14                      # DW_FORM_strp
+       .byte   19                      # DW_AT_language
+       .byte   5                       # DW_FORM_data2
+       .byte   17                      # DW_AT_low_pc
+       .byte   1                       # DW_FORM_addr
+       .byte   18                      # DW_AT_high_pc
+       .byte   6                       # DW_FORM_data4
+       .byte   0                       # EOM(1)
+       .byte   0                       # EOM(2)
+       .byte   2                       # Abbreviation Code
+       .byte   19                      # DW_TAG_structure_type
+       .byte   1                       # DW_CHILDREN_yes
+       .byte   3                       # DW_AT_name
+       .byte   14                      # DW_FORM_strp
+       .byte   11                      # DW_AT_byte_size
+       .byte   11                      # DW_FORM_data1
+       .byte   0                       # EOM(1)
+       .byte   0                       # EOM(2)
+       .byte   3                       # Abbreviation Code
+       .byte   46                      # DW_TAG_subprogram
+       .byte   0                       # DW_CHILDREN_no
+       .byte   110                     # DW_AT_linkage_name
+       .byte   14                      # DW_FORM_strp
+       .byte   3                       # DW_AT_name
+       .byte   14                      # DW_FORM_strp
+       .byte   0                       # EOM(1)
+       .byte   0                       # EOM(2)
+       .byte   6                       # Abbreviation Code
+       .byte   46                      # DW_TAG_subprogram
+       .byte   0                       # DW_CHILDREN_no
+       .byte   71                      # DW_AT_specification
+       .byte   19                      # DW_FORM_ref4
+       .byte   32                      # DW_AT_inline
+       .byte   11                      # DW_FORM_data1
+       .byte   0                       # EOM(1)
+       .byte   0                       # EOM(2)
+       .byte   8                       # Abbreviation Code
+       .byte   46                      # DW_TAG_subprogram
+       .byte   1                       # DW_CHILDREN_yes
+       .byte   17                      # DW_AT_low_pc
+       .byte   1                       # DW_FORM_addr
+       .byte   18                      # DW_AT_high_pc
+       .byte   6                       # DW_FORM_data4
+       .byte   110                     # DW_AT_linkage_name
+       .byte   14                      # DW_FORM_strp
+       .byte   3                       # DW_AT_name
+       .byte   14                      # DW_FORM_strp
+       .byte   0                       # EOM(1)
+       .byte   0                       # EOM(2)
+       .byte   10                      # Abbreviation Code
+       .byte   29                      # DW_TAG_inlined_subroutine
+       .byte   1                       # DW_CHILDREN_yes
+       .byte   49                      # DW_AT_abstract_origin
+       .byte   19                      # DW_FORM_ref4
+       .byte   17                      # DW_AT_low_pc
+       .byte   1                       # DW_FORM_addr
+       .byte   18                      # DW_AT_high_pc
+       .byte   6                       # DW_FORM_data4
+       .byte   0                       # EOM(1)
+       .byte   0                       # EOM(2)
+       .byte   0                       # EOM(3)
+       .section        .debug_info,"",@progbits
+.Lcu_begin0:
+       .long   .Lcu_end0-.Lcu_start0   # Length of Unit
+.Lcu_start0:
+       .short  4                       # DWARF version number
+       .long   .debug_abbrev           # Offset Into Abbrev. Section
+       .byte   8                       # Address Size (in bytes)
+       .byte   1                       # Abbrev [1] 0xb:0x9e 
DW_TAG_compile_unit
+       .long   .Linfo_string0          # DW_AT_producer
+       .short  4                       # DW_AT_language
+       .quad   .Lfunc_begin0           # DW_AT_low_pc
+       .long   .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+       .byte   2                       # Abbrev [2] 0x2a:0x1f 
DW_TAG_structure_type
+       .long   .Linfo_string6          # DW_AT_name
+       .byte   1                       # DW_AT_byte_size
+.Linl_spec:
+       .byte   3                       # Abbrev [3] 0x33:0x15 DW_TAG_subprogram
+       .long   .Linfo_string3          # DW_AT_linkage_name
+       .long   .Linfo_string4          # DW_AT_name
+       .byte   0                       # End Of Children Mark
+.Linl_abstract:
+       .byte   6                       # Abbrev [6] 0x50:0x12 DW_TAG_subprogram
+       .long   .Linl_spec              # DW_AT_specification
+       .byte   1                       # DW_AT_inline
+.Linl_a_abstract:
+       .byte   8                       # Abbrev [8] 0x62:0x46 DW_TAG_subprogram
+       .quad   .Lfunc_begin0           # DW_AT_low_pc
+       .long   .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+       .long   .Linfo_string8          # DW_AT_linkage_name
+       .long   .Linfo_string9          # DW_AT_name
+       .byte   10                      # Abbrev [10] 0x8c:0x1b 
DW_TAG_inlined_subroutine
+       .long   .Linl_abstract          # DW_AT_abstract_origin
+       .quad   .Lfunc_begin0           # DW_AT_low_pc
+       .long   .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+       .byte   0                       # End Of Children Mark
+       .byte   0                       # End Of Children Mark
+       .byte   0                       # End Of Children Mark
+.Lcu_end0:

Modified: lldb/trunk/lit/SymbolFile/DWARF/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/lit.local.cfg?rev=333398&r1=333397&r2=333398&view=diff
==============================================================================
--- lldb/trunk/lit/SymbolFile/DWARF/lit.local.cfg (original)
+++ lldb/trunk/lit/SymbolFile/DWARF/lit.local.cfg Tue May 29 01:16:22 2018
@@ -1 +1 @@
-config.suffixes = ['.cpp']
+config.suffixes = ['.cpp', '.s']

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp?rev=333398&r1=333397&r2=333398&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp Tue May 29 
01:16:22 2018
@@ -256,6 +256,7 @@ void ManualDWARFIndex::IndexUnitImpl(
     }
 
     switch (tag) {
+    case DW_TAG_inlined_subroutine:
     case DW_TAG_subprogram:
       if (has_address) {
         if (name) {
@@ -330,28 +331,6 @@ void ManualDWARFIndex::IndexUnitImpl(
       }
       break;
 
-    case DW_TAG_inlined_subroutine:
-      if (has_address) {
-        if (name)
-          set.function_basenames.Insert(ConstString(name),
-                                        DIERef(cu_offset, die.GetOffset()));
-        if (mangled_cstr) {
-          // Make sure our mangled name isn't the same string table entry as
-          // our name. If it starts with '_', then it is ok, else compare the
-          // string to make sure it isn't the same and we don't end up with
-          // duplicate entries
-          if (name && name != mangled_cstr &&
-              ((mangled_cstr[0] == '_') ||
-               (::strcmp(name, mangled_cstr) != 0))) {
-            set.function_fullnames.Insert(ConstString(mangled_cstr),
-                                          DIERef(cu_offset, die.GetOffset()));
-          }
-        } else
-          set.function_fullnames.Insert(ConstString(name),
-                                        DIERef(cu_offset, die.GetOffset()));
-      }
-      break;
-
     case DW_TAG_array_type:
     case DW_TAG_base_type:
     case DW_TAG_class_type:


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to