summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-08-22 02:49:39 +0000
committerGreg Clayton <gclayton@apple.com>2011-08-22 02:49:39 +0000
commit56d9a1b31b590fb4c3e546800866f4cea2f84559 (patch)
tree687e8944f13061581b3f23f1505a7e9eec35dded /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
parentaec683afec76274fbee62f90fc36bf791fd63796 (diff)
downloadbcm5719-llvm-56d9a1b31b590fb4c3e546800866f4cea2f84559.tar.gz
bcm5719-llvm-56d9a1b31b590fb4c3e546800866f4cea2f84559.zip
Added a new plug-in type: lldb_private::OperatingSystem. The operating system
plug-ins are add on plug-ins for the lldb_private::Process class that can add thread contexts that are read from memory. It is common in kernels to have a lot of threads that are not currently executing on any cores (JTAG debugging also follows this sort of thing) and are context switched out whose state is stored in memory data structures. Clients can now subclass the OperatingSystem plug-ins and then make sure their Create functions correcltly only enable themselves when the right binary/target triple are being debugged. The operating system plug-ins get a chance to attach themselves to processes just after launching or attaching and are given a lldb_private::Process object pointer which can be inspected to see if the main executable, target triple, or any shared libraries match a case where the OS plug-in should be used. Currently the OS plug-ins can create new threads, define the register contexts for these threads (which can all be different if desired), and populate and manage the thread info (stop reason, registers in the register context) as the debug session goes on. llvm-svn: 138228
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp47
1 files changed, 18 insertions, 29 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 558a02aeaae..0c02ff6073f 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -390,7 +390,7 @@ ProcessGDBRemote::DoConnectRemote (const char *remote_url)
{
// We have a valid process
SetID (pid);
- UpdateThreadListIfNeeded ();
+ GetThreadList();
if (m_gdb_comm.SendPacketAndWaitForResponse("?", 1, m_last_stop_packet, false))
{
const StateType state = SetThreadStopInfo (m_last_stop_packet);
@@ -1062,43 +1062,32 @@ ProcessGDBRemote::DoResume ()
}
uint32_t
-ProcessGDBRemote::UpdateThreadListIfNeeded ()
+ProcessGDBRemote::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list)
{
// locker will keep a mutex locked until it goes out of scope
LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_THREAD));
if (log && log->GetMask().Test(GDBR_LOG_VERBOSE))
log->Printf ("ProcessGDBRemote::%s (pid = %i)", __FUNCTION__, GetID());
+ // Update the thread list's stop id immediately so we don't recurse into this function.
- Mutex::Locker locker (m_thread_list.GetMutex ());
- const uint32_t stop_id = GetStopID();
- if (m_thread_list.GetSize(false) == 0 || stop_id != m_thread_list.GetStopID())
+ std::vector<lldb::tid_t> thread_ids;
+ bool sequence_mutex_unavailable = false;
+ const size_t num_thread_ids = m_gdb_comm.GetCurrentThreadIDs (thread_ids, sequence_mutex_unavailable);
+ if (num_thread_ids > 0)
{
- // Update the thread list's stop id immediately so we don't recurse into this function.
- ThreadList curr_thread_list (this);
- curr_thread_list.SetStopID(stop_id);
-
- std::vector<lldb::tid_t> thread_ids;
- bool sequence_mutex_unavailable = false;
- const size_t num_thread_ids = m_gdb_comm.GetCurrentThreadIDs (thread_ids, sequence_mutex_unavailable);
- if (num_thread_ids > 0)
+ for (size_t i=0; i<num_thread_ids; ++i)
{
- for (size_t i=0; i<num_thread_ids; ++i)
- {
- tid_t tid = thread_ids[i];
- ThreadSP thread_sp (GetThreadList().FindThreadByID (tid, false));
- if (!thread_sp)
- thread_sp.reset (new ThreadGDBRemote (*this, tid));
- curr_thread_list.AddThread(thread_sp);
- }
- }
-
- if (sequence_mutex_unavailable == false)
- {
- m_thread_list = curr_thread_list;
- SetThreadStopInfo (m_last_stop_packet);
+ tid_t tid = thread_ids[i];
+ ThreadSP thread_sp (old_thread_list.FindThreadByID (tid, false));
+ if (!thread_sp)
+ thread_sp.reset (new ThreadGDBRemote (*this, tid));
+ new_thread_list.AddThread(thread_sp);
}
}
- return GetThreadList().GetSize(false);
+
+ if (sequence_mutex_unavailable == false)
+ SetThreadStopInfo (m_last_stop_packet);
+ return new_thread_list.GetSize(false);
}
@@ -1318,7 +1307,7 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
}
}
if (!handled)
- gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithSignal (*thread_sp, signo));
+ gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithSignal (*thread_sp, signo));
}
else
{
OpenPOWER on IntegriCloud