While tracking down memory consumption issue a few things were needed: the 
ability to dump more information about modules in "target modules list". We
can now dump the shared pointer reference count for modules, the pointer to
the module itself (in case performance tools can help track down who has
references to said pointer), and the modification time.

Added "target delete [target-idx ...]" to be able to delete targets when they
are no longer needed. This will help track down memory usage issues and help 
to resolve when module ref counts keep getting incremented. If the command gets
no arguments, the currently selected target will be deleted. If any arguments 
are given, they must all be valid target indexes (use the "target list" 
command to get the current target indexes).

Took care of a bunch of "no newline at end of file" warnings.

TimeValue objects can now dump their time to a lldb_private::Stream object.

Modified the "target modules list --global" command to not error out if there
are no targets since it doesn't require a target.

Fixed an issue in the MacOSX DYLD dynamic loader plug-in where if a shared 
library was updated on disk, we would keep using the older one, even if it was
updated.

Don't allow the ModuleList::GetSharedModule(...) to return an empty module.
Previously we could specify a valid path on disc to a module, and specify an
architecture that wasn't contained in that module and get a shared pointer to
a module that wouldn't be able to return an object file or a symbol file. We
now make sure an object file can be extracted prior to adding the shared pointer
to the module to get added to the shared list.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@137196 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/lldb/Expression/ClangExpressionVariable.h b/include/lldb/Expression/ClangExpressionVariable.h
index bab8d0f..ced83e3 100644
--- a/include/lldb/Expression/ClangExpressionVariable.h
+++ b/include/lldb/Expression/ClangExpressionVariable.h
@@ -381,6 +381,12 @@
         return var_sp;
     }
     
+    void
+    Clear()
+    {
+        m_variables.clear();
+    }
+
 private:
     std::vector <lldb::ClangExpressionVariableSP> m_variables;
 };
diff --git a/include/lldb/Host/TimeValue.h b/include/lldb/Host/TimeValue.h
index d804111..0ef66d1 100644
--- a/include/lldb/Host/TimeValue.h
+++ b/include/lldb/Host/TimeValue.h
@@ -23,6 +23,7 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/lldb-private.h"
 
 namespace lldb_private {
 
@@ -57,6 +58,9 @@
     uint64_t
     GetAsMicroSecondsSinceJan1_1970() const;
 
+    uint64_t
+    GetAsSecondsSinceJan1_1970() const;
+
     struct timespec
     GetAsTimeSpec () const;
 
@@ -77,6 +81,9 @@
 
     static TimeValue
     Now();
+    
+    void
+    Dump (Stream *s, uint32_t width = 0) const;
 
 protected:
     //------------------------------------------------------------------
diff --git a/include/lldb/Target/Target.h b/include/lldb/Target/Target.h
index 51b27f6..82355d7 100644
--- a/include/lldb/Target/Target.h
+++ b/include/lldb/Target/Target.h
@@ -199,6 +199,9 @@
 
     lldb::TargetSP
     GetSP();
+    
+    void
+    Destroy();
 
     //------------------------------------------------------------------
     // This part handles the breakpoints.
diff --git a/source/API/SBModule.cpp b/source/API/SBModule.cpp
index 21d1375..1a76af6 100644
--- a/source/API/SBModule.cpp
+++ b/source/API/SBModule.cpp
@@ -395,4 +395,4 @@
     }
 
     return retval;
-}
\ No newline at end of file
+}
diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp
index 8b9abcf..e0b9169 100644
--- a/source/Commands/CommandObjectTarget.cpp
+++ b/source/Commands/CommandObjectTarget.cpp
@@ -400,6 +400,101 @@
     }
 };
 
