Author: spyffe
Date: Fri Oct  2 13:40:30 2015
New Revision: 249167

URL: http://llvm.org/viewvc/llvm-project?rev=249167&view=rev
Log:
Made GetScratchTypeSystemForLanguage return an error if desired.
Also made it not store nullptrs in its TypeSystemMap, so it will retry to make
the AST context if it errored out last time.

Modified:
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/source/DataFormatters/VectorType.cpp
    lldb/trunk/source/Expression/ExpressionSourceCode.cpp
    lldb/trunk/source/Expression/Materializer.cpp
    lldb/trunk/source/Plugins/Language/ObjC/CoreMedia.cpp
    lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
    lldb/trunk/source/Target/Target.cpp
    lldb/trunk/source/Target/ThreadPlanTracer.cpp

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=249167&r1=249166&r2=249167&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Fri Oct  2 13:40:30 2015
@@ -1229,7 +1229,7 @@ public:
     GetImageSearchPathList ();
     
     TypeSystem *
-    GetScratchTypeSystemForLanguage (lldb::LanguageType language, bool 
create_on_demand = true);
+    GetScratchTypeSystemForLanguage (Error *error, lldb::LanguageType 
language, bool create_on_demand = true);
     
     PersistentExpressionState *
     GetPersistentExpressionStateForLanguage (lldb::LanguageType language);
@@ -1506,7 +1506,7 @@ public:
 
 protected:
     ClangASTContext *
-    GetScratchClangASTContextImpl();
+    GetScratchClangASTContextImpl(Error *error);
     
     //------------------------------------------------------------------
     // Member variables.

Modified: lldb/trunk/source/DataFormatters/VectorType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/VectorType.cpp?rev=249167&r1=249166&r2=249167&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/VectorType.cpp (original)
+++ lldb/trunk/source/DataFormatters/VectorType.cpp Fri Oct  2 13:40:30 2015
@@ -235,7 +235,7 @@ namespace lldb_private {
                 TargetSP target_sp(m_backend.GetTargetSP());
                 m_child_type = ::GetCompilerTypeForFormat(m_parent_format,
                                                           element_type,
-                                                          target_sp ? 
target_sp->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC) : nullptr);
+                                                          target_sp ? 
target_sp->GetScratchTypeSystemForLanguage(nullptr, lldb::eLanguageTypeC) : 
nullptr);
                 m_num_children = ::CalculateNumChildren(parent_type,
                                                         m_child_type);
                 m_item_format = GetItemFormatForFormat(m_parent_format,

Modified: lldb/trunk/source/Expression/ExpressionSourceCode.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionSourceCode.cpp?rev=249167&r1=249166&r2=249167&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ExpressionSourceCode.cpp (original)
+++ lldb/trunk/source/Expression/ExpressionSourceCode.cpp Fri Oct  2 13:40:30 
2015
@@ -83,7 +83,7 @@ bool ExpressionSourceCode::GetText (std:
         
         if (ClangModulesDeclVendor *decl_vendor = 
target->GetClangModulesDeclVendor())
         {
-            ClangPersistentVariables *persistent_vars = 
llvm::cast<ClangPersistentVariables>(target->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC)->GetPersistentExpressionState());
+            ClangPersistentVariables *persistent_vars = 
llvm::cast<ClangPersistentVariables>(target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC));
             const ClangModulesDeclVendor::ModuleVector &hand_imported_modules 
= persistent_vars->GetHandLoadedClangModules();
             ClangModulesDeclVendor::ModuleVector modules_for_macros;
             

Modified: lldb/trunk/source/Expression/Materializer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Materializer.cpp?rev=249167&r1=249166&r2=249167&view=diff
==============================================================================
--- lldb/trunk/source/Expression/Materializer.cpp (original)
+++ lldb/trunk/source/Expression/Materializer.cpp Fri Oct  2 13:40:30 2015
@@ -857,11 +857,12 @@ public:
             return;
         }
         
