[Lldb-commits] [lldb] [lldb] Avoid data race when clearing an OptionValue (PR #208471)
Ebuka Ezike via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 13 10:46:50 PDT 2026
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/208471
>From ca792bf4a256048f6912d940a131b162b887f971 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <e_ezike at apple.com>
Date: Thu, 9 Jul 2026 15:03:29 +0100
Subject: [PATCH 1/4] [lldb-dap] Avoid data race when clearing an OptionValue
The clear function guarded by the internal mutex.
This happens when we have to threads one trying to set a value and the
other reseting the value.
---
lldb/include/lldb/Interpreter/OptionValue.h | 4 ++--
lldb/include/lldb/Interpreter/OptionValueArch.h | 2 ++
lldb/include/lldb/Interpreter/OptionValueArray.h | 1 +
lldb/include/lldb/Interpreter/OptionValueBoolean.h | 1 +
lldb/include/lldb/Interpreter/OptionValueChar.h | 1 +
lldb/include/lldb/Interpreter/OptionValueDictionary.h | 1 +
lldb/include/lldb/Interpreter/OptionValueEnumeration.h | 1 +
lldb/include/lldb/Interpreter/OptionValueFileColonLine.h | 1 +
lldb/include/lldb/Interpreter/OptionValueFileSpec.h | 1 +
lldb/include/lldb/Interpreter/OptionValueFormat.h | 1 +
lldb/include/lldb/Interpreter/OptionValueLanguage.h | 1 +
lldb/include/lldb/Interpreter/OptionValuePathMappings.h | 1 +
lldb/include/lldb/Interpreter/OptionValueRegex.h | 1 +
lldb/include/lldb/Interpreter/OptionValueSInt64.h | 1 +
lldb/include/lldb/Interpreter/OptionValueString.h | 1 +
lldb/include/lldb/Interpreter/OptionValueUInt64.h | 1 +
lldb/include/lldb/Interpreter/OptionValueUUID.h | 1 +
lldb/source/Interpreter/OptionValueFormatEntity.cpp | 1 +
lldb/source/Interpreter/OptionValueProperties.cpp | 1 +
19 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h
index 193f2e44aca1b..e364fc0817754 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -372,6 +372,8 @@ class OptionValue {
// set from the command line or as a setting,
// versus if we just have the default value that
// was already populated in the option value.
+ mutable std::recursive_mutex m_mutex;
+
private:
std::optional<ArchSpec> GetArchSpecValue() const;
bool SetArchSpecValue(ArchSpec arch_spec);
@@ -412,8 +414,6 @@ class OptionValue {
bool SetFormatEntityValue(const FormatEntity::Entry &entry);
const RegularExpression *GetRegexValue() const;
-
- mutable std::mutex m_mutex;
};
} // namespace lldb_private
diff --git a/lldb/include/lldb/Interpreter/OptionValueArch.h b/lldb/include/lldb/Interpreter/OptionValueArch.h
index 8b6954f03dd29..d5092fe788691 100644
--- a/lldb/include/lldb/Interpreter/OptionValueArch.h
+++ b/lldb/include/lldb/Interpreter/OptionValueArch.h
@@ -12,6 +12,7 @@
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/CompletionRequest.h"
+#include <mutex>
namespace lldb_private {
@@ -45,6 +46,7 @@ class OptionValueArch : public Cloneable<OptionValueArch, OptionValue> {
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_current_value = m_default_value;
m_value_was_set = false;
}
diff --git a/lldb/include/lldb/Interpreter/OptionValueArray.h b/lldb/include/lldb/Interpreter/OptionValueArray.h
index 34170ef06a188..38ec01bdf51fc 100644
--- a/lldb/include/lldb/Interpreter/OptionValueArray.h
+++ b/lldb/include/lldb/Interpreter/OptionValueArray.h
@@ -36,6 +36,7 @@ class OptionValueArray : public Cloneable<OptionValueArray, OptionValue> {
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_values.clear();
m_value_was_set = false;
}
diff --git a/lldb/include/lldb/Interpreter/OptionValueBoolean.h b/lldb/include/lldb/Interpreter/OptionValueBoolean.h
index 72c1ce446b8a0..e9ac654ed5e3e 100644
--- a/lldb/include/lldb/Interpreter/OptionValueBoolean.h
+++ b/lldb/include/lldb/Interpreter/OptionValueBoolean.h
@@ -38,6 +38,7 @@ class OptionValueBoolean : public Cloneable<OptionValueBoolean, OptionValue> {
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_current_value = m_default_value;
m_value_was_set = false;
}
diff --git a/lldb/include/lldb/Interpreter/OptionValueChar.h b/lldb/include/lldb/Interpreter/OptionValueChar.h
index c1f83a3daf846..e6a2ed31063a1 100644
--- a/lldb/include/lldb/Interpreter/OptionValueChar.h
+++ b/lldb/include/lldb/Interpreter/OptionValueChar.h
@@ -39,6 +39,7 @@ class OptionValueChar : public Cloneable<OptionValueChar, OptionValue> {
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_current_value = m_default_value;
m_value_was_set = false;
}
diff --git a/lldb/include/lldb/Interpreter/OptionValueDictionary.h b/lldb/include/lldb/Interpreter/OptionValueDictionary.h
index 800b7fc687640..8a28ee81585a4 100644
--- a/lldb/include/lldb/Interpreter/OptionValueDictionary.h
+++ b/lldb/include/lldb/Interpreter/OptionValueDictionary.h
@@ -41,6 +41,7 @@ class OptionValueDictionary
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_values.clear();
m_value_was_set = false;
}
diff --git a/lldb/include/lldb/Interpreter/OptionValueEnumeration.h b/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
index e8566934d9fc5..6536d1e900487 100644
--- a/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
+++ b/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
@@ -48,6 +48,7 @@ class OptionValueEnumeration
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_current_value = m_default_value;
m_value_was_set = false;
}
diff --git a/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h b/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
index e2b84f9b81e65..e7dd0f9011078 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
@@ -36,6 +36,7 @@ class OptionValueFileColonLine :
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_file_spec.Clear();
m_line_number = LLDB_INVALID_LINE_NUMBER;
m_column_number = LLDB_INVALID_COLUMN_NUMBER;
diff --git a/lldb/include/lldb/Interpreter/OptionValueFileSpec.h b/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
index 66f2b2a04ff53..dd643703912e7 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
@@ -44,6 +44,7 @@ class OptionValueFileSpec : public Cloneable<OptionValueFileSpec, OptionValue> {
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_current_value = m_default_value;
m_value_was_set = false;
m_data_sp.reset();
diff --git a/lldb/include/lldb/Interpreter/OptionValueFormat.h b/lldb/include/lldb/Interpreter/OptionValueFormat.h
index 661e8b507d64f..c5e593ff107e2 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFormat.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFormat.h
@@ -38,6 +38,7 @@ class OptionValueFormat
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_current_value = m_default_value;
m_value_was_set = false;
}
diff --git a/lldb/include/lldb/Interpreter/OptionValueLanguage.h b/lldb/include/lldb/Interpreter/OptionValueLanguage.h
index 41ddb2a13f15e..50c57ac2d32f7 100644
--- a/lldb/include/lldb/Interpreter/OptionValueLanguage.h
+++ b/lldb/include/lldb/Interpreter/OptionValueLanguage.h
@@ -40,6 +40,7 @@ class OptionValueLanguage : public Cloneable<OptionValueLanguage, OptionValue> {
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_current_value = m_default_value;
m_value_was_set = false;
}
diff --git a/lldb/include/lldb/Interpreter/OptionValuePathMappings.h b/lldb/include/lldb/Interpreter/OptionValuePathMappings.h
index e0aac2fd44484..0b523e7c8a7ff 100644
--- a/lldb/include/lldb/Interpreter/OptionValuePathMappings.h
+++ b/lldb/include/lldb/Interpreter/OptionValuePathMappings.h
@@ -36,6 +36,7 @@ class OptionValuePathMappings
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_path_mappings.Clear(m_notify_changes);
m_value_was_set = false;
}
diff --git a/lldb/include/lldb/Interpreter/OptionValueRegex.h b/lldb/include/lldb/Interpreter/OptionValueRegex.h
index 2799fea1538dc..4f544d086ac96 100644
--- a/lldb/include/lldb/Interpreter/OptionValueRegex.h
+++ b/lldb/include/lldb/Interpreter/OptionValueRegex.h
@@ -37,6 +37,7 @@ class OptionValueRegex : public Cloneable<OptionValueRegex, OptionValue> {
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_regex = RegularExpression(m_default_regex_str);
m_value_was_set = false;
}
diff --git a/lldb/include/lldb/Interpreter/OptionValueSInt64.h b/lldb/include/lldb/Interpreter/OptionValueSInt64.h
index f19f3f8ab875e..b5295c20bcc8c 100644
--- a/lldb/include/lldb/Interpreter/OptionValueSInt64.h
+++ b/lldb/include/lldb/Interpreter/OptionValueSInt64.h
@@ -44,6 +44,7 @@ class OptionValueSInt64 : public Cloneable<OptionValueSInt64, OptionValue> {
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_current_value = m_default_value;
m_value_was_set = false;
}
diff --git a/lldb/include/lldb/Interpreter/OptionValueString.h b/lldb/include/lldb/Interpreter/OptionValueString.h
index e199443fa8b49..8b4fc6c635839 100644
--- a/lldb/include/lldb/Interpreter/OptionValueString.h
+++ b/lldb/include/lldb/Interpreter/OptionValueString.h
@@ -78,6 +78,7 @@ class OptionValueString : public Cloneable<OptionValueString, OptionValue> {
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_current_value = m_default_value;
m_value_was_set = false;
}
diff --git a/lldb/include/lldb/Interpreter/OptionValueUInt64.h b/lldb/include/lldb/Interpreter/OptionValueUInt64.h
index 2a87c19c54bbf..678c3e035541d 100644
--- a/lldb/include/lldb/Interpreter/OptionValueUInt64.h
+++ b/lldb/include/lldb/Interpreter/OptionValueUInt64.h
@@ -47,6 +47,7 @@ class OptionValueUInt64 : public Cloneable<OptionValueUInt64, OptionValue> {
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_current_value = m_default_value;
m_value_was_set = false;
}
diff --git a/lldb/include/lldb/Interpreter/OptionValueUUID.h b/lldb/include/lldb/Interpreter/OptionValueUUID.h
index 2b7d9e41bcf77..7d4e6385f27f3 100644
--- a/lldb/include/lldb/Interpreter/OptionValueUUID.h
+++ b/lldb/include/lldb/Interpreter/OptionValueUUID.h
@@ -38,6 +38,7 @@ class OptionValueUUID : public Cloneable<OptionValueUUID, OptionValue> {
VarSetOperationType op = eVarSetOperationAssign) override;
void Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_uuid.Clear();
m_value_was_set = false;
}
diff --git a/lldb/source/Interpreter/OptionValueFormatEntity.cpp b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
index b31dd4e475878..60b7b52badc9d 100644
--- a/lldb/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
@@ -29,6 +29,7 @@ OptionValueFormatEntity::OptionValueFormatEntity(const char *default_format) {
}
void OptionValueFormatEntity::Clear() {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_current_entry = m_default_entry;
m_current_format = m_default_format;
m_value_was_set = false;
diff --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp
index e62c15ec36da3..705e53d50cb58 100644
--- a/lldb/source/Interpreter/OptionValueProperties.cpp
+++ b/lldb/source/Interpreter/OptionValueProperties.cpp
@@ -304,6 +304,7 @@ OptionValueString *OptionValueProperties::GetPropertyAtIndexAsOptionValueString(
}
void OptionValueProperties::Clear() {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
const size_t num_properties = m_properties.size();
for (size_t i = 0; i < num_properties; ++i)
m_properties[i].GetValue()->Clear();
>From 278010864eed73b4fa9486ce30132a2246be5918 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Fri, 10 Jul 2026 14:10:05 +0100
Subject: [PATCH 2/4] [lldb-dap] Update the mutex template
---
lldb/source/Interpreter/OptionValue.cpp | 61 +++++++++++++------------
1 file changed, 31 insertions(+), 30 deletions(-)
diff --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp
index 3ae4d7781e192..deac8300fc306 100644
--- a/lldb/source/Interpreter/OptionValue.cpp
+++ b/lldb/source/Interpreter/OptionValue.cpp
@@ -16,7 +16,7 @@ using namespace lldb;
using namespace lldb_private;
OptionValue::OptionValue(const OptionValue &other) {
- std::lock_guard<std::mutex> lock(other.m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(other.m_mutex);
m_parent_wp = other.m_parent_wp;
m_callback = other.m_callback;
@@ -24,8 +24,9 @@ OptionValue::OptionValue(const OptionValue &other) {
}
-OptionValue& OptionValue::operator=(const OptionValue &other) {
- std::scoped_lock<std::mutex, std::mutex> lock(m_mutex, other.m_mutex);
+OptionValue &OptionValue::operator=(const OptionValue &other) {
+ std::scoped_lock<std::recursive_mutex, std::recursive_mutex> lock(
+ m_mutex, other.m_mutex);
m_parent_wp = other.m_parent_wp;
m_callback = other.m_callback;
@@ -269,14 +270,14 @@ const OptionValueUUID *OptionValue::GetAsUUID() const {
}
std::optional<bool> OptionValue::GetBooleanValue() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueBoolean *option_value = GetAsBoolean())
return option_value->GetCurrentValue();
return {};
}
bool OptionValue::SetBooleanValue(bool new_value) {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (OptionValueBoolean *option_value = GetAsBoolean()) {
option_value->SetCurrentValue(new_value);
return true;
@@ -285,14 +286,14 @@ bool OptionValue::SetBooleanValue(bool new_value) {
}
std::optional<char> OptionValue::GetCharValue() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueChar *option_value = GetAsChar())
return option_value->GetCurrentValue();
return {};
}
bool OptionValue::SetCharValue(char new_value) {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (OptionValueChar *option_value = GetAsChar()) {
option_value->SetCurrentValue(new_value);
return true;
@@ -301,14 +302,14 @@ bool OptionValue::SetCharValue(char new_value) {
}
std::optional<int64_t> OptionValue::GetEnumerationValue() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueEnumeration *option_value = GetAsEnumeration())
return option_value->GetCurrentValue();
return {};
}
bool OptionValue::SetEnumerationValue(int64_t value) {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (OptionValueEnumeration *option_value = GetAsEnumeration()) {
option_value->SetCurrentValue(value);
return true;
@@ -317,14 +318,14 @@ bool OptionValue::SetEnumerationValue(int64_t value) {
}
std::optional<FileSpec> OptionValue::GetFileSpecValue() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueFileSpec *option_value = GetAsFileSpec())
return option_value->GetCurrentValue();
return {};
}
bool OptionValue::SetFileSpecValue(FileSpec file_spec) {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (OptionValueFileSpec *option_value = GetAsFileSpec()) {
option_value->SetCurrentValue(file_spec, false);
return true;
@@ -333,7 +334,7 @@ bool OptionValue::SetFileSpecValue(FileSpec file_spec) {
}
bool OptionValue::AppendFileSpecValue(FileSpec file_spec) {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (OptionValueFileSpecList *option_value = GetAsFileSpecList()) {
option_value->AppendCurrentValue(file_spec);
return true;
@@ -342,21 +343,21 @@ bool OptionValue::AppendFileSpecValue(FileSpec file_spec) {
}
std::optional<FileSpecList> OptionValue::GetFileSpecListValue() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueFileSpecList *option_value = GetAsFileSpecList())
return option_value->GetCurrentValue();
return {};
}
std::optional<lldb::Format> OptionValue::GetFormatValue() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueFormat *option_value = GetAsFormat())
return option_value->GetCurrentValue();
return {};
}
bool OptionValue::SetFormatValue(lldb::Format new_value) {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (OptionValueFormat *option_value = GetAsFormat()) {
option_value->SetCurrentValue(new_value);
return true;
@@ -365,14 +366,14 @@ bool OptionValue::SetFormatValue(lldb::Format new_value) {
}
std::optional<lldb::LanguageType> OptionValue::GetLanguageValue() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueLanguage *option_value = GetAsLanguage())
return option_value->GetCurrentValue();
return {};
}
bool OptionValue::SetLanguageValue(lldb::LanguageType new_language) {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (OptionValueLanguage *option_value = GetAsLanguage()) {
option_value->SetCurrentValue(new_language);
return true;
@@ -381,28 +382,28 @@ bool OptionValue::SetLanguageValue(lldb::LanguageType new_language) {
}
FormatEntity::Entry OptionValue::GetFormatEntityValue() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueFormatEntity *option_value = GetAsFormatEntity())
return option_value->GetCurrentValue();
return {};
}
const RegularExpression *OptionValue::GetRegexValue() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueRegex *option_value = GetAsRegex())
return option_value->GetCurrentValue();
return nullptr;
}
std::optional<int64_t> OptionValue::GetSInt64Value() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueSInt64 *option_value = GetAsSInt64())
return option_value->GetCurrentValue();
return {};
}
bool OptionValue::SetSInt64Value(int64_t new_value) {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (OptionValueSInt64 *option_value = GetAsSInt64()) {
option_value->SetCurrentValue(new_value);
return true;
@@ -411,14 +412,14 @@ bool OptionValue::SetSInt64Value(int64_t new_value) {
}
std::optional<llvm::StringRef> OptionValue::GetStringValue() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueString *option_value = GetAsString())
return option_value->GetCurrentValueAsRef();
return {};
}
bool OptionValue::SetStringValue(llvm::StringRef new_value) {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (OptionValueString *option_value = GetAsString()) {
option_value->SetCurrentValue(new_value);
return true;
@@ -427,14 +428,14 @@ bool OptionValue::SetStringValue(llvm::StringRef new_value) {
}
std::optional<uint64_t> OptionValue::GetUInt64Value() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueUInt64 *option_value = GetAsUInt64())
return option_value->GetCurrentValue();
return {};
}
bool OptionValue::SetUInt64Value(uint64_t new_value) {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (OptionValueUInt64 *option_value = GetAsUInt64()) {
option_value->SetCurrentValue(new_value);
return true;
@@ -443,14 +444,14 @@ bool OptionValue::SetUInt64Value(uint64_t new_value) {
}
std::optional<UUID> OptionValue::GetUUIDValue() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueUUID *option_value = GetAsUUID())
return option_value->GetCurrentValue();
return {};
}
bool OptionValue::SetUUIDValue(const UUID &uuid) {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (OptionValueUUID *option_value = GetAsUUID()) {
option_value->SetCurrentValue(uuid);
return true;
@@ -459,14 +460,14 @@ bool OptionValue::SetUUIDValue(const UUID &uuid) {
}
std::optional<ArchSpec> OptionValue::GetArchSpecValue() const {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (const OptionValueArch *option_value = GetAsArch())
return option_value->GetCurrentValue();
return {};
}
bool OptionValue::SetArchSpecValue(ArchSpec arch_spec) {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (OptionValueArch *option_value = GetAsArch()) {
option_value->SetCurrentValue(arch_spec, false);
return true;
@@ -475,7 +476,7 @@ bool OptionValue::SetArchSpecValue(ArchSpec arch_spec) {
}
bool OptionValue::SetFormatEntityValue(const FormatEntity::Entry &entry) {
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (OptionValueFormatEntity *option_value = GetAsFormatEntity()) {
option_value->SetCurrentValue(entry);
return true;
>From 7e3d1a7cd241c4cd3bbffad24fe6d685fa4fb064 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Fri, 10 Jul 2026 15:23:41 +0100
Subject: [PATCH 3/4] drop the extra mutex
---
lldb/include/lldb/Interpreter/OptionValueFileSpecList.h | 1 -
lldb/source/Interpreter/OptionValueBoolean.cpp | 4 ++--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
index 6250b5ee6fcb2..59505a917dc99 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
@@ -67,7 +67,6 @@ class OptionValueFileSpecList
protected:
lldb::OptionValueSP Clone() const override;
- mutable std::recursive_mutex m_mutex;
FileSpecList m_current_value;
};
diff --git a/lldb/source/Interpreter/OptionValueBoolean.cpp b/lldb/source/Interpreter/OptionValueBoolean.cpp
index 023c243b3efc1..f7e9a71eacb6a 100644
--- a/lldb/source/Interpreter/OptionValueBoolean.cpp
+++ b/lldb/source/Interpreter/OptionValueBoolean.cpp
@@ -50,8 +50,8 @@ Status OptionValueBoolean::SetValueFromString(llvm::StringRef value_str,
bool success = false;
bool value = OptionArgParser::ToBoolean(value_str, false, &success);
if (success) {
- m_value_was_set = true;
- m_current_value = value;
+ OptionWasSet();
+ SetValueAs(value);
NotifyValueChanged();
} else {
if (value_str.size() == 0)
>From 838cec35f29cdf6c22d3b0ba6ec89e1db2ca20c0 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Mon, 13 Jul 2026 18:44:55 +0100
Subject: [PATCH 4/4] [lldb] readd ClearImpl()
---
lldb/include/lldb/Interpreter/OptionValue.h | 7 ++++++-
lldb/include/lldb/Interpreter/OptionValueArch.h | 11 +++++------
lldb/include/lldb/Interpreter/OptionValueArray.h | 11 +++++------
.../include/lldb/Interpreter/OptionValueBoolean.h | 11 +++++------
lldb/include/lldb/Interpreter/OptionValueChar.h | 11 +++++------
.../lldb/Interpreter/OptionValueDictionary.h | 11 +++++------
.../lldb/Interpreter/OptionValueEnumeration.h | 11 +++++------
.../lldb/Interpreter/OptionValueFileColonLine.h | 13 ++++++-------
.../lldb/Interpreter/OptionValueFileSpec.h | 15 +++++++--------
.../lldb/Interpreter/OptionValueFileSpecList.h | 11 +++++------
lldb/include/lldb/Interpreter/OptionValueFormat.h | 11 +++++------
.../lldb/Interpreter/OptionValueFormatEntity.h | 4 ++--
.../lldb/Interpreter/OptionValueLanguage.h | 11 +++++------
.../lldb/Interpreter/OptionValuePathMappings.h | 11 +++++------
.../lldb/Interpreter/OptionValueProperties.h | 4 ++--
lldb/include/lldb/Interpreter/OptionValueRegex.h | 11 +++++------
lldb/include/lldb/Interpreter/OptionValueSInt64.h | 11 +++++------
lldb/include/lldb/Interpreter/OptionValueString.h | 11 +++++------
lldb/include/lldb/Interpreter/OptionValueUInt64.h | 11 +++++------
lldb/include/lldb/Interpreter/OptionValueUUID.h | 11 +++++------
.../Interpreter/OptionValueFormatEntity.cpp | 3 +--
lldb/source/Interpreter/OptionValueProperties.cpp | 3 +--
22 files changed, 100 insertions(+), 114 deletions(-)
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h
index e364fc0817754..201feccd431d9 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -102,7 +102,10 @@ class OptionValue {
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign);
- virtual void Clear() = 0;
+ void Clear() {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+ ClearImpl();
+ }
virtual lldb::OptionValueSP
DeepCopy(const lldb::OptionValueSP &new_parent) const;
@@ -350,6 +353,8 @@ class OptionValue {
// DeepCopy to it. Inherit from Cloneable to avoid doing this manually.
virtual lldb::OptionValueSP Clone() const = 0;
+ virtual void ClearImpl() = 0;
+
class DefaultValueFormat {
public:
DefaultValueFormat(Stream &stream) : stream(stream) {
diff --git a/lldb/include/lldb/Interpreter/OptionValueArch.h b/lldb/include/lldb/Interpreter/OptionValueArch.h
index d5092fe788691..3aff2b83ad7d9 100644
--- a/lldb/include/lldb/Interpreter/OptionValueArch.h
+++ b/lldb/include/lldb/Interpreter/OptionValueArch.h
@@ -45,12 +45,6 @@ class OptionValueArch : public Cloneable<OptionValueArch, OptionValue> {
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_current_value = m_default_value;
- m_value_was_set = false;
- }
-
bool IsDefault() const override { return m_current_value == m_default_value; }
void AutoComplete(CommandInterpreter &interpreter,
@@ -73,6 +67,11 @@ class OptionValueArch : public Cloneable<OptionValueArch, OptionValue> {
void SetDefaultValue(const ArchSpec &value) { m_default_value = value; }
protected:
+ void ClearImpl() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ }
+
ArchSpec m_current_value;
ArchSpec m_default_value;
};
diff --git a/lldb/include/lldb/Interpreter/OptionValueArray.h b/lldb/include/lldb/Interpreter/OptionValueArray.h
index 38ec01bdf51fc..0bcc9e4388cb7 100644
--- a/lldb/include/lldb/Interpreter/OptionValueArray.h
+++ b/lldb/include/lldb/Interpreter/OptionValueArray.h
@@ -35,12 +35,6 @@ class OptionValueArray : public Cloneable<OptionValueArray, OptionValue> {
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_values.clear();
- m_value_was_set = false;
- }
-
lldb::OptionValueSP
DeepCopy(const lldb::OptionValueSP &new_parent) const override;
@@ -116,6 +110,11 @@ class OptionValueArray : public Cloneable<OptionValueArray, OptionValue> {
Status SetArgs(const Args &args, VarSetOperationType op);
protected:
+ void ClearImpl() override {
+ m_values.clear();
+ m_value_was_set = false;
+ }
+
typedef std::vector<lldb::OptionValueSP> collection;
uint32_t m_type_mask;
diff --git a/lldb/include/lldb/Interpreter/OptionValueBoolean.h b/lldb/include/lldb/Interpreter/OptionValueBoolean.h
index e9ac654ed5e3e..d2dfe6d5d0654 100644
--- a/lldb/include/lldb/Interpreter/OptionValueBoolean.h
+++ b/lldb/include/lldb/Interpreter/OptionValueBoolean.h
@@ -37,12 +37,6 @@ class OptionValueBoolean : public Cloneable<OptionValueBoolean, OptionValue> {
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_current_value = m_default_value;
- m_value_was_set = false;
- }
-
void AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) override;
@@ -79,6 +73,11 @@ class OptionValueBoolean : public Cloneable<OptionValueBoolean, OptionValue> {
void SetDefaultValue(bool value) { m_default_value = value; }
protected:
+ void ClearImpl() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ }
+
bool m_current_value;
bool m_default_value;
};
diff --git a/lldb/include/lldb/Interpreter/OptionValueChar.h b/lldb/include/lldb/Interpreter/OptionValueChar.h
index e6a2ed31063a1..d47b1b8a66263 100644
--- a/lldb/include/lldb/Interpreter/OptionValueChar.h
+++ b/lldb/include/lldb/Interpreter/OptionValueChar.h
@@ -38,12 +38,6 @@ class OptionValueChar : public Cloneable<OptionValueChar, OptionValue> {
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_current_value = m_default_value;
- m_value_was_set = false;
- }
-
bool IsDefault() const override { return m_current_value == m_default_value; }
// Subclass specific functions
@@ -62,6 +56,11 @@ class OptionValueChar : public Cloneable<OptionValueChar, OptionValue> {
void SetDefaultValue(char value) { m_default_value = value; }
protected:
+ void ClearImpl() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ }
+
char m_current_value;
char m_default_value;
};
diff --git a/lldb/include/lldb/Interpreter/OptionValueDictionary.h b/lldb/include/lldb/Interpreter/OptionValueDictionary.h
index 8a28ee81585a4..db720ac91d873 100644
--- a/lldb/include/lldb/Interpreter/OptionValueDictionary.h
+++ b/lldb/include/lldb/Interpreter/OptionValueDictionary.h
@@ -40,12 +40,6 @@ class OptionValueDictionary
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_values.clear();
- m_value_was_set = false;
- }
-
lldb::OptionValueSP
DeepCopy(const lldb::OptionValueSP &new_parent) const override;
@@ -78,6 +72,11 @@ class OptionValueDictionary
Status SetArgs(const Args &args, VarSetOperationType op);
protected:
+ void ClearImpl() override {
+ m_values.clear();
+ m_value_was_set = false;
+ }
+
uint32_t m_type_mask;
OptionEnumValues m_enum_values;
llvm::StringMap<lldb::OptionValueSP> m_values;
diff --git a/lldb/include/lldb/Interpreter/OptionValueEnumeration.h b/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
index 6536d1e900487..4d71bdd8981b7 100644
--- a/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
+++ b/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
@@ -47,12 +47,6 @@ class OptionValueEnumeration
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_current_value = m_default_value;
- m_value_was_set = false;
- }
-
bool IsDefault() const override { return m_current_value == m_default_value; }
void AutoComplete(CommandInterpreter &interpreter,
@@ -77,6 +71,11 @@ class OptionValueEnumeration
void SetEnumerations(const OptionEnumValues &enumerators);
void DumpEnum(Stream &strm, enum_type value);
+ void ClearImpl() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ }
+
enum_type m_current_value;
enum_type m_default_value;
EnumerationMap m_enumerations;
diff --git a/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h b/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
index e7dd0f9011078..de6984dd6cadf 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
@@ -35,13 +35,6 @@ class OptionValueFileColonLine :
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_file_spec.Clear();
- m_line_number = LLDB_INVALID_LINE_NUMBER;
- m_column_number = LLDB_INVALID_COLUMN_NUMBER;
- }
-
void SetFile(const FileSpec &file_spec) { m_file_spec = file_spec; }
void SetLine(uint32_t line) { m_line_number = line; }
void SetColumn(uint32_t column) { m_column_number = column; }
@@ -56,6 +49,12 @@ class OptionValueFileColonLine :
void SetCompletionMask(uint32_t mask) { m_completion_mask = mask; }
protected:
+ void ClearImpl() override {
+ m_file_spec.Clear();
+ m_line_number = LLDB_INVALID_LINE_NUMBER;
+ m_column_number = LLDB_INVALID_COLUMN_NUMBER;
+ }
+
FileSpec m_file_spec;
uint32_t m_line_number = LLDB_INVALID_LINE_NUMBER;
uint32_t m_column_number = LLDB_INVALID_COLUMN_NUMBER;
diff --git a/lldb/include/lldb/Interpreter/OptionValueFileSpec.h b/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
index dd643703912e7..8d29939a53197 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
@@ -43,14 +43,6 @@ class OptionValueFileSpec : public Cloneable<OptionValueFileSpec, OptionValue> {
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_current_value = m_default_value;
- m_value_was_set = false;
- m_data_sp.reset();
- m_data_mod_time = llvm::sys::TimePoint<>();
- }
-
void AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) override;
@@ -78,6 +70,13 @@ class OptionValueFileSpec : public Cloneable<OptionValueFileSpec, OptionValue> {
void SetCompletionMask(uint32_t mask) { m_completion_mask = mask; }
protected:
+ void ClearImpl() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ m_data_sp.reset();
+ m_data_mod_time = llvm::sys::TimePoint<>();
+ }
+
FileSpec m_current_value;
FileSpec m_default_value;
lldb::DataBufferSP m_data_sp;
diff --git a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
index 59505a917dc99..bdf315c017df5 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
@@ -39,12 +39,6 @@ class OptionValueFileSpecList
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_current_value.Clear();
- m_value_was_set = false;
- }
-
bool IsAggregateValue() const override { return true; }
// Subclass specific functions
@@ -67,6 +61,11 @@ class OptionValueFileSpecList
protected:
lldb::OptionValueSP Clone() const override;
+ void ClearImpl() override {
+ m_current_value.Clear();
+ m_value_was_set = false;
+ }
+
FileSpecList m_current_value;
};
diff --git a/lldb/include/lldb/Interpreter/OptionValueFormat.h b/lldb/include/lldb/Interpreter/OptionValueFormat.h
index c5e593ff107e2..3774eda87c39b 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFormat.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFormat.h
@@ -37,12 +37,6 @@ class OptionValueFormat
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_current_value = m_default_value;
- m_value_was_set = false;
- }
-
bool IsDefault() const override { return m_current_value == m_default_value; }
// Subclass specific functions
@@ -56,6 +50,11 @@ class OptionValueFormat
void SetDefaultValue(lldb::Format value) { m_default_value = value; }
protected:
+ void ClearImpl() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ }
+
lldb::Format m_current_value;
lldb::Format m_default_value;
};
diff --git a/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h b/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
index bbc1f8c1eec43..701e0de4e982c 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
@@ -32,8 +32,6 @@ class OptionValueFormatEntity
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override;
-
bool IsDefault() const override {
return m_current_format == m_default_format;
}
@@ -50,6 +48,8 @@ class OptionValueFormatEntity
const FormatEntity::Entry &GetDefaultValue() const { return m_default_entry; }
protected:
+ void ClearImpl() override;
+
std::string m_current_format;
std::string m_default_format;
FormatEntity::Entry m_current_entry;
diff --git a/lldb/include/lldb/Interpreter/OptionValueLanguage.h b/lldb/include/lldb/Interpreter/OptionValueLanguage.h
index 50c57ac2d32f7..237ecda5e5c78 100644
--- a/lldb/include/lldb/Interpreter/OptionValueLanguage.h
+++ b/lldb/include/lldb/Interpreter/OptionValueLanguage.h
@@ -39,12 +39,6 @@ class OptionValueLanguage : public Cloneable<OptionValueLanguage, OptionValue> {
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_current_value = m_default_value;
- m_value_was_set = false;
- }
-
bool IsDefault() const override { return m_current_value == m_default_value; }
// Subclass specific functions
@@ -58,6 +52,11 @@ class OptionValueLanguage : public Cloneable<OptionValueLanguage, OptionValue> {
void SetDefaultValue(lldb::LanguageType value) { m_default_value = value; }
protected:
+ void ClearImpl() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ }
+
lldb::LanguageType m_current_value;
lldb::LanguageType m_default_value;
};
diff --git a/lldb/include/lldb/Interpreter/OptionValuePathMappings.h b/lldb/include/lldb/Interpreter/OptionValuePathMappings.h
index 0b523e7c8a7ff..e3102a31ffc6b 100644
--- a/lldb/include/lldb/Interpreter/OptionValuePathMappings.h
+++ b/lldb/include/lldb/Interpreter/OptionValuePathMappings.h
@@ -35,12 +35,6 @@ class OptionValuePathMappings
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_path_mappings.Clear(m_notify_changes);
- m_value_was_set = false;
- }
-
bool IsAggregateValue() const override { return true; }
// Subclass specific functions
@@ -50,6 +44,11 @@ class OptionValuePathMappings
const PathMappingList &GetCurrentValue() const { return m_path_mappings; }
protected:
+ void ClearImpl() override {
+ m_path_mappings.Clear(m_notify_changes);
+ m_value_was_set = false;
+ }
+
PathMappingList m_path_mappings;
bool m_notify_changes;
};
diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h
index 41c6be67bb990..f8427785fcfd8 100644
--- a/lldb/include/lldb/Interpreter/OptionValueProperties.h
+++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h
@@ -31,8 +31,6 @@ class OptionValueProperties
Type GetType() const override { return eTypeProperties; }
- void Clear() override;
-
static lldb::OptionValuePropertiesSP
CreateLocalCopy(const Properties &global_properties);
@@ -181,6 +179,8 @@ class OptionValueProperties
bool VerifyPath();
+ void ClearImpl() override;
+
std::string m_name;
std::vector<Property> m_properties;
llvm::StringMap<size_t> m_name_to_index;
diff --git a/lldb/include/lldb/Interpreter/OptionValueRegex.h b/lldb/include/lldb/Interpreter/OptionValueRegex.h
index 4f544d086ac96..49b968d905406 100644
--- a/lldb/include/lldb/Interpreter/OptionValueRegex.h
+++ b/lldb/include/lldb/Interpreter/OptionValueRegex.h
@@ -36,12 +36,6 @@ class OptionValueRegex : public Cloneable<OptionValueRegex, OptionValue> {
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_regex = RegularExpression(m_default_regex_str);
- m_value_was_set = false;
- }
-
bool IsDefault() const override {
return m_regex.GetText() == m_default_regex_str;
}
@@ -61,6 +55,11 @@ class OptionValueRegex : public Cloneable<OptionValueRegex, OptionValue> {
bool IsValid() const { return m_regex.IsValid(); }
protected:
+ void ClearImpl() override {
+ m_regex = RegularExpression(m_default_regex_str);
+ m_value_was_set = false;
+ }
+
RegularExpression m_regex;
std::string m_default_regex_str;
};
diff --git a/lldb/include/lldb/Interpreter/OptionValueSInt64.h b/lldb/include/lldb/Interpreter/OptionValueSInt64.h
index b5295c20bcc8c..796f9340e18f5 100644
--- a/lldb/include/lldb/Interpreter/OptionValueSInt64.h
+++ b/lldb/include/lldb/Interpreter/OptionValueSInt64.h
@@ -43,12 +43,6 @@ class OptionValueSInt64 : public Cloneable<OptionValueSInt64, OptionValue> {
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_current_value = m_default_value;
- m_value_was_set = false;
- }
-
bool IsDefault() const override { return m_current_value == m_default_value; }
// Subclass specific functions
@@ -86,6 +80,11 @@ class OptionValueSInt64 : public Cloneable<OptionValueSInt64, OptionValue> {
int64_t GetMaximumValue() const { return m_max_value; }
protected:
+ void ClearImpl() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ }
+
int64_t m_current_value = 0;
int64_t m_default_value = 0;
int64_t m_min_value = std::numeric_limits<int64_t>::min();
diff --git a/lldb/include/lldb/Interpreter/OptionValueString.h b/lldb/include/lldb/Interpreter/OptionValueString.h
index 8b4fc6c635839..47bd2a8093406 100644
--- a/lldb/include/lldb/Interpreter/OptionValueString.h
+++ b/lldb/include/lldb/Interpreter/OptionValueString.h
@@ -77,12 +77,6 @@ class OptionValueString : public Cloneable<OptionValueString, OptionValue> {
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_current_value = m_default_value;
- m_value_was_set = false;
- }
-
bool IsDefault() const override { return m_current_value == m_default_value; }
// Subclass specific functions
@@ -123,6 +117,11 @@ class OptionValueString : public Cloneable<OptionValueString, OptionValue> {
}
protected:
+ void ClearImpl() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ }
+
std::string m_current_value;
std::string m_default_value;
Flags m_options;
diff --git a/lldb/include/lldb/Interpreter/OptionValueUInt64.h b/lldb/include/lldb/Interpreter/OptionValueUInt64.h
index 678c3e035541d..a7bde8b40186e 100644
--- a/lldb/include/lldb/Interpreter/OptionValueUInt64.h
+++ b/lldb/include/lldb/Interpreter/OptionValueUInt64.h
@@ -46,12 +46,6 @@ class OptionValueUInt64 : public Cloneable<OptionValueUInt64, OptionValue> {
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_current_value = m_default_value;
- m_value_was_set = false;
- }
-
bool IsDefault() const override { return m_current_value == m_default_value; }
// Subclass specific functions
@@ -91,6 +85,11 @@ class OptionValueUInt64 : public Cloneable<OptionValueUInt64, OptionValue> {
uint64_t GetMaximumValue() const { return m_max_value; }
protected:
+ void ClearImpl() override {
+ m_current_value = m_default_value;
+ m_value_was_set = false;
+ }
+
uint64_t m_current_value = 0;
uint64_t m_default_value = 0;
uint64_t m_min_value = std::numeric_limits<uint64_t>::min();
diff --git a/lldb/include/lldb/Interpreter/OptionValueUUID.h b/lldb/include/lldb/Interpreter/OptionValueUUID.h
index 7d4e6385f27f3..8de73016352b1 100644
--- a/lldb/include/lldb/Interpreter/OptionValueUUID.h
+++ b/lldb/include/lldb/Interpreter/OptionValueUUID.h
@@ -37,12 +37,6 @@ class OptionValueUUID : public Cloneable<OptionValueUUID, OptionValue> {
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
- void Clear() override {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
- m_uuid.Clear();
- m_value_was_set = false;
- }
-
// Subclass specific functions
UUID &GetCurrentValue() { return m_uuid; }
@@ -55,6 +49,11 @@ class OptionValueUUID : public Cloneable<OptionValueUUID, OptionValue> {
CompletionRequest &request) override;
protected:
+ void ClearImpl() override {
+ m_uuid.Clear();
+ m_value_was_set = false;
+ }
+
UUID m_uuid;
};
diff --git a/lldb/source/Interpreter/OptionValueFormatEntity.cpp b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
index 60b7b52badc9d..63c1f110adabd 100644
--- a/lldb/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
@@ -28,8 +28,7 @@ OptionValueFormatEntity::OptionValueFormatEntity(const char *default_format) {
}
}
-void OptionValueFormatEntity::Clear() {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
+void OptionValueFormatEntity::ClearImpl() {
m_current_entry = m_default_entry;
m_current_format = m_default_format;
m_value_was_set = false;
diff --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp
index 705e53d50cb58..adea68aa530a6 100644
--- a/lldb/source/Interpreter/OptionValueProperties.cpp
+++ b/lldb/source/Interpreter/OptionValueProperties.cpp
@@ -303,8 +303,7 @@ OptionValueString *OptionValueProperties::GetPropertyAtIndexAsOptionValueString(
return nullptr;
}
-void OptionValueProperties::Clear() {
- std::lock_guard<std::recursive_mutex> lock(m_mutex);
+void OptionValueProperties::ClearImpl() {
const size_t num_properties = m_properties.size();
for (size_t i = 0; i < num_properties; ++i)
m_properties[i].GetValue()->Clear();
More information about the lldb-commits
mailing list