forked from OSchip/llvm-project
Broadcast an event when the selected thread is changed.
<rdar://problem/10976636> llvm-svn: 169810
This commit is contained in:
parent
c953a6a5eb
commit
c3faa19577
|
@ -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 *
|
||||
|
|
|
@ -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 ();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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,9 +586,21 @@ 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)
|
||||
{
|
||||
|
|
|
@ -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 |
|
||||
|
|
Loading…
Reference in New Issue