Beispiel #1
0
        def dump_symbolicated(self, crash_log, options):
            this_thread_crashed = self.app_specific_backtrace
            if not this_thread_crashed:
                this_thread_crashed = self.did_crash()
                if options.crashed_only and this_thread_crashed == False:
                    return

            print("%s" % self)
            #prev_frame_index = -1
            display_frame_idx = -1
            for frame_idx, frame in enumerate(self.frames):
                disassemble = (
                    this_thread_crashed or options.disassemble_all_threads) and frame_idx < options.disassemble_depth
                if frame_idx == 0:
                    symbolicated_frame_addresses = crash_log.symbolicate(
                        frame.pc & crash_log.addr_mask, options.verbose)
                else:
                    # Any frame above frame zero and we have to subtract one to
                    # get the previous line entry
                    symbolicated_frame_addresses = crash_log.symbolicate(
                        (frame.pc & crash_log.addr_mask) - 1, options.verbose)

                if symbolicated_frame_addresses:
                    symbolicated_frame_address_idx = 0
                    for symbolicated_frame_address in symbolicated_frame_addresses:
                        display_frame_idx += 1
                        print('[%3u] %s' % (frame_idx, symbolicated_frame_address))
                        if (options.source_all or self.did_crash(
                        )) and display_frame_idx < options.source_frames and options.source_context:
                            source_context = options.source_context
                            line_entry = symbolicated_frame_address.get_symbol_context().line_entry
                            if line_entry.IsValid():
                                strm = lldb.SBStream()
                                if line_entry:
                                    lldb.debugger.GetSourceManager().DisplaySourceLinesWithLineNumbers(
                                        line_entry.file, line_entry.line, source_context, source_context, "->", strm)
                                source_text = strm.GetData()
                                if source_text:
                                    # Indent the source a bit
                                    indent_str = '    '
                                    join_str = '\n' + indent_str
                                    print('%s%s' % (indent_str, join_str.join(source_text.split('\n'))))
                        if symbolicated_frame_address_idx == 0:
                            if disassemble:
                                instructions = symbolicated_frame_address.get_instructions()
                                if instructions:
                                    print()
                                    symbolication.disassemble_instructions(
                                        crash_log.get_target(),
                                        instructions,
                                        frame.pc,
                                        options.disassemble_before,
                                        options.disassemble_after,
                                        frame.index > 0)
                                    print()
                        symbolicated_frame_address_idx += 1
                else:
                    print(frame)
Beispiel #2
0
        def dump_symbolicated(self, crash_log, options):
            this_thread_crashed = self.app_specific_backtrace
            if not this_thread_crashed:
                this_thread_crashed = self.did_crash()
                if options.crashed_only and this_thread_crashed == False:
                    return

            print("%s" % self)
            #prev_frame_index = -1
            display_frame_idx = -1
            for frame_idx, frame in enumerate(self.frames):
                disassemble = (
                    this_thread_crashed or options.disassemble_all_threads) and frame_idx < options.disassemble_depth
                if frame_idx == 0:
                    symbolicated_frame_addresses = crash_log.symbolicate(
                        frame.pc & crash_log.addr_mask, options.verbose)
                else:
                    # Any frame above frame zero and we have to subtract one to
                    # get the previous line entry
                    symbolicated_frame_addresses = crash_log.symbolicate(
                        (frame.pc & crash_log.addr_mask) - 1, options.verbose)

                if symbolicated_frame_addresses:
                    symbolicated_frame_address_idx = 0
                    for symbolicated_frame_address in symbolicated_frame_addresses:
                        display_frame_idx += 1
                        print('[%3u] %s' % (frame_idx, symbolicated_frame_address))
                        if (options.source_all or self.did_crash(
                        )) and display_frame_idx < options.source_frames and options.source_context:
                            source_context = options.source_context
                            line_entry = symbolicated_frame_address.get_symbol_context().line_entry
                            if line_entry.IsValid():
                                strm = lldb.SBStream()
                                if line_entry:
                                    lldb.debugger.GetSourceManager().DisplaySourceLinesWithLineNumbers(
                                        line_entry.file, line_entry.line, source_context, source_context, "->", strm)
                                source_text = strm.GetData()
                                if source_text:
                                    # Indent the source a bit
                                    indent_str = '    '
                                    join_str = '\n' + indent_str
                                    print('%s%s' % (indent_str, join_str.join(source_text.split('\n'))))
                        if symbolicated_frame_address_idx == 0:
                            if disassemble:
                                instructions = symbolicated_frame_address.get_instructions()
                                if instructions:
                                    print()
                                    symbolication.disassemble_instructions(
                                        crash_log.get_target(),
                                        instructions,
                                        frame.pc,
                                        options.disassemble_before,
                                        options.disassemble_after,
                                        frame.index > 0)
                                    print()
                        symbolicated_frame_address_idx += 1
                else:
                    print(frame)
