Moved the section load list up into the target so we can use the target
to symbolicate things without the need for a valid process subclass.

llvm-svn: 113895
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 46b4e27..c86b74c 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -66,7 +66,6 @@
     Broadcaster ("Process"),
     ProcessInstanceSettings (*(Process::GetSettingsController().get())),
     m_target (target),
-    m_section_load_info (),
     m_public_state (eStateUnloaded),
     m_private_state (eStateUnloaded),
     m_private_state_broadcaster ("lldb.process.internal_state_broadcaster"),
@@ -529,7 +528,7 @@
 lldb::break_id_t
 Process::CreateBreakpointSite (BreakpointLocationSP &owner, bool use_hardware)
 {
-    const addr_t load_addr = owner->GetAddress().GetLoadAddress (this);
+    const addr_t load_addr = owner->GetAddress().GetLoadAddress (&m_target);
     if (load_addr != LLDB_INVALID_ADDRESS)
     {
         BreakpointSiteSP bp_site_sp;
@@ -1575,103 +1574,6 @@
     return NULL;
 }
 
-addr_t
-Process::GetSectionLoadAddress (const Section *section) const
-{
-    // TODO: add support for the same section having multiple load addresses
-    addr_t section_load_addr = LLDB_INVALID_ADDRESS;
-    if (m_section_load_info.GetFirstKeyForValue (section, section_load_addr))
-        return section_load_addr;
-    return LLDB_INVALID_ADDRESS;
-}
-
-bool
-Process::SectionLoaded (const Section *section, addr_t load_addr)
-{
-    Log *log = lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_SHLIB | LIBLLDB_LOG_VERBOSE);
-
-    if (log)
-        log->Printf ("Process::%s (section = %p (%s.%s), load_addr = 0x%16.16llx)",
-                     __FUNCTION__,
-                     section,
-                     section->GetModule()->GetFileSpec().GetFilename().AsCString(),
-                     section->GetName().AsCString(),
-                     load_addr);
-
-
-    const Section *existing_section = NULL;
-    Mutex::Locker locker(m_section_load_info.GetMutex());
-
-    if (m_section_load_info.GetValueForKeyNoLock (load_addr, existing_section))
-    {
-        if (existing_section == section)
-            return false;   // No change
-    }
-    m_section_load_info.SetValueForKeyNoLock (load_addr, section);
-    return true;    // Changed
-}
-
-size_t
-Process::SectionUnloaded (const Section *section)
-{
-    Log *log = lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_SHLIB | LIBLLDB_LOG_VERBOSE);
-
-    if (log)
-        log->Printf ("Process::%s (section = %p (%s.%s))",
-                     __FUNCTION__,
-                     section,
-                     section->GetModule()->GetFileSpec().GetFilename().AsCString(),
-                     section->GetName().AsCString());
-
-    Mutex::Locker locker(m_section_load_info.GetMutex());
-
-    size_t unload_count = 0;
-    addr_t section_load_addr;
-    while (m_section_load_info.GetFirstKeyForValueNoLock (section, section_load_addr))
-    {
-        unload_count += m_section_load_info.EraseNoLock (section_load_addr);
-    }
-    return unload_count;
-}
-
-bool
-Process::SectionUnloaded (const Section *section, addr_t load_addr)
-{
-    Log *log = lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_SHLIB | LIBLLDB_LOG_VERBOSE);
-
-    if (log)
-        log->Printf ("Process::%s (section = %p (%s.%s), load_addr = 0x%16.16llx)",
-                     __FUNCTION__,
-                     section,
-                     section->GetModule()->GetFileSpec().GetFilename().AsCString(),
-                     section->GetName().AsCString(),
-                     load_addr);
-
-    return m_section_load_info.Erase (load_addr) == 1;
-}
-
-
-bool
-Process::ResolveLoadAddress (addr_t load_addr, Address &so_addr) const
-{
-    addr_t section_load_addr = LLDB_INVALID_ADDRESS;
-    const Section *section = NULL;
-
-    // First find the top level section that this load address exists in
-    if (m_section_load_info.LowerBound (load_addr, section_load_addr, section, true))
-    {
-        addr_t offset = load_addr - section_load_addr;
-        if (offset < section->GetByteSize())
-        {
-            // We have found the top level section, now we need to find the
-            // deepest child section.
-            return section->ResolveContainedAddress (offset, so_addr);
-        }
-    }
-    so_addr.Clear();
-    return false;
-}
-
 //------------------------------------------------------------------
 // Process Event Data
 //------------------------------------------------------------------
diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp
index e90c738..bd9df62 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -115,7 +115,7 @@
     m_unwind_frame_index (unwind_frame_index),    
     m_thread (thread),
     m_reg_context_sp (reg_context_sp),
