We were leaking a stack frame in StackFrameList in Thread.cpp which could

cause extra shared pointer references to one or more modules to be leaked.
This would cause many object files to stay around the life of LLDB, so after
a recompile and rexecution, we would keep adding more and more memory. After
fixing the leak, we found many cases where leaked stack frames were still
being used and causing crashes in the test suite. These are now all resolved.

llvm-svn: 137516
This commit is contained in:
Greg Clayton 2011-08-12 21:40:01 +00:00
parent 2fcc1cfdce
commit 7e9b1fd045
31 changed files with 620 additions and 124 deletions

View File

@ -57,8 +57,43 @@ public:
SectionType
GetSectionType ();
// The following queries can lookup symbol information for a given address.
// An address might refer to code or data from an existing module, or it
// might refer to something on the stack or heap. The following functions
// will only return valid values if the address has been resolved to a code
// or data address using "void SBAddress::SetLoadAddress(...)" or
// "lldb::SBAddress SBTarget::ResolveLoadAddress (...)".
lldb::SBSymbolContext
GetSymbolContext (uint32_t resolve_scope);
// The following functions grab individual objects for a given address and
// are less efficient if you want more than one symbol related objects.
// Use one of the following when you want multiple debug symbol related
// objects for an address:
// lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t resolve_scope);
// lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress &addr, uint32_t resolve_scope);
// One or more bits from the SymbolContextItem enumerations can be logically
// OR'ed together to more efficiently retrieve multiple symbol objects.
lldb::SBModule
GetModule ();
lldb::SBCompileUnit
GetCompileUnit ();
lldb::SBFunction
GetFunction ();
lldb::SBBlock
GetBlock ();
lldb::SBSymbol
GetSymbol ();
lldb::SBLineEntry
GetLineEntry ();
protected:

View File

@ -60,6 +60,7 @@ public:
GetDescription (lldb::SBStream &description);
private:
friend class SBAddress;
friend class SBFrame;
friend class SBSymbolContext;

View File

@ -61,6 +61,7 @@ public:
GetDescription (lldb::SBStream &description);
private:
friend class SBAddress;
friend class SBFrame;
friend class SBSymbolContext;

View File

@ -77,6 +77,7 @@ protected:
#endif
private:
friend class SBAddress;
friend class SBFrame;
friend class SBSymbolContext;

View File

@ -67,6 +67,7 @@ protected:
get ();
private:
friend class SBAddress;
friend class SBCompileUnit;
friend class SBFrame;
friend class SBSymbolContext;

View File

@ -79,6 +79,7 @@ protected:
#endif
private:
friend class SBAddress;
friend class SBFrame;
friend class SBModule;
friend class SBSymbolContext;

View File

@ -48,6 +48,7 @@ public:
GetDescription (lldb::SBStream &description);
protected:
friend class SBAddress;
friend class SBFrame;
friend class SBModule;
friend class SBThread;

View File

@ -496,8 +496,27 @@ public:
///
/// @see SymbolContextScope::CalculateSymbolContext(SymbolContext*)
//------------------------------------------------------------------
void
CalculateSymbolContext (SymbolContext *sc);
uint32_t
CalculateSymbolContext (SymbolContext *sc,
uint32_t resolve_scope = lldb::eSymbolContextEverything);
Module *
CalculateSymbolContextModule ();
CompileUnit *
CalculateSymbolContextCompileUnit ();
Function *
CalculateSymbolContextFunction ();
Block *
CalculateSymbolContextBlock ();
Symbol *
CalculateSymbolContextSymbol ();
bool
CalculateSymbolContextLineEntry (LineEntry &line_entry);
protected:
//------------------------------------------------------------------

View File

