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, |
| 24 | std::vector<lldb::addr_t> pcs, |
| 25 | uint32_t stop_id, |
| 26 | bool stop_id_is_valid) : |
| 27 | Thread (process, LLDB_INVALID_THREAD_ID), |
| 28 | m_framelist_mutex(), |
| 29 | m_framelist(), |
| 30 | m_pcs (pcs), |
| 31 | m_stop_id (stop_id), |
Jason Molenda | a7b5afa | 2013-11-15 00:17:32 +0000 | [diff] [blame^] | 32 | m_stop_id_is_valid (stop_id_is_valid), |
| 33 | m_extended_unwind_token (LLDB_INVALID_ADDRESS) |
Jason Molenda | 02706c3 | 2013-11-08 04:59:54 +0000 | [diff] [blame] | 34 | { |
| 35 | 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] | 36 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); |
| 37 | if (log) |
| 38 | log->Printf ("%p HistoryThread::HistoryThread", this); |
Jason Molenda | 02706c3 | 2013-11-08 04:59:54 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | HistoryThread::~HistoryThread () |
| 42 | { |
Jason Molenda | ee87e75 | 2013-11-12 00:09:58 +0000 | [diff] [blame] | 43 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); |
| 44 | if (log) |
| 45 | log->Printf ("%p HistoryThread::~HistoryThread (tid=0x%" PRIx64 ")", this, GetID()); |
| 46 | DestroyThread(); |
Jason Molenda | 02706c3 | 2013-11-08 04:59:54 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | lldb::RegisterContextSP |
| 50 | HistoryThread::GetRegisterContext () |
| 51 | { |
| 52 | RegisterContextSP rctx ; |
| 53 | if (m_pcs.size() > 0) |
| 54 | { |
| 55 | rctx.reset (new RegisterContextHistory (*this, 0, GetProcess()->GetAddressByteSize(), m_pcs[0])); |
| 56 | } |
| 57 | return rctx; |
| 58 | |
| 59 | } |
| 60 | |
| 61 | lldb::RegisterContextSP |
| 62 | HistoryThread::CreateRegisterContextForFrame (StackFrame *frame) |
| 63 | { |
| 64 | return m_unwinder_ap->CreateRegisterContextForFrame (frame); |
| 65 | } |
| 66 | |
| 67 | lldb::StackFrameListSP |
| 68 | HistoryThread::GetStackFrameList () |
| 69 | { |
| 70 | Mutex::Locker (m_framelist_mutex); |
| 71 | if (m_framelist.get() == NULL) |
| 72 | { |
| 73 | m_framelist.reset (new StackFrameList (*this, StackFrameListSP(), true)); |
| 74 | } |
| 75 | |
| 76 | return m_framelist; |
| 77 | } |