[Lldb-commits] [lldb] r156610 - in /lldb/branches/apple/python-GIL: ./ examples/darwin/heap_find/heap.py examples/darwin/heap_find/heap/heap_find.cpp examples/python/crashlog.py examples/python/symbolication.py llvm.zip scripts/clang.complete-type-isSafeToConvert.diff tools/debugserver/source/RNBServices.cpp tools/driver/Driver.cpp

Filipe Cabecinhas me at filcab.net
Fri May 11 03:00:52 PDT 2012


Author: filcab
Date: Fri May 11 05:00:52 2012
New Revision: 156610

URL: http://llvm.org/viewvc/llvm-project?rev=156610&view=rev
Log:
Merged from trunk

Added:
    lldb/branches/apple/python-GIL/scripts/clang.complete-type-isSafeToConvert.diff
      - copied unchanged from r156605, lldb/trunk/scripts/clang.complete-type-isSafeToConvert.diff
Modified:
    lldb/branches/apple/python-GIL/   (props changed)
    lldb/branches/apple/python-GIL/examples/darwin/heap_find/heap.py
    lldb/branches/apple/python-GIL/examples/darwin/heap_find/heap/heap_find.cpp
    lldb/branches/apple/python-GIL/examples/python/crashlog.py
    lldb/branches/apple/python-GIL/examples/python/symbolication.py
    lldb/branches/apple/python-GIL/llvm.zip
    lldb/branches/apple/python-GIL/tools/debugserver/source/RNBServices.cpp
    lldb/branches/apple/python-GIL/tools/driver/Driver.cpp

Propchange: lldb/branches/apple/python-GIL/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri May 11 05:00:52 2012
@@ -1 +1 @@
-/lldb/trunk:156467-156548
+/lldb/trunk:156467-156605

Modified: lldb/branches/apple/python-GIL/examples/darwin/heap_find/heap.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/examples/darwin/heap_find/heap.py?rev=156610&r1=156609&r2=156610&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/examples/darwin/heap_find/heap.py (original)
+++ lldb/branches/apple/python-GIL/examples/darwin/heap_find/heap.py Fri May 11 05:00:52 2012
@@ -20,6 +20,7 @@
 
 g_libheap_dylib_dir = None
 g_libheap_dylib_dict = dict()
+g_verbose = False
 
 def load_dylib():
     if lldb.target:
@@ -72,6 +73,9 @@
         return 'error: invalid target'
         
     debugger.HandleCommand('process load "%s"' % libheap_dylib_path)
+    if lldb.target.FindModule(libheap_dylib_spec):
+        return None # success, 'libheap.dylib' already loaded
+    return 'error: failed to load "%s"' % libheap_dylib_path
     
 def add_common_options(parser):
     parser.add_option('-v', '--verbose', action='store_true', dest='verbose', help='display verbose debug info', default=False)
@@ -79,7 +83,66 @@
     parser.add_option('-m', '--memory', action='store_true', dest='memory', help='dump the memory for each matching block', default=False)
     parser.add_option('-f', '--format', type='string', dest='format', help='the format to use when dumping memory if --memory is specified', default=None)
     parser.add_option('-s', '--stack', action='store_true', dest='stack', help='gets the stack that allocated each malloc block if MallocStackLogging is enabled', default=False)