+#pragma mark CommandObjectTargetSelect
+
+//----------------------------------------------------------------------
+// "target delete"
+//----------------------------------------------------------------------
+
+class CommandObjectTargetDelete : public CommandObject
+{
+public:
+    CommandObjectTargetDelete (CommandInterpreter &interpreter) :
+    CommandObject (interpreter,
+                   "target delete",
+                   "Delete one or more targets by target index.",
+                   NULL,
+                   0)
+    {
+    }
+    
+    virtual
+    ~CommandObjectTargetDelete ()
+    {
+    }
+    
+    virtual bool
+    Execute (Args& args, CommandReturnObject &result)
+    {
+        const size_t argc = args.GetArgumentCount();
+        std::vector<TargetSP> delete_target_list;
+        TargetList &target_list = m_interpreter.GetDebugger().GetTargetList();
+        bool success = true;
+        TargetSP target_sp;
+        if (argc > 0)
+        {
+            const uint32_t num_targets = target_list.GetNumTargets();
+            for (uint32_t arg_idx = 0; success && arg_idx < argc; ++arg_idx)
+            {
+                const char *target_idx_arg = args.GetArgumentAtIndex(arg_idx);
+                uint32_t target_idx = Args::StringToUInt32 (target_idx_arg, UINT32_MAX, 0, &success);
+                if (success)
+                {
+                    if (target_idx < num_targets)
+                    {     
+                        target_sp = target_list.GetTargetAtIndex (target_idx);
+                        if (target_sp)
+                        {
+                            delete_target_list.push_back (target_sp);
+                            continue;
+                        }
+                    }
+                    result.AppendErrorWithFormat ("target index %u is out of range, valid target indexes are 0 - %u\n", 
+                                                  target_idx,
+                                                  num_targets - 1);
+                    result.SetStatus (eReturnStatusFailed);
+                    success = false;
+                }
+                else
+                {
+                    result.AppendErrorWithFormat("invalid target index '%s'\n", target_idx_arg);
+                    result.SetStatus (eReturnStatusFailed);
+                    success = false;
+                }
+            }
+            
+        }
+        else
+        {
+            target_sp = target_list.GetSelectedTarget();
+            if (target_sp)
+            {
+                delete_target_list.push_back (target_sp);
+            }
+            else
+            {
+                result.AppendErrorWithFormat("no target is currently selected\n");
+                result.SetStatus (eReturnStatusFailed);
+                success = false;
+            }
+        }
+        if (success)
+        {
+            const size_t num_targets_to_delete = delete_target_list.size();
+            for (size_t idx = 0; idx < num_targets_to_delete; ++idx)
+            {
+                target_sp = delete_target_list[idx];
+                target_list.DeleteTarget(target_sp);
+                target_sp->Destroy();
+            }
+            result.GetOutputStream().Printf("%u targets deleted.\n", (uint32_t)num_targets_to_delete);
+            result.SetStatus(eReturnStatusSuccessFinishResult);
+        }
+        
+        return result.Succeeded();
+    }
+};
+
 
 #pragma mark CommandObjectTargetVariable
 
@@ -991,7 +1086,10 @@
 static void
 DumpModuleUUID (Stream &strm, Module *module)
 {
-    module->GetUUID().Dump (&strm);
+    if (module->GetUUID().IsValid())
+        module->GetUUID().Dump (&strm);
+    else
+        strm.PutCString("                                    ");
 }
 
 static uint32_t
@@ -2545,7 +2643,8 @@
              CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-        if (target == NULL)
