diff options
author | Jason Molenda <jmolenda@apple.com> | 2014-03-06 06:31:18 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2014-03-06 06:31:18 +0000 |
commit | a8ff543c280f9f2eee2fac4c5cdacd97b21ea1a1 (patch) | |
tree | fcc91283836c03a11857d4c0903f398c12451301 | |
parent | 568a833f68def7b1dddd4de06c0dd2a7510a0723 (diff) | |
download | bcm5719-llvm-a8ff543c280f9f2eee2fac4c5cdacd97b21ea1a1.tar.gz bcm5719-llvm-a8ff543c280f9f2eee2fac4c5cdacd97b21ea1a1.zip |
When a client asks for a queue pending item's extended backtrace,
hold a strong pointer to that extended backtrace thread in the Process
just like we do for asking a thread's extended backtrace.
Also, give extended backtrace threads an invalid ThreadIndexID number.
We'll still give them valid thread_id's. Clients who want to know the
original thread's IndexID can call GetExtendedBacktraceOriginatingIndexID().
<rdar://problem/16126034>
llvm-svn: 203088
-rw-r--r-- | lldb/include/lldb/Target/QueueItem.h | 4 | ||||
-rw-r--r-- | lldb/include/lldb/Target/Thread.h | 20 | ||||
-rw-r--r-- | lldb/source/API/SBQueueItem.cpp | 19 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/Utility/HistoryThread.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Target/QueueItem.cpp | 12 | ||||
-rw-r--r-- | lldb/source/Target/Thread.cpp | 4 |
7 files changed, 60 insertions, 9 deletions
diff --git a/lldb/include/lldb/Target/QueueItem.h b/lldb/include/lldb/Target/QueueItem.h index 76270da3bee..1e4dbb786b8 100644 --- a/lldb/include/lldb/Target/QueueItem.h +++ b/lldb/include/lldb/Target/QueueItem.h @@ -14,6 +14,7 @@ #include "lldb/lldb-private.h" #include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" #include "lldb/Core/Address.h" #include "lldb/Core/ConstString.h" @@ -213,6 +214,9 @@ public: m_target_queue_label = queue_name; } + lldb::ProcessSP + GetProcessSP (); + protected: lldb::QueueWP m_queue_wp; lldb::QueueItemKind m_kind; diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index 20687e977bf..dc627961823 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -153,7 +153,25 @@ public: static const ThreadPropertiesSP & GetGlobalProperties(); - Thread (Process &process, lldb::tid_t tid); + //------------------------------------------------------------------ + /// Constructor + /// + /// @param [in] process + /// + /// @param [in] tid + /// + /// @param [in] use_invalid_index_id + /// Optional parameter, defaults to false. The only subclass that + /// is likely to set use_invalid_index_id == true is the HistoryThread + /// class. In that case, the Thread we are constructing represents + /// a thread from earlier in the program execution. We may have the + /// tid of the original thread that they represent but we don't want + /// to reuse the IndexID of that thread, or create a new one. If a + /// client wants to know the original thread's IndexID, they should use + /// Thread::GetExtendedBacktraceOriginatingIndexID(). + //------------------------------------------------------------------ + Thread (Process &process, lldb::tid_t tid, bool use_invalid_index_id = false); + virtual ~Thread(); lldb::ProcessSP diff --git a/lldb/source/API/SBQueueItem.cpp b/lldb/source/API/SBQueueItem.cpp index 481d51e5542..5cc37da7990 100644 --- a/lldb/source/API/SBQueueItem.cpp +++ b/lldb/source/API/SBQueueItem.cpp @@ -14,6 +14,7 @@ #include "lldb/API/SBQueueItem.h" #include "lldb/API/SBThread.h" #include "lldb/Core/Address.h" +#include "lldb/Target/Process.h" #include "lldb/Target/QueueItem.h" #include "lldb/Target/Thread.h" @@ -108,12 +109,20 @@ SBQueueItem::GetExtendedBacktraceThread (const char *type) SBThread result; if (m_queue_item_sp) { - ThreadSP thread_sp; - ConstString type_const (type); - thread_sp = m_queue_item_sp->GetExtendedBacktraceThread (type_const); - if (thread_sp) + ProcessSP process_sp = m_queue_item_sp->GetProcessSP(); + Process::StopLocker stop_locker; + if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock())) { - result.SetThread (thread_sp); + ThreadSP thread_sp; + ConstString type_const (type); + thread_sp = m_queue_item_sp->GetExtendedBacktraceThread (type_const); + if (thread_sp) + { + // Save this in the Process' ExtendedThreadList so a strong pointer retains the + // object + process_sp->GetExtendedThreadList().AddThread (thread_sp); + result.SetThread (thread_sp); + } } } return result; diff --git a/lldb/source/Plugins/Process/Utility/HistoryThread.cpp b/lldb/source/Plugins/Process/Utility/HistoryThread.cpp index d045bc7e10d..6b8c7dfd5d3 100644 --- a/lldb/source/Plugins/Process/Utility/HistoryThread.cpp +++ b/lldb/source/Plugins/Process/Utility/HistoryThread.cpp @@ -20,12 +20,14 @@ using namespace lldb; using namespace lldb_private; +// Constructor + HistoryThread::HistoryThread (lldb_private::Process &process, lldb::tid_t tid, std::vector<lldb::addr_t> pcs, uint32_t stop_id, bool stop_id_is_valid) : - Thread (process, tid), + Thread (process, tid, true), m_framelist_mutex(), m_framelist(), m_pcs (pcs), @@ -43,6 +45,8 @@ HistoryThread::HistoryThread (lldb_private::Process &process, log->Printf ("%p HistoryThread::HistoryThread", this); } +// Destructor + HistoryThread::~HistoryThread () { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); diff --git a/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp b/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp index 86665fd17b1..4659e485962 100644 --- a/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp +++ b/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp @@ -20,6 +20,8 @@ using namespace lldb; using namespace lldb_private; +// Constructor + HistoryUnwind::HistoryUnwind (Thread &thread, std::vector<lldb::addr_t> pcs, uint32_t stop_id, @@ -31,6 +33,8 @@ HistoryUnwind::HistoryUnwind (Thread &thread, { } +// Destructor + HistoryUnwind::~HistoryUnwind () { } diff --git a/lldb/source/Target/QueueItem.cpp b/lldb/source/Target/QueueItem.cpp index bb6762829ca..afb5cd028d5 100644 --- a/lldb/source/Target/QueueItem.cpp +++ b/lldb/source/Target/QueueItem.cpp @@ -75,3 +75,15 @@ QueueItem::GetExtendedBacktraceThread (ConstString type) } return return_thread; } + +ProcessSP +QueueItem::GetProcessSP() +{ + ProcessSP process_sp; + QueueSP queue_sp = m_queue_wp.lock (); + if (queue_sp) + { + process_sp = queue_sp->GetProcess(); + } + return process_sp; +} diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index 39f26995288..1550fce86bb 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -250,14 +250,14 @@ Thread::GetStaticBroadcasterClass () return class_name; } -Thread::Thread (Process &process, lldb::tid_t tid) : +Thread::Thread (Process &process, lldb::tid_t tid, bool use_invalid_index_id) : ThreadProperties (false), UserID (tid), Broadcaster(&process.GetTarget().GetDebugger(), Thread::GetStaticBroadcasterClass().AsCString()), m_process_wp (process.shared_from_this()), m_stop_info_sp (), m_stop_info_stop_id (0), - m_index_id (process.GetNextThreadIndexID(tid)), + m_index_id (use_invalid_index_id ? LLDB_INVALID_INDEX32 : process.GetNextThreadIndexID(tid)), m_reg_context_sp (), m_state (eStateUnloaded), m_state_mutex (Mutex::eMutexTypeRecursive), |