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

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 24 16:15:56 PDT 2019


clayborg added inline comments.


================
Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:3032
+    
+     type_sp = dwarf_ast->ParseTypeFromDWARF(sc, die, log, type_is_new_ptr);
   if (type_sp) {
----------------
indent is wrong


================
Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:3061-3075
+      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:
----------------
We should add a "IsType()" to DWARFDie here. This list can get out of date as new type tags are added. There are a few other places that could use the "bool DWARFDie::ItType() const" function too. Or we should just fix ParseType by adding an option to it like an extra bool like "bool warnIfNotType" so you don't get the "error:" message.


================
Comment at: tools/lldb-test/lldb-test.cpp:552-579
+    
+    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);
----------------
I know that there is already clang AST stuff in this file, but it seems like anything in this file should be just passed to the type system for dumping? This code could be:

```
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)
  type_list.GetTypeAtIndex(i)->DumpTypeValue(...);
```

Better yet this entire function could just become:

```
Error opts::symbols::dumpAST(lldb_private::Module &Module) {
  Module.ParseAllDebugSymbols();

  auto symfile = Module.GetSymbolFile();
  if (!symfile)
    return make_string_error("Module has no symbol file.");

  auto type_system_or_err =
      symfile->GetTypeSystemForLanguage(eLanguageTypeC_plus_plus);
  if (type_system_or_err)
    type_system_or_err->DumpAST(...);
  else
    return make_string_error("Can't retrieve TypeSystem");
}
```
And all clang AST specific stuff can be removed from this binary? Tests would need to be updated.



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

https://reviews.llvm.org/D67994





More information about the lldb-commits mailing list