def make_symbolizer(project, binary_images, threads=None): """Creates a symbolizer for the given project and binary images. If a list of threads is referenced (from an apple crash report) then only images needed by those frames are loaded. """ if not have_symsynd: raise RuntimeError('symsynd is unavailable. Install sentry with ' 'the dsym feature flag.') driver = Driver(options.get('dsym.llvm-symbolizer-path') or None) if threads is None: to_load = [x['uuid'] for x in binary_images] else: image_map = {} for image in binary_images: image_map[image['image_addr']] = image['uuid'] to_load = set() for thread in threads: for frame in thread['backtrace']['contents']: img_uuid = image_map.get(frame['object_addr']) if img_uuid is not None: to_load.add(img_uuid) to_load = list(to_load) dsym_paths, loaded = dsymcache.fetch_dsyms(project, to_load) return ReportSymbolizer(driver, dsym_paths, binary_images)
def make_symbolizer(project, image_lookup, referenced_images=None, on_dsym_file_referenced=None): """Creates a symbolizer for the given project and binary images. If a list of referenced images is referenced (UUIDs) then only images needed by those frames are loaded. """ driver = Driver() to_load = referenced_images if to_load is None: to_load = image_lookup.get_uuids() dsym_paths, loaded = dsymcache.fetch_dsyms( project, to_load, on_dsym_file_referenced=on_dsym_file_referenced) # We only want to pass the actually loaded symbols to the report # symbolizer to avoid the expensive FS operations that will otherwise # happen. user_images = [] for img in image_lookup.iter_images(): if img['uuid'] in loaded: user_images.append(img) return ReportSymbolizer(driver, dsym_paths, user_images)
def make_symbolizer(project, binary_images): if not have_symsynd: raise RuntimeError('symsynd is unavailable. Install sentry with ' 'the dsym feature flag.') driver = Driver() dsym_path, loaded = dsymcache.fetch_dsyms( project, [x['uuid'] for x in binary_images]) return ReportSymbolizer(driver, dsym_path, binary_images)
def make_symbolizer(project, binary_images, referenced_images=None): """Creates a symbolizer for the given project and binary images. If a list of referenced images is referenced (UUIDs) then only images needed by those frames are loaded. """ if not have_symsynd: raise RuntimeError('symsynd is unavailable. Install sentry with ' 'the dsym feature flag.') driver = Driver(options.get('dsym.llvm-symbolizer-path') or None) to_load = referenced_images if to_load is None: to_load = [x['uuid'] for x in binary_images] dsym_paths, loaded = dsymcache.fetch_dsyms(project, to_load) return ReportSymbolizer(driver, dsym_paths, binary_images)
def driver(request): from symsynd.driver import Driver rv = Driver() request.addfinalizer(rv.close) return rv
import os import gc import json from symsynd.driver import Driver from symsynd.report import ReportSymbolizer here = os.path.abspath(os.path.dirname(__file__)) res_path = os.path.join(here, 'tests', 'res') with open(os.path.join(res_path, 'crash-report.json')) as f: report = json.load(f) driver = Driver() def iterate(): bt = None dsym_path = os.path.join(res_path, 'Crash-Tester.app.dSYM') rep = ReportSymbolizer(driver, [dsym_path], report['binary_images']) for thread in report['crash']['threads']: if thread['crashed']: assert bt is None bt = rep.symbolize_backtrace(thread['backtrace']['contents']) assert bt is not None def main(): while 1: iterate() gc.collect()