Beispiel #3
0
def SymbolicateCrashLog(crash_log, options):
    if crash_log.error:
        print crash_log.error
        return
    if options.debug:
        crash_log.dump()
    if not crash_log.images:
        print 'error: no images in crash log'
        return

    if options.dump_image_list:
        print "Binary Images:"
        for image in crash_log.images:
            if options.verbose:
                print image.debug_dump()
            else:
                print image

    target = crash_log.create_target()
    if not target:
        return
    exe_module = target.GetModuleAtIndex(0)
    images_to_load = list()
    loaded_images = list()
    if options.load_all_images:
        # --load-all option was specified, load everything up
        for image in crash_log.images:
            images_to_load.append(image)
    else:
        # Only load the images found in stack frames for the crashed threads
        if options.crashed_only:
            for thread in crash_log.threads:
                if thread.did_crash():
                    for ident in thread.idents:
                        images = crash_log.find_images_with_identifier(ident)
                        if images:
                            for image in images:
                                images_to_load.append(image)
                        else:
                            print 'error: can\'t find image for identifier "%s"' % ident
        else:
            for ident in crash_log.idents:
                images = crash_log.find_images_with_identifier(ident)
                if images:
                    for image in images:
                        images_to_load.append(image)
                else:
                    print 'error: can\'t find image for identifier "%s"' % ident

    for image in images_to_load:
        if image in loaded_images:
            print "warning: skipping %s loaded at %#16.16x duplicate entry (probably commpage)" % (
                image.path, image.text_addr_lo)
        else:
            err = image.add_module(target)
            if err:
                print err
            else:
                #print 'loaded %s' % image
                loaded_images.append(image)

    for thread in crash_log.threads:
        this_thread_crashed = thread.did_crash()
        if options.crashed_only and this_thread_crashed == False:
            continue
        print "%s" % thread
        #prev_frame_index = -1
        display_frame_idx = -1
        for frame_idx, frame in enumerate(thread.frames):
            disassemble = (this_thread_crashed
                           or options.disassemble_all_threads
                           ) and frame_idx < options.disassemble_depth
            if frame_idx == 0:
                symbolicated_frame_addresses = crash_log.symbolicate(
                    frame.pc, options.verbose)
            else:
                # Any frame above frame zero and we have to subtract one to get the previous line entry
                symbolicated_frame_addresses = crash_log.symbolicate(
                    frame.pc - 1, options.verbose)

            if symbolicated_frame_addresses:
                symbolicated_frame_address_idx = 0
                for symbolicated_frame_address in symbolicated_frame_addresses:
                    display_frame_idx += 1
                    print '[%3u] %s' % (frame_idx, symbolicated_frame_address)
                    if (
                            options.source_all or thread.did_crash()
                    ) and display_frame_idx < options.source_frames and options.source_context:
                        source_context = options.source_context
                        line_entry = symbolicated_frame_address.get_symbol_context(
                        ).line_entry
                        if line_entry.IsValid():
                            strm = lldb.SBStream()
                            if line_entry:
                                lldb.debugger.GetSourceManager(
                                ).DisplaySourceLinesWithLineNumbers(
                                    line_entry.file, line_entry.line,
                                    source_context, source_context, "->", strm)
                            source_text = strm.GetData()
                            if source_text:
                                # Indent the source a bit
                                indent_str = '    '
                                join_str = '\n' + indent_str
                                print '%s%s' % (indent_str,
                                                join_str.join(
                                                    source_text.split('\n')))
                    if symbolicated_frame_address_idx == 0:
                        if disassemble:
                            instructions = symbolicated_frame_address.get_instructions(
                            )
                            if instructions:
                                print
                                symbolication.disassemble_instructions(
                                    target, instructions, frame.pc,
                                    options.disassemble_before,
                                    options.disassemble_after, frame.index > 0)
                                print
                    symbolicated_frame_address_idx += 1
            else:
                print frame
        print
