#ifndef lldb_UnwindLLDB_h_
#define lldb_UnwindLLDB_h_
#include <vector>
#include "lldb/lldb-public.h"
#include "lldb/Symbol/FuncUnwinders.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Unwind.h"
namespace lldb_private {
class RegisterContextLLDB;
class UnwindLLDB : public lldb_private::Unwind
{
public:
UnwindLLDB (lldb_private::Thread &thread);
virtual
~UnwindLLDB() { }
enum RegisterSearchResult
{
eRegisterFound = 0,
eRegisterNotFound,
eRegisterIsVolatile
};
protected:
friend class lldb_private::RegisterContextLLDB;
struct RegisterLocation {
enum RegisterLocationTypes
{
eRegisterNotSaved = 0, eRegisterSavedAtMemoryLocation, eRegisterInRegister, eRegisterSavedAtHostMemoryLocation, eRegisterValueInferred };
int type;
union
{
lldb::addr_t target_memory_location;
uint32_t register_number; void* host_memory_location;
uint64_t inferred_value; } location;
};
void
DoClear()
{
m_frames.clear();
m_unwind_complete = false;
}
virtual uint32_t
DoGetFrameCount();
bool
DoGetFrameInfoAtIndex (uint32_t frame_idx,
lldb::addr_t& cfa,
lldb::addr_t& start_pc);
lldb::RegisterContextSP
DoCreateRegisterContextForFrame (lldb_private::StackFrame *frame);
typedef STD_SHARED_PTR(RegisterContextLLDB) RegisterContextLLDBSP;
RegisterContextLLDBSP
GetRegisterContextForFrameNum (uint32_t frame_num);
bool
SearchForSavedLocationForRegister (uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation ®loc, uint32_t starting_frame_num, bool pc_or_return_address_reg);
private:
struct Cursor
{
lldb::addr_t start_pc; lldb::addr_t cfa; lldb_private::SymbolContext sctx; RegisterContextLLDBSP reg_ctx_lldb_sp;
Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx_lldb_sp() { }
private:
DISALLOW_COPY_AND_ASSIGN (Cursor);
};
typedef STD_SHARED_PTR(Cursor) CursorSP;
std::vector<CursorSP> m_frames;
bool m_unwind_complete;
bool AddOneMoreFrame (ABI *abi);
bool AddFirstFrame ();
DISALLOW_COPY_AND_ASSIGN (UnwindLLDB);
};
}
#endif // lldb_UnwindLLDB_h_