[Lldb-commits] [lldb] r331234 - Move the persistent variable counter into Target
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Mon Apr 30 16:59:15 PDT 2018
Author: adrian
Date: Mon Apr 30 16:59:15 2018
New Revision: 331234
URL: http://llvm.org/viewvc/llvm-project?rev=331234&view=rev
Log:
Move the persistent variable counter into Target
so it can be shared across multiple language plugins.
In a multi-language project it is counterintuitive to have a result
variables reuse numbers just because they are using a different
language plugin in LLDB (but not for example, when they are
Objective-C versus C++, since they are both handled by Clang).
This is NFC on llvm.org except for the Go plugin.
rdar://problem/39299889
Differential Revision: https://reviews.llvm.org/D46083
Modified:
lldb/trunk/include/lldb/Expression/ExpressionVariable.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Expression/Materializer.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/Plugins/ExpressionParser/Clang/ClangUserExpression.h
lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h
lldb/trunk/source/Target/ABI.cpp
Modified: lldb/trunk/include/lldb/Expression/ExpressionVariable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionVariable.h?rev=331234&r1=331233&r2=331234&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ExpressionVariable.h (original)
+++ lldb/trunk/include/lldb/Expression/ExpressionVariable.h Mon Apr 30 16:59:15 2018
@@ -239,7 +239,7 @@ public:
lldb::ByteOrder byte_order,
uint32_t addr_byte_size) = 0;
- virtual ConstString GetNextPersistentVariableName() = 0;
+ virtual ConstString GetNextPersistentVariableName(Target &target) = 0;
virtual void
RemovePersistentVariable(lldb::ExpressionVariableSP variable) = 0;
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=331234&r1=331233&r2=331234&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Mon Apr 30 16:59:15 2018
@@ -1082,6 +1082,11 @@ public:
lldb::ExpressionVariableSP GetPersistentVariable(const ConstString &name);
+ /// Return the next available number for numbered persistent variables.
+ unsigned GetNextPersistentVariableIndex() {
+ return m_next_persistent_variable_index++;
+ }
+
lldb::addr_t GetPersistentSymbol(const ConstString &name);
//------------------------------------------------------------------
@@ -1271,6 +1276,7 @@ protected:
bool m_valid;
bool m_suppress_stop_hooks;
bool m_is_dummy_target;
+ unsigned m_next_persistent_variable_index = 0;
static void ImageSearchPathsChanged(const PathMappingList &path_list,
void *baton);
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=331234&r1=331233&r2=331234&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Mon Apr 30 16:59:15 2018
@@ -3311,7 +3311,7 @@ ValueObjectSP ValueObject::Persist() {
if (!persistent_state)
return nullptr;
- ConstString name(persistent_state->GetNextPersistentVariableName());
+ ConstString name(persistent_state->GetNextPersistentVariableName(*target_sp));
ValueObjectSP const_result_sp =
ValueObjectConstResult::Create(target_sp.get(), GetValue(), name);
Modified: lldb/trunk/source/Expression/Materializer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Materializer.cpp?rev=331234&r1=331233&r2=331234&view=diff
==============================================================================
--- lldb/trunk/source/Expression/Materializer.cpp (original)
+++ lldb/trunk/source/Expression/Materializer.cpp Mon Apr 30 16:59:15 2018
@@ -888,9 +888,10 @@ public:
return;
}
- ConstString name = m_delegate
- ? m_delegate->GetName()
- : persistent_state->GetNextPersistentVariableName();
+ ConstString name =
+ m_delegate
+ ? m_delegate->GetName()
+ : persistent_state->GetNextPersistentVariableName(*target_sp);
lldb::ExpressionVariableSP ret = persistent_state->CreatePersistentVariable(
exe_scope, name, m_type, map.GetByteOrder(), map.GetAddressByteSize());
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=331234&r1=331233&r2=331234&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp Mon Apr 30 16:59:15 2018
@@ -10,6 +10,7 @@
#include "ClangPersistentVariables.h"
#include "lldb/Core/Value.h"
+#include "lldb/Target/Target.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
@@ -52,10 +53,11 @@ void ClangPersistentVariables::RemovePer
m_next_persistent_variable_id--;
}
-ConstString ClangPersistentVariables::GetNextPersistentVariableName() {
+ConstString
+ClangPersistentVariables::GetNextPersistentVariableName(Target &target) {
char name_cstr[256];
::snprintf(name_cstr, sizeof(name_cstr), "$%u",
- m_next_persistent_variable_id++);
+ target.GetNextPersistentVariableIndex());
ConstString name(name_cstr);
return name;
}
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=331234&r1=331233&r2=331234&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h Mon Apr 30 16:59:15 2018
@@ -61,7 +61,7 @@ public:
/// @return
/// A string that contains the next persistent variable name.
//----------------------------------------------------------------------
- ConstString GetNextPersistentVariableName() override;
+ ConstString GetNextPersistentVariableName(Target &target) override;
void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
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=331234&r1=331233&r2=331234&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Mon Apr 30 16:59:15 2018
@@ -65,7 +65,8 @@ ClangUserExpression::ClangUserExpression
options),
m_type_system_helper(*m_target_wp.lock().get(),
options.GetExecutionPolicy() ==
- eExecutionPolicyTopLevel) {
+ eExecutionPolicyTopLevel),
+ m_result_delegate(exe_scope.CalculateTarget()) {
switch (m_language) {
case lldb::eLanguageTypeC_plus_plus:
m_allow_cxx = true;
@@ -663,10 +664,8 @@ void ClangUserExpression::ClangUserExpre
}
}
-ClangUserExpression::ResultDelegate::ResultDelegate() {}
-
ConstString ClangUserExpression::ResultDelegate::GetName() {
- return m_persistent_state->GetNextPersistentVariableName();
+ return m_persistent_state->GetNextPersistentVariableName(*m_target_sp);
}
void ClangUserExpression::ResultDelegate::DidDematerialize(
Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h?rev=331234&r1=331233&r2=331234&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h Mon Apr 30 16:59:15 2018
@@ -178,7 +178,7 @@ private:
class ResultDelegate : public Materializer::PersistentVariableDelegate {
public:
- ResultDelegate();
+ ResultDelegate(lldb::TargetSP target) : m_target_sp(target) {}
ConstString GetName() override;
void DidDematerialize(lldb::ExpressionVariableSP &variable) override;
@@ -188,6 +188,7 @@ private:
private:
PersistentExpressionState *m_persistent_state;
lldb::ExpressionVariableSP m_variable;
+ lldb::TargetSP m_target_sp;
};
ResultDelegate m_result_delegate;
Modified: lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp?rev=331234&r1=331233&r2=331234&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp Mon Apr 30 16:59:15 2018
@@ -272,7 +272,7 @@ GoUserExpression::DoExecute(DiagnosticMa
PersistentExpressionState *pv =
target->GetPersistentExpressionStateForLanguage(eLanguageTypeGo);
if (pv != nullptr) {
- result->SetName(pv->GetNextPersistentVariableName());
+ result->SetName(pv->GetNextPersistentVariableName(*target));
pv->AddVariable(result);
}
return lldb::eExpressionCompleted;
@@ -650,11 +650,12 @@ ValueObjectSP GoUserExpression::GoInterp
GoPersistentExpressionState::GoPersistentExpressionState()
: PersistentExpressionState(eKindGo) {}
-ConstString GoPersistentExpressionState::GetNextPersistentVariableName() {
+ConstString
+GoPersistentExpressionState::GetNextPersistentVariableName(Target &target) {
char name_cstr[256];
// We can't use the same variable format as clang.
::snprintf(name_cstr, sizeof(name_cstr), "$go%u",
- m_next_persistent_variable_id++);
+ target.GetNextPersistentVariableIndex());
ConstString name(name_cstr);
return name;
}
Modified: lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h?rev=331234&r1=331233&r2=331234&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h Mon Apr 30 16:59:15 2018
@@ -29,7 +29,7 @@ class GoPersistentExpressionState : publ
public:
GoPersistentExpressionState();
- ConstString GetNextPersistentVariableName() override;
+ ConstString GetNextPersistentVariableName(Target &target) override;
void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
Modified: lldb/trunk/source/Target/ABI.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ABI.cpp?rev=331234&r1=331233&r2=331234&view=diff
==============================================================================
--- lldb/trunk/source/Target/ABI.cpp (original)
+++ lldb/trunk/source/Target/ABI.cpp Mon Apr 30 16:59:15 2018
@@ -102,15 +102,16 @@ ValueObjectSP ABI::GetReturnValueObject(
// work.
if (persistent) {
+ Target &target = *thread.CalculateTarget();
PersistentExpressionState *persistent_expression_state =
- thread.CalculateTarget()->GetPersistentExpressionStateForLanguage(
+ target.GetPersistentExpressionStateForLanguage(
ast_type.GetMinimumLanguage());
if (!persistent_expression_state)
return ValueObjectSP();
ConstString persistent_variable_name(
- persistent_expression_state->GetNextPersistentVariableName());
+ persistent_expression_state->GetNextPersistentVariableName(target));
lldb::ValueObjectSP const_valobj_sp;
More information about the lldb-commits
mailing list