@ -475,12 +475,12 @@ private:
}
if (log)
log->Printf("stripping ObjC pointer");
/*
for some reason, C++ can quite easily obtain the type hierarchy for a ValueObject
even if the VO represent a pointer-to-class, as long as the typePtr is right
Objective-C on the other hand cannot really complete an @interface when
the VO refers to a pointer-to-@interface
*/
// For some reason, C++ can quite easily obtain the type hierarchy for a ValueObject
// even if the VO represent a pointer-to-class, as long as the typePtr is right
// Objective-C on the other hand cannot really complete an @interface when
// the VO refers to a pointer-to-@interface
Error error;
ValueObject* target = vobj.Dereference(error).get();
if (error.Fail() || !target)

View File

@ -116,6 +116,9 @@ public:
virtual void
CalculateSymbolContext (SymbolContext* sc);
virtual Module *
CalculateSymbolContextModule ();
void
GetDescription (Stream *s);

View File

@ -107,6 +107,18 @@ public:
virtual void
CalculateSymbolContext(SymbolContext* sc);
virtual Module *
CalculateSymbolContextModule ();
virtual CompileUnit *
CalculateSymbolContextCompileUnit ();
virtual Function *
CalculateSymbolContextFunction ();
virtual Block *
CalculateSymbolContextBlock ();
//------------------------------------------------------------------
/// Check if an offset is in one of the block offset ranges.
///

View File

@ -127,6 +127,12 @@ public:
virtual void
CalculateSymbolContext(SymbolContext* sc);
virtual Module *
CalculateSymbolContextModule ();
virtual CompileUnit *
CalculateSymbolContextCompileUnit ();
//------------------------------------------------------------------
/// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
///

View File

@ -422,6 +422,15 @@ public:
virtual void
CalculateSymbolContext(SymbolContext* sc);
virtual Module *
CalculateSymbolContextModule ();
virtual CompileUnit *
CalculateSymbolContextCompileUnit ();
virtual Function *
CalculateSymbolContextFunction ();
const AddressRange &
GetAddressRange()
{

View File

@ -175,6 +175,12 @@ public:
virtual void
CalculateSymbolContext (SymbolContext *sc);
virtual Module *
CalculateSymbolContextModule ();
virtual Symbol *
CalculateSymbolContextSymbol ();
//------------------------------------------------------------------
/// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
///

View File

@ -87,6 +87,37 @@ public:
virtual void
CalculateSymbolContext (SymbolContext *sc) = 0;
virtual Module *
CalculateSymbolContextModule ()
{
return NULL;
}
virtual CompileUnit *
CalculateSymbolContextCompileUnit ()
{
return NULL;
}
virtual Function *
CalculateSymbolContextFunction ()
{
return NULL;
}
virtual Block *
CalculateSymbolContextBlock ()
{
return NULL;
}
virtual Symbol *
CalculateSymbolContextSymbol ()
{
return NULL;
}
//------------------------------------------------------------------
/// Dump the object's symbolc context to the stream \a s.
///

View File

@ -781,7 +781,7 @@ protected:
plan_stack m_plan_stack; ///< The stack of plans this thread is executing.
plan_stack m_completed_plan_stack; ///< Plans that have been completed by this stop. They get deleted when the thread resumes.
plan_stack m_discarded_plan_stack; ///< Plans that have been discarded by this stop. They get deleted when the thread resumes.
std::auto_ptr<StackFrameList> m_curr_frames_ap; ///< The stack frames that get lazily populated after a thread stops.
lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily populated after a thread stops.
lldb::StackFrameListSP m_prev_frames_sp; ///< The previous stack frames from the last time this thread stopped.
int m_resume_signal; ///< The signal that should be used when continuing this thread.
lldb::StateType m_resume_state; ///< The state that indicates what this thread should do when the process is resumed.

View File

@ -111,12 +111,14 @@ public:
virtual void TracingEnded ();
virtual void Log();
private:
void InitializeTracer();
Process &m_process;
Target &m_target;
Disassembler *m_disassembler;
const ABI *m_abi;
Disassembler *
GetDisassembler ();
TypeFromUser
GetIntPointerType();
std::auto_ptr<Disassembler> m_disassembler_ap;
TypeFromUser m_intptr_type;
std::vector<RegisterValue> m_register_values;
lldb::DataBufferSP m_buffer_sp;

View File

@ -441,6 +441,97 @@ const_pointer_cast(const SharingPtr<U>& r)
return SharingPtr<T>(r, const_cast<T*>(r.get()));
}
template <class T>
class LoggingSharingPtr
: public SharingPtr<T>
{
typedef SharingPtr<T> base;
public:
typedef void (*Callback)(void*, const LoggingSharingPtr&, bool action);
// action: false means increment just happened
// true means decrement is about to happen
private:
Callback cb_;
void* baton_;
public:
LoggingSharingPtr() : cb_(0), baton_(0) {}
LoggingSharingPtr(Callback cb, void* baton)
: cb_(cb), baton_(baton)
{
if (cb_)
cb_(baton_, *this, false);
}
template <class Y>
LoggingSharingPtr(Y* p)
: base(p), cb_(0), baton_(0) {}
template <class Y>
LoggingSharingPtr(Y* p, Callback cb, void* baton)
: base(p), cb_(cb), baton_(baton)
{
if (cb_)
cb_(baton_, *this, false);
}
~LoggingSharingPtr()
{
if (cb_)
cb_(baton_, *this, true);
}
LoggingSharingPtr(const LoggingSharingPtr& p)
: base(p), cb_(p.cb_), baton_(p.baton_)
{
if (cb_)
cb_(baton_, *this, false);
}
LoggingSharingPtr& operator=(const LoggingSharingPtr& p)
{
if (cb_)
cb_(baton_, *this, true);
base::operator=(p);
cb_ = p.cb_;
baton_ = p.baton_;
if (cb_)
cb_(baton_, *this, false);
return *this;
}
void reset()
{
if (cb_)
cb_(baton_, *this, true);
base::reset();
}
template <class Y>
void reset(Y* p)
{
if (cb_)
cb_(baton_, *this, true);
base::reset(p);
if (cb_)
cb_(baton_, *this, false);
}
void SetCallback(Callback cb, void* baton)
{
cb_ = cb;
baton_ = baton;
}
void ClearCallback()
{
cb_ = 0;
baton_ = 0;
}
};
} // namespace lldb
#endif // utility_SharingPtr_h_