+        const bool use_global_module_list = m_options.m_use_global_module_list;
+        if (target == NULL && use_global_module_list == false)
         {
             result.AppendError ("invalid target, create a debug target using the 'target create' command");
             result.SetStatus (eReturnStatusFailed);
@@ -2553,13 +2652,16 @@
         }
         else
         {
-            uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize();
-            result.GetOutputStream().SetAddressByteSize(addr_byte_size);
-            result.GetErrorStream().SetAddressByteSize(addr_byte_size);
+            if (target)
+            {
+                uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize();
+                result.GetOutputStream().SetAddressByteSize(addr_byte_size);
+                result.GetErrorStream().SetAddressByteSize(addr_byte_size);
+            }
             // Dump all sections for all modules images
             uint32_t num_modules = 0;
             Mutex::Locker locker;
-            if (m_options.m_use_global_module_list)
+            if (use_global_module_list)
             {
                 locker.Reset (Module::GetAllocationModuleCollectionMutex().GetMutex());
                 num_modules = Module::GetNumberAllocatedModules();
@@ -2573,20 +2675,21 @@
                 
                 for (uint32_t image_idx = 0; image_idx<num_modules; ++image_idx)
                 {
+                    ModuleSP module_sp;
                     Module *module;
-                    if (m_options.m_use_global_module_list)
+                    if (use_global_module_list)
                     {
                         module = Module::GetAllocatedModuleAtIndex(image_idx);
-                        ModuleSP module_sp(module->GetSP());
-                        // Show the module reference count when showing the global module index
-                        strm.Printf("[%3u] ref_count = %lu ", image_idx, module_sp ? module_sp.use_count() - 1 : 0);
+                        module_sp = module->GetSP();
                     }
                     else
                     {
-                        module = target->GetImages().GetModulePointerAtIndex(image_idx);
-                        strm.Printf("[%3u] ", image_idx);
+                        module_sp = target->GetImages().GetModuleAtIndex(image_idx);
+                        module = module_sp.get();
                     }
-                    
+
+                    strm.Printf("[%3u] ", image_idx);
+
                     bool dump_object_name = false;
                     if (m_options.m_format_array.empty())
                     {
@@ -2626,27 +2729,50 @@
                                     dump_object_name = true;
                                     break;
                                     
+                                case 'r':
+                                    {
+                                        uint32_t ref_count = 0;
+                                        if (module_sp)
+                                        {
+                                            // Take one away to make sure we don't count our local "module_sp"
+                                            ref_count = module_sp.use_count() - 1;
+                                        }
+                                        if (width)
+                                            strm.Printf("{%*u}", width, ref_count);
+                                        else
+                                            strm.Printf("{%u}", ref_count);
+                                    }
+                                    break;
+
                                 case 's':
                                 case 'S':
-                                {
-                                    SymbolVendor *symbol_vendor = module->GetSymbolVendor();
-                                    if (symbol_vendor)
                                     {
-                                        SymbolFile *symbol_file = symbol_vendor->GetSymbolFile();
-                                        if (symbol_file)
+                                        SymbolVendor *symbol_vendor = module->GetSymbolVendor();
+                                        if (symbol_vendor)
                                         {
-                                            if (format_char == 'S')
-                                                DumpBasename(strm, &symbol_file->GetObjectFile()->GetFileSpec(), width);
-                                            else
-                                                DumpFullpath (strm, &symbol_file->GetObjectFile()->GetFileSpec(), width);
-                                            dump_object_name = true;
-                                            break;
+                                            SymbolFile *symbol_file = symbol_vendor->GetSymbolFile();
+                                            if (symbol_file)
+                                            {
+                                                if (format_char == 'S')
+                                                    DumpBasename(strm, &symbol_file->GetObjectFile()->GetFileSpec(), width);
+                                                else
+                                                    DumpFullpath (strm, &symbol_file->GetObjectFile()->GetFileSpec(), width);
+                                                dump_object_name = true;
+                                                break;
+                                            }
                                         }
+                                        strm.Printf("%.*s", width, "<NONE>");
                                     }
-                                    strm.Printf("%.*s", width, "<NONE>");
-                                }
                                     break;
                                     
+                                case 'm':
+                                    module->GetModificationTime().Dump(&strm, width);
+                                    break;
+
+                                case 'p':
+                                    strm.Printf("%p", module);
+                                    break;
+
                                 case 'u':
                                     DumpModuleUUID(strm, module);
                                     break;
@@ -2669,7 +2795,10 @@
             }
             else
             {
-                result.AppendError ("the target has no associated executable images");
+                if (use_global_module_list)
+                    result.AppendError ("the global module list is empty");
+                else
+                    result.AppendError ("the target has no associated executable images");
                 result.SetStatus (eReturnStatusFailed);
                 return false;
             }
@@ -2692,6 +2821,9 @@
     { LLDB_OPT_SET_1, false, "basename",   'b', optional_argument, NULL, 0, eArgTypeWidth,   "Display the basename with optional width for the image object file."},
     { LLDB_OPT_SET_1, false, "symfile",    's', optional_argument, NULL, 0, eArgTypeWidth,   "Display the fullpath to the image symbol file with optional width."},
     { LLDB_OPT_SET_1, false, "symfile-basename", 'S', optional_argument, NULL, 0, eArgTypeWidth,   "Display the basename to the image symbol file with optional width."},
+    { LLDB_OPT_SET_1, false, "mod-time",   'm', optional_argument, NULL, 0, eArgTypeWidth,   "Display the modification time with optional width of the module."},
+    { LLDB_OPT_SET_1, false, "ref-count",  'r', optional_argument, NULL, 0, eArgTypeWidth,   "Display the reference count if the module is still in the shared module cache."},
+    { LLDB_OPT_SET_1, false, "pointer",    'p', optional_argument, NULL, 0, eArgTypeNone,    "Display the module pointer."},
     { LLDB_OPT_SET_1, false, "global",     'g', no_argument,       NULL, 0, eArgTypeNone,    "Display the modules from the global module list, not just the current target."},
     { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
@@ -3811,6 +3943,7 @@
 {
     
     LoadSubCommand ("create",    CommandObjectSP (new CommandObjectTargetCreate (interpreter)));
+    LoadSubCommand ("delete",    CommandObjectSP (new CommandObjectTargetDelete (interpreter)));
     LoadSubCommand ("list",      CommandObjectSP (new CommandObjectTargetList   (interpreter)));
     LoadSubCommand ("select",    CommandObjectSP (new CommandObjectTargetSelect (interpreter)));
     LoadSubCommand ("stop-hook", CommandObjectSP (new CommandObjectMultiwordTargetStopHooks (interpreter)));
diff --git a/source/Core/FormatClasses.cpp b/source/Core/FormatClasses.cpp
index aeace97..843b986 100644
--- a/source/Core/FormatClasses.cpp
+++ b/source/Core/FormatClasses.cpp
@@ -231,4 +231,4 @@
                 m_python_class.c_str());
     
     return sstr.GetString();
-}
\ No newline at end of file
+}
diff --git a/source/Core/FormatManager.cpp b/source/Core/FormatManager.cpp
index 47426fc..c0242fe 100644
--- a/source/Core/FormatManager.cpp
+++ b/source/Core/FormatManager.cpp
@@ -258,4 +258,4 @@
         default:
             return lldb::eFormatInvalid;
     }
-}
\ No newline at end of file
+}
diff --git a/source/Core/InputReader.cpp b/source/Core/InputReader.cpp
index ebde2be..c9372e4 100644
--- a/source/Core/InputReader.cpp
+++ b/source/Core/InputReader.cpp
@@ -382,4 +382,4 @@
 InputReader::HandlerData::GetOutStream()
 {
     return reader.GetDebugger().GetAsyncOutputStream();
-}
\ No newline at end of file
+}
diff --git a/source/Core/InputReaderEZ.cpp b/source/Core/InputReaderEZ.cpp
index c8362fb..5a2a8d4 100644
--- a/source/Core/InputReaderEZ.cpp
+++ b/source/Core/InputReaderEZ.cpp
@@ -93,4 +93,4 @@
 
 InputReaderEZ::~InputReaderEZ ()
 {
-}
\ No newline at end of file
+}
diff --git a/source/Core/ModuleList.cpp b/source/Core/ModuleList.cpp
index d27b30e..7a47483 100644
--- a/source/Core/ModuleList.cpp
+++ b/source/Core/ModuleList.cpp
@@ -756,7 +756,10 @@
         else
         {
             module_sp.reset (new Module (in_file_spec, arch, object_name_ptr, object_offset));
-            if (module_sp)
+            // 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
+            if (module_sp && module_sp->GetObjectFile())
             {
                 // If we get in here we got the correct arch, now we just need
                 // to verify the UUID if one was given
@@ -766,7 +769,7 @@
                 {
                     if (did_create_ptr)
                         *did_create_ptr = true;
-
+                    
                     shared_module_list.Append(module_sp);
                     return error;
                 }
@@ -844,7 +847,10 @@
         if (module_sp.get() == NULL)
         {
             module_sp.reset (new Module (file_spec, arch, object_name_ptr, object_offset));
-            if (module_sp)
+            // 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
+            if (module_sp && module_sp->GetObjectFile())
             {
                 if (did_create_ptr)
                     *did_create_ptr = true;
diff --git a/source/Core/StringList.cpp b/source/Core/StringList.cpp
index fbe0cfe..1df8b7b 100644
--- a/source/Core/StringList.cpp
+++ b/source/Core/StringList.cpp
@@ -236,4 +236,4 @@
 {
     AppendList(strings);
     return *this;
-}
\ No newline at end of file
+}
diff --git a/source/Expression/ProcessDataAllocator.cpp b/source/Expression/ProcessDataAllocator.cpp
index 8b826df..3ac0770 100644
--- a/source/Expression/ProcessDataAllocator.cpp
+++ b/source/Expression/ProcessDataAllocator.cpp
@@ -40,4 +40,4 @@
                    0);                              // bit alignment (bitfields only; 0 means ignore)
     
     stream.PutChar('\n');
-}
\ No newline at end of file
+}
diff --git a/source/Host/common/TimeValue.cpp b/source/Host/common/TimeValue.cpp
index 416db41..d872229 100644
--- a/source/Host/common/TimeValue.cpp
+++ b/source/Host/common/TimeValue.cpp
@@ -8,12 +8,15 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/Host/TimeValue.h"
-#include <stddef.h>
 
 // C Includes
