1 //===-- HistoryThread.cpp ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/lldb-private.h"
12 #include "Plugins/Process/Utility/HistoryUnwind.h"
13 #include "Plugins/Process/Utility/HistoryThread.h"
14 #include "Plugins/Process/Utility/RegisterContextHistory.h"
16 #include "lldb/Core/Log.h"
17 #include "lldb/Target/StackFrameList.h"
18 #include "lldb/Target/Process.h"
21 using namespace lldb_private;
23 HistoryThread::HistoryThread (lldb_private::Process &process,
25 std::vector<lldb::addr_t> pcs,
27 bool stop_id_is_valid) :
28 Thread (process, tid),
33 m_stop_id_is_valid (stop_id_is_valid),
34 m_extended_unwind_token (LLDB_INVALID_ADDRESS),
37 m_originating_unique_thread_id (tid),
38 m_queue_id (LLDB_INVALID_QUEUE_ID)
40 m_unwinder_ap.reset (new HistoryUnwind (*this, pcs, stop_id, stop_id_is_valid));
41 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
43 log->Printf ("%p HistoryThread::HistoryThread", this);
46 HistoryThread::~HistoryThread ()
48 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
50 log->Printf ("%p HistoryThread::~HistoryThread (tid=0x%" PRIx64 ")", this, GetID());
54 lldb::RegisterContextSP
55 HistoryThread::GetRegisterContext ()
57 RegisterContextSP rctx ;
60 rctx.reset (new RegisterContextHistory (*this, 0, GetProcess()->GetAddressByteSize(), m_pcs[0]));
66 lldb::RegisterContextSP
67 HistoryThread::CreateRegisterContextForFrame (StackFrame *frame)
69 return m_unwinder_ap->CreateRegisterContextForFrame (frame);
72 lldb::StackFrameListSP
73 HistoryThread::GetStackFrameList ()
75 Mutex::Locker (m_framelist_mutex);
76 if (m_framelist.get() == NULL)
78 m_framelist.reset (new StackFrameList (*this, StackFrameListSP(), true));
85 HistoryThread::GetExtendedBacktraceOriginatingIndexID ()
87 if (m_originating_unique_thread_id != LLDB_INVALID_THREAD_ID)
89 if (GetProcess()->HasAssignedIndexIDToThread (m_originating_unique_thread_id))
91 return GetProcess()->AssignIndexIDToThread (m_originating_unique_thread_id);
94 return LLDB_INVALID_THREAD_ID;