[Lldb-commits] [lldb] r159297 - in /lldb/branches/lldb-platform-work: ./ examples/darwin/heap_find/ examples/darwin/heap_find/heap/ examples/python/ include/lldb/API/ include/lldb/Breakpoint/ scripts/Python/interface/ source/API/ source/Breakpoint/ source/Commands/ source/Core/

Johnny Chen johnny.chen at apple.com
Wed Jun 27 15:05:22 PDT 2012


Author: johnny
Date: Wed Jun 27 17:05:22 2012
New Revision: 159297

URL: http://llvm.org/viewvc/llvm-project?rev=159297&view=rev
Log:
Merge changes from ToT trunk.

Modified:
    lldb/branches/lldb-platform-work/   (props changed)
    lldb/branches/lldb-platform-work/examples/darwin/heap_find/heap.py
    lldb/branches/lldb-platform-work/examples/darwin/heap_find/heap/heap_find.cpp
    lldb/branches/lldb-platform-work/examples/python/crashlog.py
    lldb/branches/lldb-platform-work/include/lldb/API/SBCommandReturnObject.h
    lldb/branches/lldb-platform-work/include/lldb/Breakpoint/Breakpoint.h
    lldb/branches/lldb-platform-work/include/lldb/Breakpoint/BreakpointLocation.h
    lldb/branches/lldb-platform-work/include/lldb/Breakpoint/StoppointLocation.h
    lldb/branches/lldb-platform-work/scripts/Python/interface/SBBlock.i
    lldb/branches/lldb-platform-work/scripts/Python/interface/SBCommandReturnObject.i
    lldb/branches/lldb-platform-work/scripts/Python/interface/SBProcess.i
    lldb/branches/lldb-platform-work/source/API/SBCommandReturnObject.cpp
    lldb/branches/lldb-platform-work/source/API/SBLineEntry.cpp
    lldb/branches/lldb-platform-work/source/Breakpoint/Breakpoint.cpp
    lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocation.cpp
    lldb/branches/lldb-platform-work/source/Commands/CommandObjectCommands.cpp
    lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp
    lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp

Propchange: lldb/branches/lldb-platform-work/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 27 17:05:22 2012
@@ -1 +1 @@
-/lldb/trunk:154223-159180
+/lldb/trunk:154223-159291

Modified: lldb/branches/lldb-platform-work/examples/darwin/heap_find/heap.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/examples/darwin/heap_find/heap.py?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/examples/darwin/heap_find/heap.py (original)
+++ lldb/branches/lldb-platform-work/examples/darwin/heap_find/heap.py Wed Jun 27 17:05:22 2012
@@ -44,8 +44,9 @@
             # Remake the dylib
             make_command = '(cd "%s" ; make EXE="%s" ARCH=%s)' % (heap_code_directory, libheap_dylib_path, string.split(triple, '-')[0])
             # print make_command
-            make_output = commands.getoutput(make_command)
-            # print make_output
+            (make_exit_status, make_output) = commands.getstatusoutput(make_command)
+            if make_exit_status != 0:
+                print make_output
         if os.path.exists(libheap_dylib_path):
             libheap_dylib_spec = lldb.SBFileSpec(libheap_dylib_path)
             if lldb.target.FindModule(libheap_dylib_spec):

Modified: lldb/branches/lldb-platform-work/examples/darwin/heap_find/heap/heap_find.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/examples/darwin/heap_find/heap/heap_find.cpp?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/examples/darwin/heap_find/heap/heap_find.cpp (original)
+++ lldb/branches/lldb-platform-work/examples/darwin/heap_find/heap/heap_find.cpp Wed Jun 27 17:05:22 2012
@@ -68,14 +68,80 @@
 #include <ctype.h>
 #include <mach/mach.h>
 #include <malloc/malloc.h>
-extern "C" {
-#include <stack_logging.h>
-}
 #include <stdio.h>
 #include <stdlib.h>
 #include <vector>
 
