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