-    #parser.add_option('-S', '--stack-history', action='store_true', dest='stack_history', help='gets the stack history for all allocations whose start address matches each malloc block if MallocStackLogging is enabled', default=False)
+    parser.add_option('-S', '--stack-history', action='store_true', dest='stack_history', help='gets the stack history for all allocations whose start address matches each malloc block if MallocStackLogging is enabled', default=False)
+
+def dump_stack_history_entry(stack_history_entry, idx):
+    address = int(stack_history_entry.address)
+    if address:
+        type_flags = int(stack_history_entry.type_flags)
+        symbolicator = lldb.utils.symbolication.Symbolicator()
+        symbolicator.target = lldb.target
+        type_str = ''
+        if type_flags == 0:
+            type_str = 'free'
+        else:
+            if type_flags & 2:
+                type_str = 'alloc'
+            elif type_flags & 4:
+                type_str = 'free'
+            elif type_flags & 1:
+                type_str = 'generic'
+            else:
+                type_str = hex(type_flags)
+        print 'stack[%u]: addr = 0x%x, type=%s, frames:' % (idx, address, type_str)
+        frame_idx = 0
+        idx = 0
+        pc = int(stack_history_entry.frames[idx])
+        while pc != 0:
+            if pc >= 0x1000:
+                frames = symbolicator.symbolicate(pc)
+                if frames:
+                    for frame in frames:
+                        print '     [%u] %s' % (frame_idx, frame)
+                        frame_idx += 1
+                else:
+                    print '     [%u] 0x%x' % (frame_idx, pc)
+                    frame_idx += 1
+                idx = idx + 1
+                pc = int(stack_history_entry.frames[idx])
+            else:
+                pc = 0
+        print
+            
+def dump_stack_history_entries(addr, history):
+    # malloc_stack_entry *get_stack_history_for_address (const void * addr)
+    expr = 'get_stack_history_for_address((void *)0x%x, %u)' % (addr, history)
+    print 'expr = "%s"' % (expr)
+    expr_sbvalue = lldb.frame.EvaluateExpression (expr)
+    if expr_sbvalue.error.Success():
+        if expr_sbvalue.unsigned:
+            expr_value = lldb.value(expr_sbvalue)  
+            #print 'expr_value = ', expr_value
+            idx = 0;
+            stack_history_entry = expr_value[idx]
+            while int(stack_history_entry.address) != 0:
+                dump_stack_history_entry(stack_history_entry, idx)
+                idx = idx + 1
+                stack_history_entry = expr_value[idx]
+        else:
+            print 'error: expression returned => %s' % (expr_sbvalue)
+    else:
+        print 'error: expression failed "%s" => %s' % (expr, expr_sbvalue.error)
+    
     
 def heap_search(options, arg_str):
     dylid_load_err = load_dylib()
@@ -186,41 +249,10 @@
                     memory_command = "memory read -f %s 0x%x 0x%x" % (memory_format, malloc_addr, malloc_addr + malloc_size)
                     lldb.debugger.GetCommandInterpreter().HandleCommand(memory_command, cmd_result)
                     print cmd_result.GetOutput()
-                if options.stack:
-                    symbolicator = lldb.utils.symbolication.Symbolicator()
-                    symbolicator.target = lldb.target
-                    expr_str = "g_stack_frames_count = sizeof(g_stack_frames)/sizeof(uint64_t); (int)__mach_stack_logging_get_frames((unsigned)mach_task_self(), 0x%xull, g_stack_frames, g_stack_frames_count, &g_stack_frames_count)" % (malloc_addr)
-                    #print expr_str
-                    expr = lldb.frame.EvaluateExpression (expr_str);
-                    expr_error = expr.GetError()
-                    if expr_error.Success():
-                        err = expr.unsigned
-                        if err:
-                            print 'error: __mach_stack_logging_get_frames() returned error %i' % (err)
-                        else:
-                            count_expr = lldb.frame.EvaluateExpression ("g_stack_frames_count")
-                            count = count_expr.unsigned
-                            #print 'g_stack_frames_count is %u' % (count)
-                            if count > 0:
-                                frame_idx = 0
-                                frames_expr = lldb.value(lldb.frame.EvaluateExpression ("g_stack_frames"))
-                                done = False
-                                for stack_frame_idx in range(count):
-                                    if not done:
-                                        frame_load_addr = int(frames_expr[stack_frame_idx])
-                                        if frame_load_addr >= 0x1000:
-                                            frames = symbolicator.symbolicate(frame_load_addr)
-                                            if frames:
-                                                for frame in frames:
-                                                    print '[%3u] %s' % (frame_idx, frame)
-                                                    frame_idx += 1
-                                            else:
-                                                print '[%3u] 0x%x' % (frame_idx, frame_load_addr)
-                                                frame_idx += 1
-                                        else:
-                                            done = True
-                    else:
-                        print 'error: %s' % (expr_error)
+                if options.stack_history:
+                    dump_stack_history_entries(malloc_addr, 1)
+                elif options.stack:
+                    dump_stack_history_entries(malloc_addr, 0)
         else:
             print '%s %s was not found in any malloc blocks' % (options.type, arg_str)
     else:
@@ -229,7 +261,7 @@
     
 def ptr_refs(debugger, command, result, dict):
     command_args = shlex.split(command)
