]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / source / Plugins / Process / Utility / HistoryUnwind.cpp
1 //===-- HistoryUnwind.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/RegisterContextHistory.h"
13 #include "Plugins/Process/Utility/HistoryUnwind.h"
14
15 #include "lldb/Target/StackFrame.h"
16 #include "lldb/Target/Thread.h"
17 #include "lldb/Target/Process.h"
18 #include "lldb/Target/Target.h"
19
20 using namespace lldb;
21 using namespace lldb_private;
22
23 HistoryUnwind::HistoryUnwind (Thread &thread,
24                               std::vector<lldb::addr_t> pcs,
25                               uint32_t stop_id,
26                               bool stop_id_is_valid) :
27         Unwind (thread),
28         m_pcs (pcs),
29         m_stop_id (stop_id),
30         m_stop_id_is_valid (stop_id_is_valid)
31 {
32 }
33
34 HistoryUnwind::~HistoryUnwind ()
35 {
36 }
37
38 void
39 HistoryUnwind::DoClear ()
40 {
41     Mutex::Locker locker(m_unwind_mutex);
42     m_pcs.clear();
43     m_stop_id_is_valid = false;
44 }
45
46 lldb::RegisterContextSP
47 HistoryUnwind::DoCreateRegisterContextForFrame (StackFrame *frame)
48 {
49     RegisterContextSP rctx;
50     if (frame)
51     {
52         addr_t pc = frame->GetFrameCodeAddress().GetLoadAddress (&frame->GetThread()->GetProcess()->GetTarget());
53         if (pc != LLDB_INVALID_ADDRESS)
54         {
55             rctx.reset (new RegisterContextHistory (*frame->GetThread().get(), frame->GetConcreteFrameIndex(), 
56                         frame->GetThread()->GetProcess()->GetAddressByteSize(), pc));
57         }
58     }
59     return rctx;
60 }
61
62 bool
63 HistoryUnwind::DoGetFrameInfoAtIndex (uint32_t frame_idx, lldb::addr_t& cfa, lldb::addr_t& pc)
64 {
65     Mutex::Locker (m_unwind_mutex);
66     if (frame_idx < m_pcs.size())
67     {
68         cfa = frame_idx;
69         pc = m_pcs[frame_idx];
70         return true;
71     }
72     return false;
73 }
74
75 uint32_t
76 HistoryUnwind::DoGetFrameCount ()
77 {
78     return m_pcs.size();
79 }