summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Utility
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-01-29 20:56:30 +0000
committerGreg Clayton <gclayton@apple.com>2012-01-29 20:56:30 +0000
commite1cd1be6d64cde1765336489d05d71cd2785f15a (patch)
treeb387c4c316a696ab74c5dbf3a780224544076284 /lldb/source/Plugins/Process/Utility
parent3f09de6442ebf51b80359e3639d863a3945170dd (diff)
downloadbcm5719-llvm-e1cd1be6d64cde1765336489d05d71cd2785f15a.tar.gz
bcm5719-llvm-e1cd1be6d64cde1765336489d05d71cd2785f15a.zip
Switching back to using std::tr1::shared_ptr. We originally switched away
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
Diffstat (limited to 'lldb/source/Plugins/Process/Utility')
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp16
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h2
-rw-r--r--lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp47
-rw-r--r--lldb/source/Plugins/Process/Utility/UnwindLLDB.h10
4 files changed, 41 insertions, 34 deletions
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index 3dc21027be8..3ae19f9f511 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -126,7 +126,7 @@ RegisterContextLLDB::InitializeZerothFrame()
{
m_current_offset = frame_sp->GetFrameCodeAddress().GetOffset() - m_start_pc.GetOffset();
}
- else if (frame_sp->GetFrameCodeAddress().GetModule() == m_start_pc.GetModule())
+ else if (frame_sp->GetFrameCodeAddress().GetModulePtr() == m_start_pc.GetModulePtr())
{
// This means that whatever symbol we kicked up isn't really correct
// as no should cross section boundaries... We really should NULL out
@@ -284,7 +284,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
// If we don't have a Module for some reason, we're not going to find symbol/function information - just
// stick in some reasonable defaults and hope we can unwind past this frame.
- if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL)
+ if (!m_current_pc.IsValid() || m_current_pc.GetModulePtr() == NULL)
{
if (log)
{
@@ -397,7 +397,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
}
// We require that eSymbolContextSymbol be successfully filled in or this context is of no use to us.
- if ((m_current_pc.GetModule()->ResolveSymbolContextForAddress (m_current_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
+ if ((m_current_pc.GetModulePtr()->ResolveSymbolContextForAddress (m_current_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
{
m_sym_ctx_valid = true;
}
@@ -436,7 +436,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
temporary_pc.SetOffset(m_current_pc.GetOffset() - 1);
m_sym_ctx.Clear();
m_sym_ctx_valid = false;
- if ((m_current_pc.GetModule()->ResolveSymbolContextForAddress (temporary_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
+ if ((m_current_pc.GetModulePtr()->ResolveSymbolContextForAddress (temporary_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
{
m_sym_ctx_valid = true;
}
@@ -619,13 +619,13 @@ UnwindPlanSP
RegisterContextLLDB::GetFastUnwindPlanForFrame ()
{
UnwindPlanSP unwind_plan_sp;
- if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL || m_current_pc.GetModule()->GetObjectFile() == NULL)
+ if (!m_current_pc.IsValid() || m_current_pc.GetModulePtr() == NULL || m_current_pc.GetModulePtr()->GetObjectFile() == NULL)
return unwind_plan_sp;
if (IsFrameZero ())
return unwind_plan_sp;
- FuncUnwindersSP func_unwinders_sp (m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx));
+ FuncUnwindersSP func_unwinders_sp (m_current_pc.GetModulePtr()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx));
if (!func_unwinders_sp)
return unwind_plan_sp;
@@ -712,7 +712,7 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame ()
}
// No Module for the current pc, try using the architecture default unwind.
- if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL || m_current_pc.GetModule()->GetObjectFile() == NULL)
+ if (!m_current_pc.IsValid() || m_current_pc.GetModulePtr() == NULL || m_current_pc.GetModulePtr()->GetObjectFile() == NULL)
{
m_frame_type = eNormalFrame;
return arch_default_unwind_plan_sp;
@@ -721,7 +721,7 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame ()
FuncUnwindersSP func_unwinders_sp;
if (m_sym_ctx_valid)
{
- func_unwinders_sp = m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx);
+ func_unwinders_sp = m_current_pc.GetModulePtr()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx);
}
// No FuncUnwinders available for this pc, try using architectural default unwind.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h
index a578fd779fe..cdb0ccbc325 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h
@@ -25,7 +25,7 @@ class UnwindLLDB;
class RegisterContextLLDB : public lldb_private::RegisterContext
{
public:
- typedef lldb::SharedPtr<RegisterContextLLDB>::Type SharedPtr;
+ typedef SHARED_PTR(RegisterContextLLDB) SharedPtr;
RegisterContextLLDB (lldb_private::Thread &thread,
const SharedPtr& next_frame,
diff --git a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp b/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp
index 954ad8b3283..bf71b008bd5 100644
--- a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp
+++ b/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp
@@ -69,10 +69,10 @@ UnwindLLDB::AddFirstFrame ()
{
// First, set up the 0th (initial) frame
CursorSP first_cursor_sp(new Cursor ());
- RegisterContextLLDBSharedPtr reg_ctx_sp (new RegisterContextLLDB (m_thread,
- RegisterContextLLDBSharedPtr(),
- first_cursor_sp->sctx,
- 0, *this));
+ RegisterContextLLDBSP reg_ctx_sp (new RegisterContextLLDB (m_thread,
+ RegisterContextLLDBSP(),
+ first_cursor_sp->sctx,
+ 0, *this));
if (reg_ctx_sp.get() == NULL)
return false;
@@ -87,7 +87,7 @@ UnwindLLDB::AddFirstFrame ()
// Everything checks out, so release the auto pointer value and let the
// cursor own it in its shared pointer
- first_cursor_sp->reg_ctx = reg_ctx_sp;
+ first_cursor_sp->reg_ctx_lldb_sp = reg_ctx_sp;
m_frames.push_back (first_cursor_sp);
return true;
}
@@ -104,10 +104,11 @@ UnwindLLDB::AddOneMoreFrame (ABI *abi)
return false;
uint32_t cur_idx = m_frames.size ();
- RegisterContextLLDBSharedPtr reg_ctx_sp(new RegisterContextLLDB (m_thread,
- m_frames[cur_idx - 1]->reg_ctx,
- cursor_sp->sctx,
- cur_idx, *this));
+ RegisterContextLLDBSP reg_ctx_sp(new RegisterContextLLDB (m_thread,
+ m_frames[cur_idx - 1]->reg_ctx_lldb_sp,
+ cursor_sp->sctx,
+ cur_idx,
+ *this));
if (reg_ctx_sp.get() == NULL)
return false;
@@ -171,7 +172,7 @@ UnwindLLDB::AddOneMoreFrame (ABI *abi)
}
}
}
- cursor_sp->reg_ctx = reg_ctx_sp;
+ cursor_sp->reg_ctx_lldb_sp = reg_ctx_sp;
m_frames.push_back (cursor_sp);
return true;
}
@@ -218,21 +219,27 @@ UnwindLLDB::DoCreateRegisterContextForFrame (StackFrame *frame)
ABI *abi = m_thread.GetProcess().GetABI().get();
- while (idx >= m_frames.size() && AddOneMoreFrame (abi))
- ;
+ while (idx >= m_frames.size())
+ {
+ if (!AddOneMoreFrame (abi))
+ break;
+ }
- if (idx < m_frames.size ())
- reg_ctx_sp = m_frames[idx]->reg_ctx;
+ const uint32_t num_frames = m_frames.size();
+ if (idx < num_frames)
+ {
+ Cursor *frame_cursor = m_frames[idx].get();
+ reg_ctx_sp = frame_cursor->reg_ctx_lldb_sp->shared_from_this();
+ }
return reg_ctx_sp;
}
-UnwindLLDB::RegisterContextLLDBSharedPtr
+UnwindLLDB::RegisterContextLLDBSP
UnwindLLDB::GetRegisterContextForFrameNum (uint32_t frame_num)
{
- RegisterContextLLDBSharedPtr reg_ctx_sp;
- if (frame_num >= m_frames.size())
- return reg_ctx_sp;
- reg_ctx_sp = m_frames[frame_num]->reg_ctx;
+ RegisterContextLLDBSP reg_ctx_sp;
+ if (frame_num < m_frames.size())
+ reg_ctx_sp = m_frames[frame_num]->reg_ctx_lldb_sp;
return reg_ctx_sp;
}
@@ -244,7 +251,7 @@ UnwindLLDB::SearchForSavedLocationForRegister (uint32_t lldb_regnum, lldb_privat
return false;
while (frame_num >= 0)
{
- if (m_frames[frame_num]->reg_ctx->SavedLocationForRegister (lldb_regnum, regloc, false))
+ if (m_frames[frame_num]->reg_ctx_lldb_sp->SavedLocationForRegister (lldb_regnum, regloc, false))
return true;
frame_num--;
}
diff --git a/lldb/source/Plugins/Process/Utility/UnwindLLDB.h b/lldb/source/Plugins/Process/Utility/UnwindLLDB.h
index ec9271ba8da..b9352b61b8b 100644
--- a/lldb/source/Plugins/Process/Utility/UnwindLLDB.h
+++ b/lldb/source/Plugins/Process/Utility/UnwindLLDB.h
@@ -69,11 +69,11 @@ protected:
lldb::RegisterContextSP
DoCreateRegisterContextForFrame (lldb_private::StackFrame *frame);
- typedef lldb::SharedPtr<lldb_private::RegisterContextLLDB>::Type RegisterContextLLDBSharedPtr;
+ 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.
- RegisterContextLLDBSharedPtr
+ RegisterContextLLDBSP
GetRegisterContextForFrameNum (uint32_t frame_num);
// Iterate over the RegisterContextLLDB's in our m_frames vector, look for the first one that
@@ -89,14 +89,14 @@ private:
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
- RegisterContextLLDBSharedPtr reg_ctx; // These are all RegisterContextLLDB's
+ RegisterContextLLDBSP reg_ctx_lldb_sp; // These are all RegisterContextLLDB's
- Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx() { }
+ Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx_lldb_sp() { }
private:
DISALLOW_COPY_AND_ASSIGN (Cursor);
};
- typedef lldb::SharedPtr<Cursor>::Type CursorSP;
+ typedef SHARED_PTR(Cursor) CursorSP;
std::vector<CursorSP> m_frames;
bool AddOneMoreFrame (ABI *abi);
OpenPOWER on IntegriCloud