[Lldb-commits] [lldb] r333266 - ManualDWARFIndex: Fix misclassification of methods in unions

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri May 25 03:49:12 PDT 2018


Author: labath
Date: Fri May 25 03:49:11 2018
New Revision: 333266

URL: http://llvm.org/viewvc/llvm-project?rev=333266&view=rev
Log:
ManualDWARFIndex: Fix misclassification of methods in unions

Apple index was already treating them as methods. Not doing the same
seems like an omission.

Added:
    lldb/trunk/lit/SymbolFile/DWARF/find-method.cpp
Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp

Added: lldb/trunk/lit/SymbolFile/DWARF/find-method.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/find-method.cpp?rev=333266&view=auto
==============================================================================
--- lldb/trunk/lit/SymbolFile/DWARF/find-method.cpp (added)
+++ lldb/trunk/lit/SymbolFile/DWARF/find-method.cpp Fri May 25 03:49:11 2018
@@ -0,0 +1,31 @@
+// REQUIRES: lld
+
+// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux
+// RUN: ld.lld %t.o -o %t
+// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
+// RUN:   FileCheck %s
+//
+// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
+// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
+// RUN:   FileCheck %s
+
+// CHECK-DAG: name = "A::foo()", mangled = "_ZN1A3fooEv"
+// CHECK-DAG: name = "B::foo()", mangled = "_ZN1B3fooEv"
+// CHECK-DAG: name = "C::foo()", mangled = "_ZN1C3fooEv"
+
+struct A {
+  void foo();
+};
+void A::foo() {}
+
+class B {
+  void foo();
+};
+void B::foo() {}
+
+union C {
+  void foo();
+};
+void C::foo() {}
+
+extern "C" void _start() {}

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp?rev=333266&r1=333265&r2=333266&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp Fri May 25 03:49:11 2018
@@ -209,9 +209,10 @@ DWARFDIE::GetParentDeclContextDIE() cons
     return DWARFDIE();
 }
 
-bool DWARFDIE::IsStructOrClass() const {
+bool DWARFDIE::IsStructClassOrUnion() const {
   const dw_tag_t tag = Tag();
-  return tag == DW_TAG_class_type || tag == DW_TAG_structure_type;
+  return tag == DW_TAG_class_type || tag == DW_TAG_structure_type ||
+         tag == DW_TAG_union_type;
 }
 
 DWARFDIE

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h?rev=333266&r1=333265&r2=333266&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h Fri May 25 03:49:11 2018
@@ -19,7 +19,7 @@ public:
   //----------------------------------------------------------------------
   // Tests
   //----------------------------------------------------------------------
-  bool IsStructOrClass() const;
+  bool IsStructClassOrUnion() const;
 
   //----------------------------------------------------------------------
   // Accessors

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=333266&r1=333265&r2=333266&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp Fri May 25 03:49:11 2018
@@ -290,16 +290,15 @@ void ManualDWARFIndex::IndexUnitImpl(
           const DWARFDebugInfoEntry *parent = die.GetParent();
           bool is_method = false;
           if (parent) {
-            dw_tag_t parent_tag = parent->Tag();
-            if (parent_tag == DW_TAG_class_type ||
-                parent_tag == DW_TAG_structure_type) {
+            DWARFDIE parent_die(&unit, parent);
+            if (parent_die.IsStructClassOrUnion())
               is_method = true;
-            } else {
+            else {
               if (specification_die_form.IsValid()) {
                 DWARFDIE specification_die =
                     unit.GetSymbolFileDWARF()->DebugInfo()->GetDIE(
                         DIERef(specification_die_form));
-                if (specification_die.GetParent().IsStructOrClass())
+                if (specification_die.GetParent().IsStructClassOrUnion())
                   is_method = true;
               }
             }




More information about the lldb-commits mailing list