-    usage = "usage: %prog [options] <PTR> [PTR ...]"
+    usage = "usage: %prog [options] <EXPR> [EXPR ...]"
     description='''Searches the heap for pointer references on darwin user space programs. 
     
     Any matches that were found will dump the malloc blocks that contain the pointers 
@@ -277,7 +309,7 @@
 
 def malloc_info(debugger, command, result, dict):
     command_args = shlex.split(command)
-    usage = "usage: %prog [options] <ADDR> [ADDR ...]"
+    usage = "usage: %prog [options] <EXPR> [EXPR ...]"
     description='''Searches the heap a malloc block that contains the addresses specified as arguments. 
 
     Any matches that were found will dump the malloc blocks that match or contain
@@ -289,16 +321,37 @@
         (options, args) = parser.parse_args(command_args)
     except:
         return
-
     options.type = 'addr'
-
     if args:
-
         for data in args:
             heap_search (options, data)
     else:
         print 'error: no c string arguments were given to search for'
 
+def malloc_history(debugger, command, result, dict):
+    command_args = shlex.split(command)
+    usage = "usage: %prog [options] <EXPR> [EXPR ...]"
+    description='''Gets the allocation history for an expression whose result is an address.
+
+    Programs should set the MallocStackLoggingNoCompact=1 in the environment to enable stack history. This can be done
+    with "process launch -v MallocStackLoggingNoCompact=1 -- [arg1 ...]"'''
+
+    dylid_load_err = load_dylib()
+    if dylid_load_err:
+        print dylid_load_err
+    else:
+        if command_args:
+            for addr_expr_str in command_args:
+                expr_sbvalue = lldb.frame.EvaluateExpression (addr_expr_str)
+                if expr_sbvalue.error.Success():
+                    addr = expr_sbvalue.unsigned
+                    if addr != 0:
+                        dump_stack_history_entries (addr, 1)
+                else:
+                    print 'error: expression error for "%s": %s' % (addr_expr_str, expr_sbvalue.error)
+        else:
+            print 'error: no address expressions were specified'
+
 if __name__ == '__main__':
     lldb.debugger = lldb.SBDebugger.Create()
 
@@ -307,7 +360,8 @@
 lldb.debugger.HandleCommand('command script add -f lldb.macosx.heap.ptr_refs ptr_refs')
 lldb.debugger.HandleCommand('command script add -f lldb.macosx.heap.cstr_refs cstr_refs')
 lldb.debugger.HandleCommand('command script add -f lldb.macosx.heap.malloc_info malloc_info')
-print '"ptr_refs", "cstr_refs", and "malloc_info" commands have been installed, use the "--help" options on these commands for detailed help.'
+lldb.debugger.HandleCommand('command script add -f lldb.macosx.heap.malloc_history malloc_history')
+print '"ptr_refs", "cstr_refs", "malloc_info", and "malloc_history" commands have been installed, use the "--help" options on these commands for detailed help.'
 
 
 

Modified: lldb/branches/apple/python-GIL/examples/darwin/heap_find/heap/heap_find.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/examples/darwin/heap_find/heap/heap_find.cpp?rev=156610&r1=156609&r2=156610&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/examples/darwin/heap_find/heap/heap_find.cpp (original)
+++ lldb/branches/apple/python-GIL/examples/darwin/heap_find/heap/heap_find.cpp Fri May 11 05:00:52 2012
@@ -68,7 +68,9 @@
 #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>
@@ -117,10 +119,20 @@
     intptr_t offset;
 };
 
+struct malloc_stack_entry
+{
+    const void *address;
+    uint64_t argument;
+    uint32_t type_flags;
+    std::vector<uintptr_t> frames;
+};
+
+
 std::vector<malloc_match> g_matches;
 const void *g_lookup_addr = 0;
+std::vector<malloc_stack_entry> g_malloc_stack_history;
 mach_vm_address_t g_stack_frames[MAX_FRAMES];
-uint32_t g_stack_frames_count = 0;
+char g_error_string[PATH_MAX];
 
 //----------------------------------------------------------------------
 // task_peek
@@ -242,6 +254,71 @@
     }
 }
 