View File

@ -64,6 +64,11 @@ namespace lldb {
{
typedef lldb_private::SharingPtr<_Tp> Type;
};
template<typename _Tp>
struct LoggingSharedPtr
{
typedef lldb_private::LoggingSharingPtr<_Tp> Type;
};
} // namespace lldb

View File

@ -228,4 +228,62 @@ SBAddress::GetModule ()
return sb_module;
}
SBSymbolContext
SBAddress::GetSymbolContext (uint32_t resolve_scope)
{
SBSymbolContext sb_sc;
if (m_opaque_ap.get())
m_opaque_ap->CalculateSymbolContext (&sb_sc.ref(), resolve_scope);
return sb_sc;
}
SBCompileUnit
SBAddress::GetCompileUnit ()
{
SBCompileUnit sb_comp_unit;
if (m_opaque_ap.get())
sb_comp_unit.reset(m_opaque_ap->CalculateSymbolContextCompileUnit());
return sb_comp_unit;
}
SBFunction
SBAddress::GetFunction ()
{
SBFunction sb_function;
if (m_opaque_ap.get())
sb_function.reset(m_opaque_ap->CalculateSymbolContextFunction());
return sb_function;
}
SBBlock
SBAddress::GetBlock ()
{
SBBlock sb_block;
if (m_opaque_ap.get())
sb_block.reset(m_opaque_ap->CalculateSymbolContextBlock());
return sb_block;
}
SBSymbol
SBAddress::GetSymbol ()
{
SBSymbol sb_symbol;
if (m_opaque_ap.get())
sb_symbol.reset(m_opaque_ap->CalculateSymbolContextSymbol());
return sb_symbol;
}
SBLineEntry
SBAddress::GetLineEntry ()
{
SBLineEntry sb_line_entry;
if (m_opaque_ap.get())
{
LineEntry line_entry;
if (m_opaque_ap->CalculateSymbolContextLineEntry (line_entry))
sb_line_entry.SetLineEntry (line_entry);
}
return sb_line_entry;
}

