[Lldb-commits] [lldb] r137196 - in /lldb/trunk: include/lldb/Expression/ include/lldb/Host/ include/lldb/Target/ source/API/ source/Commands/ source/Core/ source/Expression/ source/Host/common/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/Process/gdb-remote/ source/Symbol/ source/Target/

Greg Clayton gclayton at apple.com
Tue Aug 9 19:10:13 PDT 2011


Author: gclayton
Date: Tue Aug  9 21:10:13 2011
New Revision: 137196

URL: http://llvm.org/viewvc/llvm-project?rev=137196&view=rev
Log:
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.


Modified:
    lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h
    lldb/trunk/include/lldb/Host/TimeValue.h
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/source/API/SBModule.cpp
    lldb/trunk/source/Commands/CommandObjectTarget.cpp
    lldb/trunk/source/Core/FormatClasses.cpp
    lldb/trunk/source/Core/FormatManager.cpp
    lldb/trunk/source/Core/InputReader.cpp
    lldb/trunk/source/Core/InputReaderEZ.cpp
    lldb/trunk/source/Core/ModuleList.cpp
    lldb/trunk/source/Core/StringList.cpp
    lldb/trunk/source/Expression/ProcessDataAllocator.cpp
    lldb/trunk/source/Host/common/TimeValue.cpp
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Symbol/ClangASTImporter.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Tue Aug  9 21:10:13 2011
@@ -381,6 +381,12 @@
         return var_sp;
     }
     
+    void
+    Clear()
+    {
+        m_variables.clear();
+    }
+
 private:
     std::vector <lldb::ClangExpressionVariableSP> m_variables;
 };

Modified: lldb/trunk/include/lldb/Host/TimeValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/TimeValue.h?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/TimeValue.h (original)
+++ lldb/trunk/include/lldb/Host/TimeValue.h Tue Aug  9 21:10:13 2011
@@ -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:
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Tue Aug  9 21:10:13 2011
@@ -199,6 +199,9 @@
 
     lldb::TargetSP
     GetSP();
+    
+    void
+    Destroy();
 
     //------------------------------------------------------------------
     // This part handles the breakpoints.

Modified: lldb/trunk/source/API/SBModule.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/API/SBModule.cpp (original)
+++ lldb/trunk/source/API/SBModule.cpp Tue Aug  9 21:10:13 2011
@@ -395,4 +395,4 @@
     }
 
     return retval;
-}
\ No newline at end of file
+}

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Tue Aug  9 21:10:13 2011
@@ -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)));

Modified: lldb/trunk/source/Core/FormatClasses.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatClasses.cpp (original)
+++ lldb/trunk/source/Core/FormatClasses.cpp Tue Aug  9 21:10:13 2011
@@ -231,4 +231,4 @@
                 m_python_class.c_str());
     
     return sstr.GetString();
-}
\ No newline at end of file
+}

Modified: lldb/trunk/source/Core/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatManager.cpp (original)
+++ lldb/trunk/source/Core/FormatManager.cpp Tue Aug  9 21:10:13 2011
@@ -258,4 +258,4 @@
         default:
             return lldb::eFormatInvalid;
     }
-}
\ No newline at end of file
+}

Modified: lldb/trunk/source/Core/InputReader.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/InputReader.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Core/InputReader.cpp (original)
+++ lldb/trunk/source/Core/InputReader.cpp Tue Aug  9 21:10:13 2011
@@ -382,4 +382,4 @@
 InputReader::HandlerData::GetOutStream()
 {
     return reader.GetDebugger().GetAsyncOutputStream();
-}
\ No newline at end of file
+}

Modified: lldb/trunk/source/Core/InputReaderEZ.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/InputReaderEZ.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Core/InputReaderEZ.cpp (original)
+++ lldb/trunk/source/Core/InputReaderEZ.cpp Tue Aug  9 21:10:13 2011
@@ -93,4 +93,4 @@
 
 InputReaderEZ::~InputReaderEZ ()
 {
-}
\ No newline at end of file
+}

Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Tue Aug  9 21:10:13 2011
@@ -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;

Modified: lldb/trunk/source/Core/StringList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/StringList.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Core/StringList.cpp (original)
+++ lldb/trunk/source/Core/StringList.cpp Tue Aug  9 21:10:13 2011
@@ -236,4 +236,4 @@
 {
     AppendList(strings);
     return *this;
-}
\ No newline at end of file
+}

Modified: lldb/trunk/source/Expression/ProcessDataAllocator.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ProcessDataAllocator.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ProcessDataAllocator.cpp (original)
+++ lldb/trunk/source/Expression/ProcessDataAllocator.cpp Tue Aug  9 21:10:13 2011
@@ -40,4 +40,4 @@
                    0);                              // bit alignment (bitfields only; 0 means ignore)
     
     stream.PutChar('\n');
-}
\ No newline at end of file
+}

Modified: lldb/trunk/source/Host/common/TimeValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TimeValue.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/TimeValue.cpp (original)
+++ lldb/trunk/source/Host/common/TimeValue.cpp Tue Aug  9 21:10:13 2011
@@ -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)

Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Tue Aug  9 21:10:13 2011
@@ -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;

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Tue Aug  9 21:10:13 2011
@@ -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, 

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Aug  9 21:10:13 2011
@@ -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()));

Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Tue Aug  9 21:10:13 2011
@@ -121,4 +121,4 @@
     }
     
     return clang::ASTImporter::Imported(from, to);
-}
\ No newline at end of file
+}

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=137196&r1=137195&r2=137196&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Tue Aug  9 21:10:13 2011
@@ -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)
 {





More information about the lldb-commits mailing list