+static void 
+get_stack_for_address_enumerator(mach_stack_logging_record_t stack_record, void *task_ptr)
+{
+    uint32_t num_frames = 0;
+    kern_return_t err = __mach_stack_logging_frames_for_uniqued_stack (*(task_t *)task_ptr, 
+                                                                       stack_record.stack_identifier,
+                                                                       g_stack_frames,
+                                                                       MAX_FRAMES,
+                                                                       &num_frames);    
+    g_malloc_stack_history.resize(g_malloc_stack_history.size() + 1);
+    g_malloc_stack_history.back().address = (void *)stack_record.address;
+    g_malloc_stack_history.back().type_flags = stack_record.type_flags;
+    g_malloc_stack_history.back().argument = stack_record.argument;
+    if (num_frames > 0)
+        g_malloc_stack_history.back().frames.assign(g_stack_frames, g_stack_frames + num_frames);
+    g_malloc_stack_history.back().frames.push_back(0); // Terminate the frames with zero
+}
+
+malloc_stack_entry *
+get_stack_history_for_address (const void * addr, int history)
+{
+    std::vector<malloc_stack_entry> empty;
+    g_malloc_stack_history.swap(empty);
+    if (!stack_logging_enable_logging || (history && !stack_logging_dontcompact))
+    {
+        if (history)
+            strncpy(g_error_string, "error: stack history logging is not enabled, set MallocStackLoggingNoCompact=1 in the environment when launching to enable stack history logging.", sizeof(g_error_string));
+        else
+            strncpy(g_error_string, "error: stack logging is not enabled, set MallocStackLogging=1 in the environment when launching to enable stack logging.", sizeof(g_error_string));
+        return NULL;
+    }
+    kern_return_t err;
+    task_t task = mach_task_self();
+    if (history)
+    {
+        err = __mach_stack_logging_enumerate_records (task,
+                                                      (mach_vm_address_t)addr, 
+                                                      get_stack_for_address_enumerator,
+                                                      &task);
+    }
+    else
+    {
+        uint32_t num_frames = 0;
+        err = __mach_stack_logging_get_frames(task, (mach_vm_address_t)addr, g_stack_frames, MAX_FRAMES, &num_frames);
+        if (err == 0 && num_frames > 0)
+        {
+            g_malloc_stack_history.resize(1);
+            g_malloc_stack_history.back().address = addr;
+            g_malloc_stack_history.back().type_flags = stack_logging_type_alloc;
+            g_malloc_stack_history.back().argument = 0;
+            if (num_frames > 0)
+                g_malloc_stack_history.back().frames.assign(g_stack_frames, g_stack_frames + num_frames);
+            g_malloc_stack_history.back().frames.push_back(0); // Terminate the frames with zero
+        }
+    }
+    // Append an empty entry
+    if (g_malloc_stack_history.empty())
+        return NULL;
+    g_malloc_stack_history.resize(g_malloc_stack_history.size() + 1);
+    g_malloc_stack_history.back().address = 0;
+    g_malloc_stack_history.back().type_flags = 0;
+    g_malloc_stack_history.back().argument = 0;
+    return g_malloc_stack_history.data();
+}
+
 //----------------------------------------------------------------------
 // find_pointer_in_heap
 //

Modified: lldb/branches/apple/python-GIL/examples/python/crashlog.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/examples/python/crashlog.py?rev=156610&r1=156609&r2=156610&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/examples/python/crashlog.py (original)
+++ lldb/branches/apple/python-GIL/examples/python/crashlog.py Fri May 11 05:00:52 2012
@@ -121,14 +121,15 @@
             if self.resolved_path:
                 # Don't load a module twice...
                 return True
-            print 'Getting symbols for %s %s...' % (self.uuid, self.path),
+            uuid_str = self.get_normalized_uuid_string()
+            print 'Getting symbols for %s %s...' % (uuid_str, self.path),
             if os.path.exists(self.dsymForUUIDBinary):
-                dsym_for_uuid_command = '%s %s' % (self.dsymForUUIDBinary, self.uuid)
+                dsym_for_uuid_command = '%s %s' % (self.dsymForUUIDBinary, uuid_str)
                 s = commands.getoutput(dsym_for_uuid_command)
                 if s:
                     plist_root = plistlib.readPlistFromString (s)
                     if plist_root:
-                        plist = plist_root[self.uuid]
+                        plist = plist_root[uuid_str]
                         if plist:
                             if 'DBGArchitecture' in plist:
                                 self.arch = plist['DBGArchitecture']
@@ -138,7 +139,7 @@
                                 self.resolved_path = os.path.expanduser (plist['DBGSymbolRichExecutable'])
             if not self.resolved_path and os.path.exists(self.path):
                 dwarfdump_cmd_output = commands.getoutput('dwarfdump --uuid "%s"' % self.path)