View File

@ -727,20 +727,115 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum
return true;
}
void
Address::CalculateSymbolContext (SymbolContext *sc)
uint32_t
Address::CalculateSymbolContext (SymbolContext *sc, uint32_t resolve_scope)
{
sc->Clear();
// Absolute addresses don't have enough information to reconstruct even their target.
if (m_section == NULL)
return;
if (m_section->GetModule())
if (m_section)
{
sc->module_sp = m_section->GetModule()->GetSP();
if (sc->module_sp)
sc->module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextEverything, *sc);
Module *address_module = m_section->GetModule();
if (address_module)
{
sc->module_sp = address_module->GetSP();
if (sc->module_sp)
return sc->module_sp->ResolveSymbolContextForAddress (*this, resolve_scope, *sc);
}
}
return 0;
}
Module *
Address::CalculateSymbolContextModule ()
{
if (m_section)
return m_section->GetModule();
return NULL;
}
CompileUnit *
Address::CalculateSymbolContextCompileUnit ()
{
if (m_section)
{
SymbolContext sc;
sc.module_sp = m_section->GetModule()->GetSP();
if (sc.module_sp)
{
sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextCompUnit, sc);
return sc.comp_unit;
}
}
return NULL;
}
Function *
Address::CalculateSymbolContextFunction ()
{
if (m_section)
{
SymbolContext sc;
sc.module_sp = m_section->GetModule()->GetSP();
if (sc.module_sp)
{
sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextFunction, sc);
return sc.function;
}
}
return NULL;
}
Block *
Address::CalculateSymbolContextBlock ()
{
if (m_section)
{
SymbolContext sc;
sc.module_sp = m_section->GetModule()->GetSP();
if (sc.module_sp)
{
sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextBlock, sc);
return sc.block;
}
}
return NULL;
}
Symbol *
Address::CalculateSymbolContextSymbol ()
{
if (m_section)
{
SymbolContext sc;
sc.module_sp = m_section->GetModule()->GetSP();
if (sc.module_sp)
{
sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextSymbol, sc);
return sc.symbol;
}
}
return NULL;
}
bool
Address::CalculateSymbolContextLineEntry (LineEntry &line_entry)
{
if (m_section)
{
SymbolContext sc;
sc.module_sp = m_section->GetModule()->GetSP();
if (sc.module_sp)
{
sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextLineEntry, sc);
if (sc.line_entry.IsValid())
{
line_entry = sc.line_entry;
return true;
}
}
}
line_entry.Clear();
return false;
}
int

View File

