Make ThreadList::GetSelectedThread() select and return the 0th thread if there's no

currently selected thread.  And update the call sites accordingly.

llvm-svn: 138577
This commit is contained in:
Johnny Chen 2011-08-25 19:38:34 +00:00
parent 1b7f49c2d6
commit bbfa68b090
6 changed files with 5 additions and 16 deletions

View File

@ -45,6 +45,8 @@ public:
void
AddThread (lldb::ThreadSP &thread_sp);
// Return the selected thread if there is one. Otherwise, return the thread
// selected at index 0.
lldb::ThreadSP
GetSelectedThread ();

View File

@ -346,8 +346,6 @@ Debugger::GetSelectedExecutionContext ()
if (exe_ctx.process && exe_ctx.process->IsRunning() == false)
{
exe_ctx.thread = exe_ctx.process->GetThreadList().GetSelectedThread().get();
if (exe_ctx.thread == NULL)
exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get();
if (exe_ctx.thread)
{
exe_ctx.frame = exe_ctx.thread->GetSelectedFrame().get();

View File

@ -2230,13 +2230,6 @@ CommandInterpreter::UpdateExecutionContext (ExecutionContext *override_context)
if (m_exe_ctx.process && m_exe_ctx.process->IsAlive() && !m_exe_ctx.process->IsRunning())
{
m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetSelectedThread().get();
if (m_exe_ctx.thread == NULL)
{
m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get();
// If we didn't have a selected thread, select one here.
if (m_exe_ctx.thread != NULL)
m_exe_ctx.process->GetThreadList().SetSelectedThreadByID(m_exe_ctx.thread->GetID());
}
if (m_exe_ctx.thread)
{
m_exe_ctx.frame = m_exe_ctx.thread->GetSelectedFrame().get();

View File

@ -25,8 +25,6 @@ bool lldb_private::InferiorCallMmap(Process *process, addr_t &allocated_addr,
addr_t addr, addr_t length, unsigned prot,
unsigned flags, addr_t fd, addr_t offset) {
Thread *thread = process->GetThreadList().GetSelectedThread().get();
if (thread == NULL)
thread = process->GetThreadList().GetThreadAtIndex(0).get();
if (thread == NULL)
return false;
@ -129,7 +127,7 @@ bool lldb_private::InferiorCallMunmap(Process *process, addr_t addr,
addr_t length) {
Thread *thread = process->GetThreadList().GetSelectedThread().get();
if (thread == NULL)
thread = process->GetThreadList().GetThreadAtIndex(0).get();
return false;
const bool append = true;
const bool include_symbols = true;

View File

@ -1138,8 +1138,6 @@ Process::LoadImage (const FileSpec &image_spec, Error &error)
if (error.Success())
{
ThreadSP thread_sp(GetThreadList ().GetSelectedThread());
if (thread_sp == NULL)
thread_sp = GetThreadList ().GetThreadAtIndex(0, true);
if (thread_sp)
{
@ -1205,8 +1203,6 @@ Process::UnloadImage (uint32_t image_token)
if (error.Success())
{
ThreadSP thread_sp(GetThreadList ().GetSelectedThread());
if (thread_sp == NULL)
thread_sp = GetThreadList ().GetThreadAtIndex(0, true);
if (thread_sp)
{

View File

@ -545,6 +545,8 @@ ThreadSP
ThreadList::GetSelectedThread ()
{
Mutex::Locker locker(m_threads_mutex);
if (m_selected_tid == LLDB_INVALID_THREAD_ID)
SetSelectedThreadByID(m_threads[0]->GetID());
return FindThreadByID(m_selected_tid);
}