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.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@137516 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBAddress.cpp b/source/API/SBAddress.cpp
index 57b58bf..110ef2d 100644
--- a/source/API/SBAddress.cpp
+++ b/source/API/SBAddress.cpp
@@ -228,4 +228,62 @@
     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;
+}
+
 
diff --git a/source/Core/Address.cpp b/source/Core/Address.cpp
index 9d7af37..e90561c 100644
--- a/source/Core/Address.cpp
+++ b/source/Core/Address.cpp
@@ -727,20 +727,115 @@
     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
diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp
index 65f2fb7..4c99796 100644
--- a/source/Core/Module.cpp
+++ b/source/Core/Module.cpp
@@ -214,6 +214,12 @@
     sc->module_sp = GetSP();
 }
 
+Module *
+Module::CalculateSymbolContextModule ()
+{
+    return this;
+}
+
 void
 Module::DumpSymbolContext(Stream *s)
 {
diff --git a/source/Core/ModuleList.cpp b/source/Core/ModuleList.cpp
index f83a235..5cde91f 100644
--- a/source/Core/ModuleList.cpp
+++ b/source/Core/ModuleList.cpp
@@ -707,6 +707,33 @@
 {
     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 @@
             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 @@
 
         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
diff --git a/source/Core/ValueObject.cpp b/source/Core/ValueObject.cpp
index 26b7a48..46feb99 100644
--- a/source/Core/ValueObject.cpp
+++ b/source/Core/ValueObject.cpp
@@ -3260,31 +3260,35 @@
 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 @@
 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();
-    }
 }
         
 
diff --git a/source/Expression/ClangFunction.cpp b/source/Expression/ClangFunction.cpp
index 21e2cd2..2e05e67 100644
--- a/source/Expression/ClangFunction.cpp
+++ b/source/Expression/ClangFunction.cpp
@@ -386,11 +386,9 @@
 {
     // 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;
     }
 
diff --git a/source/Symbol/Block.cpp b/source/Symbol/Block.cpp
index 8be43e7..8cca445 100644
--- a/source/Symbol/Block.cpp
+++ b/source/Symbol/Block.cpp
@@ -152,6 +152,36 @@
     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 @@
         }
         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 @@
 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::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 @@
 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 @@
 {
     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 @@
     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;
     }
diff --git a/source/Symbol/CompileUnit.cpp b/source/Symbol/CompileUnit.cpp
index ea49eb3..8f51210 100644
--- a/source/Symbol/CompileUnit.cpp
+++ b/source/Symbol/CompileUnit.cpp
@@ -57,6 +57,18 @@
     GetModule()->CalculateSymbolContext(sc);
 }
 
+Module *
+CompileUnit::CalculateSymbolContextModule ()
+{
+    return GetModule();
+}
+
+CompileUnit *
+CompileUnit::CalculateSymbolContextCompileUnit ()
+{
+    return this;
+}
+
 void
 CompileUnit::DumpSymbolContext(Stream *s)
 {
diff --git a/source/Symbol/Function.cpp b/source/Symbol/Function.cpp
index 5328159..ca14997 100644
--- a/source/Symbol/Function.cpp
+++ b/source/Symbol/Function.cpp
@@ -386,6 +386,31 @@
     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)
 {
diff --git a/source/Symbol/Symbol.cpp b/source/Symbol/Symbol.cpp
index 480405e..7b44d77 100644
--- a/source/Symbol/Symbol.cpp
+++ b/source/Symbol/Symbol.cpp
@@ -366,6 +366,22 @@
     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)
 {
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index 5906d53..11d28ac 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -51,7 +51,8 @@
     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 @@
 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 @@
 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
diff --git a/source/Target/ThreadPlanTracer.cpp b/source/Target/ThreadPlanTracer.cpp
index 177fdab..1a3f0d4 100644
--- a/source/Target/ThreadPlanTracer.cpp
+++ b/source/Target/ThreadPlanTracer.cpp
@@ -91,45 +91,47 @@
 
 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 @@
     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 @@
         }
     }
     
-    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 @@
         {
             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)
             {