Ejemplo n.º 1
0
def main():
    parser = argparse.ArgumentParser(description="""
        Pull binaries needed by perf.data from device to binary_cache directory."""
                                     )
    parser.add_argument('-i',
                        '--perf_data_path',
                        default='perf.data',
                        type=extant_file,
                        help="""
        The path of profiling data.""")
    parser.add_argument('-lib',
                        '--native_lib_dir',
                        type=extant_dir,
                        nargs='+',
                        help="""
        Path to find debug version of native shared libraries used in the app.""",
                        action='append')
    parser.add_argument('--disable_adb_root',
                        action='store_true',
                        help="""
        Force adb to run in non root mode.""")
    parser.add_argument('--ndk_path',
                        nargs=1,
                        help='Find tools in the ndk path.')
    parser.add_argument('--log',
                        choices=['debug', 'info', 'warning'],
                        default='info',
                        help='set log level')
    args = parser.parse_args()
    set_log_level(args.log)
    ndk_path = None if not args.ndk_path else args.ndk_path[0]
    builder = BinaryCacheBuilder(ndk_path, args.disable_adb_root)
    symfs_dirs = flatten_arg_list(args.native_lib_dir)
    builder.build_binary_cache(args.perf_data_path, symfs_dirs)
Ejemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser(description="""
        Annotate source files based on profiling data. It reads line information from binary_cache
        generated by app_profiler.py or binary_cache_builder.py, and generate annotated source
        files in annotated_files directory.""")
    parser.add_argument('-i', '--perf_data_list', nargs='+', action='append', help="""
        The paths of profiling data. Default is perf.data.""")
    parser.add_argument('-s', '--source_dirs', type=extant_dir, nargs='+', action='append', help="""
        Directories to find source files.""")
    parser.add_argument('--comm', nargs='+', action='append', help="""
        Use samples only in threads with selected names.""")
    parser.add_argument('--pid', nargs='+', action='append', help="""
        Use samples only in processes with selected process ids.""")
    parser.add_argument('--tid', nargs='+', action='append', help="""
        Use samples only in threads with selected thread ids.""")
    parser.add_argument('--dso', nargs='+', action='append', help="""
        Use samples only in selected binaries.""")
    parser.add_argument('--ndk_path', type=extant_dir, help='Set the path of a ndk release.')

    args = parser.parse_args()
    config = {}
    config['perf_data_list'] = flatten_arg_list(args.perf_data_list)
    if not config['perf_data_list']:
        config['perf_data_list'].append('perf.data')
    config['source_dirs'] = flatten_arg_list(args.source_dirs)
    config['comm_filters'] = flatten_arg_list(args.comm)
    config['pid_filters'] = flatten_arg_list(args.pid)
    config['tid_filters'] = flatten_arg_list(args.tid)
    config['dso_filters'] = flatten_arg_list(args.dso)
    config['ndk_path'] = args.ndk_path

    annotator = SourceFileAnnotator(config)
    annotator.annotate()
    log_info('annotate finish successfully, please check result in annotated_files/.')
Ejemplo n.º 3
0
def main():
    parser = argparse.ArgumentParser(description="""
        Annotate source files based on profiling data. It reads line information from binary_cache
        generated by app_profiler.py or binary_cache_builder.py, and generate annotated source
        files in annotated_files directory.""")
    parser.add_argument('-i',
                        '--perf_data_list',
                        nargs='+',
                        action='append',
                        help="""
        The paths of profiling data. Default is perf.data.""")
    parser.add_argument('-s',
                        '--source_dirs',
                        type=extant_dir,
                        nargs='+',
                        action='append',
                        help="""
        Directories to find source files.""")
    parser.add_argument('--comm',
                        nargs='+',
                        action='append',
                        help="""
        Use samples only in threads with selected names.""")
    parser.add_argument('--pid',
                        nargs='+',
                        action='append',
                        help="""
        Use samples only in processes with selected process ids.""")
    parser.add_argument('--tid',
                        nargs='+',
                        action='append',
                        help="""
        Use samples only in threads with selected thread ids.""")
    parser.add_argument('--dso',
                        nargs='+',
                        action='append',
                        help="""
        Use samples only in selected binaries.""")
    parser.add_argument('--ndk_path',
                        type=extant_dir,
                        help='Set the path of a ndk release.')

    args = parser.parse_args()
    config = {}
    config['perf_data_list'] = flatten_arg_list(args.perf_data_list)
    if not config['perf_data_list']:
        config['perf_data_list'].append('perf.data')
    config['source_dirs'] = flatten_arg_list(args.source_dirs)
    config['comm_filters'] = flatten_arg_list(args.comm)
    config['pid_filters'] = flatten_arg_list(args.pid)
    config['tid_filters'] = flatten_arg_list(args.tid)
    config['dso_filters'] = flatten_arg_list(args.dso)
    config['ndk_path'] = args.ndk_path

    annotator = SourceFileAnnotator(config)
    annotator.annotate()
    log_info(
        'annotate finish successfully, please check result in annotated_files/.'
    )
