[Lldb-commits] [PATCH] D67994: [WIP] Modify lldb-test to print out ASTs from symbol file

Shafik Yaghmour via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 24 16:15:54 PDT 2019


shafik updated this revision to Diff 221622.
shafik added a comment.

- Formatting code
- Removing FunctionDecl case since it was not correct


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

https://reviews.llvm.org/D67994

Files:
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  tools/lldb-test/lldb-test.cpp


Index: tools/lldb-test/lldb-test.cpp
===================================================================
--- tools/lldb-test/lldb-test.cpp
+++ tools/lldb-test/lldb-test.cpp
@@ -42,6 +42,7 @@
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/WithColor.h"
+
 #include <cstdio>
 #include <thread>
 
@@ -548,6 +549,34 @@
 
   tu->print(outs());
 
+  lldb_private::TypeList type_list;
+  size_t ntypes = symfile->GetTypes(nullptr, eTypeClassAny, type_list);
+  printf("Type list size: %zu\n", ntypes);
+
+  for (size_t i = 0; i < ntypes; ++i) {
+    auto type = type_list.GetTypeAtIndex(i);
+    printf("%s\n", type->GetName().AsCString());
+
+    if (clang::CXXRecordDecl *record_decl = clang_ast_ctx->GetAsCXXRecordDecl(
+            type->GetFullCompilerType().GetOpaqueQualType()))
+      record_decl->dump();
+    else if (clang::TagDecl *tag_decl =
+                 clang_ast_ctx->GetAsTagDecl(type->GetFullCompilerType()))
+      tag_decl->dump();
+    else if (clang::TypedefNameDecl *typedef_decl =
+                 clang_ast_ctx->GetAsTypedefDecl(type->GetFullCompilerType()))
+      typedef_decl->dump();
+    else if (clang::EnumDecl *enum_decl =
+                 clang_ast_ctx->GetAsEnumDecl(type->GetFullCompilerType()))
+      enum_decl->dump();
+    else {
+      clang_ast_ctx
+          ->GetCanonicalQualType(
+              type->GetFullCompilerType().GetOpaqueQualType())
+          .dump();
+    }
+  }
+
   return Error::success();
 }
 
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3049,13 +3049,38 @@
                                    bool parse_siblings, bool parse_children) {
   size_t types_added = 0;
   DWARFDIE die = orig_die;
+
   while (die) {
+    const dw_tag_t tag = die.Tag();
     bool type_is_new = false;
-    if (ParseType(sc, die, &type_is_new).get()) {
-      if (type_is_new)
-        ++types_added;
+
+    switch (tag) {
+    case DW_TAG_array_type:
+    case DW_TAG_unspecified_type:
+    case DW_TAG_base_type:
+    case DW_TAG_class_type:
+    case DW_TAG_structure_type:
+    case DW_TAG_union_type:
+    case DW_TAG_enumeration_type:
+    case DW_TAG_subroutine_type:
+    case DW_TAG_subprogram:
+    case DW_TAG_inlined_subroutine:
+    case DW_TAG_pointer_type:
+    case DW_TAG_rvalue_reference_type:
+    case DW_TAG_reference_type:
+    case DW_TAG_typedef:
+    case DW_TAG_ptr_to_member_type:
+      ParseType(sc, die, &type_is_new).get();
+      printf("pubname: %s is_type = %d\n", die.GetPubname(), true);
+      break;
+    default:
+      printf("pubname: %s is_type = %d\n", die.GetPubname(), false);
+      break;
     }
 
+    if (type_is_new)
+      ++types_added;
+
     if (parse_children && die.HasChildren()) {
       if (die.Tag() == DW_TAG_subprogram) {
         SymbolContext child_sc(sc);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67994.221622.patch
Type: text/x-patch
Size: 3015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190924/bc094879/attachment.bin>


More information about the lldb-commits mailing list