Beispiel #4
0
def SymbolicateCrashLog(crash_log, options):
    if crash_log.error:
        print crash_log.error
        return
    if options.debug:
        crash_log.dump()
    if not crash_log.images:
        print 'error: no images in crash log'
        return

    if options.dump_image_list:
        print "Binary Images:"
        for image in crash_log.images:
            if options.verbose:
                print image.debug_dump()
            else:
                print image

    target = crash_log.create_target ()
    if not target:
        return
    exe_module = target.GetModuleAtIndex(0)
    images_to_load = list()
    loaded_images = list()
    if options.load_all_images:
        # --load-all option was specified, load everything up
        for image in crash_log.images:
            images_to_load.append(image)
    else:
        # Only load the images found in stack frames for the crashed threads
        if options.crashed_only:
            for thread in crash_log.threads:
                if thread.did_crash():
                    for ident in thread.idents:
                        images = crash_log.find_images_with_identifier (ident)
                        if images:
                            for image in images:
                                images_to_load.append(image)
                        else:
                            print 'error: can\'t find image for identifier "%s"' % ident
        else:
            for ident in crash_log.idents:
                images = crash_log.find_images_with_identifier (ident)
                if images:
                    for image in images:
                        images_to_load.append(image)
                else:
                    print 'error: can\'t find image for identifier "%s"' % ident

    for image in images_to_load:
        if image in loaded_images:
            print "warning: skipping %s loaded at %#16.16x duplicate entry (probably commpage)" % (image.path, image.text_addr_lo)
        else:
            err = image.add_module (target)
            if err:
                print err
            else:
                #print 'loaded %s' % image
                loaded_images.append(image)

    for thread in crash_log.threads:
        this_thread_crashed = thread.did_crash()
        if options.crashed_only and this_thread_crashed == False:
            continue
        print "%s" % thread
        #prev_frame_index = -1
        display_frame_idx = -1
        for frame_idx, frame in enumerate(thread.frames):
            disassemble = (this_thread_crashed or options.disassemble_all_threads) and frame_idx < options.disassemble_depth;
            if frame_idx == 0:
                symbolicated_frame_addresses = crash_log.symbolicate (frame.pc, options.verbose)
            else:
                # Any frame above frame zero and we have to subtract one to get the previous line entry
                symbolicated_frame_addresses = crash_log.symbolicate (frame.pc - 1, options.verbose)
            
            if symbolicated_frame_addresses:
                symbolicated_frame_address_idx = 0
                for symbolicated_frame_address in symbolicated_frame_addresses:
                    display_frame_idx += 1
                    print '[%3u] %s' % (frame_idx, symbolicated_frame_address)
                    if (options.source_all or thread.did_crash()) and display_frame_idx < options.source_frames and options.source_context:
                        source_context = options.source_context
                        line_entry = symbolicated_frame_address.get_symbol_context().line_entry
                        if line_entry.IsValid():
                            strm = lldb.SBStream()
                            if line_entry:
                                lldb.debugger.GetSourceManager().DisplaySourceLinesWithLineNumbers(line_entry.file, line_entry.line, source_context, source_context, "->", strm)
                            source_text = strm.GetData()
                            if source_text:
                                # Indent the source a bit
                                indent_str = '    '
                                join_str = '\n' + indent_str
                                print '%s%s' % (indent_str, join_str.join(source_text.split('\n')))
                    if symbolicated_frame_address_idx == 0:
                        if disassemble:
                            instructions = symbolicated_frame_address.get_instructions()
                            if instructions:
                                print
                                symbolication.disassemble_instructions (target, 
                                                                        instructions, 
                                                                        frame.pc, 
                                                                        options.disassemble_before, 
                                                                        options.disassemble_after, frame.index > 0)
                                print
                    symbolicated_frame_address_idx += 1
            else:
                print frame
        print                
Beispiel #5
0
def SymbolicateCrashLog(crash_log, options):
    if crash_log.error:
        print crash_log.error
        return
    if options.debug:
        crash_log.dump()
    if not crash_log.images:
        print 'error: no images in crash log'
        return

    target = crash_log.create_target ()
    if not target:
        return
    exe_module = target.GetModuleAtIndex(0)
    images_to_load = list()
    loaded_images = list()
    if options.load_all_images:
        # --load-all option was specified, load everything up
        for image in crash_log.images:
            images_to_load.append(image)
    else:
        # Only load the images found in stack frames for the crashed threads
        for ident in crash_log.idents:
            images = crash_log.find_images_with_identifier (ident)
            if images:
                for image in images:
                    images_to_load.append(image)
            else:
                print 'error: can\'t find image for identifier "%s"' % ident

    for image in images_to_load:
        if image in loaded_images:
            print "warning: skipping %s loaded at %#16.16x duplicate entry (probably commpage)" % (image.path, image.text_addr_lo)
        else:
            err = image.add_module (target)
            if err:
                print err
            else:
                #print 'loaded %s' % image
                loaded_images.append(image)

    for thread in crash_log.threads:
        this_thread_crashed = thread.did_crash()
        if options.crashed_only and this_thread_crashed == False:
            continue
        print "%s" % thread
        #prev_frame_index = -1
        for frame_idx, frame in enumerate(thread.frames):
            disassemble = (this_thread_crashed or options.disassemble_all_threads) and frame_idx < options.disassemble_depth;
            if frame_idx == 0:
                symbolicated_frame_addresses = crash_log.symbolicate (frame.pc, options.verbose)
            else:
                # Any frame above frame zero and we have to subtract one to get the previous line entry
                symbolicated_frame_addresses = crash_log.symbolicate (frame.pc - 1, options.verbose)
            
            if symbolicated_frame_addresses:
                symbolicated_frame_address_idx = 0
                for symbolicated_frame_address in symbolicated_frame_addresses:
                    print '[%3u] %s' % (frame_idx, symbolicated_frame_address)
                
                    if symbolicated_frame_address_idx == 0:
                        if disassemble:
                            instructions = symbolicated_frame_address.get_instructions()
                            if instructions:
                                print
                                symbolication.disassemble_instructions (target, 
                                                                        instructions, 
                                                                        frame.pc, 
                                                                        options.disassemble_before, 
                                                                        options.disassemble_after, frame.index > 0)
                                print
                    symbolicated_frame_address_idx += 1
            else:
                print frame
        print                

    if options.dump_image_list:
        print "Binary Images:"
        for image in crash_log.images:
            print image