[all-commits] [llvm/llvm-project] c9a39a: [lldb] Add a display name to ClangASTContext insta...
Raphael Isemann via All-commits
all-commits at lists.llvm.org
Tue Jan 21 23:54:37 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: c9a39a896c95402ede07061380346c725556e308
https://github.com/llvm/llvm-project/commit/c9a39a896c95402ede07061380346c725556e308
Author: Raphael Isemann <teemperor at gmail.com>
Date: 2020-01-22 (Wed, 22 Jan 2020)
Changed paths:
M lldb/include/lldb/Symbol/ClangASTContext.h
M lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
M lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
M lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
M lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
M lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
M lldb/source/Symbol/ClangASTContext.cpp
M lldb/unittests/Symbol/TestClangASTContext.cpp
M lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
M lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h
Log Message:
-----------
[lldb] Add a display name to ClangASTContext instances
Summary:
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";
```
Reviewers: shafik, labath, JDevlieghere, mib
Reviewed By: shafik
Subscribers: clayborg, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D72391
More information about the All-commits
mailing list