Ejemplo n.º 4
0
def main():
    parser = argparse.ArgumentParser(description='Generate pprof profile data in pprof.profile.')
    parser.add_argument('--show', nargs='?', action='append', help='print existing pprof.profile.')
    parser.add_argument('-i', '--perf_data_path', default='perf.data', help="""
        The path of profiling data.""")
    parser.add_argument('-o', '--output_file', default='pprof.profile', help="""
        The path of generated pprof profile data.""")
    parser.add_argument('--comm', nargs='+', action='append', help="""
        Use samples only in threads with selected names.""")
    parser.add_argument('--pid', nargs='+', action='append', help="""
        Use samples only in processes with selected process ids.""")
    parser.add_argument('--tid', nargs='+', action='append', help="""
        Use samples only in threads with selected thread ids.""")
    parser.add_argument('--dso', nargs='+', action='append', help="""
        Use samples only in selected binaries.""")
    parser.add_argument('--ndk_path', type=extant_dir, help='Set the path of a ndk release.')

    args = parser.parse_args()
    if args.show:
        show_file = args.show[0] if args.show[0] else 'pprof.profile'
        profile = load_pprof_profile(show_file)
        printer = PprofProfilePrinter(profile)
        printer.show()
        return

    config = {}
    config['perf_data_path'] = args.perf_data_path
    config['output_file'] = args.output_file
    config['comm_filters'] = flatten_arg_list(args.comm)
    config['pid_filters'] = flatten_arg_list(args.pid)
    config['tid_filters'] = flatten_arg_list(args.tid)
    config['dso_filters'] = flatten_arg_list(args.dso)
    config['ndk_path'] = args.ndk_path
    generator = PprofProfileGenerator(config)
    profile = generator.gen()
    store_pprof_profile(config['output_file'], profile)
def main():
    parser = argparse.ArgumentParser(description="""
        Pull binaries needed by perf.data from device to binary_cache directory.""")
    parser.add_argument('-i', '--perf_data_path', default='perf.data', type=extant_file, help="""
        The path of profiling data.""")
    parser.add_argument('-lib', '--native_lib_dir', type=extant_dir, nargs='+', help="""
        Path to find debug version of native shared libraries used in the app.""", action='append')
    parser.add_argument('--disable_adb_root', action='store_true', help="""
        Force adb to run in non root mode.""")
    parser.add_argument('--ndk_path', nargs=1, help='Find tools in the ndk path.')
    args = parser.parse_args()

    ndk_path = None if not args.ndk_path else args.ndk_path[0]
    builder = BinaryCacheBuilder(ndk_path, args.disable_adb_root)
    symfs_dirs = flatten_arg_list(args.native_lib_dir)
    builder.build_binary_cache(args.perf_data_path, symfs_dirs)
Ejemplo n.º 6
0
def main():
    parser = argparse.ArgumentParser(
        description='Generate pprof profile data in pprof.profile.')
    parser.add_argument('--show',
                        nargs='?',
                        action='append',
                        help='print existing pprof.profile.')
    parser.add_argument('-i',
                        '--record_file',
                        nargs='+',
                        default=['perf.data'],
                        help="""
        Set profiling data file to report. Default is perf.data""")
    parser.add_argument('-o',
                        '--output_file',
                        default='pprof.profile',
                        help="""
        The path of generated pprof profile data.""")
    parser.add_argument('--comm',
                        nargs='+',
                        action='append',
                        help="""
        Use samples only in threads with selected names.""")
    parser.add_argument('--pid',
                        nargs='+',
                        action='append',
                        help="""
        Use samples only in processes with selected process ids.""")
    parser.add_argument('--tid',
                        nargs='+',
                        action='append',
                        help="""
        Use samples only in threads with selected thread ids.""")
    parser.add_argument('--dso',
                        nargs='+',
                        action='append',
                        help="""
        Use samples only in selected binaries.""")
    parser.add_argument('--max_chain_length',
                        type=int,
                        default=1000000000,
                        help="""
        Maximum depth of samples to be converted."""
                        )  # Large value as infinity standin.
    parser.add_argument('--ndk_path',
                        type=extant_dir,
                        help='Set the path of a ndk release.')
    parser.add_argument(
        '--show_art_frames',
        action='store_true',
        help='Show frames of internal methods in the ART Java interpreter.')

    args = parser.parse_args()
    if args.show:
        show_file = args.show[0] if args.show[0] else 'pprof.profile'
        profile = load_pprof_profile(show_file)
        printer = PprofProfilePrinter(profile)
        printer.show()
        return

    config = {}
    config['output_file'] = args.output_file
    config['comm_filters'] = flatten_arg_list(args.comm)
    config['pid_filters'] = flatten_arg_list(args.pid)
    config['tid_filters'] = flatten_arg_list(args.tid)
    config['dso_filters'] = flatten_arg_list(args.dso)
    config['ndk_path'] = args.ndk_path
    config['show_art_frames'] = args.show_art_frames
    config['max_chain_length'] = args.max_chain_length
    generator = PprofProfileGenerator(config)
    for record_file in args.record_file:
        generator.load_record_file(record_file)
    profile = generator.gen()
    store_pprof_profile(config['output_file'], profile)