blob: 86665fd17b13a7a41fc83fe9dd372ac1b53bb33a [file] [log] [blame]
Jason Molenda02706c32013-11-08 04:59:54 +00001//===-- 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
20using namespace lldb;
21using namespace lldb_private;
22
23HistoryUnwind::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
34HistoryUnwind::~HistoryUnwind ()
35{
36}
37
38void
39HistoryUnwind::DoClear ()
40{
41 Mutex::Locker locker(m_unwind_mutex);
42 m_pcs.clear();
43 m_stop_id_is_valid = false;
44}
45
46lldb::RegisterContextSP
47HistoryUnwind::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
62bool
63HistoryUnwind::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
75uint32_t
76HistoryUnwind::DoGetFrameCount ()
77{
78 return m_pcs.size();
79}