-        TypeSystem *type_system = 
target_sp->GetScratchTypeSystemForLanguage(m_type.GetMinimumLanguage());
+        Error type_system_error;
+        TypeSystem *type_system = 
target_sp->GetScratchTypeSystemForLanguage(&type_system_error, 
m_type.GetMinimumLanguage());
         
         if (!type_system)
         {
-            err.SetErrorString("Couldn't dematerialize a result variable: 
couldn't get the corresponding type system");
+            err.SetErrorStringWithFormat("Couldn't dematerialize a result 
variable: couldn't get the corresponding type system: %s", 
type_system_error.AsCString());
             return;
         }
         

Modified: lldb/trunk/source/Plugins/Language/ObjC/CoreMedia.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/CoreMedia.cpp?rev=249167&r1=249166&r2=249167&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/CoreMedia.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/CoreMedia.cpp Fri Oct  2 13:40:30 
2015
@@ -25,7 +25,7 @@ lldb_private::formatters::CMTimeSummaryP
     if (!type.IsValid())
         return false;
 
-    TypeSystem *type_system = 
valobj.GetExecutionContextRef().GetTargetSP()->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC);
+    TypeSystem *type_system = 
valobj.GetExecutionContextRef().GetTargetSP()->GetScratchTypeSystemForLanguage(nullptr,
 lldb::eLanguageTypeC);
     if (!type_system)
         return false;
     

Modified: 
lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp?rev=249167&r1=249166&r2=249167&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp 
(original)
+++ lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp 
Fri Oct  2 13:40:30 2015
@@ -181,7 +181,7 @@ AppleGetItemInfoHandler::SetupGetItemInf
             // Next make the runner function for our implementation utility 
function.
             Error error;
             
-            TypeSystem *type_system = 
thread.GetProcess()->GetTarget().GetScratchTypeSystemForLanguage(eLanguageTypeC);
+            TypeSystem *type_system = 
thread.GetProcess()->GetTarget().GetScratchTypeSystemForLanguage(nullptr, 
eLanguageTypeC);
             CompilerType get_item_info_return_type = 
type_system->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType();
             
             get_item_info_caller = 
m_get_item_info_impl_code->MakeFunctionCaller(get_item_info_return_type,

Modified: lldb/trunk/source/Target/Target.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=249167&r1=249166&r2=249167&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Fri Oct  2 13:40:30 2015
@@ -1890,10 +1890,16 @@ Target::ImageSearchPathsChanged
 }
 
 TypeSystem *
-Target::GetScratchTypeSystemForLanguage (lldb::LanguageType language, bool 
create_on_demand)
+Target::GetScratchTypeSystemForLanguage (Error *error, lldb::LanguageType 
language, bool create_on_demand)
 {
+    if (error)
+    {
+        error->Clear();
+    }
+    
     if (language == eLanguageTypeMipsAssembler // GNU AS and LLVM use it for 
all assembly code
-        || language == eLanguageTypeUnknown) {
+        || language == eLanguageTypeUnknown)
+    {
         language = eLanguageTypeC;
     }
     
@@ -1920,8 +1926,16 @@ Target::GetScratchTypeSystemForLanguage
        || Language::LanguageIsObjC(language)
        || Language::LanguageIsCPlusPlus(language))
     {
-        
m_scratch_type_system_map[language].reset(GetScratchClangASTContextImpl());
-        return m_scratch_type_system_map[language].get();
+        TypeSystem* ret = GetScratchClangASTContextImpl(error);
+        if (ret)
+        {
+            m_scratch_type_system_map[language].reset(ret);
+            return m_scratch_type_system_map[language].get();
+        }
+        else
+        {
+            return nullptr;
+        }
     }
 
     return nullptr;
