due to RTTI worries since llvm and clang don't use RTTI, but I was able to switch back with no issues as far as I can tell. Once the RTTI issue wasn't an issue, we were looking for a way to properly track weak pointers to objects to solve some of the threading issues we have been running into which naturally led us back to std::tr1::weak_ptr. We also wanted the ability to make a shared pointer from just a pointer, which is also easily solved using the std::tr1::enable_shared_from_this class. The main reason for this move back is so we can start properly having weak references to objects. Currently a lldb_private::Thread class has a refrence to its parent lldb_private::Process. This doesn't work well when we now hand out a SBThread object that contains a shared pointer to a lldb_private::Thread as this SBThread can be held onto by external clients and if they end up using one of these objects we can easily crash. So the next task is to start adopting std::tr1::weak_ptr where ever it makes sense which we can do with lldb_private::Debugger, lldb_private::Target, lldb_private::Process, lldb_private::Thread, lldb_private::StackFrame, and many more objects now that they are no longer using intrusive ref counted pointer objects (you can't do std::tr1::weak_ptr functionality with intrusive pointers). llvm-svn: 149207
114 lines
3.9 KiB
C++
114 lines
3.9 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-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() { }
|
|
|
|
protected:
|
|
friend class lldb_private::RegisterContextLLDB;
|
|
|
|
struct RegisterLocation {
|
|
enum RegisterLocationTypes
|
|
{
|
|
eRegisterNotSaved = 0, // register was not preserved by callee. If volatile reg, is unavailable
|
|
eRegisterSavedAtMemoryLocation, // register is saved at a specific word of target mem (target_memory_location)
|
|
eRegisterInRegister, // register is available in a (possible other) register (register_number)
|
|
eRegisterSavedAtHostMemoryLocation, // register is saved at a word in lldb's address space
|
|
eRegisterValueInferred // register val was computed (and is in inferred_value)
|
|
};
|
|
int type;
|
|
union
|
|
{
|
|
lldb::addr_t target_memory_location;
|
|
uint32_t register_number; // in eRegisterKindLLDB register numbering system
|
|
void* host_memory_location;
|
|
uint64_t inferred_value; // eRegisterValueInferred - e.g. stack pointer == cfa + offset
|
|
} location;
|
|
};
|
|
|
|
void
|
|
DoClear()
|
|
{
|
|
m_frames.clear();
|
|
}
|
|
|
|
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 SHARED_PTR(RegisterContextLLDB) RegisterContextLLDBSP;
|
|
|
|
// Needed to retrieve the "next" frame (e.g. frame 2 needs to retrieve frame 1's RegisterContextLLDB)
|
|
// The RegisterContext for frame_num must already exist or this returns an empty shared pointer.
|
|
RegisterContextLLDBSP
|
|
GetRegisterContextForFrameNum (uint32_t frame_num);
|
|
|
|
// Iterate over the RegisterContextLLDB's in our m_frames vector, look for the first one that
|
|
// has a saved location for this reg.
|
|
bool
|
|
SearchForSavedLocationForRegister (uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation ®loc, uint32_t starting_frame_num);
|
|
|
|
|
|
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
|
|
RegisterContextLLDBSP reg_ctx_lldb_sp; // These are all RegisterContextLLDB's
|
|
|
|
Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx_lldb_sp() { }
|
|
private:
|
|
DISALLOW_COPY_AND_ASSIGN (Cursor);
|
|
};
|
|
|
|
typedef SHARED_PTR(Cursor) CursorSP;
|
|
std::vector<CursorSP> m_frames;
|
|
|
|
bool AddOneMoreFrame (ABI *abi);
|
|
bool AddFirstFrame ();
|
|
|
|
//------------------------------------------------------------------
|
|
// For UnwindLLDB only
|
|
//------------------------------------------------------------------
|
|
DISALLOW_COPY_AND_ASSIGN (UnwindLLDB);
|
|
};
|
|
|
|
} // namespace lldb_private
|
|
|
|
#endif // lldb_UnwindLLDB_h_
|