[Lldb-commits] [lldb] 2847020 - [lldb][TypeSystemClang][NFC] Log failure to InitBuiltinTypes

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Sun Aug 25 02:09:10 PDT 2024


Author: Michael Buch
Date: 2024-08-25T10:08:45+01:00
New Revision: 2847020dbd9b8f932ee564651ec72ce15fa37d07

URL: https://github.com/llvm/llvm-project/commit/2847020dbd9b8f932ee564651ec72ce15fa37d07
DIFF: https://github.com/llvm/llvm-project/commit/2847020dbd9b8f932ee564651ec72ce15fa37d07.diff

LOG: [lldb][TypeSystemClang][NFC] Log failure to InitBuiltinTypes

If we fail to initialize the ASTContext builtins, LLDB
may crash in non-obvious ways down-the-line, e.g., when
it tries to call `ASTContext::getTypeSize` on a builtin like
`ast.UnsignedCharTy`, which would derefernce a `null` `QualType`.

The initialization can fail if we either didn't set the
`TypeSystemClang` target triple, or if the embedded clang isn't
enabled for a certain target.

This patch attempts to help pin-point the failure case post-mortem
by adding a log message here that prints the triple.

rdar://134260837

Added: 
    

Modified: 
    lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 8f646803848096..695801da9da69a 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -697,6 +697,10 @@ void TypeSystemClang::CreateASTContext() {
   TargetInfo *target_info = getTargetInfo();
   if (target_info)
     m_ast_up->InitBuiltinTypes(*target_info);
+  else if (auto *log = GetLog(LLDBLog::Expressions))
+    LLDB_LOG(log,
+             "Failed to initialize builtin ASTContext types for target '{0}'",
+             m_target_triple);
 
   GetASTMap().Insert(m_ast_up.get(), this);
 


        


More information about the lldb-commits mailing list