diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h index b32bb8fa91c85..4782d7eff947b 100644 --- a/lldb/include/lldb/Interpreter/OptionValueProperties.h +++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h @@ -68,8 +68,6 @@ class OptionValueProperties // Subclass specific functions - virtual size_t GetNumProperties() const; - // Get the index of a property given its exact name in this property // collection, "name" can't be a path to a property path that refers to a // property within a property @@ -205,10 +203,12 @@ class OptionValueProperties protected: Property *ProtectedGetPropertyAtIndex(uint32_t idx) { + assert(idx < m_properties.size() && "invalid property index"); return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr); } const Property *ProtectedGetPropertyAtIndex(uint32_t idx) const { + assert(idx < m_properties.size() && "invalid property index"); return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr); } diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 349f1c91d1e38..ff249bc1952f4 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -812,6 +812,9 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton) GetStaticBroadcasterClass().AsCString()), m_forward_listener_sp(), m_clear_once() { m_instance_name.SetString(llvm::formatv("debugger_{0}", GetID()).str()); + // Initialize the debugger properties as early as possible as other parts of + // LLDB will start querying them during construction. + m_collection_sp->Initialize(g_debugger_properties); if (log_callback) m_callback_handler_sp = std::make_shared(log_callback, baton); @@ -833,7 +836,6 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton) } assert(m_dummy_target_sp.get() && "Couldn't construct dummy target?"); - m_collection_sp->Initialize(g_debugger_properties); m_collection_sp->AppendProperty( ConstString("target"), "Settings specify to debugging targets.", true, Target::GetGlobalProperties().GetValueProperties()); diff --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp index 7f402374a12ec..20d613af94817 100644 --- a/lldb/source/Interpreter/OptionValueProperties.cpp +++ b/lldb/source/Interpreter/OptionValueProperties.cpp @@ -22,10 +22,6 @@ using namespace lldb_private; OptionValueProperties::OptionValueProperties(ConstString name) : m_name(name) {} -size_t OptionValueProperties::GetNumProperties() const { - return m_properties.size(); -} - void OptionValueProperties::Initialize(const PropertyDefinitions &defs) { for (const auto &definition : defs) { Property property(definition);