diff options
author | Jim Ingham <jingham@apple.com> | 2016-09-22 22:00:59 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2016-09-22 22:00:59 +0000 |
commit | 778ef392940c6ff5cf44c2f2b248c48390d274dd (patch) | |
tree | 44c9316ce13f43fe40e809559e15bacef3d46926 /lldb/source/Target/ThreadSpec.cpp | |
parent | 547ebad0b9843b3a5416195fd787281c8e8e7bd3 (diff) | |
download | bcm5719-llvm-778ef392940c6ff5cf44c2f2b248c48390d274dd.tar.gz bcm5719-llvm-778ef392940c6ff5cf44c2f2b248c48390d274dd.zip |
Serilize the thread options within the breakpoint options.
llvm-svn: 282205
Diffstat (limited to 'lldb/source/Target/ThreadSpec.cpp')
-rw-r--r-- | lldb/source/Target/ThreadSpec.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lldb/source/Target/ThreadSpec.cpp b/lldb/source/Target/ThreadSpec.cpp index 1d217e00035..c7eec078612 100644 --- a/lldb/source/Target/ThreadSpec.cpp +++ b/lldb/source/Target/ThreadSpec.cpp @@ -12,11 +12,16 @@ // Other libraries and framework includes // Project includes #include "lldb/Target/Thread.h" +#include "lldb/Core/StructuredData.h" #include "lldb/Target/ThreadSpec.h" using namespace lldb; using namespace lldb_private; +const char *ThreadSpec::g_option_names[static_cast<uint32_t>( + ThreadSpec::OptionNames::LastOptionName)]{"Index", "ID", "Name", + "QueueName"}; + ThreadSpec::ThreadSpec() : m_index(UINT32_MAX), m_tid(LLDB_INVALID_THREAD_ID), m_name(), m_queue_name() {} @@ -33,6 +38,52 @@ const ThreadSpec &ThreadSpec::operator=(const ThreadSpec &rhs) { return *this; } +std::unique_ptr<ThreadSpec> ThreadSpec::CreateFromStructuredData( + const StructuredData::Dictionary &spec_dict, Error &error) { + uint32_t index = UINT32_MAX; + lldb::tid_t tid = LLDB_INVALID_THREAD_ID; + std::string name; + std::string queue_name; + + std::unique_ptr<ThreadSpec> thread_spec_up(new ThreadSpec()); + bool success = spec_dict.GetValueForKeyAsInteger( + GetKey(OptionNames::ThreadIndex), index); + if (success) + thread_spec_up->SetIndex(index); + + success = + spec_dict.GetValueForKeyAsInteger(GetKey(OptionNames::ThreadID), tid); + if (success) + thread_spec_up->SetTID(tid); + + success = + spec_dict.GetValueForKeyAsString(GetKey(OptionNames::ThreadName), name); + if (success) + thread_spec_up->SetName(name.c_str()); + + success = spec_dict.GetValueForKeyAsString(GetKey(OptionNames::ThreadName), + queue_name); + if (success) + thread_spec_up->SetQueueName(queue_name.c_str()); + + return thread_spec_up; +} + +StructuredData::ObjectSP ThreadSpec::SerializeToStructuredData() { + StructuredData::DictionarySP data_dict_sp(new StructuredData::Dictionary()); + + if (m_index != UINT32_MAX) + data_dict_sp->AddIntegerItem(GetKey(OptionNames::ThreadIndex), m_index); + if (m_tid != LLDB_INVALID_THREAD_ID) + data_dict_sp->AddIntegerItem(GetKey(OptionNames::ThreadID), m_tid); + if (!m_name.empty()) + data_dict_sp->AddStringItem(GetKey(OptionNames::ThreadName), m_name); + if (!m_queue_name.empty()) + data_dict_sp->AddStringItem(GetKey(OptionNames::QueueName), m_queue_name); + + return data_dict_sp; +} + const char *ThreadSpec::GetName() const { return m_name.empty() ? nullptr : m_name.c_str(); } |