+#include <stddef.h>
+#include <time.h>
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/Core/Stream.h"
+
 
 using namespace lldb_private;
 
@@ -63,6 +66,14 @@
     return m_nano_seconds / NanoSecPerMicroSec;
 }
 
+uint64_t
+TimeValue::GetAsSecondsSinceJan1_1970() const
+{
+    return m_nano_seconds / NanoSecPerSec;
+}
+
+
+
 struct timespec
 TimeValue::GetAsTimeSpec () const
 {
@@ -130,6 +141,28 @@
     return *this;
 }
 
+void
+TimeValue::Dump (Stream *s, uint32_t width) const
+{
+    if (s == NULL)
+        return;
+
+    char time_buf[32];
+    time_t time = GetAsSecondsSinceJan1_1970();
+    char *time_cstr = ::ctime_r(&time, time_buf);
+    if (time_cstr)
+    {
+        char *newline = ::strpbrk(time_cstr, "\n\r");
+        if (newline)
+            *newline = '\0';
+        if (width > 0)
+            s->Printf("%-*s", width, time_cstr);
+        else
+            s->PutCString(time_cstr);
+    }
+    else if (width > 0)
+        s->Printf("%-*s", width, "");
+}
 
 bool
 lldb_private::operator == (const TimeValue &lhs, const TimeValue &rhs)
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 8031b3a..92f359b 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -263,13 +263,32 @@
 
         module_sp = target_images.FindFirstModuleForFileSpec (image_info.file_spec, &arch, NULL);
 
