Jason Molenda | ab4f192 | 2010-10-25 11:12:07 +0000 | [diff] [blame] | 1 | //===-- 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 Molenda | ab4f192 | 2010-10-25 11:12:07 +0000 | [diff] [blame] | 13 | #include <vector> |
| 14 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 15 | #include "lldb/lldb-public.h" |
Greg Clayton | e576ab2 | 2011-02-15 00:19:15 +0000 | [diff] [blame] | 16 | #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 Molenda | ab4f192 | 2010-10-25 11:12:07 +0000 | [diff] [blame] | 22 | |
| 23 | namespace lldb_private { |
| 24 | |
| 25 | class UnwindLLDB : public lldb_private::Unwind |
| 26 | { |
| 27 | public: |
| 28 | UnwindLLDB (lldb_private::Thread &thread); |
| 29 | |
| 30 | virtual |
| 31 | ~UnwindLLDB() { } |
| 32 | |
Jim Ingham | 8f07716 | 2011-10-21 01:49:48 +0000 | [diff] [blame] | 33 | protected: |
Jason Molenda | ab4f192 | 2010-10-25 11:12:07 +0000 | [diff] [blame] | 34 | void |
Jim Ingham | 8f07716 | 2011-10-21 01:49:48 +0000 | [diff] [blame] | 35 | DoClear() |
Jason Molenda | ab4f192 | 2010-10-25 11:12:07 +0000 | [diff] [blame] | 36 | { |
| 37 | m_frames.clear(); |
| 38 | } |
| 39 | |
| 40 | virtual uint32_t |
Jim Ingham | 8f07716 | 2011-10-21 01:49:48 +0000 | [diff] [blame] | 41 | DoGetFrameCount(); |
Jason Molenda | ab4f192 | 2010-10-25 11:12:07 +0000 | [diff] [blame] | 42 | |
| 43 | bool |
Jim Ingham | 8f07716 | 2011-10-21 01:49:48 +0000 | [diff] [blame] | 44 | DoGetFrameInfoAtIndex (uint32_t frame_idx, |
Jason Molenda | ab4f192 | 2010-10-25 11:12:07 +0000 | [diff] [blame] | 45 | lldb::addr_t& cfa, |
| 46 | lldb::addr_t& start_pc); |
| 47 | |
Greg Clayton | 5ccbd29 | 2011-01-06 22:15:06 +0000 | [diff] [blame] | 48 | lldb::RegisterContextSP |
Jim Ingham | 8f07716 | 2011-10-21 01:49:48 +0000 | [diff] [blame] | 49 | DoCreateRegisterContextForFrame (lldb_private::StackFrame *frame); |
Jason Molenda | ab4f192 | 2010-10-25 11:12:07 +0000 | [diff] [blame] | 50 | |
| 51 | private: |
| 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 Clayton | e576ab2 | 2011-02-15 00:19:15 +0000 | [diff] [blame] | 57 | RegisterContextLLDB::SharedPtr reg_ctx; // These are all RegisterContextLLDB's |
Jason Molenda | ab4f192 | 2010-10-25 11:12:07 +0000 | [diff] [blame] | 58 | |
| 59 | Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx() { } |
Jason Molenda | 45b4924 | 2010-11-09 01:21:22 +0000 | [diff] [blame] | 60 | private: |
Jason Molenda | fa19c3e7 | 2010-11-04 09:40:56 +0000 | [diff] [blame] | 61 | DISALLOW_COPY_AND_ASSIGN (Cursor); |
Jason Molenda | ab4f192 | 2010-10-25 11:12:07 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
Jason Molenda | 5976200 | 2010-11-04 00:53:20 +0000 | [diff] [blame] | 64 | typedef lldb::SharedPtr<Cursor>::Type CursorSP; |
| 65 | std::vector<CursorSP> m_frames; |
Jason Molenda | ab4f192 | 2010-10-25 11:12:07 +0000 | [diff] [blame] | 66 | |
Greg Clayton | 9b72eb7 | 2011-05-24 23:06:02 +0000 | [diff] [blame] | 67 | bool AddOneMoreFrame (ABI *abi); |
Jason Molenda | 8fed295 | 2010-11-09 02:31:21 +0000 | [diff] [blame] | 68 | bool AddFirstFrame (); |
| 69 | |
Jason Molenda | ab4f192 | 2010-10-25 11:12:07 +0000 | [diff] [blame] | 70 | //------------------------------------------------------------------ |
| 71 | // For UnwindLLDB only |
| 72 | //------------------------------------------------------------------ |
| 73 | DISALLOW_COPY_AND_ASSIGN (UnwindLLDB); |
| 74 | }; |
| 75 | |
Greg Clayton | 58be07b | 2011-01-07 06:08:19 +0000 | [diff] [blame] | 76 | } // namespace lldb_private |
Jason Molenda | ab4f192 | 2010-10-25 11:12:07 +0000 | [diff] [blame] | 77 | |
| 78 | #endif // lldb_UnwindLLDB_h_ |