<commit_before>//===-- SBValue.cpp ---------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "lldb/lldb-python.h"

#include "lldb/API/SBValue.h"

#include "lldb/API/SBDeclaration.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBTypeFilter.h"
#include "lldb/API/SBTypeFormat.h"
#include "lldb/API/SBTypeSummary.h"
#include "lldb/API/SBTypeSynthetic.h"

#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Declaration.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"

#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBExpressionOptions.h"
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBTarget.h"
#include "lldb/API/SBThread.h"

using namespace lldb;
using namespace lldb_private;

namespace {
    class ValueImpl
    {
    public:
        ValueImpl ()
        {
        }
        
        ValueImpl (lldb::ValueObjectSP opaque_sp,
                   lldb::DynamicValueType use_dynamic,
                   bool use_synthetic) :
            m_opaque_sp(opaque_sp),
            m_use_dynamic(use_dynamic),
            m_use_synthetic(use_synthetic)
        {
        }
        
        ValueImpl (const ValueImpl& rhs) :
            m_opaque_sp(rhs.m_opaque_sp),
            m_use_dynamic(rhs.m_use_dynamic),
            m_use_synthetic(rhs.m_use_synthetic)
        {
        }
        
        ValueImpl &
        operator = (const ValueImpl &rhs)
        {
            if (this != &rhs)
            {
                m_opaque_sp = rhs.m_opaque_sp;
                m_use_dynamic = rhs.m_use_dynamic;
                m_use_synthetic = rhs.m_use_synthetic;
            }
            return *this;
        }
        
        bool
        IsValid ()
        {
            return m_opaque_sp.get() != NULL;
        }
        
        lldb::ValueObjectSP
        GetRootSP ()
        {
            return m_opaque_sp;
        }
        
        lldb::ValueObjectSP
        GetSP ()
        {
            if (!m_opaque_sp)
                return m_opaque_sp;
            lldb::ValueObjectSP value_sp = m_opaque_sp;
            if (value_sp->GetDynamicValue(m_use_dynamic))
                value_sp = value_sp->GetDynamicValue(m_use_dynamic);
            if (value_sp->GetSyntheticValue(m_use_synthetic))
                value_sp = value_sp->GetSyntheticValue(m_use_synthetic);
            return value_sp;
        }
        
        void
        SetUseDynamic (lldb::DynamicValueType use_dynamic)
        {
            m_use_dynamic = use_dynamic;<commit_msg>The SBValue impl class's GetSP can now fetch the dynamic type or the synthetic children - which it may have to compute.  Thus it needs to take the API lock.<commit_after>//===-- SBValue.cpp ---------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "lldb/lldb-python.h"

#include "lldb/API/SBValue.h"

#include "lldb/API/SBDeclaration.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBTypeFilter.h"
#include "lldb/API/SBTypeFormat.h"
#include "lldb/API/SBTypeSummary.h"
#include "lldb/API/SBTypeSynthetic.h"

#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Declaration.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"

#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBExpressionOptions.h"
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBTarget.h"
#include "lldb/API/SBThread.h"

using namespace lldb;
using namespace lldb_private;

namespace {
    class ValueImpl
    {
    public:
        ValueImpl ()
        {
        }
        
        ValueImpl (lldb::ValueObjectSP opaque_sp,
                   lldb::DynamicValueType use_dynamic,
                   bool use_synthetic) :
            m_opaque_sp(opaque_sp),
            m_use_dynamic(use_dynamic),
            m_use_synthetic(use_synthetic)
        {
        }
        
        ValueImpl (const ValueImpl& rhs) :
            m_opaque_sp(rhs.m_opaque_sp),
            m_use_dynamic(rhs.m_use_dynamic),
            m_use_synthetic(rhs.m_use_synthetic)
        {
        }
        
        ValueImpl &
        operator = (const ValueImpl &rhs)
        {
            if (this != &rhs)
            {
                m_opaque_sp = rhs.m_opaque_sp;
                m_use_dynamic = rhs.m_use_dynamic;
                m_use_synthetic = rhs.m_use_synthetic;
            }
            return *this;
        }
        
        bool
        IsValid ()
        {
            return m_opaque_sp.get() != NULL;
        }
        
        lldb::ValueObjectSP
        GetRootSP ()
        {
            return m_opaque_sp;
        }
        
        lldb::ValueObjectSP
        GetSP ()
        {
            if (!m_opaque_sp)
                return m_opaque_sp;
            lldb::ValueObjectSP value_sp = m_opaque_sp;
            
            Mutex::Locker api_lock;
            Target *target = value_sp->GetTargetSP().get();
            if (target)
                api_lock.Lock(target->GetAPIMutex());
            
            if (value_sp->GetDynamicValue(m_use_dynamic))
                value_sp = value_sp->GetDynamicValue(m_use_dynamic);
            if (value_sp->GetSyntheticValue(m_use_synthetic))
                value_sp = value_sp->GetSyntheticValue(m_use_synthetic);
            return value_sp;
        }
        
        void
        SetUseDynamic (lldb::DynamicValueType use_dynamic)
        {
            m_use_dynamic = use_dynamic;
{'fraction_non_alphanumeric': 0.1465600441196746, 'fraction_numerical': 0.0, 'mean_word_length': 1.9644462607274213, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2322009', 'n_tokens_mistral': 2490, 'n_tokens_neox': 2460, 'n_words': 385}