-                self_uuid = uuid.UUID(self.uuid)
+                self_uuid = self.get_uuid()
                 for line in dwarfdump_cmd_output.splitlines():
                     match = self.dwarfdump_uuid_regex.search (line)
                     if match:
@@ -149,7 +150,7 @@
                             self.arch = match.group(2)
                             break;
                 if not self.resolved_path:
-                    print "error: file %s '%s' doesn't match the UUID in the installed file" % (self.uuid, self.path)
+                    print "error: file %s '%s' doesn't match the UUID in the installed file" % (uuid_str, self.path)
                     return False
             if (self.resolved_path and os.path.exists(self.resolved_path)) or (self.path and os.path.exists(self.path)):
                 print 'ok'
@@ -213,8 +214,14 @@
                 elif line.startswith ('Identifier:'):
                     self.process_identifier = line[11:].strip()
                 elif line.startswith ('Version:'):
-                    (self.process_version, compatability_version) = line[8:].strip().split()
-                    self.process_compatability_version = compatability_version.strip('()')
+                    version_string = line[8:].strip()
+                    matched_pair = re.search("(.+)\((.+)\)", version_string)
+                    if matched_pair:
+                        self.process_version = matched_pair.group(1)
+                        self.process_compatability_version = matched_pair.group(2)
+                    else:
+                        self.process = version_string
+                        self.process_compatability_version = version_string
                 elif line.startswith ('Parent Process:'):
                     (self.parent_process_name, pid_with_brackets) = line[15:].strip().split()
                     self.parent_process_id = pid_with_brackets.strip('[]') 
@@ -261,6 +268,8 @@
                     continue
                 self.info_lines.append(line.strip())
             elif parse_mode == PARSE_MODE_THREAD:
+                if line.startswith ('Thread'):
+                    continue
                 frame_match = self.frame_regex.search(line)
                 if frame_match:
                     ident = frame_match.group(2)
@@ -276,7 +285,7 @@
                                                   int(image_match.group(2),0), 
                                                   image_match.group(3).strip(), 
                                                   image_match.group(4).strip(), 
-                                                  image_match.group(5), 
+                                                  uuid.UUID(image_match.group(5)), 
                                                   image_match.group(6))
                     self.images.append (image)
                 else:
@@ -294,9 +303,12 @@
 
             elif parse_mode == PARSE_MODE_THREGS:
                 stripped_line = line.strip()
-                reg_values = stripped_line.split('  ')
+                reg_values = re.split('  +', stripped_line);
                 for reg_value in reg_values:
+                    #print 'reg_value = "%s"' % reg_value
                     (reg, value) = reg_value.split(': ')
+                    #print 'reg = "%s"' % reg
+                    #print 'value = "%s"' % value
                     thread.registers[reg.strip()] = int(value, 0)
             elif parse_mode == PARSE_MODE_SYSTEM:
                 self.system_profile.append(line)
@@ -392,24 +404,29 @@
         except:
             return
         
-        for image_path in args:
-            fullpath_search = image_path[0] == '/'
+        if args:
+            for image_path in args:
+                fullpath_search = image_path[0] == '/'
+                for crash_log in self.crash_logs:
+                    matches_found = 0
+                    for (image_idx, image) in enumerate(crash_log.images):
+                        if fullpath_search:
+                            if image.get_resolved_path() == image_path:
+                                matches_found += 1
+                                print image
+                        else:
+                            image_basename = image.get_resolved_path_basename()
+                            if image_basename == image_path:
+                                matches_found += 1
+                                print image
+                    if matches_found == 0:
+                        for (image_idx, image) in enumerate(crash_log.images):
+                            if string.find(image.get_resolved_path(), image_path) >= 0:
+                                print image
+        else:
             for crash_log in self.crash_logs:
-                matches_found = 0
                 for (image_idx, image) in enumerate(crash_log.images):
-                    if fullpath_search:
-                        if image.get_resolved_path() == image_path:
-                            matches_found += 1
-                            print image
-                    else:
-                        image_basename = image.get_resolved_path_basename()
-                        if image_basename == image_path:
-                            matches_found += 1
-                            print image
-                if matches_found == 0:
-                    for (image_idx, image) in enumerate(crash_log.images):
-                        if string.find(image.get_resolved_path(), image_path) >= 0:
-                            print image                            
+                    print '[%u] %s' % (image_idx, image)            
         return False
 
 

