1 //===-- ThreadSpec.cpp ----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Target/Thread.h"
11 #include "lldb/Target/ThreadSpec.h"
14 using namespace lldb_private;
16 ThreadSpec::ThreadSpec() :
18 m_tid (LLDB_INVALID_THREAD_ID),
24 ThreadSpec::ThreadSpec (const ThreadSpec &rhs) :
28 m_queue_name(rhs.m_queue_name)
33 ThreadSpec::operator=(const ThreadSpec &rhs)
35 m_index = rhs.m_index;
38 m_queue_name = rhs.m_queue_name;
43 ThreadSpec::GetName () const
48 return m_name.c_str();
52 ThreadSpec::GetQueueName () const
54 if (m_queue_name.empty())
57 return m_queue_name.c_str();
61 ThreadSpec::TIDMatches (Thread &thread) const
63 if (m_tid == LLDB_INVALID_THREAD_ID)
66 lldb::tid_t thread_id = thread.GetID();
67 return TIDMatches (thread_id);
70 ThreadSpec::IndexMatches (Thread &thread) const
72 if (m_index == UINT32_MAX)
74 uint32_t index = thread.GetIndexID();
75 return IndexMatches (index);
78 ThreadSpec::NameMatches (Thread &thread) const
83 const char *name = thread.GetName();
84 return NameMatches (name);
87 ThreadSpec::QueueNameMatches (Thread &thread) const
89 if (m_queue_name.empty())
92 const char *queue_name = thread.GetQueueName();
93 return QueueNameMatches (queue_name);
97 ThreadSpec::ThreadPassesBasicTests (Thread &thread) const
100 if (!HasSpecification())
103 if (!TIDMatches(thread))
106 if (!IndexMatches(thread))
109 if (!NameMatches (thread))
112 if (!QueueNameMatches (thread))
120 ThreadSpec::HasSpecification() const
122 return (m_index != UINT32_MAX || m_tid != LLDB_INVALID_THREAD_ID || !m_name.empty() || !m_queue_name.empty());
125 ThreadSpec::GetDescription (Stream *s, lldb::DescriptionLevel level) const
127 if (!HasSpecification())
129 if (level == eDescriptionLevelBrief)
131 s->PutCString("thread spec: no ");
136 if (level == eDescriptionLevelBrief)
138 s->PutCString("thread spec: yes ");
142 if (GetTID() != LLDB_INVALID_THREAD_ID)
143 s->Printf("tid: 0x%" PRIx64 " ", GetTID());
145 if (GetIndex() != UINT32_MAX)
146 s->Printf("index: %d ", GetIndex());
148 const char *name = GetName();
150 s->Printf ("thread name: \"%s\" ", name);
152 const char *queue_name = GetQueueName();
154 s->Printf ("queue name: \"%s\" ", queue_name);