-    m_id (pc_addr.GetLoadAddress (&thread.GetProcess()), cfa, NULL),
+    m_id (pc_addr.GetLoadAddress (&thread.GetProcess().GetTarget()), cfa, NULL),
     m_frame_code_addr (pc_addr),
     m_sc (),
     m_flags (),
@@ -213,7 +213,7 @@
         // Resolve the PC into a temporary address because if ResolveLoadAddress
         // fails to resolve the address, it will clear the address object...
         Address resolved_pc;
-        if (m_thread.GetProcess().ResolveLoadAddress(m_frame_code_addr.GetOffset(), resolved_pc))
+        if (m_thread.GetProcess().GetTarget().GetSectionLoadList().ResolveLoadAddress(m_frame_code_addr.GetOffset(), resolved_pc))
         {
             m_frame_code_addr = resolved_pc;
             const Section *section = m_frame_code_addr.GetSection();
@@ -488,7 +488,7 @@
             Value expr_value;
             addr_t loclist_base_addr = LLDB_INVALID_ADDRESS;
             if (m_sc.function->GetFrameBaseExpression().IsLocationList())
-                loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (&m_thread.GetProcess());
+                loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (&m_thread.GetProcess().GetTarget());
 
             if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx, NULL, loclist_base_addr, NULL, expr_value, &m_frame_base_error) == false)
             {
@@ -629,7 +629,7 @@
 
     if (show_frame_index)
         strm->Printf("frame #%u: ", m_frame_index);
-    strm->Printf("0x%0*llx ", m_thread.GetProcess().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess()));
+    strm->Printf("0x%0*llx ", m_thread.GetProcess().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess().GetTarget()));
     GetSymbolContext(eSymbolContextEverything);
     const bool show_module = true;
     const bool show_inline = true;
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 3d206ea..7d8eb8b 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -37,6 +37,7 @@
     Broadcaster("Target"),
     m_debugger (debugger),
     m_images(),
+    m_section_load_list (),
     m_breakpoint_list (false),
     m_internal_breakpoint_list (true),
     m_process_sp(),
@@ -162,10 +163,8 @@
     // Attempt to resolve our load address if possible, though it is ok if
     // it doesn't resolve to section/offset.
 
-    Process *process = GetProcessSP().get();
     // Try and resolve as a load address if possible