Modified: lldb/branches/apple/python-GIL/examples/python/symbolication.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/examples/python/symbolication.py?rev=156610&r1=156609&r2=156610&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/examples/python/symbolication.py (original)
+++ lldb/branches/apple/python-GIL/examples/python/symbolication.py Fri May 11 05:00:52 2012
@@ -283,12 +283,13 @@
         '''Add the Image described in this object to "target" and load the sections if "load" is True.'''
         if target:
             # Try and find using UUID only first so that paths need not match up
-            if self.uuid:
-                self.module = target.AddModule (None, None, str(self.uuid))
+            uuid_str = self.get_normalized_uuid_string()
+            if uuid_str:
+                self.module = target.AddModule (None, None, uuid_str)
             if not self.module:
                 self.locate_module_and_debug_symbols ()
                 resolved_path = self.get_resolved_path()
-                self.module = target.AddModule (resolved_path, self.arch, self.uuid)#, self.symfile)
+                self.module = target.AddModule (resolved_path, self.arch, uuid_str, self.symfile)
             if not self.module:
                 return 'error: unable to get module for (%s) "%s"' % (self.arch, self.get_resolved_path())
             if self.has_section_load_info():
@@ -308,10 +309,15 @@
         return True
     
     def get_uuid(self):
-        if not self.uuid:
+        if not self.uuid and self.module:
             self.uuid = uuid.UUID(self.module.GetUUIDString())
         return self.uuid
 
+    def get_normalized_uuid_string(self):
+        if self.uuid:
+            return str(self.uuid).upper()
+        return None
+
     def create_target(self):
         '''Create a target using the information in this Image object.'''
         if self.locate_module_and_debug_symbols ():

Modified: lldb/branches/apple/python-GIL/llvm.zip
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/llvm.zip?rev=156610&r1=156609&r2=156610&view=diff
==============================================================================
Binary files - no diff available.

Modified: lldb/branches/apple/python-GIL/tools/debugserver/source/RNBServices.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/tools/debugserver/source/RNBServices.cpp?rev=156610&r1=156609&r2=156610&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/tools/debugserver/source/RNBServices.cpp (original)
+++ lldb/branches/apple/python-GIL/tools/debugserver/source/RNBServices.cpp Fri May 11 05:00:52 2012
@@ -36,7 +36,8 @@
     CFReleaser<CFStringRef> sbsFrontAppID (::SBSCopyFrontmostApplicationDisplayIdentifier ());
     CFReleaser<CFArrayRef> sbsAppIDs (::SBSCopyApplicationDisplayIdentifiers (opt_runningApps, opt_debuggable));
 
-    CFIndex count = ::CFArrayGetCount (sbsAppIDs.get());
+    // Need to check the return value from SBSCopyApplicationDisplayIdentifiers.
+    CFIndex count = sbsAppIDs.get() ? ::CFArrayGetCount (sbsAppIDs.get()) : 0;
     CFIndex i = 0;
     for (i = 0; i < count; i++)
     {

Modified: lldb/branches/apple/python-GIL/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/tools/driver/Driver.cpp?rev=156610&r1=156609&r2=156610&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/tools/driver/Driver.cpp (original)
+++ lldb/branches/apple/python-GIL/tools/driver/Driver.cpp Fri May 11 05:00:52 2012
@@ -1106,14 +1106,6 @@
     return bytes_len;
 }
 
-// Intercept when the quit command is called and tell our driver that it is done
-static bool
-QuitCommandOverrideCallback (void *baton, const char **argv)
-{
-    ((Driver *)baton)->SetIsDone();
-    return true;
-}
-
 void
 Driver::MainLoop ()
 {
@@ -1216,10 +1208,6 @@
 
     SBCommandInterpreter sb_interpreter = m_debugger.GetCommandInterpreter();
 
-    // Intercept when the quit command is called and tell our driver that it is done
-    bool quit_success = sb_interpreter.SetCommandOverrideCallback ("quit", QuitCommandOverrideCallback, this);
-    assert (quit_success);
-
     m_io_channel_ap.reset (new IOChannel(m_editline_slave_fh, editline_output_slave_fh, stdout, stderr, this));
 
     SBCommunication out_comm_2("driver.editline_output");





More information about the lldb-commits mailing list