+//----------------------------------------------------------------------
+// Redefine private types from "/usr/local/include/stack_logging.h"
+//----------------------------------------------------------------------
+typedef struct {
+	uint32_t		type_flags;
+	uint64_t		stack_identifier;
+	uint64_t		argument;
+	mach_vm_address_t	address;
+} mach_stack_logging_record_t;
+
+//----------------------------------------------------------------------
+// Redefine private defines from "/usr/local/include/stack_logging.h"
+//----------------------------------------------------------------------
+#define stack_logging_type_free		0
+#define stack_logging_type_generic	1
+#define stack_logging_type_alloc	2
+#define stack_logging_type_dealloc	4
+
+//----------------------------------------------------------------------
+// Redefine private function prototypes from 
+// "/usr/local/include/stack_logging.h"
+//----------------------------------------------------------------------
+extern "C" kern_return_t 
+__mach_stack_logging_set_file_path (
+    task_t task, 
+    char* file_path
+);
+
+extern "C" kern_return_t 
+__mach_stack_logging_get_frames (
+    task_t task, 
+    mach_vm_address_t address, 
+    mach_vm_address_t *stack_frames_buffer, 
+    uint32_t max_stack_frames, 
+    uint32_t *count
+);
+
+extern "C" kern_return_t
+__mach_stack_logging_enumerate_records (
+    task_t task,
+    mach_vm_address_t address, 
+    void enumerator(mach_stack_logging_record_t, void *), 
+    void *context
+);
+
+extern "C" kern_return_t
+__mach_stack_logging_frames_for_uniqued_stack (
+    task_t task, 
+    uint64_t stack_identifier, 
+    mach_vm_address_t *stack_frames_buffer, 
+    uint32_t max_stack_frames, 
+    uint32_t *count
+);
+
+//----------------------------------------------------------------------
+// Redefine private gloval variables prototypes from 
+// "/usr/local/include/stack_logging.h"
+//----------------------------------------------------------------------
+
+extern "C" int stack_logging_enable_logging;
+extern "C" int stack_logging_dontcompact;
+
+//----------------------------------------------------------------------
+// Local defines
+//----------------------------------------------------------------------
 #define MAX_FRAMES 1024
+
+//----------------------------------------------------------------------
+// Local Typedefs and Types
+//----------------------------------------------------------------------
 typedef void range_callback_t (task_t task, void *baton, unsigned type, uint64_t ptr_addr, uint64_t ptr_size);
 typedef void zone_callback_t (void *info, const malloc_zone_t *zone);
 
@@ -127,7 +193,9 @@
     std::vector<uintptr_t> frames;
 };
 
-
+//----------------------------------------------------------------------
+// Local global variables
+//----------------------------------------------------------------------
 std::vector<malloc_match> g_matches;
 const void *g_lookup_addr = 0;
 std::vector<malloc_stack_entry> g_malloc_stack_history;

Modified: lldb/branches/lldb-platform-work/examples/python/crashlog.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/examples/python/crashlog.py?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/examples/python/crashlog.py (original)
+++ lldb/branches/lldb-platform-work/examples/python/crashlog.py Wed Jun 27 17:05:22 2012
@@ -29,9 +29,11 @@
 import lldb
 import commands
 import cmd
+import datetime
 import glob
 import optparse
 import os
+import platform
 import plistlib
 import pprint # pp = pprint.PrettyPrinter(indent=4); pp.pprint(command_args)
 import re
@@ -480,7 +482,84 @@
     interpreter.do_list()
     interpreter.cmdloop()
     
