blob: dfd488d8f9c3cd3e7eeb948856ac99e6af710f85 [file] [log] [blame]
Jason Molendaab4f1922010-10-25 11:12:07 +00001//===-- UnwindLLDB.h --------------------------------------------*- 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#ifndef lldb_UnwindLLDB_h_
11#define lldb_UnwindLLDB_h_
12
Jason Molendaab4f1922010-10-25 11:12:07 +000013#include <vector>
14
Greg Claytone0d378b2011-03-24 21:19:54 +000015#include "lldb/lldb-public.h"
Greg Claytone576ab22011-02-15 00:19:15 +000016#include "lldb/Symbol/FuncUnwinders.h"
17#include "lldb/Symbol/UnwindPlan.h"
18#include "lldb/Target/RegisterContext.h"
19#include "lldb/Target/Unwind.h"
20
21#include "RegisterContextLLDB.h"
Jason Molendaab4f1922010-10-25 11:12:07 +000022
23namespace lldb_private {
24
25class UnwindLLDB : public lldb_private::Unwind
26{
27public:
28 UnwindLLDB (lldb_private::Thread &thread);
29
30 virtual
31 ~UnwindLLDB() { }
32
Jim Ingham8f077162011-10-21 01:49:48 +000033protected:
Jason Molendaab4f1922010-10-25 11:12:07 +000034 void
Jim Ingham8f077162011-10-21 01:49:48 +000035 DoClear()
Jason Molendaab4f1922010-10-25 11:12:07 +000036 {
37 m_frames.clear();
38 }
39
40 virtual uint32_t
Jim Ingham8f077162011-10-21 01:49:48 +000041 DoGetFrameCount();
Jason Molendaab4f1922010-10-25 11:12:07 +000042
43 bool
Jim Ingham8f077162011-10-21 01:49:48 +000044 DoGetFrameInfoAtIndex (uint32_t frame_idx,
Jason Molendaab4f1922010-10-25 11:12:07 +000045 lldb::addr_t& cfa,
46 lldb::addr_t& start_pc);
47
Greg Clayton5ccbd292011-01-06 22:15:06 +000048 lldb::RegisterContextSP
Jim Ingham8f077162011-10-21 01:49:48 +000049 DoCreateRegisterContextForFrame (lldb_private::StackFrame *frame);
Jason Molendaab4f1922010-10-25 11:12:07 +000050
51private:
52 struct Cursor
53 {
54 lldb::addr_t start_pc; // The start address of the function/symbol for this frame - current pc if unknown
55 lldb::addr_t cfa; // The canonical frame address for this stack frame
56 lldb_private::SymbolContext sctx; // A symbol context we'll contribute to & provide to the StackFrame creation
Greg Claytone576ab22011-02-15 00:19:15 +000057 RegisterContextLLDB::SharedPtr reg_ctx; // These are all RegisterContextLLDB's
Jason Molendaab4f1922010-10-25 11:12:07 +000058
59 Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx() { }
Jason Molenda45b49242010-11-09 01:21:22 +000060 private:
Jason Molendafa19c3e72010-11-04 09:40:56 +000061 DISALLOW_COPY_AND_ASSIGN (Cursor);
Jason Molendaab4f1922010-10-25 11:12:07 +000062 };
63
Jason Molenda59762002010-11-04 00:53:20 +000064 typedef lldb::SharedPtr<Cursor>::Type CursorSP;
65 std::vector<CursorSP> m_frames;
Jason Molendaab4f1922010-10-25 11:12:07 +000066
Greg Clayton9b72eb72011-05-24 23:06:02 +000067 bool AddOneMoreFrame (ABI *abi);
Jason Molenda8fed2952010-11-09 02:31:21 +000068 bool AddFirstFrame ();
69
Jason Molendaab4f1922010-10-25 11:12:07 +000070 //------------------------------------------------------------------
71 // For UnwindLLDB only
72 //------------------------------------------------------------------
73 DISALLOW_COPY_AND_ASSIGN (UnwindLLDB);
74};
75
Greg Clayton58be07b2011-01-07 06:08:19 +000076} // namespace lldb_private
Jason Molendaab4f1922010-10-25 11:12:07 +000077
78#endif // lldb_UnwindLLDB_h_