[Lldb-commits] [PATCH] D72391: [lldb] Add a display name to ClangASTContext instances

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 8 03:30:33 PST 2020


teemperor created this revision.
teemperor added reviewers: shafik, labath, JDevlieghere, mib.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
teemperor added a comment.

I don't know if this needs a unit test where we call the constructor and explicitly check the name is the one we passed in. Let me know if you think this would make sense.


I often struggle to understand what exactly LLDB is doing by looking at our expression evaluation logging as our messages look like this:

  CompleteTagDecl[2] on (ASTContext*)0x7ff31f01d240 Completing (TagDecl*)0x7ff31f01d568 named DeclName1

>From the log messages it's unclear what this ASTContext is. Is it the scratch context, the expression context, some decl vendor context or a context from a module?
The pointer value isn't helpful for anyone unless I'm in a debugger where I could inspect the memory at the address. But even with a debugger it's not easy to
figure out what this ASTContext is without having deeper understanding about all the different ASTContext instances in LLDB (e.g., valid SourceLocation
from the file system usually means that this is the Objective-C decl vendor, a file name from multiple expressions is probably the scratch context, etc.).

This patch adds a name field to ClangASTContext instances that we can use to store a name which can be used for logging and debugging. With this
our log messages now look like this:

  CompleteTagDecl[2] on scratch ASTContext. Completing (TagDecl*)0x7ff31f01d568 named Foo

We can now also just print a ClangASTContext from the debugger and see a useful name in the `m_display_name` field, e.g.

  m_display_name = "AST for /Users/user/test/main.o";


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D72391

Files:
  lldb/include/lldb/Symbol/ClangASTContext.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
  lldb/source/Symbol/ClangASTContext.cpp
  lldb/unittests/Symbol/TestClangASTContext.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72391.236786.patch
Type: text/x-patch
Size: 16812 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200108/514e3172/attachment-0001.bin>


More information about the lldb-commits mailing list