[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
Wed Sep 25 17:02:18 PDT 2019


shafik marked an inline comment as done.
shafik added inline comments.


================
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);
----------------
clayborg wrote:
> 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.
> 
If we do stick with this approach pushing the `DumpAST(...)` into `TypeSystem` seems reasonable.


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

https://reviews.llvm.org/D67994





More information about the lldb-commits mailing list