blob: 4659e48596250cd0f77f416ad6340c4b6a4e690a [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
Jason Molendaa8ff5432014-03-06 06:31:18 +000023// Constructor
24
Jason Molenda02706c32013-11-08 04:59:54 +000025HistoryUnwind::HistoryUnwind (Thread &thread,
26 std::vector<lldb::addr_t> pcs,
27 uint32_t stop_id,
28 bool stop_id_is_valid) :
29 Unwind (thread),
30 m_pcs (pcs),
31 m_stop_id (stop_id),
32 m_stop_id_is_valid (stop_id_is_valid)
33{
34}
35
Jason Molendaa8ff5432014-03-06 06:31:18 +000036// Destructor
37
Jason Molenda02706c32013-11-08 04:59:54 +000038HistoryUnwind::~HistoryUnwind ()
39{
40}
41
42void
43HistoryUnwind::DoClear ()
44{
45 Mutex::Locker locker(m_unwind_mutex);
46 m_pcs.clear();
47 m_stop_id_is_valid = false;
48}
49
50lldb::RegisterContextSP
51HistoryUnwind::DoCreateRegisterContextForFrame (StackFrame *frame)
52{
53 RegisterContextSP rctx;
54 if (frame)
55 {
56 addr_t pc = frame->GetFrameCodeAddress().GetLoadAddress (&frame->GetThread()->GetProcess()->GetTarget());
57 if (pc != LLDB_INVALID_ADDRESS)
58 {
59 rctx.reset (new RegisterContextHistory (*frame->GetThread().get(), frame->GetConcreteFrameIndex(),
60 frame->GetThread()->GetProcess()->GetAddressByteSize(), pc));
61 }
62 }
63 return rctx;
64}
65
66bool
67HistoryUnwind::DoGetFrameInfoAtIndex (uint32_t frame_idx, lldb::addr_t& cfa, lldb::addr_t& pc)
68{
69 Mutex::Locker (m_unwind_mutex);
70 if (frame_idx < m_pcs.size())
71 {
72 cfa = frame_idx;
73 pc = m_pcs[frame_idx];
74 return true;
75 }
76 return false;
77}
78
79uint32_t
80HistoryUnwind::DoGetFrameCount ()
81{
82 return m_pcs.size();
83}