Greg Clayton e576ab2996 All UnwindPlan objects are now passed around as shared pointers.
ArchDefaultUnwindPlan plug-in interfaces are now cached per architecture 
instead of being leaked for every frame.

Split the ArchDefaultUnwindPlan_x86 into ArchDefaultUnwindPlan_x86_64 and
ArchDefaultUnwindPlan_i386 interfaces.

There were sporadic crashes that were due to something leaking or being 
destroyed when doing stack crawls. This patch should clear up these issues.

llvm-svn: 125541
2011-02-15 00:19:15 +00:00

78 lines
2.1 KiB
C++

//===-- UnwindLLDB.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_UnwindLLDB_h_
#define lldb_UnwindLLDB_h_
#include <vector>
#include "lldb/lldb-include.h"
#include "lldb/Symbol/FuncUnwinders.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Unwind.h"
#include "RegisterContextLLDB.h"
namespace lldb_private {
class UnwindLLDB : public lldb_private::Unwind
{
public:
UnwindLLDB (lldb_private::Thread &thread);
virtual
~UnwindLLDB() { }
void
Clear()
{
m_frames.clear();
}
virtual uint32_t
GetFrameCount();
bool
GetFrameInfoAtIndex (uint32_t frame_idx,
lldb::addr_t& cfa,
lldb::addr_t& start_pc);
lldb::RegisterContextSP
CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
private:
struct Cursor
{
lldb::addr_t start_pc; // The start address of the function/symbol for this frame - current pc if unknown
lldb::addr_t cfa; // The canonical frame address for this stack frame
lldb_private::SymbolContext sctx; // A symbol context we'll contribute to & provide to the StackFrame creation
RegisterContextLLDB::SharedPtr reg_ctx; // These are all RegisterContextLLDB's
Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx() { }
private:
DISALLOW_COPY_AND_ASSIGN (Cursor);
};
typedef lldb::SharedPtr<Cursor>::Type CursorSP;
std::vector<CursorSP> m_frames;
bool AddOneMoreFrame ();
bool AddFirstFrame ();
//------------------------------------------------------------------
// For UnwindLLDB only
//------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (UnwindLLDB);
};
} // namespace lldb_private
#endif // lldb_UnwindLLDB_h_