@@ -1930,7 +1944,7 @@ Target::GetScratchTypeSystemForLanguage
 PersistentExpressionState *
 Target::GetPersistentExpressionStateForLanguage (lldb::LanguageType language)
 {
-    TypeSystem *type_system = GetScratchTypeSystemForLanguage(language, true);
+    TypeSystem *type_system = GetScratchTypeSystemForLanguage(nullptr, 
language, true);
     
     if (type_system)
     {
@@ -1944,17 +1958,19 @@ Target::GetPersistentExpressionStateForL
 
 UserExpression *
 Target::GetUserExpressionForLanguage(const char *expr,
-                             const char *expr_prefix,
-                             lldb::LanguageType language,
-                             Expression::ResultType desired_type,
-                             Error &error)
+                                     const char *expr_prefix,
+                                     lldb::LanguageType language,
+                                     Expression::ResultType desired_type,
+                                     Error &error)
 {
-    TypeSystem *type_system = GetScratchTypeSystemForLanguage (language);
+    Error type_system_error;
+    
+    TypeSystem *type_system = GetScratchTypeSystemForLanguage 
(&type_system_error, language);
     UserExpression *user_expr = nullptr;
     
     if (!type_system)
     {
-        error.SetErrorStringWithFormat("Could not find type system for 
language: %s", Language::GetNameForLanguageType(language));
+        error.SetErrorStringWithFormat("Could not find type system for 
language %s: %s", Language::GetNameForLanguageType(language), 
type_system_error.AsCString());
         return nullptr;
     }
     
@@ -1973,12 +1989,13 @@ Target::GetFunctionCallerForLanguage (ll
                                       const char *name,
                                       Error &error)
 {
-    TypeSystem *type_system = GetScratchTypeSystemForLanguage (language);
+    Error type_system_error;
+    TypeSystem *type_system = GetScratchTypeSystemForLanguage 
(&type_system_error, language);
     FunctionCaller *persistent_fn = nullptr;
     
     if (!type_system)
     {
-        error.SetErrorStringWithFormat("Could not find type system for 
language: %s", Language::GetNameForLanguageType(language));
+        error.SetErrorStringWithFormat("Could not find type system for 
language %s: %s", Language::GetNameForLanguageType(language), 
type_system_error.AsCString());
         return persistent_fn;
     }
     
@@ -1995,12 +2012,13 @@ Target::GetUtilityFunctionForLanguage (c
                                        const char *name,
                                        Error &error)
 {
-    TypeSystem *type_system = GetScratchTypeSystemForLanguage (language);
+    Error type_system_error;
+    TypeSystem *type_system = GetScratchTypeSystemForLanguage 
(&type_system_error, language);
     UtilityFunction *utility_fn = nullptr;
     
     if (!type_system)
     {
-        error.SetErrorStringWithFormat("Could not find type system for 
language: %s", Language::GetNameForLanguageType(language));
+        error.SetErrorStringWithFormat("Could not find type system for 
language %s: %s", Language::GetNameForLanguageType(language), 
type_system_error.AsCString());
         return utility_fn;
     }
     
@@ -2014,7 +2032,7 @@ Target::GetUtilityFunctionForLanguage (c
 ClangASTContext *
 Target::GetScratchClangASTContext(bool create_on_demand)
 {
-    if (TypeSystem* type_system = 
GetScratchTypeSystemForLanguage(eLanguageTypeC, create_on_demand))
+    if (TypeSystem* type_system = GetScratchTypeSystemForLanguage(nullptr, 
eLanguageTypeC, create_on_demand))
     {
         return llvm::dyn_cast<ClangASTContext>(type_system);
     }
@@ -2025,7 +2043,7 @@ Target::GetScratchClangASTContext(bool c
 }
 
 ClangASTContext *
-Target::GetScratchClangASTContextImpl()
+Target::GetScratchClangASTContextImpl(Error *error)
 {
     ClangASTContextForExpressions *ast_context = new 
ClangASTContextForExpressions(*this);
         
@@ -2166,7 +2184,7 @@ Target::EvaluateExpression
     lldb::ExpressionVariableSP persistent_var_sp;
     // Only check for persistent variables the expression starts with a '$' 
     if (expr_cstr[0] == '$')
-        persistent_var_sp = 
GetScratchTypeSystemForLanguage(eLanguageTypeC)->GetPersistentExpressionState()->GetVariable
 (expr_cstr);
+        persistent_var_sp = GetScratchTypeSystemForLanguage(nullptr, 
eLanguageTypeC)->GetPersistentExpressionState()->GetVariable (expr_cstr);
 
     if (persistent_var_sp)
     {

Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=249167&r1=249166&r2=249167&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Fri Oct  2 13:40:30 2015
@@ -135,7 +135,7 @@ ThreadPlanAssemblyTracer::GetIntPointerT
         TargetSP target_sp (m_thread.CalculateTarget());
         if (target_sp)
         {
-            TypeSystem *type_system = 
target_sp->GetScratchTypeSystemForLanguage(eLanguageTypeC);
+            TypeSystem *type_system = 
target_sp->GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC);
             if (type_system)
                 m_intptr_type = 
TypeFromUser(type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 
target_sp->GetArchitecture().GetAddressByteSize() * 8));
         }        


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to