[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 16:54:39 PDT 2019


shafik added a comment.

In D67994#1682051 <https://reviews.llvm.org/D67994#1682051>, @labath wrote:

> For dumping a specific type something like this could be right, but for "indiscriminately dumping" everything, this seems to be a bit fragile.
>
> Would it be possible to make this use the `SymbolFile::DumpClangAST` method (this is what the "image dump ast" lldb command uses), and then possibly change that method to include any extra information you need? I already see the `DefinitionData` line when i do a "image dump clang ast", so it's possible you wouldn't need to change anything there...
>
> FTR, this is what i get from image dump ast:
>
>   Dumping clang ast for 1 modules.
>   TranslationUnitDecl 0x561fa5fd9128 <<invalid sloc>> <invalid sloc> <undeserialized declarations>
>   `-NamespaceDecl 0x561fa5fd99e8 <<invalid sloc>> <invalid sloc> Q
>     `-CXXRecordDecl 0x561fa5fd9a70 <<invalid sloc>> <invalid sloc> struct A definition
>       |-DefinitionData pass_in_registers empty standard_layout trivially_copyable has_user_declared_ctor can_const_default_init
>       | |-DefaultConstructor exists non_trivial user_provided defaulted_is_constexpr
>       | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
>       | |-MoveConstructor exists simple trivial needs_implicit
>       | |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param
>       | |-MoveAssignment exists simple trivial needs_implicit
>       | `-Destructor simple irrelevant trivial needs_implicit
>       `-CXXConstructorDecl 0x561fa5fd9bf0 <<invalid sloc>> <invalid sloc> A 'void ()'
>


Using this approach for this simple example:

  using ULongArrayTypedef = unsigned long[10];
  
  int main() {
      ULongArrayTypedef *p;
  }

I only obtain:

  TranslationUnitDecl 0x7fd5eb023608 <<invalid sloc>> <invalid sloc> <undeserialized declarations>

Vs this output for what I have now:

  ULongArrayTypedef *
  PointerType 0x7fea0a825080 'unsigned long (*)[10]'
  `-ConstantArrayType 0x7fea0a824ed0 'unsigned long [10]' 10 
    `-BuiltinType 0x7fea0a8247c0 'unsigned long'
  int
  BuiltinType 0x7fea0a824700 'int'
  ULongArrayTypedef
  TypedefDecl 0x7fea0a825000 <<invalid sloc>> <invalid sloc> ULongArrayTypedef 'unsigned long [10]'
  `-ConstantArrayType 0x7fea0a824ed0 'unsigned long [10]' 10 
    `-BuiltinType 0x7fea0a8247c0 'unsigned long'
  long unsigned int
  BuiltinType 0x7fea0a8247c0 'unsigned long'
  unsigned long [10]
  ConstantArrayType 0x7fea0a824ed0 'unsigned long [10]' 10 
  `-BuiltinType 0x7fea0a8247c0 'unsigned long'
  main
  FunctionProtoType 0x7fea0a824f10 'int (void)' cdecl
  `-BuiltinType 0x7fea0a824700 'int'

I believe this is due to us being lazy as to when we import.


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

https://reviews.llvm.org/D67994





More information about the lldb-commits mailing list