blob: 7d1f070305a1074c3cd387a2ddba6f86f1edbc23 [file] [log] [blame]
Jason Molenda8280cbe2010-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
13#include "lldb/lldb-private.h"
Jason Molenda800d11d2010-11-04 00:53:20 +000014#include "lldb/lldb-types.h"
Jason Molenda8280cbe2010-10-25 11:12:07 +000015#include "lldb/Target/Unwind.h"
16#include "lldb/Symbol/FuncUnwinders.h"
17#include "lldb/Symbol/UnwindPlan.h"
18#include "RegisterContextLLDB.h"
19#include "lldb/Target/RegisterContext.h"
20#include <vector>
21
22
23namespace lldb_private {
24
25class UnwindLLDB : public lldb_private::Unwind
26{
27public:
28 UnwindLLDB (lldb_private::Thread &thread);
29
30 virtual
31 ~UnwindLLDB() { }
32
33 void
34 Clear()
35 {
36 m_frames.clear();
37 }
38
39 virtual uint32_t
40 GetFrameCount();
41
42 bool
43 GetFrameInfoAtIndex (uint32_t frame_idx,
44 lldb::addr_t& cfa,
45 lldb::addr_t& start_pc);
46
Greg Clayton08d7d3a2011-01-06 22:15:06 +000047 lldb::RegisterContextSP
Jason Molenda8280cbe2010-10-25 11:12:07 +000048 CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
49
50private:
51 struct Cursor
52 {
53 lldb::addr_t start_pc; // The start address of the function/symbol for this frame - current pc if unknown
54 lldb::addr_t cfa; // The canonical frame address for this stack frame
55 lldb_private::SymbolContext sctx; // A symbol context we'll contribute to & provide to the StackFrame creation
56 lldb::RegisterContextSP reg_ctx; // These are all RegisterContextLLDB's
57
58 Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx() { }
Jason Molendad6ef16a2010-11-09 01:21:22 +000059 private:
Jason Molendaa6b71de2010-11-04 09:40:56 +000060 DISALLOW_COPY_AND_ASSIGN (Cursor);
Jason Molenda8280cbe2010-10-25 11:12:07 +000061 };
62
Jason Molenda800d11d2010-11-04 00:53:20 +000063 typedef lldb::SharedPtr<Cursor>::Type CursorSP;
64 std::vector<CursorSP> m_frames;
Jason Molenda8280cbe2010-10-25 11:12:07 +000065
Jason Molenda1da513b2010-11-09 02:31:21 +000066 bool AddOneMoreFrame ();
67 bool AddFirstFrame ();
68
Jason Molenda8280cbe2010-10-25 11:12:07 +000069 //------------------------------------------------------------------
70 // For UnwindLLDB only
71 //------------------------------------------------------------------
72 DISALLOW_COPY_AND_ASSIGN (UnwindLLDB);
73};
74
Greg Claytonfd119992011-01-07 06:08:19 +000075} // namespace lldb_private
Jason Molenda8280cbe2010-10-25 11:12:07 +000076
77#endif // lldb_UnwindLLDB_h_