diff options
-rw-r--r-- | lldb/include/lldb/API/SBThread.h | 3 | ||||
-rw-r--r-- | lldb/include/lldb/Target/Thread.h | 4 | ||||
-rw-r--r-- | lldb/include/lldb/Target/ThreadList.h | 7 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectThread.cpp | 10 | ||||
-rw-r--r-- | lldb/source/Target/ThreadList.cpp | 19 | ||||
-rw-r--r-- | lldb/tools/driver/Driver.cpp | 6 |
6 files changed, 32 insertions, 17 deletions
diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h index a77bd5b1787..62abed16452 100644 --- a/lldb/include/lldb/API/SBThread.h +++ b/lldb/include/lldb/API/SBThread.h @@ -26,7 +26,8 @@ public: eBroadcastBitStackChanged = (1 << 0), eBroadcastBitThreadSuspended = (1 << 1), eBroadcastBitThreadResumed = (1 << 2), - eBroadcastBitSelectedFrameChanged = (1 << 3) + eBroadcastBitSelectedFrameChanged = (1 << 3), + eBroadcastBitThreadSelected = (1 << 4) }; static const char * diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index d02d0706a86..8eb320270b3 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -57,6 +57,7 @@ class Thread : public Broadcaster { friend class ThreadEventData; +friend class ThreadList; public: //------------------------------------------------------------------ @@ -67,7 +68,8 @@ public: eBroadcastBitStackChanged = (1 << 0), eBroadcastBitThreadSuspended = (1 << 1), eBroadcastBitThreadResumed = (1 << 2), - eBroadcastBitSelectedFrameChanged = (1 << 3) + eBroadcastBitSelectedFrameChanged = (1 << 3), + eBroadcastBitThreadSelected = (1 << 4) }; static ConstString &GetStaticBroadcasterClass (); diff --git a/lldb/include/lldb/Target/ThreadList.h b/lldb/include/lldb/Target/ThreadList.h index 609cb518c12..85c68633de6 100644 --- a/lldb/include/lldb/Target/ThreadList.h +++ b/lldb/include/lldb/Target/ThreadList.h @@ -51,10 +51,10 @@ public: GetSelectedThread (); bool - SetSelectedThreadByID (lldb::tid_t tid); + SetSelectedThreadByID (lldb::tid_t tid, bool notify = false); bool - SetSelectedThreadByIndexID (uint32_t index_id); + SetSelectedThreadByIndexID (uint32_t index_id, bool notify = false); void Clear(); @@ -131,6 +131,9 @@ public: protected: + void + NotifySelectedThreadChanged (lldb::tid_t tid); + typedef std::vector<lldb::ThreadSP> collection; //------------------------------------------------------------------ // Classes that inherit from Process can see and modify these diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 7098ca26c3b..b5fa5192371 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -1185,17 +1185,9 @@ protected: return false; } - process->GetThreadList().SetSelectedThreadByID(new_thread->GetID()); + process->GetThreadList().SetSelectedThreadByID(new_thread->GetID(), true); result.SetStatus (eReturnStatusSuccessFinishNoResult); - const uint32_t start_frame = 0; - const uint32_t num_frames = 1; - const uint32_t num_frames_with_source = 1; - new_thread->GetStatus (result.GetOutputStream(), - start_frame, - num_frames, - num_frames_with_source); - return result.Succeeded(); } diff --git a/lldb/source/Target/ThreadList.cpp b/lldb/source/Target/ThreadList.cpp index fe38b5769f9..9ce772e5a36 100644 --- a/lldb/source/Target/ThreadList.cpp +++ b/lldb/source/Target/ThreadList.cpp @@ -555,7 +555,7 @@ ThreadList::GetSelectedThread () } bool -ThreadList::SetSelectedThreadByID (lldb::tid_t tid) +ThreadList::SetSelectedThreadByID (lldb::tid_t tid, bool notify) { Mutex::Locker locker(m_threads_mutex); ThreadSP selected_thread_sp(FindThreadByID(tid)); @@ -567,11 +567,14 @@ ThreadList::SetSelectedThreadByID (lldb::tid_t tid) else m_selected_tid = LLDB_INVALID_THREAD_ID; + if (notify) + NotifySelectedThreadChanged(m_selected_tid); + return m_selected_tid != LLDB_INVALID_THREAD_ID; } bool -ThreadList::SetSelectedThreadByIndexID (uint32_t index_id) +ThreadList::SetSelectedThreadByIndexID (uint32_t index_id, bool notify) { Mutex::Locker locker(m_threads_mutex); ThreadSP selected_thread_sp (FindThreadByIndexID(index_id)); @@ -583,10 +586,22 @@ ThreadList::SetSelectedThreadByIndexID (uint32_t index_id) else m_selected_tid = LLDB_INVALID_THREAD_ID; + if (notify) + NotifySelectedThreadChanged(m_selected_tid); + return m_selected_tid != LLDB_INVALID_THREAD_ID; } void +ThreadList::NotifySelectedThreadChanged (lldb::tid_t tid) +{ + ThreadSP selected_thread_sp (FindThreadByID(tid)); + if (selected_thread_sp->EventTypeHasListeners(Thread::eBroadcastBitThreadSelected)) + selected_thread_sp->BroadcastEvent(Thread::eBroadcastBitThreadSelected, + new Thread::ThreadEventData(selected_thread_sp)); +} + +void ThreadList::Update (ThreadList &rhs) { if (this != &rhs) diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 2fbaf4e91aa..38f2a34d5e5 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -986,7 +986,8 @@ Driver::HandleThreadEvent (const SBEvent &event) // reprint the thread status for that thread. using namespace lldb; const uint32_t event_type = event.GetType(); - if (event_type == SBThread::eBroadcastBitStackChanged) + if (event_type == SBThread::eBroadcastBitStackChanged + || event_type == SBThread::eBroadcastBitThreadSelected) { SBThread thread = SBThread::GetThreadFromEvent (event); if (thread.IsValid()) @@ -1302,7 +1303,8 @@ Driver::MainLoop () SBTarget::eBroadcastBitBreakpointChanged); listener.StartListeningForEventClass(m_debugger, SBThread::GetBroadcasterClassName(), - SBThread::eBroadcastBitStackChanged); + SBThread::eBroadcastBitStackChanged | + SBThread::eBroadcastBitThreadSelected); listener.StartListeningForEvents (*m_io_channel_ap, IOChannel::eBroadcastBitHasUserInput | IOChannel::eBroadcastBitUserInterrupt | |