[lldb] Move redundant persistent variable counter to ClangPersistentVariables

Currently Target::m_next_persistent_variable_index is counting up
for our persistent variables ($0, $1, ...) but we also have a
unused counter that is supposed to do this in
ClangPersistentVariables but that stays always at 0 (because
we currently increase the target counter when we should increase
that unused counter).

This patch removes the counter in Target and lets the documented
counter in ClangPersistentVariables do the variable counting.

Patch *should* be NFC, but it might unexpectedly bring LLDB to
new code paths that could contain exciting new bugs to fix.

llvm-svn: 367842
This commit is contained in:
Raphael Isemann 2019-08-05 12:32:59 +00:00
parent 6e52d40ce3
commit 6c64a9b8ab
4 changed files with 14 additions and 20 deletions

View File

@ -223,8 +223,8 @@ public:
uint32_t addr_byte_size) = 0; uint32_t addr_byte_size) = 0;
/// Return a new persistent variable name with the specified prefix. /// Return a new persistent variable name with the specified prefix.
ConstString GetNextPersistentVariableName(Target &target, virtual ConstString GetNextPersistentVariableName(Target &target,
llvm::StringRef prefix); llvm::StringRef prefix) = 0;
virtual llvm::StringRef virtual llvm::StringRef
GetPersistentVariablePrefix(bool is_error = false) const = 0; GetPersistentVariablePrefix(bool is_error = false) const = 0;

View File

@ -1106,11 +1106,6 @@ public:
lldb::ExpressionVariableSP GetPersistentVariable(ConstString name); lldb::ExpressionVariableSP GetPersistentVariable(ConstString name);
/// Return the next available number for numbered persistent variables.
unsigned GetNextPersistentVariableIndex() {
return m_next_persistent_variable_index++;
}
lldb::addr_t GetPersistentSymbol(ConstString name); lldb::addr_t GetPersistentSymbol(ConstString name);
/// This method will return the address of the starting function for /// This method will return the address of the starting function for
@ -1320,7 +1315,6 @@ protected:
bool m_valid; bool m_valid;
bool m_suppress_stop_hooks; bool m_suppress_stop_hooks;
bool m_is_dummy_target; bool m_is_dummy_target;
unsigned m_next_persistent_variable_index = 0;
static void ImageSearchPathsChanged(const PathMappingList &path_list, static void ImageSearchPathsChanged(const PathMappingList &path_list,
void *baton); void *baton);

View File

@ -76,13 +76,3 @@ void PersistentExpressionState::RegisterExecutionUnit(
} }
} }
} }
ConstString PersistentExpressionState::GetNextPersistentVariableName(
Target &target, llvm::StringRef Prefix) {
llvm::SmallString<64> name;
{
llvm::raw_svector_ostream os(name);
os << Prefix << target.GetNextPersistentVariableIndex();
}
return ConstString(name);
}

View File

@ -45,8 +45,18 @@ public:
uint32_t addr_byte_size) override; uint32_t addr_byte_size) override;
void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override; void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
llvm::StringRef
GetPersistentVariablePrefix(bool is_error) const override { ConstString GetNextPersistentVariableName(Target &target,
llvm::StringRef prefix) override {
llvm::SmallString<64> name;
{
llvm::raw_svector_ostream os(name);
os << prefix << m_next_persistent_variable_id++;
}
return ConstString(name);
}
llvm::StringRef GetPersistentVariablePrefix(bool is_error) const override {
return "$"; return "$";
} }