-        if (can_create && !module_sp)
+        if (can_create)
         {
-            module_sp = m_process->GetTarget().GetSharedModule (image_info.file_spec,
-                                                                arch,
-                                                                image_info_uuid_is_valid ? &image_info.uuid : NULL);
-            if (did_create_ptr)
-                *did_create_ptr = module_sp;
+            if (module_sp)
+            {
+                if (image_info.UUIDValid())
+                {
+                    if (module_sp->GetUUID() != image_info.uuid)
+                        module_sp.reset();
+                }
+                else
+                {
+                    // No UUID, we must rely upon the cached module modification 
+                    // time and the modification time of the file on disk
+                    if (module_sp->GetModificationTime() != module_sp->GetFileSpec().GetModificationTime())
+                        module_sp.reset();
+                }
+            }
+            
+            if (!module_sp)
+            {
+                module_sp = m_process->GetTarget().GetSharedModule (image_info.file_spec,
+                                                                    arch,
+                                                                    image_info_uuid_is_valid ? &image_info.uuid : NULL);
+                if (did_create_ptr)
+                    *did_create_ptr = module_sp;
+            }
         }
     }
     return module_sp;
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index e9cd2f8..2a86042 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1446,7 +1446,7 @@
                 end_time = TimeValue::Now();
                 total_time_nsec = end_time.GetAsNanoSecondsSinceJan1_1970() - start_time.GetAsNanoSecondsSinceJan1_1970();
                 packets_per_second = (((float)num_packets)/(float)total_time_nsec) * (float)TimeValue::NanoSecPerSec;