-    if (process)
-        process->ResolveLoadAddress(addr, so_addr);
+    m_section_load_list.ResolveLoadAddress(addr, so_addr);
     if (!so_addr.IsValid())
     {
         // The address didn't resolve, so just set this as an absolute address
@@ -567,7 +566,7 @@
     {
         if (process_is_valid)
         {
-            m_process_sp->ResolveLoadAddress (addr.GetOffset(), resolved_addr);
+            m_section_load_list.ResolveLoadAddress (addr.GetOffset(), resolved_addr);
         }
         else
         {
@@ -578,7 +577,7 @@
     
     if (process_is_valid)
     {
-        lldb::addr_t load_addr = resolved_addr.GetLoadAddress(m_process_sp.get());
+        lldb::addr_t load_addr = resolved_addr.GetLoadAddress (this);
         if (load_addr == LLDB_INVALID_ADDRESS)
         {
             if (resolved_addr.GetModule() && resolved_addr.GetModule()->GetFileSpec())
diff --git a/lldb/source/Target/ThreadPlanCallFunction.cpp b/lldb/source/Target/ThreadPlanCallFunction.cpp
index 7dc3047..f8d7f6a 100644
--- a/lldb/source/Target/ThreadPlanCallFunction.cpp
+++ b/lldb/source/Target/ThreadPlanCallFunction.cpp
@@ -66,13 +66,13 @@
     contexts.GetContextAtIndex(0, context);
     
     m_start_addr = context.symbol->GetValue();
-    lldb::addr_t StartLoadAddr = m_start_addr.GetLoadAddress(&process);
+    lldb::addr_t StartLoadAddr = m_start_addr.GetLoadAddress(&target);
 
     if (!thread.SaveFrameZeroState(m_register_backup))
         return;
 
     m_function_addr = function;
-    lldb::addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&process);
+    lldb::addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target);
         
     if (!abi->PrepareTrivialCall(thread, 
                                  spBelowRedZone, 
@@ -120,13 +120,13 @@
     contexts.GetContextAtIndex(0, context);
     
     m_start_addr = context.symbol->GetValue();
-    lldb::addr_t StartLoadAddr = m_start_addr.GetLoadAddress(&process);
+    lldb::addr_t StartLoadAddr = m_start_addr.GetLoadAddress(&target);
     
     if(!thread.SaveFrameZeroState(m_register_backup))
         return;
     
     m_function_addr = function;
-    lldb::addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&process);
+    lldb::addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target);
     
     if (!abi->PrepareNormalCall(thread, 
                                 spBelowRedZone, 
@@ -152,9 +152,9 @@
     else
     {
         if (m_args)
-            s->Printf("Thread plan to call 0x%llx with parsed arguments", m_function_addr.GetLoadAddress(&m_process), m_arg_addr);
+            s->Printf("Thread plan to call 0x%llx with parsed arguments", m_function_addr.GetLoadAddress(&m_process.GetTarget()), m_arg_addr);
         else
-            s->Printf("Thread plan to call 0x%llx void * argument at: 0x%llx", m_function_addr.GetLoadAddress(&m_process), m_arg_addr);
+            s->Printf("Thread plan to call 0x%llx void * argument at: 0x%llx", m_function_addr.GetLoadAddress(&m_process.GetTarget()), m_arg_addr);
     }
 }
 
diff --git a/lldb/source/Target/ThreadPlanRunToAddress.cpp b/lldb/source/Target/ThreadPlanRunToAddress.cpp
index edfe7e5..5560f45 100644
--- a/lldb/source/Target/ThreadPlanRunToAddress.cpp
+++ b/lldb/source/Target/ThreadPlanRunToAddress.cpp
@@ -39,7 +39,7 @@
     m_addresses (),
     m_break_ids ()
 {
-    m_addresses.push_back (address.GetLoadAddress(&m_thread.GetProcess()));
+    m_addresses.push_back (address.GetLoadAddress(&m_thread.GetProcess().GetTarget()));
     SetInitialBreakpoints();
 }
 
diff --git a/lldb/source/Target/ThreadPlanStepInRange.cpp b/lldb/source/Target/ThreadPlanStepInRange.cpp
index d6abddd..d83e558 100644
--- a/lldb/source/Target/ThreadPlanStepInRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -61,7 +61,7 @@
     else
     {
         s->Printf ("Stepping through range (stepping into functions): ");
-        m_address_range.Dump (s, &m_thread.GetProcess(), Address::DumpStyleLoadAddress);
+        m_address_range.Dump (s, &m_thread.GetProcess().GetTarget(), Address::DumpStyleLoadAddress);
     }
 }
 
diff --git a/lldb/source/Target/ThreadPlanStepOverRange.cpp b/lldb/source/Target/ThreadPlanStepOverRange.cpp
index bbc5104..83e9c23 100644
--- a/lldb/source/Target/ThreadPlanStepOverRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepOverRange.cpp
@@ -56,7 +56,7 @@
     else
     {
         s->Printf ("stepping through range (stepping over functions): ");
-        m_address_range.Dump (s, &m_thread.GetProcess(), Address::DumpStyleLoadAddress);
+        m_address_range.Dump (s, &m_thread.GetProcess().GetTarget(), Address::DumpStyleLoadAddress);
     }
 }
 
diff --git a/lldb/source/Target/ThreadPlanStepRange.cpp b/lldb/source/Target/ThreadPlanStepRange.cpp
index dd21566..3538482 100644
--- a/lldb/source/Target/ThreadPlanStepRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepRange.cpp
@@ -100,7 +100,7 @@
 
     lldb::addr_t pc_load_addr = m_thread.GetRegisterContext()->GetPC();
 
-    ret_value = m_address_range.ContainsLoadAddress(pc_load_addr, &m_thread.GetProcess());
+    ret_value = m_address_range.ContainsLoadAddress(pc_load_addr, &m_thread.GetProcess().GetTarget());
     
     if (!ret_value)
     {
@@ -119,7 +119,7 @@
                 if (log)
                 {
                     StreamString s;
-                    m_address_range.Dump (&s, &m_thread.GetProcess(), Address::DumpStyleLoadAddress);
+                    m_address_range.Dump (&s, &m_thread.GetProcess().GetTarget(), Address::DumpStyleLoadAddress);
 
                     log->Printf ("Step range plan stepped to another range of same line: %s", s.GetData());
                 }
@@ -138,15 +138,13 @@
 ThreadPlanStepRange::InSymbol()
 {
     lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC();
-    Process *process = m_thread.CalculateProcess();
-    
     if (m_addr_context.function != NULL)
     {
-        return m_addr_context.function->GetAddressRange().ContainsLoadAddress (cur_pc, process);
+        return m_addr_context.function->GetAddressRange().ContainsLoadAddress (cur_pc, &m_thread.GetProcess().GetTarget());
     }
     else if (m_addr_context.symbol != NULL)
     {
-        return m_addr_context.symbol->GetAddressRangeRef().ContainsLoadAddress (cur_pc, process);
+        return m_addr_context.symbol->GetAddressRangeRef().ContainsLoadAddress (cur_pc, &m_thread.GetProcess().GetTarget());
     }
     return false;
 }