Jason Molenda | 02706c3 | 2013-11-08 04:59:54 +0000 | [diff] [blame] | 1 | //===-- HistoryThread.cpp ---------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "lldb/lldb-private.h" |
| 11 | |
| 12 | #include "Plugins/Process/Utility/HistoryUnwind.h" |
| 13 | #include "Plugins/Process/Utility/HistoryThread.h" |
| 14 | #include "Plugins/Process/Utility/RegisterContextHistory.h" |
| 15 | |
Jason Molenda | ee87e75 | 2013-11-12 00:09:58 +0000 | [diff] [blame] | 16 | #include "lldb/Core/Log.h" |
Jason Molenda | 02706c3 | 2013-11-08 04:59:54 +0000 | [diff] [blame] | 17 | #include "lldb/Target/StackFrameList.h" |
| 18 | #include "lldb/Target/Process.h" |
| 19 | |
| 20 | using namespace lldb; |
| 21 | using namespace lldb_private; |
| 22 | |
| 23 | HistoryThread::HistoryThread (lldb_private::Process &process, |
Jason Molenda | 8ee9cb5 | 2013-11-16 01:24:22 +0000 | [diff] [blame] | 24 | lldb::tid_t tid, |
Jason Molenda | 02706c3 | 2013-11-08 04:59:54 +0000 | [diff] [blame] | 25 | std::vector<lldb::addr_t> pcs, |
| 26 | uint32_t stop_id, |
| 27 | bool stop_id_is_valid) : |
| 28 | Thread (process, LLDB_INVALID_THREAD_ID), |
| 29 | m_framelist_mutex(), |
| 30 | m_framelist(), |
| 31 | m_pcs (pcs), |
| 32 | m_stop_id (stop_id), |
Jason Molenda | a7b5afa | 2013-11-15 00:17:32 +0000 | [diff] [blame] | 33 | m_stop_id_is_valid (stop_id_is_valid), |
Jason Molenda | 8ee9cb5 | 2013-11-16 01:24:22 +0000 | [diff] [blame] | 34 | m_extended_unwind_token (LLDB_INVALID_ADDRESS), |
| 35 | m_queue_name (), |
| 36 | m_thread_name (), |
Jason Molenda | a6e9130 | 2013-11-19 05:44:41 +0000 | [diff] [blame^] | 37 | m_originating_unique_thread_id (tid), |
| 38 | m_queue_id (LLDB_INVALID_QUEUE_ID) |
Jason Molenda | 02706c3 | 2013-11-08 04:59:54 +0000 | [diff] [blame] | 39 | { |
| 40 | m_unwinder_ap.reset (new HistoryUnwind (*this, pcs, stop_id, stop_id_is_valid)); |
Jason Molenda | ee87e75 | 2013-11-12 00:09:58 +0000 | [diff] [blame] | 41 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); |
| 42 | if (log) |
| 43 | log->Printf ("%p HistoryThread::HistoryThread", this); |
Jason Molenda | 02706c3 | 2013-11-08 04:59:54 +0000 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | HistoryThread::~HistoryThread () |
| 47 | { |
Jason Molenda | ee87e75 | 2013-11-12 00:09:58 +0000 | [diff] [blame] | 48 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); |
| 49 | if (log) |
| 50 | log->Printf ("%p HistoryThread::~HistoryThread (tid=0x%" PRIx64 ")", this, GetID()); |
| 51 | DestroyThread(); |
Jason Molenda | 02706c3 | 2013-11-08 04:59:54 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | lldb::RegisterContextSP |
| 55 | HistoryThread::GetRegisterContext () |
| 56 | { |
| 57 | RegisterContextSP rctx ; |
| 58 | if (m_pcs.size() > 0) |
| 59 | { |
| 60 | rctx.reset (new RegisterContextHistory (*this, 0, GetProcess()->GetAddressByteSize(), m_pcs[0])); |
| 61 | } |
| 62 | return rctx; |
| 63 | |
| 64 | } |
| 65 | |
| 66 | lldb::RegisterContextSP |
| 67 | HistoryThread::CreateRegisterContextForFrame (StackFrame *frame) |
| 68 | { |
| 69 | return m_unwinder_ap->CreateRegisterContextForFrame (frame); |
| 70 | } |
| 71 | |
| 72 | lldb::StackFrameListSP |
| 73 | HistoryThread::GetStackFrameList () |
| 74 | { |
| 75 | Mutex::Locker (m_framelist_mutex); |
| 76 | if (m_framelist.get() == NULL) |
| 77 | { |
| 78 | m_framelist.reset (new StackFrameList (*this, StackFrameListSP(), true)); |
| 79 | } |
| 80 | |
| 81 | return m_framelist; |
| 82 | } |
Jason Molenda | 8ee9cb5 | 2013-11-16 01:24:22 +0000 | [diff] [blame] | 83 | |
| 84 | uint32_t |
| 85 | HistoryThread::GetExtendedBacktraceOriginatingIndexID () |
| 86 | { |
| 87 | if (m_originating_unique_thread_id != LLDB_INVALID_THREAD_ID) |
| 88 | { |
| 89 | if (GetProcess()->HasAssignedIndexIDToThread (m_originating_unique_thread_id)) |
| 90 | { |
| 91 | return GetProcess()->AssignIndexIDToThread (m_originating_unique_thread_id); |
| 92 | } |
| 93 | } |
| 94 | return LLDB_INVALID_THREAD_ID; |
| 95 | } |