-                printf ("%u qSpeedTest(send=%-5u, recv=%-5u) in %llu.%09.9llu sec for %f packets/sec.\n", 
+                printf ("%u qSpeedTest(send=%-5u, recv=%-5u) in %llu.%9.9llu sec for %f packets/sec.\n", 
                         num_packets, 
                         send_size,
                         recv_size,
@@ -1470,7 +1470,7 @@
         end_time = TimeValue::Now();
         total_time_nsec = end_time.GetAsNanoSecondsSinceJan1_1970() - start_time.GetAsNanoSecondsSinceJan1_1970();
         packets_per_second = (((float)num_packets)/(float)total_time_nsec) * (float)TimeValue::NanoSecPerSec;
-        printf ("%u 'qC' packets packets in 0x%llu%09.9llu sec for %f packets/sec.\n", 
+        printf ("%u 'qC' packets packets in 0x%llu%9.9llu sec for %f packets/sec.\n", 
                 num_packets, 
                 total_time_nsec / TimeValue::NanoSecPerSec, 
                 total_time_nsec % TimeValue::NanoSecPerSec, 
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index a670112..b1a48b2 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1331,7 +1331,7 @@
                         if (stop_info_sp)
                         {
                             stop_info_sp->SetDescription (description.c_str());
-            }
+                        }
                         else
                         {
                             gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithException (*thread_sp, description.c_str()));
diff --git a/source/Symbol/ClangASTImporter.cpp b/source/Symbol/ClangASTImporter.cpp
index 08f176a..ccb59dc 100644
--- a/source/Symbol/ClangASTImporter.cpp
+++ b/source/Symbol/ClangASTImporter.cpp
@@ -121,4 +121,4 @@
     }
     
     return clang::ASTImporter::Imported(from, to);
-}
\ No newline at end of file
+}
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index a5103b4..e65f2d1 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -145,6 +145,29 @@
     return m_debugger.GetTargetList().GetTargetSP(this);
 }
 
+void
+Target::Destroy()
+{
+    Mutex::Locker locker (m_mutex);
+    DeleteCurrentProcess ();
+    m_platform_sp.reset();
+    m_arch.Clear();
+    m_images.Clear();
+    m_section_load_list.Clear();
+    const bool notify = false;
+    m_breakpoint_list.RemoveAll(notify);
+    m_internal_breakpoint_list.RemoveAll(notify);
+    m_last_created_breakpoint.reset();
+    m_search_filter_sp.reset();
+    m_image_search_paths.Clear(notify);
+    m_scratch_ast_context_ap.reset();
+    m_persistent_variables.Clear();
+    m_stop_hooks.clear();
+    m_stop_hook_next_id = 0;
+    m_suppress_stop_hooks = false;
+}
+
+
 BreakpointList &
 Target::GetBreakpointList(bool internal)
 {