[Lldb-commits] [lldb] r248934 - Now persistent expression data no longer lives with the Target, but rather with

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 1 11:21:00 PDT 2015


The way I understand this from talking with Sean about it is that the persistent variables for each type system will need to generate non-conflicting names

In your example,

(lldb) expr -l c — 1
$1 = 1
(lldb) expr -l go — 2
$G1 = 2
(lldb) expr -l go — $1
Identifier ‘$1’ not recognized (or whatever equivalent error Go would produce, unless you had somehow gotten Go and Clang to interop with each other in a smart way)

But that is simply my understanding

> On Oct 1, 2015, at 11:15 AM, Ryan Brown via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> Oh, now I see the search in 249027.
> But how does this work with multiple type systems?
> Target no longer manages persistent variable names so won't each type system generate conflicting names? 
> e.g.
> (lldb) expr -l c -- 1
> $1 = 1
> (lldb) expr -l go -- 2
> $1 = 2
> (lldb) expr -l go -- $1
> 
> Which $1 do you get?
> 
> 
> On Thu, Oct 1, 2015 at 10:59 AM Ryan Brown <ribrdb at google.com <mailto:ribrdb at google.com>> wrote:
> Shouldn't Target::GetPersistentVariable take a language parameter instead of assuming clang?
> 
> On Wed, Sep 30, 2015 at 12:59 PM Sean Callanan via lldb-commits <lldb-commits at lists.llvm.org <mailto:lldb-commits at lists.llvm.org>> wrote:
> Author: spyffe
> Date: Wed Sep 30 14:57:57 2015
> New Revision: 248934
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=248934&view=rev <http://llvm.org/viewvc/llvm-project?rev=248934&view=rev>
> Log:
> Now persistent expression data no longer lives with the Target, but rather with
> the corresponding TypeSystem.  This makes sense because what kind of data there
> is -- and how it can be looked up -- depends on the language.
> 
> Functionality that is common to all type systems is factored out into
> PersistentExpressionState.
> 
> Modified:
>     lldb/trunk/include/lldb/Expression/ExpressionVariable.h
>     lldb/trunk/include/lldb/Symbol/ClangASTContext.h
>     lldb/trunk/include/lldb/Symbol/TypeSystem.h
>     lldb/trunk/include/lldb/Target/Target.h
>     lldb/trunk/include/lldb/lldb-forward.h
>     lldb/trunk/source/API/SBFrame.cpp
>     lldb/trunk/source/Commands/CommandObjectMemory.cpp
>     lldb/trunk/source/Core/ValueObject.cpp
>     lldb/trunk/source/Expression/ExpressionSourceCode.cpp
>     lldb/trunk/source/Expression/ExpressionVariable.cpp
>     lldb/trunk/source/Expression/Materializer.cpp
>     lldb/trunk/source/Expression/UserExpression.cpp
>     lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
>     lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
>     lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
>     lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
>     lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
>     lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
>     lldb/trunk/source/Symbol/ClangASTContext.cpp
>     lldb/trunk/source/Target/ABI.cpp
>     lldb/trunk/source/Target/Target.cpp
> 
> Modified: lldb/trunk/include/lldb/Expression/ExpressionVariable.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionVariable.h?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionVariable.h?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/include/lldb/Expression/ExpressionVariable.h (original)
> +++ lldb/trunk/include/lldb/Expression/ExpressionVariable.h Wed Sep 30 14:57:57 2015
> @@ -265,6 +265,36 @@ private:
>      std::vector <lldb::ExpressionVariableSP> m_variables;
>  };
> 
> +class PersistentExpressionState : public ExpressionVariableList {
> +public:
> +    //----------------------------------------------------------------------
> +    // See TypeSystem.h for how to add subclasses to this.
> +    //----------------------------------------------------------------------
> +    enum LLVMCastKind {
> +        eKindClang,
> +        eKindSwift,
> +        eKindGo,
> +        kNumKinds
> +    };
> +
> +    LLVMCastKind getKind() const { return m_kind; }
> +
> +    PersistentExpressionState(LLVMCastKind kind) :
> +        m_kind(kind)
> +    {
> +    }
> +
> +    virtual ~PersistentExpressionState ();
> +
> +    virtual ConstString
> +    GetNextPersistentVariableName () = 0;
> +
> +    virtual void
> +    RemovePersistentVariable (lldb::ExpressionVariableSP variable) = 0;
> +private:
> +    LLVMCastKind m_kind;
> +};
> +
>  }
> 
>  #endif /* liblldb_ExpressionVariable_h_ */
> 
> Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
> +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Wed Sep 30 14:57:57 2015
> @@ -20,6 +20,8 @@
>  #include <utility>
> 
>  // Other libraries and framework includes
> +#include "ClangPersistentVariables.h"
> +
>  #include "llvm/ADT/SmallVector.h"
>  #include "clang/AST/ASTContext.h"
>  #include "clang/AST/TemplateBase.h"
> @@ -1188,8 +1190,12 @@ public:
> 
>      UtilityFunction *
>      GetUtilityFunction(const char *text, const char *name) override;
> +
> +    PersistentExpressionState *
> +    GetPersistentExpressionState() override;
>  private:
>      lldb::TargetWP m_target_wp;
> +    lldb::ClangPersistentVariablesUP m_persistent_variables;      ///< These are the persistent variables associated with this process for the expression parser.
>  };
> 
>  } // namespace lldb_private
> 
> Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)
> +++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Wed Sep 30 14:57:57 2015
> @@ -504,6 +504,12 @@ public:
>          return nullptr;
>      }
> 
> +    virtual PersistentExpressionState *
> +    GetPersistentExpressionState()
> +    {
> +        return nullptr;
> +    }
> +
>      virtual CompilerType
>      GetTypeForFormatters (void* type);
> 
> 
> Modified: lldb/trunk/include/lldb/Target/Target.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/include/lldb/Target/Target.h (original)
> +++ lldb/trunk/include/lldb/Target/Target.h Wed Sep 30 14:57:57 2015
> @@ -1319,9 +1319,9 @@ public:
>                          lldb::ValueObjectSP &result_valobj_sp,
>                          const EvaluateExpressionOptions& options = EvaluateExpressionOptions());
> 
> -    ClangPersistentVariables &
> -    GetPersistentVariables();
> -
> +    lldb::ExpressionVariableSP
> +    GetPersistentVariable(const ConstString &name);
> +
>      //------------------------------------------------------------------
>      // Target Stop Hooks
>      //------------------------------------------------------------------
> @@ -1523,7 +1523,6 @@ protected:
>      lldb::ClangASTSourceUP m_scratch_ast_source_ap;
>      lldb::ClangASTImporterUP m_ast_importer_ap;
>      lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_ap;
> -    lldb::ClangPersistentVariablesUP m_persistent_variables;      ///< These are the persistent variables associated with this process for the expression parser.
> 
>      lldb::SourceManagerUP m_source_manager_ap;
> 
> 
> Modified: lldb/trunk/include/lldb/lldb-forward.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/include/lldb/lldb-forward.h (original)
> +++ lldb/trunk/include/lldb/lldb-forward.h Wed Sep 30 14:57:57 2015
> @@ -165,6 +165,7 @@ class   OptionValueUUID;
>  class   NamedOption;
>  class   PathMappingList;
>  class   FunctionCaller;
> +class   PersistentExpressionState;
>  class   Platform;
>  class   Process;
>  class   ProcessAttachInfo;
> 
> Modified: lldb/trunk/source/API/SBFrame.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/API/SBFrame.cpp (original)
> +++ lldb/trunk/source/API/SBFrame.cpp Wed Sep 30 14:57:57 2015
> @@ -956,7 +956,7 @@ SBFrame::FindValue (const char *name, Va
>                  case eValueTypeConstResult:         // constant result variables
>                      {
>                          ConstString const_name(name);
> -                        ExpressionVariableSP expr_var_sp (target->GetPersistentVariables().GetVariable (const_name));
> +                        ExpressionVariableSP expr_var_sp (target->GetPersistentVariable (const_name));
>                          if (expr_var_sp)
>                          {
>                              value_sp = expr_var_sp->GetValueObject();
> 
> Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
> +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Wed Sep 30 14:57:57 2015
> @@ -530,7 +530,7 @@ protected:
> 
>              if (type_list.GetSize() == 0 && lookup_type_name.GetCString() && *lookup_type_name.GetCString() == '$')
>              {
> -                clang::TypeDecl *tdecl = target->GetPersistentVariables().GetPersistentType(ConstString(lookup_type_name));
> +                clang::TypeDecl *tdecl = llvm::cast<ClangPersistentVariables>(target->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC)->GetPersistentExpressionState())->GetPersistentType(ConstString(lookup_type_name));
>                  if (tdecl)
>                  {
>                      clang_ast_type.SetCompilerType(ClangASTContext::GetASTContext(&tdecl->getASTContext()),(const lldb::opaque_compiler_type_t)tdecl->getTypeForDecl());
> 
> Modified: lldb/trunk/source/Core/ValueObject.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Core/ValueObject.cpp (original)
> +++ lldb/trunk/source/Core/ValueObject.cpp Wed Sep 30 14:57:57 2015
> @@ -4277,14 +4277,19 @@ ValueObject::Persist ()
>      if (!target_sp)
>          return nullptr;
> 
> -    ConstString name(target_sp->GetPersistentVariables().GetNextPersistentVariableName());
> +    PersistentExpressionState *persistent_state = target_sp->GetScratchTypeSystemForLanguage(GetCompilerType().GetMinimumLanguage())->GetPersistentExpressionState();
> +
> +    if (!persistent_state)
> +        return nullptr;
> +
> +    ConstString name(persistent_state->GetNextPersistentVariableName());
> 
>      ExpressionVariableSP clang_var_sp(new ClangExpressionVariable(target_sp.get(), GetValue(), name));
>      if (clang_var_sp)
>      {
>          clang_var_sp->m_live_sp = clang_var_sp->m_frozen_sp;
>          clang_var_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference;
> -        target_sp->GetPersistentVariables().AddVariable(clang_var_sp);
> +        persistent_state->AddVariable(clang_var_sp);
>      }
> 
>      return clang_var_sp->GetValueObject();
> 
> Modified: lldb/trunk/source/Expression/ExpressionSourceCode.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionSourceCode.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionSourceCode.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Expression/ExpressionSourceCode.cpp (original)
> +++ lldb/trunk/source/Expression/ExpressionSourceCode.cpp Wed Sep 30 14:57:57 2015
> @@ -13,6 +13,7 @@
>  #include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
>  #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
>  #include "lldb/Symbol/Block.h"
> +#include "lldb/Symbol/TypeSystem.h"
>  #include "lldb/Target/ExecutionContext.h"
>  #include "lldb/Target/Platform.h"
>  #include "lldb/Target/StackFrame.h"
> @@ -82,7 +83,8 @@ bool ExpressionSourceCode::GetText (std:
> 
>          if (ClangModulesDeclVendor *decl_vendor = target->GetClangModulesDeclVendor())
>          {
> -            const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = target->GetPersistentVariables().GetHandLoadedClangModules();
> +            ClangPersistentVariables *persistent_vars = llvm::cast<ClangPersistentVariables>(target->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC)->GetPersistentExpressionState());
> +            const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = persistent_vars->GetHandLoadedClangModules();
>              ClangModulesDeclVendor::ModuleVector modules_for_macros;
> 
>              for (ClangModulesDeclVendor::ModuleID module : hand_imported_modules)
> 
> Modified: lldb/trunk/source/Expression/ExpressionVariable.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionVariable.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionVariable.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Expression/ExpressionVariable.cpp (original)
> +++ lldb/trunk/source/Expression/ExpressionVariable.cpp Wed Sep 30 14:57:57 2015
> @@ -30,3 +30,7 @@ ExpressionVariable::GetValueBytes()
>      }
>      return NULL;
>  }
> +
> +PersistentExpressionState::~PersistentExpressionState ()
> +{
> +}
> 
> Modified: lldb/trunk/source/Expression/Materializer.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Materializer.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Materializer.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Expression/Materializer.cpp (original)
> +++ lldb/trunk/source/Expression/Materializer.cpp Wed Sep 30 14:57:57 2015
> @@ -11,8 +11,7 @@
>  #include "lldb/Core/RegisterValue.h"
>  #include "lldb/Core/ValueObjectConstResult.h"
>  #include "lldb/Core/ValueObjectVariable.h"
> -#include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h"
> -#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
> +#include "lldb/Expression/ExpressionVariable.h"
>  #include "lldb/Expression/Materializer.h"
>  #include "lldb/Symbol/ClangASTContext.h"
>  #include "lldb/Symbol/Symbol.h"
> @@ -858,9 +857,25 @@ public:
>              return;
>          }
> 
> -        ConstString name = target_sp->GetPersistentVariables().GetNextPersistentVariableName();
> +        TypeSystem *type_system = target_sp->GetScratchTypeSystemForLanguage(m_type.GetMinimumLanguage());
> 
> -        lldb::ExpressionVariableSP ret = ClangExpressionVariable::CreateVariableInList(target_sp->GetPersistentVariables(),
> +        if (!type_system)
> +        {
> +            err.SetErrorString("Couldn't dematerialize a result variable: couldn't get the corresponding type system");
> +            return;
> +        }
> +
> +        PersistentExpressionState *persistent_state = type_system->GetPersistentExpressionState();
> +
> +        if (!persistent_state)
> +        {
> +            err.SetErrorString("Couldn't dematerialize a result variable: corresponding type system doesn't handle persistent variables");
> +            return;
> +        }
> +
> +        ConstString name = persistent_state->GetNextPersistentVariableName();
> +
> +        lldb::ExpressionVariableSP ret = ClangExpressionVariable::CreateVariableInList(*persistent_state,
>                                                                                         exe_scope,
>                                                                                         name,
>                                                                                         m_type,
> 
> Modified: lldb/trunk/source/Expression/UserExpression.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/UserExpression.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/UserExpression.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Expression/UserExpression.cpp (original)
> +++ lldb/trunk/source/Expression/UserExpression.cpp Wed Sep 30 14:57:57 2015
> @@ -34,6 +34,7 @@
>  #include "lldb/Symbol/ObjectFile.h"
>  #include "lldb/Symbol/SymbolVendor.h"
>  #include "lldb/Symbol/Type.h"
> +#include "lldb/Symbol/TypeSystem.h"
>  #include "lldb/Symbol/VariableList.h"
>  #include "lldb/Target/ExecutionContext.h"
>  #include "lldb/Target/Process.h"
> @@ -586,7 +587,7 @@ UserExpression::Evaluate (ExecutionConte
> 
>              if (options.GetResultIsInternal() && expr_result && process)
>              {
> -                process->GetTarget().GetPersistentVariables().RemovePersistentVariable (expr_result);
> +                process->GetTarget().GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC)->GetPersistentExpressionState()->RemovePersistentVariable (expr_result);
>              }
> 
>              if (execution_results != lldb::eExpressionCompleted)
> 
> Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp (original)
> +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp Wed Sep 30 14:57:57 2015
> @@ -464,7 +464,7 @@ ASTResultSynthesizer::MaybeRecordPersist
>                                                                   D);
> 
>      if (TypeDecl *TypeDecl_scratch = dyn_cast<TypeDecl>(D_scratch))
> -        m_target.GetPersistentVariables().RegisterPersistentType(name_cs, TypeDecl_scratch);
> +        llvm::cast<ClangPersistentVariables>(m_target.GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC)->GetPersistentExpressionState())->RegisterPersistentType(name_cs, TypeDecl_scratch);
>  }
> 
>  void
> 
> Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp (original)
> +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp Wed Sep 30 14:57:57 2015
> @@ -104,7 +104,7 @@ ClangExpressionDeclMap::WillParse(Execut
> 
>      if (target)
>      {
> -        m_parser_vars->m_persistent_vars = &target->GetPersistentVariables();
> +        m_parser_vars->m_persistent_vars = llvm::cast<ClangPersistentVariables>(target->GetScratchTypeSystemForLanguage(eLanguageTypeC)->GetPersistentExpressionState());
> 
>          if (!target->GetScratchClangASTContext())
>              return false;
> 
> Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original)
> +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Wed Sep 30 14:57:57 2015
> @@ -331,7 +331,8 @@ ClangExpressionParser::ClangExpressionPa
> 
>      if (ClangModulesDeclVendor *decl_vendor = target_sp->GetClangModulesDeclVendor())
>      {
> -        std::unique_ptr<PPCallbacks> pp_callbacks(new LLDBPreprocessorCallbacks(*decl_vendor, target_sp->GetPersistentVariables()));
> +        ClangPersistentVariables *clang_persistent_vars = llvm::cast<ClangPersistentVariables>(target_sp->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC)->GetPersistentExpressionState());
> +        std::unique_ptr<PPCallbacks> pp_callbacks(new LLDBPreprocessorCallbacks(*decl_vendor, *clang_persistent_vars));
>          m_pp_callbacks = static_cast<LLDBPreprocessorCallbacks*>(pp_callbacks.get());
>          m_compiler->getPreprocessor().addPPCallbacks(std::move(pp_callbacks));
>      }
> 
> Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp (original)
> +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp Wed Sep 30 14:57:57 2015
> @@ -20,7 +20,7 @@ using namespace lldb;
>  using namespace lldb_private;
> 
>  ClangPersistentVariables::ClangPersistentVariables () :
> -    ExpressionVariableList(),
> +    lldb_private::PersistentExpressionState(LLVMCastKind::eKindClang),
>      m_next_persistent_variable_id (0)
>  {
>  }
> 
> Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h (original)
> +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h Wed Sep 30 14:57:57 2015
> @@ -13,6 +13,8 @@
>  #include "ClangExpressionVariable.h"
>  #include "ClangModulesDeclVendor.h"
> 
> +#include "lldb/Expression/ExpressionVariable.h"
> +
>  #include "llvm/ADT/DenseMap.h"
> 
>  namespace lldb_private
> @@ -26,7 +28,7 @@ namespace lldb_private
>  /// ClangPersistentVariable for more discussion.  Also provides an increasing,
>  /// 0-based counter for naming result variables.
>  //----------------------------------------------------------------------
> -class ClangPersistentVariables : public ExpressionVariableList
> +class ClangPersistentVariables : public PersistentExpressionState
>  {
>  public:
> 
> @@ -34,6 +36,16 @@ public:
>      /// Constructor
>      //----------------------------------------------------------------------
>      ClangPersistentVariables ();
> +
> +    ~ClangPersistentVariables () { }
> +
> +    //------------------------------------------------------------------
> +    // llvm casting support
> +    //------------------------------------------------------------------
> +    static bool classof(const PersistentExpressionState *pv)
> +    {
> +        return pv->getKind() == PersistentExpressionState::eKindClang;
> +    }
> 
>      lldb::ExpressionVariableSP
>      CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp);
> @@ -53,10 +65,10 @@ public:
>      ///     A string that contains the next persistent variable name.
>      //----------------------------------------------------------------------
>      ConstString
> -    GetNextPersistentVariableName ();
> +    GetNextPersistentVariableName () override;
> 
>      void
> -    RemovePersistentVariable (lldb::ExpressionVariableSP variable);
> +    RemovePersistentVariable (lldb::ExpressionVariableSP variable) override;
> 
>      void
>      RegisterPersistentType (const ConstString &name,
> 
> Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original)
> +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Wed Sep 30 14:57:57 2015
> @@ -357,7 +357,7 @@ ClangUserExpression::Parse (Stream &erro
> 
>      if (ClangModulesDeclVendor *decl_vendor = m_target->GetClangModulesDeclVendor())
>      {
> -        const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = m_target->GetPersistentVariables().GetHandLoadedClangModules();
> +        const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = llvm::cast<ClangPersistentVariables>(m_target->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC)->GetPersistentExpressionState())->GetHandLoadedClangModules();
>          ClangModulesDeclVendor::ModuleVector modules_for_macros;
> 
>          for (ClangModulesDeclVendor::ModuleID module : hand_imported_modules)
> 
> Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
> +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Sep 30 14:57:57 2015
> @@ -9158,7 +9158,8 @@ ClangASTContext::DeclContextGetClangASTC
> 
>  ClangASTContextForExpressions::ClangASTContextForExpressions (Target &target) :
>      ClangASTContext (target.GetArchitecture().GetTriple().getTriple().c_str()),
> -    m_target_wp(target.shared_from_this())
> +    m_target_wp(target.shared_from_this()),
> +    m_persistent_variables (new ClangPersistentVariables)
>  {
>  }
> 
> @@ -9196,9 +9197,15 @@ UtilityFunction *
>  ClangASTContextForExpressions::GetUtilityFunction (const char *text,
>                                                     const char *name)
>  {
> -     TargetSP target_sp = m_target_wp.lock();
> +    TargetSP target_sp = m_target_wp.lock();
>      if (!target_sp)
>          return nullptr;
> 
>      return new ClangUtilityFunction(*target_sp.get(), text, name);
>  }
> +
> +PersistentExpressionState *
> +ClangASTContextForExpressions::GetPersistentExpressionState ()
> +{
> +    return m_persistent_variables.get();
> +}
> 
> Modified: lldb/trunk/source/Target/ABI.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ABI.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ABI.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Target/ABI.cpp (original)
> +++ lldb/trunk/source/Target/ABI.cpp Wed Sep 30 14:57:57 2015
> @@ -13,6 +13,7 @@
>  #include "lldb/Core/ValueObjectConstResult.h"
>  #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
>  #include "lldb/Symbol/CompilerType.h"
> +#include "lldb/Symbol/TypeSystem.h"
>  #include "lldb/Target/Target.h"
>  #include "lldb/Target/Thread.h"
> 
> @@ -123,8 +124,8 @@ ABI::GetReturnValueObject (Thread &threa
> 
>      if (persistent)
>      {
> -        ClangPersistentVariables& persistent_variables = thread.CalculateTarget()->GetPersistentVariables();
> -        ConstString persistent_variable_name (persistent_variables.GetNextPersistentVariableName());
> +        PersistentExpressionState *persistent_expression_state = thread.CalculateTarget()->GetScratchTypeSystemForLanguage(ast_type.GetMinimumLanguage())->GetPersistentExpressionState();
> +        ConstString persistent_variable_name (persistent_expression_state->GetNextPersistentVariableName());
> 
>          lldb::ValueObjectSP const_valobj_sp;
> 
> @@ -141,7 +142,7 @@ ABI::GetReturnValueObject (Thread &threa
> 
>          return_valobj_sp = const_valobj_sp;
> 
> -        ExpressionVariableSP clang_expr_variable_sp(persistent_variables.CreatePersistentVariable(return_valobj_sp));
> +        ExpressionVariableSP clang_expr_variable_sp(ClangExpressionVariable::CreateVariableInList(*persistent_expression_state, return_valobj_sp)->shared_from_this());
> 
>          assert (clang_expr_variable_sp.get());
> 
> 
> Modified: lldb/trunk/source/Target/Target.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=248934&r1=248933&r2=248934&view=diff <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=248934&r1=248933&r2=248934&view=diff>
> ==============================================================================
> --- lldb/trunk/source/Target/Target.cpp (original)
> +++ lldb/trunk/source/Target/Target.cpp Wed Sep 30 14:57:57 2015
> @@ -88,7 +88,6 @@ Target::Target(Debugger &debugger, const
>      m_scratch_ast_context_ap (),
>      m_scratch_ast_source_ap (),
>      m_ast_importer_ap (),
> -    m_persistent_variables (new ClangPersistentVariables),
>      m_source_manager_ap(),
>      m_stop_hooks (),
>      m_stop_hook_next_id (0),
> @@ -231,7 +230,6 @@ Target::Destroy()
>      m_last_created_watchpoint.reset();
>      m_search_filter_sp.reset();
>      m_image_search_paths.Clear(notify);
> -    m_persistent_variables->Clear();
>      m_stop_hooks.clear();
>      m_stop_hook_next_id = 0;
>      m_suppress_stop_hooks = false;
> @@ -2119,7 +2117,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 = m_persistent_variables->GetVariable (expr_cstr);
> +        persistent_var_sp = GetScratchTypeSystemForLanguage(eLanguageTypeC)->GetPersistentExpressionState()->GetVariable (expr_cstr);
> 
>      if (persistent_var_sp)
>      {
> @@ -2143,10 +2141,18 @@ Target::EvaluateExpression
>      return execution_results;
>  }
> 
> -ClangPersistentVariables &
> -Target::GetPersistentVariables()
> +lldb::ExpressionVariableSP
> +Target::GetPersistentVariable(const ConstString &name)
>  {
> -    return *m_persistent_variables;
> +    if (ClangASTContext *ast_context = GetScratchClangASTContext(false))
> +    {
> +        if (PersistentExpressionState *persistent_state = ast_context->GetPersistentExpressionState())
> +        {
> +            return persistent_state->GetVariable(name);
> +        }
> +    }
> +
> +    return ExpressionVariableSP();
>  }
> 
>  lldb::addr_t
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org <mailto:lldb-commits at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits <http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Thanks,
- Enrico
📩 egranata@.com ☎️ 27683

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151001/7957cfb2/attachment-0001.html>


More information about the lldb-commits mailing list