@ -214,6 +214,12 @@ Module::CalculateSymbolContext(SymbolContext* sc)
sc->module_sp = GetSP();
}
Module *
Module::CalculateSymbolContextModule ()
{
return this;
}
void
Module::DumpSymbolContext(Stream *s)
{

View File

@ -707,6 +707,33 @@ ModuleList::RemoveOrphanSharedModules ()
{
return GetSharedModuleList ().RemoveOrphans();
}
//#define ENABLE_MODULE_SP_LOGGING
#if defined (ENABLE_MODULE_SP_LOGGING)
#include "lldb/Core/StreamFile.h"
#include "lldb/Host/Host.h"
static void
ModuleSharedPtrLogger(void* p, const ModuleSP& sp, bool will_decrement)
{
if (sp.get())
{
const char *module_basename = sp->GetFileSpec().GetFilename().GetCString();
// If "p" is set, then it is the basename of a module to watch for. This
// basename MUST be uniqued first by getting it from a ConstString or this
// won't work.
if (p && p != module_basename)
{
return;
}
long use_count = sp.use_count();
if (will_decrement)
--use_count;
printf("\nModuleSP(%p): %c %p {%lu} %s/%s\n", &sp, will_decrement ? '-' : '+', sp.get(), use_count, sp->GetFileSpec().GetDirectory().GetCString(), module_basename);
StreamFile stdout_strm(stdout, false);
Host::Backtrace (stdout_strm, 512);
}
}
#endif
Error
ModuleList::GetSharedModule
@ -783,7 +810,12 @@ ModuleList::GetSharedModule
return error;
else
{
#if defined ENABLE_MODULE_SP_LOGGING
ModuleSP logging_module_sp (new Module (in_file_spec, arch, object_name_ptr, object_offset), ModuleSharedPtrLogger, (void *)ConstString("a.out").GetCString());
module_sp = logging_module_sp;
#else
module_sp.reset (new Module (in_file_spec, arch, object_name_ptr, object_offset));
#endif
// Make sure there are a module and an object file since we can specify
// a valid file path with an architecture that might not be in that file.
// By getting the object file we can guarantee that the architecture matches
@ -874,7 +906,12 @@ ModuleList::GetSharedModule
if (module_sp.get() == NULL)
{
#if defined ENABLE_MODULE_SP_LOGGING
ModuleSP logging_module_sp (new Module (file_spec, arch, object_name_ptr, object_offset), ModuleSharedPtrLogger, 0);
module_sp = logging_module_sp;
#else
module_sp.reset (new Module (file_spec, arch, object_name_ptr, object_offset));
#endif
// Make sure there are a module and an object file since we can specify
// a valid file path with an architecture that might not be in that file.
// By getting the object file we can guarantee that the architecture matches

View File

@ -3260,31 +3260,35 @@ ValueObject::EvaluationPoint::GetExecutionContextScope ()
bool
ValueObject::EvaluationPoint::SyncWithProcessState()
{
// If we're already invalid, we don't need to do anything, and nothing has changed:
if (!m_mod_id.IsValid())
{
// Can't update with an invalid state.
m_needs_update = false;
return false;
}
// If we don't have a process nothing can change.
if (!m_process_sp)
{
m_exe_scope = m_target_sp.get();
return false;
}
// If our stop id is the current stop ID, nothing has changed:
ProcessModID current_mod_id = m_process_sp->GetModID();
if (m_mod_id == current_mod_id)
return false;
// If the current stop id is 0, either we haven't run yet, or the process state has been cleared.
// In either case, we aren't going to be able to sync with the process state.
if (current_mod_id.GetStopID() == 0)
{
m_exe_scope = m_target_sp.get();
return false;
}
m_mod_id = current_mod_id;
m_needs_update = true;
if (m_mod_id.IsValid())
{
if (m_mod_id == current_mod_id)
{
// Everything is already up to date in this object, no need do
// update the execution context scope.
return false;
}
m_mod_id = current_mod_id;
m_needs_update = true;
}
m_exe_scope = m_process_sp.get();
// Something has changed, so we will return true. Now make sure the thread & frame still exist, and if either
@ -3317,12 +3321,10 @@ ValueObject::EvaluationPoint::SyncWithProcessState()
void
ValueObject::EvaluationPoint::SetUpdated ()
{
// this will update the execution context scope and the m_mod_id
SyncWithProcessState();
m_first_update = false;
m_needs_update = false;
if (m_process_sp)
{
m_mod_id = m_process_sp->GetModID();
}
}

View File

@ -386,11 +386,9 @@ ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx,
{
// FIXME: Use the errors Stream for better error reporting.
Process *process = exe_ctx.process;
if (process == NULL)
if (exe_ctx.thread == NULL)
{
errors.Printf("Can't call a function without a process.");
errors.Printf("Can't call a function without a valid thread.");
return NULL;
}

View File

@ -152,6 +152,36 @@ Block::CalculateSymbolContext (SymbolContext* sc)
sc->block = this;
}
Module *
Block::CalculateSymbolContextModule ()
{
if (m_parent_scope)
return m_parent_scope->CalculateSymbolContextModule ();
return NULL;
}
CompileUnit *
Block::CalculateSymbolContextCompileUnit ()
{
if (m_parent_scope)
return m_parent_scope->CalculateSymbolContextCompileUnit ();
return NULL;
}
Function *
Block::CalculateSymbolContextFunction ()
{
if (m_parent_scope)
return m_parent_scope->CalculateSymbolContextFunction ();
return NULL;
}
Block *
Block::CalculateSymbolContextBlock ()
{
return this;
}
void
Block::DumpStopContext
(
@ -225,12 +255,11 @@ Block::DumpStopContext
}
else if (child_inline_call_site)
{
SymbolContext sc;
CalculateSymbolContext(&sc);
if (sc.function)
Function *function = CalculateSymbolContextFunction();
if (function)
{
s->EOL();
s->Indent (sc.function->GetMangled().GetName().AsCString());
s->Indent (function->GetMangled().GetName().AsCString());
if (child_inline_call_site && child_inline_call_site->IsValid())
{
s->PutCString(" at ");
@ -245,10 +274,9 @@ Block::DumpStopContext
void
Block::DumpSymbolContext(Stream *s)
{
SymbolContext sc;
CalculateSymbolContext(&sc);
if (sc.function)
sc.function->DumpSymbolContext(s);
Function *function = CalculateSymbolContextFunction();
if (function)
function->DumpSymbolContext(s);
s->Printf(", Block{0x%8.8x}", GetID());
}
@ -297,12 +325,7 @@ Block *
Block::GetParent () const
{
if (m_parent_scope)
{
SymbolContext sc;
m_parent_scope->CalculateSymbolContext(&sc);
if (sc.block)
return sc.block;
}
return m_parent_scope->CalculateSymbolContextBlock();
return NULL;
}
@ -346,11 +369,10 @@ Block::GetRangeContainingOffset (const addr_t offset, VMRange &range)
bool
Block::GetRangeContainingAddress (const Address& addr, AddressRange &range)
{
SymbolContext sc;
CalculateSymbolContext(&sc);
if (sc.function)
Function *function = CalculateSymbolContextFunction();
if (function)
{
const AddressRange &func_range = sc.function->GetAddressRange();
const AddressRange &func_range = function->GetAddressRange();
if (addr.GetSection() == func_range.GetBaseAddress().GetSection())
{
const addr_t addr_offset = addr.GetOffset();
@ -379,11 +401,10 @@ Block::GetRangeAtIndex (uint32_t range_idx, AddressRange &range)
{
if (range_idx < m_ranges.size())
{
SymbolContext sc;
CalculateSymbolContext(&sc);
if (sc.function)
Function *function = CalculateSymbolContextFunction();
if (function)
{
range.GetBaseAddress() = sc.function->GetAddressRange().GetBaseAddress();
range.GetBaseAddress() = function->GetAddressRange().GetBaseAddress();
range.GetBaseAddress().Slide(m_ranges[range_idx].GetBaseAddress ());
range.SetByteSize (m_ranges[range_idx].GetByteSize());
return true;
@ -398,11 +419,10 @@ Block::GetStartAddress (Address &addr)
if (m_ranges.empty())
return false;
SymbolContext sc;
CalculateSymbolContext(&sc);
if (sc.function)
Function *function = CalculateSymbolContextFunction();
if (function)
{
addr = sc.function->GetAddressRange().GetBaseAddress();
addr = function->GetAddressRange().GetBaseAddress();
addr.Slide(m_ranges.front().GetBaseAddress ());
return true;
}

View File

@ -57,6 +57,18 @@ CompileUnit::CalculateSymbolContext(SymbolContext* sc)
GetModule()->CalculateSymbolContext(sc);
}
Module *
CompileUnit::CalculateSymbolContextModule ()
{
return GetModule();
}
CompileUnit *
CompileUnit::CalculateSymbolContextCompileUnit ()
{
return this;
}
void
CompileUnit::DumpSymbolContext(Stream *s)
{

View File

@ -386,6 +386,31 @@ Function::CalculateSymbolContext(SymbolContext* sc)
m_comp_unit->CalculateSymbolContext(sc);
}
Module *
Function::CalculateSymbolContextModule ()
{
return this->GetCompileUnit()->GetModule();
}
CompileUnit *
Function::CalculateSymbolContextCompileUnit ()
{
return this->GetCompileUnit();
}
Function *
Function::CalculateSymbolContextFunction ()
{
return this;
}
//Symbol *
//Function::CalculateSymbolContextSymbol ()
//{
// return // TODO: find the symbol for the function???
//}
void
Function::DumpSymbolContext(Stream *s)
{

View File

@ -366,6 +366,22 @@ Symbol::CalculateSymbolContext (SymbolContext *sc)
sc->module_sp.reset();
}
Module *
Symbol::CalculateSymbolContextModule ()
{
const AddressRange *range = GetAddressRangePtr();
if (range)
return range->GetBaseAddress().GetModule ();
return NULL;
}
Symbol *
Symbol::CalculateSymbolContextSymbol ()
{
return this;
}
void
Symbol::DumpSymbolContext (Stream *s)
{

View File

@ -51,7 +51,8 @@ Thread::Thread (Process &process, lldb::tid_t tid) :
m_state_mutex (Mutex::eMutexTypeRecursive),
m_plan_stack (),
m_completed_plan_stack(),
m_curr_frames_ap (),
m_curr_frames_sp (),
m_prev_frames_sp (),
m_resume_signal (LLDB_INVALID_SIGNAL_NUMBER),
m_resume_state (eStateRunning),
m_unwinder_ap (),
@ -916,9 +917,9 @@ Thread::CalculateExecutionContext (ExecutionContext &exe_ctx)
StackFrameList &
Thread::GetStackFrameList ()
{
if (m_curr_frames_ap.get() == NULL)
m_curr_frames_ap.reset (new StackFrameList (*this, m_prev_frames_sp, true));
return *m_curr_frames_ap;
if (!m_curr_frames_sp)
m_curr_frames_sp.reset (new StackFrameList (*this, m_prev_frames_sp, true));
return *m_curr_frames_sp;
}
@ -933,13 +934,9 @@ Thread::GetStackFrameCount()
void
Thread::ClearStackFrames ()
{
if (m_curr_frames_ap.get() && m_curr_frames_ap->GetNumFrames (false) > 1)
m_prev_frames_sp.reset (m_curr_frames_ap.release());
else
m_curr_frames_ap.release();
// StackFrameList::Merge (m_curr_frames_ap, m_prev_frames_sp);
// assert (m_curr_frames_ap.get() == NULL);
if (m_curr_frames_sp && m_curr_frames_sp->GetNumFrames (false) > 1)
m_prev_frames_sp.swap (m_curr_frames_sp);
m_curr_frames_sp.reset();
}
lldb::StackFrameSP

View File

@ -91,45 +91,47 @@ ThreadPlanTracer::TracerExplainsStop ()
ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer (Thread &thread, lldb::StreamSP &stream_sp) :
ThreadPlanTracer (thread, stream_sp),
m_process(thread.GetProcess()),
m_target(thread.GetProcess().GetTarget())
m_disassembler_ap (),
m_intptr_type (),
m_register_values ()
{
InitializeTracer ();
}
ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer (Thread &thread) :
ThreadPlanTracer (thread),
m_process(thread.GetProcess()),
m_target(thread.GetProcess().GetTarget())
m_disassembler_ap (),
m_intptr_type (),
m_register_values ()
{
InitializeTracer ();
}
void
ThreadPlanAssemblyTracer::InitializeTracer()
Disassembler *
ThreadPlanAssemblyTracer::GetDisassembler ()
{
Process &process = m_thread.GetProcess();
Target &target = process.GetTarget();
ArchSpec arch(target.GetArchitecture());
m_disassembler = Disassembler::FindPlugin(arch, NULL);
m_abi = process.GetABI().get();
Module *exe_module = target.GetExecutableModulePointer();
if (exe_module)
{
m_intptr_type = TypeFromUser(exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, arch.GetAddressByteSize() * 8),
exe_module->GetClangASTContext().getASTContext());
}
const unsigned int buf_size = 32;
m_buffer_sp.reset(new DataBufferHeap(buf_size, 0));
if (m_disassembler_ap.get() == NULL)
m_disassembler_ap.reset(Disassembler::FindPlugin(m_thread.GetProcess().GetTarget().GetArchitecture(), NULL));
return m_disassembler_ap.get();
}
TypeFromUser
ThreadPlanAssemblyTracer::GetIntPointerType()
{
if (!m_intptr_type.IsValid ())
{
Target &target = m_thread.GetProcess().GetTarget();
Module *exe_module = target.GetExecutableModulePointer();
if (exe_module)
{
m_intptr_type = TypeFromUser(exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, m_thread.GetProcess().GetAddressByteSize() * 8),
exe_module->GetClangASTContext().getASTContext());
}
}
return m_intptr_type;
}
ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer()
{
}
@ -171,33 +173,33 @@ ThreadPlanAssemblyTracer::Log ()
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
lldb::addr_t pc = reg_ctx->GetPC();
Process &process = m_thread.GetProcess();
Address pc_addr;
bool addr_valid = false;
addr_valid = m_process.GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, pc_addr);
uint8_t buffer[16] = {0}; // Must be big enough for any single instruction
addr_valid = process.GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, pc_addr);
pc_addr.Dump(stream, &m_thread, Address::DumpStyleResolvedDescription, Address::DumpStyleModuleWithFileAddress);
stream->PutCString (" ");
if (m_disassembler)
Disassembler *disassembler = GetDisassembler();
if (disassembler)
{
::memset(m_buffer_sp->GetBytes(), 0, m_buffer_sp->GetByteSize());
Error err;
m_process.ReadMemory(pc, m_buffer_sp->GetBytes(), m_buffer_sp->GetByteSize(), err);
process.ReadMemory(pc, buffer, sizeof(buffer), err);
if (err.Success())
{
DataExtractor extractor(m_buffer_sp,
m_process.GetByteOrder(),
m_process.GetAddressByteSize());
DataExtractor extractor(buffer, sizeof(buffer),
process.GetByteOrder(),
process.GetAddressByteSize());
if (addr_valid)
m_disassembler->DecodeInstructions (pc_addr, extractor, 0, 1, false);
disassembler->DecodeInstructions (pc_addr, extractor, 0, 1, false);
else
m_disassembler->DecodeInstructions (Address (NULL, pc), extractor, 0, 1, false);
disassembler->DecodeInstructions (Address (NULL, pc), extractor, 0, 1, false);
InstructionList &instruction_list = m_disassembler->GetInstructionList();
InstructionList &instruction_list = disassembler->GetInstructionList();
const uint32_t max_opcode_byte_size = instruction_list.GetMaxOpcocdeByteSize();
if (instruction_list.GetSize())
@ -215,7 +217,10 @@ ThreadPlanAssemblyTracer::Log ()
}
}
if (m_abi && m_intptr_type.GetOpaqueQualType())
const ABI *abi = process.GetABI().get();
TypeFromUser intptr_type = GetIntPointerType();
if (abi && intptr_type.IsValid())
{
ValueList value_list;
const int num_args = 1;
@ -224,11 +229,11 @@ ThreadPlanAssemblyTracer::Log ()
{
Value value;
value.SetValueType (Value::eValueTypeScalar);
value.SetContext (Value::eContextTypeClangType, m_intptr_type.GetOpaqueQualType());
value.SetContext (Value::eContextTypeClangType, intptr_type.GetOpaqueQualType());
value_list.PushValue (value);
}
if (m_abi->GetArgumentValues (m_thread, value_list))
if (abi->GetArgumentValues (m_thread, value_list))
{
for (int arg_index = 0; arg_index < num_args; ++arg_index)
{