+
+def save_crashlog(debugger, command, result, dict):
+    usage = "usage: %prog [options] <output-path>"
+    description='''Export the state of current target into a crashlog file'''
+    parser = optparse.OptionParser(description=description, prog='save_crashlog',usage=usage)
+    parser.add_option('-v', '--verbose', action='store_true', dest='verbose', help='display verbose debug info', default=False)
+    try:
+        (options, args) = parser.parse_args(shlex.split(command))
+    except:
+        result.PutCString ("error: invalid options");
+        return
+    if len(args) != 1:
+        result.PutCString ("error: invalid arguments, a single output file is the only valid argument")
+        return
+    out_file = open(args[0], 'w')
+    if not out_file:
+        result.PutCString ("error: failed to open file '%s' for writing...", args[0]);
+        return
+    if lldb.target:
+        identifier = lldb.target.executable.basename
+        if lldb.process:
+            pid = lldb.process.id
+            if pid != lldb.LLDB_INVALID_PROCESS_ID:
+                out_file.write('Process:         %s [%u]\n' % (identifier, pid))
+        out_file.write('Path:            %s\n' % (lldb.target.executable.fullpath))
+        out_file.write('Identifier:      %s\n' % (identifier))
+        out_file.write('\nDate/Time:       %s\n' % (datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
+        out_file.write('OS Version:      Mac OS X %s (%s)\n' % (platform.mac_ver()[0], commands.getoutput('sysctl -n kern.osversion')));
+        out_file.write('Report Version:  9\n')
+        for thread_idx in range(lldb.process.num_threads):
+            thread = lldb.process.thread[thread_idx]
+            out_file.write('\nThread %u:\n' % (thread_idx))
+            for (frame_idx, frame) in enumerate(thread.frames):
+                frame_pc = frame.pc
+                frame_offset = 0
+                if frame.function:
+                    block = frame.GetFrameBlock()
+                    block_range = block.range[frame.addr]
+                    if block_range:
+                        block_start_addr = block_range[0]
+                        frame_offset = frame_pc - block_start_addr.load_addr
+                    else:
+                        frame_offset = frame_pc - frame.function.addr.load_addr
+                elif frame.symbol:
+                    frame_offset = frame_pc - frame.symbol.addr.load_addr
+                out_file.write('%-3u %-32s 0x%16.16x %s' % (frame_idx, frame.module.file.basename, frame_pc, frame.name))
+                if frame_offset > 0: 
+                    out_file.write(' + %u' % (frame_offset))
+                line_entry = frame.line_entry
+                if line_entry:
+                    if options.verbose:
+                        # This will output the fullpath + line + column
+                        out_file.write(' %s' % (line_entry))
+                    else:
+                        out_file.write(' %s:%u' % (line_entry.file.basename, line_entry.line))
+                        column = line_entry.column
+                        if column: 
+                            out_file.write(':%u' % (column))
+                out_file.write('\n')
+                
+        out_file.write('\nBinary Images:\n')
+        for module in lldb.target.modules:
+            text_segment = module.section['__TEXT']
+            if text_segment:
+                text_segment_load_addr = text_segment.GetLoadAddress(lldb.target)
+                if text_segment_load_addr != lldb.LLDB_INVALID_ADDRESS:
+                    text_segment_end_load_addr = text_segment_load_addr + text_segment.size
+                    identifier = module.file.basename
+                    module_version = '???'
+                    module_version_array = module.GetVersion()
+                    if module_version_array:
+                        module_version = '.'.join(map(str,module_version_array))
+                    out_file.write ('    0x%16.16x - 0x%16.16x  %s (%s - ???) <%s> %s\n' % (text_segment_load_addr, text_segment_end_load_addr, identifier, module_version, module.GetUUIDString(), module.file.fullpath))
+        out_file.close()
+    else:
+        result.PutCString ("error: invalid target");
         
+    
 def Symbolicate(debugger, command, result, dict):
     try:
         SymbolicateCrashLogs (shlex.split(command))
@@ -623,5 +702,6 @@
     SymbolicateCrashLogs (sys.argv[1:])
 elif getattr(lldb, 'debugger', None):
     lldb.debugger.HandleCommand('command script add -f lldb.macosx.crashlog.Symbolicate crashlog')
-    print '"crashlog" command installed, type "crashlog --help" for detailed help'
+    lldb.debugger.HandleCommand('command script add -f lldb.macosx.crashlog.save_crashlog save_crashlog')
+    print '"crashlog" and "save_crashlog" command installed, use the "--help" option for detailed help'
 

Modified: lldb/branches/lldb-platform-work/include/lldb/API/SBCommandReturnObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/API/SBCommandReturnObject.h?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/API/SBCommandReturnObject.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/API/SBCommandReturnObject.h Wed Jun 27 17:05:22 2012
@@ -61,6 +61,9 @@
 
     lldb::ReturnStatus
     GetStatus();
+    
+    void
+    SetStatus (lldb::ReturnStatus status);
 
     bool
     Succeeded ();

Modified: lldb/branches/lldb-platform-work/include/lldb/Breakpoint/Breakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/Breakpoint/Breakpoint.h?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/Breakpoint/Breakpoint.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/Breakpoint/Breakpoint.h Wed Jun 27 17:05:22 2012
@@ -345,7 +345,7 @@
     //------------------------------------------------------------------
     uint32_t
     GetIgnoreCount () const;
-
+    
     //------------------------------------------------------------------
     /// Return the current hit count for all locations.
     /// @return
@@ -551,6 +551,18 @@
     //------------------------------------------------------------------
     // This is the generic constructor
     Breakpoint(Target &target, lldb::SearchFilterSP &filter_sp, lldb::BreakpointResolverSP &resolver_sp);
+    
+    friend class BreakpointLocation;  // To call the following two when determining whether to stop.
+
+    void
+    DecrementIgnoreCount();
+
+    // BreakpointLocation::IgnoreCountShouldStop & Breakpoint::IgnoreCountShouldStop can only be called once per stop, 
+    // and BreakpointLocation::IgnoreCountShouldStop should be tested first, and if it returns false we should
+    // continue, otherwise we should test Breakpoint::IgnoreCountShouldStop.
+    
+    bool
+    IgnoreCountShouldStop ();
 
 private:
     //------------------------------------------------------------------

Modified: lldb/branches/lldb-platform-work/include/lldb/Breakpoint/BreakpointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/Breakpoint/BreakpointLocation.h?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/Breakpoint/BreakpointLocation.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/Breakpoint/BreakpointLocation.h Wed Jun 27 17:05:22 2012
@@ -336,6 +336,12 @@
     bool
     SetBreakpointSite (lldb::BreakpointSiteSP& bp_site_sp);
 
+    void
+    DecrementIgnoreCount();
+
+    bool
+    IgnoreCountShouldStop();
+
 private:
 
     //------------------------------------------------------------------

Modified: lldb/branches/lldb-platform-work/include/lldb/Breakpoint/StoppointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/Breakpoint/StoppointLocation.h?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/Breakpoint/StoppointLocation.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/Breakpoint/StoppointLocation.h Wed Jun 27 17:05:22 2012
@@ -69,12 +69,6 @@
         return m_hit_count;
     }
 
-    void
-    IncrementHitCount ()
-    {
-        ++m_hit_count;
-    }
-
     uint32_t
     GetHardwareIndex () const
     {
@@ -133,6 +127,13 @@
                                     // hardware breakpoints, or the length of the watchpoint.
     uint32_t    m_hit_count;        // Number of times this breakpoint/watchpoint has been hit
 
+    // If you override this, be sure to call the base class to increment the internal counter.
+    void
+    IncrementHitCount ()
+    {
+        ++m_hit_count;
+    }
+
 private:
     //------------------------------------------------------------------
     // For StoppointLocation only

Modified: lldb/branches/lldb-platform-work/scripts/Python/interface/SBBlock.i
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/scripts/Python/interface/SBBlock.i?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/scripts/Python/interface/SBBlock.i (original)
+++ lldb/branches/lldb-platform-work/scripts/Python/interface/SBBlock.i Wed Jun 27 17:05:22 2012
@@ -123,6 +123,10 @@
                 count = len(self)
                 if type(key) is int:
                     return self.sbblock.get_range_at_index (key);
+                if isinstance(key, SBAddress):
+                    range_idx = self.sbblock.GetRangeIndexForBlockAddress(key);
+                    if range_idx < len(self):
+                        return [self.sbblock.GetRangeStartAddress(range_idx), self.sbblock.GetRangeEndAddress(range_idx)]
                 else:
                     print "error: unsupported item type: %s" % type(key)
                 return None

Modified: lldb/branches/lldb-platform-work/scripts/Python/interface/SBCommandReturnObject.i
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/scripts/Python/interface/SBCommandReturnObject.i?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/scripts/Python/interface/SBCommandReturnObject.i (original)
+++ lldb/branches/lldb-platform-work/scripts/Python/interface/SBCommandReturnObject.i Wed Jun 27 17:05:22 2012
@@ -50,6 +50,9 @@
     void
     Clear();
 
+    void
+    SetStatus (lldb::ReturnStatus status);
+
     lldb::ReturnStatus
     GetStatus();
 

Modified: lldb/branches/lldb-platform-work/scripts/Python/interface/SBProcess.i
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/scripts/Python/interface/SBProcess.i?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/scripts/Python/interface/SBProcess.i (original)
+++ lldb/branches/lldb-platform-work/scripts/Python/interface/SBProcess.i Wed Jun 27 17:05:22 2012
@@ -341,7 +341,7 @@
             '''An accessor function that returns a list() that contains all threads in a lldb.SBProcess object.'''
             threads = []
             for idx in range(self.GetNumThreads()):
-                threads.append(GetThreadAtIndex(idx))
+                threads.append(self.threads_access(idx))
             return threads
         
         __swig_getmethods__["threads"] = get_process_thread_list

Modified: lldb/branches/lldb-platform-work/source/API/SBCommandReturnObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBCommandReturnObject.cpp?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBCommandReturnObject.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBCommandReturnObject.cpp Wed Jun 27 17:05:22 2012
@@ -160,6 +160,13 @@
     return lldb::eReturnStatusInvalid;
 }
 
+void
+SBCommandReturnObject::SetStatus(lldb::ReturnStatus status)
+{
+    if (m_opaque_ap.get())
+         m_opaque_ap->SetStatus(status);
+}
+
 bool
 SBCommandReturnObject::Succeeded ()
 {

Modified: lldb/branches/lldb-platform-work/source/API/SBLineEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBLineEntry.cpp?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBLineEntry.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBLineEntry.cpp Wed Jun 27 17:05:22 2012
@@ -110,7 +110,7 @@
 bool
 SBLineEntry::IsValid () const
 {
-    return m_opaque_ap.get() != NULL;
+    return m_opaque_ap.get() && m_opaque_ap->IsValid();
 }
 
 

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/Breakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/Breakpoint.cpp?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/Breakpoint.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/Breakpoint.cpp Wed Jun 27 17:05:22 2012
@@ -152,12 +152,36 @@
     SendBreakpointChangedEvent (eBreakpointEventTypeIgnoreChanged);
 }
 
+void
+Breakpoint::DecrementIgnoreCount ()
+{
+    uint32_t ignore = m_options.GetIgnoreCount();
+    if (ignore != 0)
+        m_options.SetIgnoreCount(ignore - 1);
+}
+
 uint32_t
 Breakpoint::GetIgnoreCount () const
 {
     return m_options.GetIgnoreCount();
 }
 
+bool
+Breakpoint::IgnoreCountShouldStop ()
+{
+    uint32_t ignore = GetIgnoreCount();
+    if (ignore != 0)
+    {
+        // When we get here we know the location that caused the stop doesn't have an ignore count,
+        // since by contract we call it first...  So we don't have to find & decrement it, we only have
+        // to decrement our own ignore count.
+        DecrementIgnoreCount();
+        return false;
+    }
+    else
+        return true;
+}
+
 uint32_t
 Breakpoint::GetHitCount () const
 {

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocation.cpp?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocation.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocation.cpp Wed Jun 27 17:05:22 2012
@@ -254,6 +254,34 @@
     SendBreakpointLocationChangedEvent (eBreakpointEventTypeIgnoreChanged);
 }
 
+void
+BreakpointLocation::DecrementIgnoreCount()
+{
+    if (m_options_ap.get() != NULL)
+    {
+        uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
+        if (loc_ignore != 0)
+            m_options_ap->SetIgnoreCount(loc_ignore - 1);
+    }
+}
+
+bool
+BreakpointLocation::IgnoreCountShouldStop()
+{
+    if (m_options_ap.get() != NULL)
+    {
+        uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
+        if (loc_ignore != 0)
+        {
+            m_owner.DecrementIgnoreCount();
+            DecrementIgnoreCount();          // Have to decrement our owners' ignore count, since it won't get a
+                                             // chance to.
+            return false;
+        }
+    }
+    return true;
+}
+
 const BreakpointOptions *
 BreakpointLocation::GetOptionsNoCreate () const
 {
@@ -297,7 +325,10 @@
     if (!IsEnabled())
         return false;
 
-    if (GetHitCount() <= GetIgnoreCount())
+    if (!IgnoreCountShouldStop())
+        return false;
+    
+    if (!m_owner.IgnoreCountShouldStop())
         return false;
 
     // We only run synchronous callbacks in ShouldStop:

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectCommands.cpp?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectCommands.cpp Wed Jun 27 17:05:22 2012
@@ -1214,6 +1214,8 @@
         
         Error error;
         
+        result.SetStatus(eReturnStatusInvalid);
+        
         if (!scripter || scripter->RunScriptBasedCommand(m_function_name.c_str(),
                                                          raw_command_line,
                                                          m_synchro,
@@ -1224,7 +1226,16 @@
             result.SetStatus(eReturnStatusFailed);
         }
         else
-            result.SetStatus(eReturnStatusSuccessFinishNoResult);
+        {
+            // Don't change the status if the command already set it...
+            if (result.GetStatus() == eReturnStatusInvalid)
+            {
+                if (result.GetOutputData() == NULL || result.GetOutputData()[0] == '\0')
+                    result.SetStatus(eReturnStatusSuccessFinishNoResult);
+                else
+                    result.SetStatus(eReturnStatusSuccessFinishResult);
+            }
+        }
         
         return result.Succeeded();
     }

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp Wed Jun 27 17:05:22 2012
@@ -2929,6 +2929,10 @@
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
         const bool use_global_module_list = m_options.m_use_global_module_list;
+        // Define a local module list here to ensure it lives longer than any "locker"
+        // object which might lock its contents below (through the "module_list_ptr"
+        // variable).
+        ModuleList module_list;
         if (target == NULL && use_global_module_list == false)
         {
             result.AppendError ("invalid target, create a debug target using the 'target create' command");
@@ -2983,8 +2987,6 @@
             Mutex::Locker locker;      // This locker will be locked on the mutex in module_list_ptr if it is non-NULL.
                                        // Otherwise it will lock the AllocationModuleCollectionMutex when accessing
                                        // the global module list directly.
-            
-            ModuleList module_list;
             ModuleList *module_list_ptr = NULL;
             const size_t argc = command.GetArgumentCount();
             if (argc == 0)

Modified: lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp?rev=159297&r1=159296&r2=159297&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp Wed Jun 27 17:05:22 2012
@@ -37,8 +37,12 @@
 // Copy constructor
 //----------------------------------------------------------------------
 ModuleList::ModuleList(const ModuleList& rhs) :
-    m_modules(rhs.m_modules)
+    m_modules(),
+    m_modules_mutex (Mutex::eMutexTypeRecursive)
 {
+    Mutex::Locker lhs_locker(m_modules_mutex);
+    Mutex::Locker rhs_locker(rhs.m_modules_mutex);
+    m_modules = rhs.m_modules;
 }
 
 //----------------------------------------------------------------------
@@ -49,7 +53,8 @@
 {
     if (this != &rhs)
     {
-        Mutex::Locker locker(m_modules_mutex);
+        Mutex::Locker lhs_locker(m_modules_mutex);
+        Mutex::Locker rhs_locker(rhs.m_modules_mutex);
         m_modules = rhs.m_modules;
     }
     return *this;





More information about the lldb-commits mailing list