We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Crash Reports Corrupt When System Symbols are Missing
Currently it appears to be the case that when system symbols are missing on iOS frames are entirely removed from the output.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/sentry/lang/native/symbolizer.py`
Content:
```
1 from __future__ import absolute_import
2 
3 import re
4 import six
5 
6 from symsynd.driver import Driver, SymbolicationError
7 from symsynd.report import ReportSymbolizer
8 from symsynd.macho.arch import get_cpu_name
9 
10 from sentry.lang.native.dsymcache import dsymcache
11 from sentry.utils.safe import trim
12 from sentry.utils.compat import implements_to_string
13 from sentry.models import DSymSymbol, EventError
14 from sentry.constants import MAX_SYM
15 
16 
17 APP_BUNDLE_PATHS = (
18     '/var/containers/Bundle/Application/',
19     '/private/var/containers/Bundle/Application/',
20 )
21 _sim_platform_re = re.compile(r'/\w+?Simulator\.platform/')
22 _known_app_bundled_frameworks_re = re.compile(r'''(?x)
23     /Frameworks/(
24             libswift([a-zA-Z0-9]+)\.dylib$
25         |   (KSCrash|SentrySwift)\.framework/
26     )
27 ''')
28 SIM_PATH = '/Developer/CoreSimulator/Devices/'
29 SIM_APP_PATH = '/Containers/Bundle/Application/'
30 
31 
32 @implements_to_string
33 class SymbolicationFailed(Exception):
34     message = None
35 
36     def __init__(self, message=None, type=None, image=None):
37         Exception.__init__(self)
38         self.message = six.text_type(message)
39         self.type = type
40         if image is not None:
41             self.image_uuid = image['uuid']
42             self.image_name = image['name'].rsplit('/', 1)[-1]
43         else:
44             self.image_uuid = None
45             self.image_name = None
46 
47     @property
48     def is_user_fixable(self):
49         """These are errors that a user can fix themselves."""
50         return self.type in ('missing-dsym', 'bad-dsym')
51 
52     @property
53     def is_sdk_failure(self):
54         """An error that most likely happened because of a bad SDK."""
55         return self.type == 'unknown-image'
56 
57     def __str__(self):
58         rv = []
59         if self.type is not None:
60             rv.append(u'%s: ' % self.type)
61         rv.append(self.message or 'no information available')
62         if self.image_uuid is not None:
63             rv.append(' image-uuid=%s' % self.image_uuid)
64         if self.image_name is not None:
65             rv.append(' image-name=%s' % self.image_name)
66         return u''.join(rv)
67 
68 
69 def trim_frame(frame):
70     # This matches what's in stacktrace.py
71     frame['symbol_name'] = trim(frame.get('symbol_name'), MAX_SYM)
72     frame['filename'] = trim(frame.get('filename'), 256)
73     return frame
74 
75 
76 def find_system_symbol(img, instruction_addr, sdk_info=None):
77     """Finds a system symbol."""
78     return DSymSymbol.objects.lookup_symbol(
79         instruction_addr=instruction_addr,
80         image_addr=img['image_addr'],
81         image_vmaddr=img['image_vmaddr'],
82         uuid=img['uuid'],
83         cpu_name=get_cpu_name(img['cpu_type'],
84                               img['cpu_subtype']),
85         object_path=img['name'],
86         sdk_info=sdk_info
87     )
88 
89 
90 def make_symbolizer(project, binary_images, referenced_images=None):
91     """Creates a symbolizer for the given project and binary images.  If a
92     list of referenced images is referenced (UUIDs) then only images
93     needed by those frames are loaded.
94     """
95     driver = Driver()
96 
97     to_load = referenced_images
98     if to_load is None:
99         to_load = [x['uuid'] for x in binary_images]
100 
101     dsym_paths, loaded = dsymcache.fetch_dsyms(project, to_load)
102 
103     # We only want to pass the actually loaded symbols to the report
104     # symbolizer to avoid the expensive FS operations that will otherwise
105     # happen.
106     user_images = []
107     for img in binary_images:
108         if img['uuid'] in loaded:
109             user_images.append(img)
110 
111     return ReportSymbolizer(driver, dsym_paths, user_images)
112 
113 
114 class Symbolizer(object):
115 
116     def __init__(self, project, binary_images, referenced_images=None):
117         self.symsynd_symbolizer = make_symbolizer(
118             project, binary_images, referenced_images=referenced_images)
119         self.images = dict((img['image_addr'], img) for img in binary_images)
120 
121     def __enter__(self):
122         return self.symsynd_symbolizer.driver.__enter__()
123 
124     def __exit__(self, *args):
125         return self.symsynd_symbolizer.driver.__exit__(*args)
126 
127     def _process_frame(self, frame, img):
128         rv = trim_frame(frame)
129         if img is not None:
130             # Only set the object name if we "upgrade" it from a filename to
131             # full path.
132             if rv.get('object_name') is None or \
133                ('/' not in rv['object_name'] and '/' in img['name']):
134                 rv['object_name'] = img['name']
135             rv['uuid'] = img['uuid']
136         return rv
137 
138     def _get_frame_package(self, frame, img):
139         obj_name = frame.get('object_name')
140         if obj_name and '/' in obj_name:
141             return obj_name
142         return img['name']
143 
144     def _is_app_bundled_frame(self, frame, img):
145         fn = self._get_frame_package(frame, img)
146         if not (fn.startswith(APP_BUNDLE_PATHS) or
147                 (SIM_PATH in fn and SIM_APP_PATH in fn)):
148             return False
149         return True
150 
151     def _is_app_frame(self, frame, img):
152         if not self._is_app_bundled_frame(frame, img):
153             return False
154         fn = self._get_frame_package(frame, img)
155         # Ignore known frameworks
156         match = _known_app_bundled_frameworks_re.search(fn)
157         if match is not None:
158             return False
159         return True
160 
161     def _is_simulator_frame(self, frame, img):
162         fn = self._get_frame_package(frame, img)
163         return _sim_platform_re.search(fn) is not None
164 
165     def is_in_app(self, frame):
166         img = self.images.get(frame['object_addr'])
167         return img is not None and self._is_app_frame(frame, img)
168 
169     def symbolize_app_frame(self, frame, img):
170         if frame['object_addr'] not in self.symsynd_symbolizer.images:
171             raise SymbolicationFailed(
172                 type='missing-dsym',
173                 message=(
174                     'Frame references a missing dSYM file.'
175                 ),
176                 image=img
177             )
178 
179         try:
180             new_frame = self.symsynd_symbolizer.symbolize_frame(
181                 frame, silent=False, demangle=False)
182         except SymbolicationError as e:
183             raise SymbolicationFailed(
184                 type='bad-dsym',
185                 message='Symbolication failed due to bad dsym: %s' % e,
186                 image=img
187             )
188 
189         if new_frame is None:
190             raise SymbolicationFailed(
191                 type='missing-symbol',
192                 message=(
193                     'Upon symbolication a frame could not be resolved.'
194                 ),
195                 image=img
196             )
197 
198         return self._process_frame(new_frame, img)
199 
200     def symbolize_system_frame(self, frame, img, sdk_info):
201         """Symbolizes a frame with system symbols only."""
202         symbol = find_system_symbol(img, frame['instruction_addr'], sdk_info)
203         if symbol is None:
204             # Simulator frames cannot be symbolicated
205             if self._is_simulator_frame(frame, img):
206                 type = 'simulator-frame'
207                 message = 'Cannot symbolicate simulator system frames.'
208             else:
209                 type = 'missing-system-dsym'
210                 message = (
211                     'Attempted to look up system in the system symbols but '
212                     'no symbol could be found.  This might happen with beta '
213                     'releases of SDKs.'
214                 )
215             raise SymbolicationFailed(
216                 type=type,
217                 message=message,
218                 image=img
219             )
220 
221         rv = dict(frame, symbol_name=symbol, filename=None,
222                   line=0, column=0, uuid=img['uuid'],
223                   object_name=img['name'])
224         return self._process_frame(rv, img)
225 
226     def symbolize_frame(self, frame, sdk_info=None):
227         img = self.images.get(frame['object_addr'])
228         if img is None:
229             raise SymbolicationFailed(
230                 type='unknown-image',
231                 message=(
232                     'The stacktrace referred to an object at an address '
233                     'that was not registered in the debug meta information.'
234                 )
235             )
236 
237         # If we are dealing with a frame that is not bundled with the app
238         # we look at system symbols.  If that fails, we go to looking for
239         # app symbols explicitly.
240         if not self._is_app_bundled_frame(frame, img):
241             return self.symbolize_system_frame(frame, img, sdk_info)
242 
243         return self.symbolize_app_frame(frame, img)
244 
245     def symbolize_backtrace(self, backtrace, sdk_info=None):
246         rv = []
247         errors = []
248         idx = -1
249 
250         for idx, frm in enumerate(backtrace):
251             try:
252                 rv.append(self.symbolize_frame(frm, sdk_info) or frm)
253             except SymbolicationFailed as e:
254                 errors.append({
255                     'type': EventError.NATIVE_INTERNAL_FAILURE,
256                     'frame': frm,
257                     'error': u'frame #%d: %s' % (idx, e),
258                 })
259         return rv, errors
260
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/sentry/lang/native/symbolizer.py b/src/sentry/lang/native/symbolizer.py
--- a/src/sentry/lang/native/symbolizer.py
+++ b/src/sentry/lang/native/symbolizer.py
@@ -249,8 +249,9 @@
 
         for idx, frm in enumerate(backtrace):
             try:
-                rv.append(self.symbolize_frame(frm, sdk_info) or frm)
+                rv.append(self.symbolize_frame(frm, sdk_info))
             except SymbolicationFailed as e:
+                rv.append(frm)
                 errors.append({
                     'type': EventError.NATIVE_INTERNAL_FAILURE,
                     'frame': frm,

{"golden_diff": "diff --git a/src/sentry/lang/native/symbolizer.py b/src/sentry/lang/native/symbolizer.py\n--- a/src/sentry/lang/native/symbolizer.py\n+++ b/src/sentry/lang/native/symbolizer.py\n@@ -249,8 +249,9 @@\n \n         for idx, frm in enumerate(backtrace):\n             try:\n-                rv.append(self.symbolize_frame(frm, sdk_info) or frm)\n+                rv.append(self.symbolize_frame(frm, sdk_info))\n             except SymbolicationFailed as e:\n+                rv.append(frm)\n                 errors.append({\n                     'type': EventError.NATIVE_INTERNAL_FAILURE,\n                     'frame': frm,\n", "issue": "Crash Reports Corrupt When System Symbols are Missing\nCurrently it appears to be the case that when system symbols are missing on iOS frames are entirely removed from the output.\n", "before_files": [{"content": "from __future__ import absolute_import\n\nimport re\nimport six\n\nfrom symsynd.driver import Driver, SymbolicationError\nfrom symsynd.report import ReportSymbolizer\nfrom symsynd.macho.arch import get_cpu_name\n\nfrom sentry.lang.native.dsymcache import dsymcache\nfrom sentry.utils.safe import trim\nfrom sentry.utils.compat import implements_to_string\nfrom sentry.models import DSymSymbol, EventError\nfrom sentry.constants import MAX_SYM\n\n\nAPP_BUNDLE_PATHS = (\n    '/var/containers/Bundle/Application/',\n    '/private/var/containers/Bundle/Application/',\n)\n_sim_platform_re = re.compile(r'/\\w+?Simulator\\.platform/')\n_known_app_bundled_frameworks_re = re.compile(r'''(?x)\n    /Frameworks/(\n            libswift([a-zA-Z0-9]+)\\.dylib$\n        |   (KSCrash|SentrySwift)\\.framework/\n    )\n''')\nSIM_PATH = '/Developer/CoreSimulator/Devices/'\nSIM_APP_PATH = '/Containers/Bundle/Application/'\n\n\n@implements_to_string\nclass SymbolicationFailed(Exception):\n    message = None\n\n    def __init__(self, message=None, type=None, image=None):\n        Exception.__init__(self)\n        self.message = six.text_type(message)\n        self.type = type\n        if image is not None:\n            self.image_uuid = image['uuid']\n            self.image_name = image['name'].rsplit('/', 1)[-1]\n        else:\n            self.image_uuid = None\n            self.image_name = None\n\n    @property\n    def is_user_fixable(self):\n        \"\"\"These are errors that a user can fix themselves.\"\"\"\n        return self.type in ('missing-dsym', 'bad-dsym')\n\n    @property\n    def is_sdk_failure(self):\n        \"\"\"An error that most likely happened because of a bad SDK.\"\"\"\n        return self.type == 'unknown-image'\n\n    def __str__(self):\n        rv = []\n        if self.type is not None:\n            rv.append(u'%s: ' % self.type)\n        rv.append(self.message or 'no information available')\n        if self.image_uuid is not None:\n            rv.append(' image-uuid=%s' % self.image_uuid)\n        if self.image_name is not None:\n            rv.append(' image-name=%s' % self.image_name)\n        return u''.join(rv)\n\n\ndef trim_frame(frame):\n    # This matches what's in stacktrace.py\n    frame['symbol_name'] = trim(frame.get('symbol_name'), MAX_SYM)\n    frame['filename'] = trim(frame.get('filename'), 256)\n    return frame\n\n\ndef find_system_symbol(img, instruction_addr, sdk_info=None):\n    \"\"\"Finds a system symbol.\"\"\"\n    return DSymSymbol.objects.lookup_symbol(\n        instruction_addr=instruction_addr,\n        image_addr=img['image_addr'],\n        image_vmaddr=img['image_vmaddr'],\n        uuid=img['uuid'],\n        cpu_name=get_cpu_name(img['cpu_type'],\n                              img['cpu_subtype']),\n        object_path=img['name'],\n        sdk_info=sdk_info\n    )\n\n\ndef make_symbolizer(project, binary_images, referenced_images=None):\n    \"\"\"Creates a symbolizer for the given project and binary images.  If a\n    list of referenced images is referenced (UUIDs) then only images\n    needed by those frames are loaded.\n    \"\"\"\n    driver = Driver()\n\n    to_load = referenced_images\n    if to_load is None:\n        to_load = [x['uuid'] for x in binary_images]\n\n    dsym_paths, loaded = dsymcache.fetch_dsyms(project, to_load)\n\n    # We only want to pass the actually loaded symbols to the report\n    # symbolizer to avoid the expensive FS operations that will otherwise\n    # happen.\n    user_images = []\n    for img in binary_images:\n        if img['uuid'] in loaded:\n            user_images.append(img)\n\n    return ReportSymbolizer(driver, dsym_paths, user_images)\n\n\nclass Symbolizer(object):\n\n    def __init__(self, project, binary_images, referenced_images=None):\n        self.symsynd_symbolizer = make_symbolizer(\n            project, binary_images, referenced_images=referenced_images)\n        self.images = dict((img['image_addr'], img) for img in binary_images)\n\n    def __enter__(self):\n        return self.symsynd_symbolizer.driver.__enter__()\n\n    def __exit__(self, *args):\n        return self.symsynd_symbolizer.driver.__exit__(*args)\n\n    def _process_frame(self, frame, img):\n        rv = trim_frame(frame)\n        if img is not None:\n            # Only set the object name if we \"upgrade\" it from a filename to\n            # full path.\n            if rv.get('object_name') is None or \\\n               ('/' not in rv['object_name'] and '/' in img['name']):\n                rv['object_name'] = img['name']\n            rv['uuid'] = img['uuid']\n        return rv\n\n    def _get_frame_package(self, frame, img):\n        obj_name = frame.get('object_name')\n        if obj_name and '/' in obj_name:\n            return obj_name\n        return img['name']\n\n    def _is_app_bundled_frame(self, frame, img):\n        fn = self._get_frame_package(frame, img)\n        if not (fn.startswith(APP_BUNDLE_PATHS) or\n                (SIM_PATH in fn and SIM_APP_PATH in fn)):\n            return False\n        return True\n\n    def _is_app_frame(self, frame, img):\n        if not self._is_app_bundled_frame(frame, img):\n            return False\n        fn = self._get_frame_package(frame, img)\n        # Ignore known frameworks\n        match = _known_app_bundled_frameworks_re.search(fn)\n        if match is not None:\n            return False\n        return True\n\n    def _is_simulator_frame(self, frame, img):\n        fn = self._get_frame_package(frame, img)\n        return _sim_platform_re.search(fn) is not None\n\n    def is_in_app(self, frame):\n        img = self.images.get(frame['object_addr'])\n        return img is not None and self._is_app_frame(frame, img)\n\n    def symbolize_app_frame(self, frame, img):\n        if frame['object_addr'] not in self.symsynd_symbolizer.images:\n            raise SymbolicationFailed(\n                type='missing-dsym',\n                message=(\n                    'Frame references a missing dSYM file.'\n                ),\n                image=img\n            )\n\n        try:\n            new_frame = self.symsynd_symbolizer.symbolize_frame(\n                frame, silent=False, demangle=False)\n        except SymbolicationError as e:\n            raise SymbolicationFailed(\n                type='bad-dsym',\n                message='Symbolication failed due to bad dsym: %s' % e,\n                image=img\n            )\n\n        if new_frame is None:\n            raise SymbolicationFailed(\n                type='missing-symbol',\n                message=(\n                    'Upon symbolication a frame could not be resolved.'\n                ),\n                image=img\n            )\n\n        return self._process_frame(new_frame, img)\n\n    def symbolize_system_frame(self, frame, img, sdk_info):\n        \"\"\"Symbolizes a frame with system symbols only.\"\"\"\n        symbol = find_system_symbol(img, frame['instruction_addr'], sdk_info)\n        if symbol is None:\n            # Simulator frames cannot be symbolicated\n            if self._is_simulator_frame(frame, img):\n                type = 'simulator-frame'\n                message = 'Cannot symbolicate simulator system frames.'\n            else:\n                type = 'missing-system-dsym'\n                message = (\n                    'Attempted to look up system in the system symbols but '\n                    'no symbol could be found.  This might happen with beta '\n                    'releases of SDKs.'\n                )\n            raise SymbolicationFailed(\n                type=type,\n                message=message,\n                image=img\n            )\n\n        rv = dict(frame, symbol_name=symbol, filename=None,\n                  line=0, column=0, uuid=img['uuid'],\n                  object_name=img['name'])\n        return self._process_frame(rv, img)\n\n    def symbolize_frame(self, frame, sdk_info=None):\n        img = self.images.get(frame['object_addr'])\n        if img is None:\n            raise SymbolicationFailed(\n                type='unknown-image',\n                message=(\n                    'The stacktrace referred to an object at an address '\n                    'that was not registered in the debug meta information.'\n                )\n            )\n\n        # If we are dealing with a frame that is not bundled with the app\n        # we look at system symbols.  If that fails, we go to looking for\n        # app symbols explicitly.\n        if not self._is_app_bundled_frame(frame, img):\n            return self.symbolize_system_frame(frame, img, sdk_info)\n\n        return self.symbolize_app_frame(frame, img)\n\n    def symbolize_backtrace(self, backtrace, sdk_info=None):\n        rv = []\n        errors = []\n        idx = -1\n\n        for idx, frm in enumerate(backtrace):\n            try:\n                rv.append(self.symbolize_frame(frm, sdk_info) or frm)\n            except SymbolicationFailed as e:\n                errors.append({\n                    'type': EventError.NATIVE_INTERNAL_FAILURE,\n                    'frame': frm,\n                    'error': u'frame #%d: %s' % (idx, e),\n                })\n        return rv, errors\n", "path": "src/sentry/lang/native/symbolizer.py"}], "after_files": [{"content": "from __future__ import absolute_import\n\nimport re\nimport six\n\nfrom symsynd.driver import Driver, SymbolicationError\nfrom symsynd.report import ReportSymbolizer\nfrom symsynd.macho.arch import get_cpu_name\n\nfrom sentry.lang.native.dsymcache import dsymcache\nfrom sentry.utils.safe import trim\nfrom sentry.utils.compat import implements_to_string\nfrom sentry.models import DSymSymbol, EventError\nfrom sentry.constants import MAX_SYM\n\n\nAPP_BUNDLE_PATHS = (\n    '/var/containers/Bundle/Application/',\n    '/private/var/containers/Bundle/Application/',\n)\n_sim_platform_re = re.compile(r'/\\w+?Simulator\\.platform/')\n_known_app_bundled_frameworks_re = re.compile(r'''(?x)\n    /Frameworks/(\n            libswift([a-zA-Z0-9]+)\\.dylib$\n        |   (KSCrash|SentrySwift)\\.framework/\n    )\n''')\nSIM_PATH = '/Developer/CoreSimulator/Devices/'\nSIM_APP_PATH = '/Containers/Bundle/Application/'\n\n\n@implements_to_string\nclass SymbolicationFailed(Exception):\n    message = None\n\n    def __init__(self, message=None, type=None, image=None):\n        Exception.__init__(self)\n        self.message = six.text_type(message)\n        self.type = type\n        if image is not None:\n            self.image_uuid = image['uuid']\n            self.image_name = image['name'].rsplit('/', 1)[-1]\n        else:\n            self.image_uuid = None\n            self.image_name = None\n\n    @property\n    def is_user_fixable(self):\n        \"\"\"These are errors that a user can fix themselves.\"\"\"\n        return self.type in ('missing-dsym', 'bad-dsym')\n\n    @property\n    def is_sdk_failure(self):\n        \"\"\"An error that most likely happened because of a bad SDK.\"\"\"\n        return self.type == 'unknown-image'\n\n    def __str__(self):\n        rv = []\n        if self.type is not None:\n            rv.append(u'%s: ' % self.type)\n        rv.append(self.message or 'no information available')\n        if self.image_uuid is not None:\n            rv.append(' image-uuid=%s' % self.image_uuid)\n        if self.image_name is not None:\n            rv.append(' image-name=%s' % self.image_name)\n        return u''.join(rv)\n\n\ndef trim_frame(frame):\n    # This matches what's in stacktrace.py\n    frame['symbol_name'] = trim(frame.get('symbol_name'), MAX_SYM)\n    frame['filename'] = trim(frame.get('filename'), 256)\n    return frame\n\n\ndef find_system_symbol(img, instruction_addr, sdk_info=None):\n    \"\"\"Finds a system symbol.\"\"\"\n    return DSymSymbol.objects.lookup_symbol(\n        instruction_addr=instruction_addr,\n        image_addr=img['image_addr'],\n        image_vmaddr=img['image_vmaddr'],\n        uuid=img['uuid'],\n        cpu_name=get_cpu_name(img['cpu_type'],\n                              img['cpu_subtype']),\n        object_path=img['name'],\n        sdk_info=sdk_info\n    )\n\n\ndef make_symbolizer(project, binary_images, referenced_images=None):\n    \"\"\"Creates a symbolizer for the given project and binary images.  If a\n    list of referenced images is referenced (UUIDs) then only images\n    needed by those frames are loaded.\n    \"\"\"\n    driver = Driver()\n\n    to_load = referenced_images\n    if to_load is None:\n        to_load = [x['uuid'] for x in binary_images]\n\n    dsym_paths, loaded = dsymcache.fetch_dsyms(project, to_load)\n\n    # We only want to pass the actually loaded symbols to the report\n    # symbolizer to avoid the expensive FS operations that will otherwise\n    # happen.\n    user_images = []\n    for img in binary_images:\n        if img['uuid'] in loaded:\n            user_images.append(img)\n\n    return ReportSymbolizer(driver, dsym_paths, user_images)\n\n\nclass Symbolizer(object):\n\n    def __init__(self, project, binary_images, referenced_images=None):\n        self.symsynd_symbolizer = make_symbolizer(\n            project, binary_images, referenced_images=referenced_images)\n        self.images = dict((img['image_addr'], img) for img in binary_images)\n\n    def __enter__(self):\n        return self.symsynd_symbolizer.driver.__enter__()\n\n    def __exit__(self, *args):\n        return self.symsynd_symbolizer.driver.__exit__(*args)\n\n    def _process_frame(self, frame, img):\n        rv = trim_frame(frame)\n        if img is not None:\n            # Only set the object name if we \"upgrade\" it from a filename to\n            # full path.\n            if rv.get('object_name') is None or \\\n               ('/' not in rv['object_name'] and '/' in img['name']):\n                rv['object_name'] = img['name']\n            rv['uuid'] = img['uuid']\n        return rv\n\n    def _get_frame_package(self, frame, img):\n        obj_name = frame.get('object_name')\n        if obj_name and '/' in obj_name:\n            return obj_name\n        return img['name']\n\n    def _is_app_bundled_frame(self, frame, img):\n        fn = self._get_frame_package(frame, img)\n        if not (fn.startswith(APP_BUNDLE_PATHS) or\n                (SIM_PATH in fn and SIM_APP_PATH in fn)):\n            return False\n        return True\n\n    def _is_app_frame(self, frame, img):\n        if not self._is_app_bundled_frame(frame, img):\n            return False\n        fn = self._get_frame_package(frame, img)\n        # Ignore known frameworks\n        match = _known_app_bundled_frameworks_re.search(fn)\n        if match is not None:\n            return False\n        return True\n\n    def _is_simulator_frame(self, frame, img):\n        fn = self._get_frame_package(frame, img)\n        return _sim_platform_re.search(fn) is not None\n\n    def is_in_app(self, frame):\n        img = self.images.get(frame['object_addr'])\n        return img is not None and self._is_app_frame(frame, img)\n\n    def symbolize_app_frame(self, frame, img):\n        if frame['object_addr'] not in self.symsynd_symbolizer.images:\n            raise SymbolicationFailed(\n                type='missing-dsym',\n                message=(\n                    'Frame references a missing dSYM file.'\n                ),\n                image=img\n            )\n\n        try:\n            new_frame = self.symsynd_symbolizer.symbolize_frame(\n                frame, silent=False, demangle=False)\n        except SymbolicationError as e:\n            raise SymbolicationFailed(\n                type='bad-dsym',\n                message='Symbolication failed due to bad dsym: %s' % e,\n                image=img\n            )\n\n        if new_frame is None:\n            raise SymbolicationFailed(\n                type='missing-symbol',\n                message=(\n                    'Upon symbolication a frame could not be resolved.'\n                ),\n                image=img\n            )\n\n        return self._process_frame(new_frame, img)\n\n    def symbolize_system_frame(self, frame, img, sdk_info):\n        \"\"\"Symbolizes a frame with system symbols only.\"\"\"\n        symbol = find_system_symbol(img, frame['instruction_addr'], sdk_info)\n        if symbol is None:\n            # Simulator frames cannot be symbolicated\n            if self._is_simulator_frame(frame, img):\n                type = 'simulator-frame'\n                message = 'Cannot symbolicate simulator system frames.'\n            else:\n                type = 'missing-system-dsym'\n                message = (\n                    'Attempted to look up system in the system symbols but '\n                    'no symbol could be found.  This might happen with beta '\n                    'releases of SDKs.'\n                )\n            raise SymbolicationFailed(\n                type=type,\n                message=message,\n                image=img\n            )\n\n        rv = dict(frame, symbol_name=symbol, filename=None,\n                  line=0, column=0, uuid=img['uuid'],\n                  object_name=img['name'])\n        return self._process_frame(rv, img)\n\n    def symbolize_frame(self, frame, sdk_info=None):\n        img = self.images.get(frame['object_addr'])\n        if img is None:\n            raise SymbolicationFailed(\n                type='unknown-image',\n                message=(\n                    'The stacktrace referred to an object at an address '\n                    'that was not registered in the debug meta information.'\n                )\n            )\n\n        # If we are dealing with a frame that is not bundled with the app\n        # we look at system symbols.  If that fails, we go to looking for\n        # app symbols explicitly.\n        if not self._is_app_bundled_frame(frame, img):\n            return self.symbolize_system_frame(frame, img, sdk_info)\n\n        return self.symbolize_app_frame(frame, img)\n\n    def symbolize_backtrace(self, backtrace, sdk_info=None):\n        rv = []\n        errors = []\n        idx = -1\n\n        for idx, frm in enumerate(backtrace):\n            try:\n                rv.append(self.symbolize_frame(frm, sdk_info))\n            except SymbolicationFailed as e:\n                rv.append(frm)\n                errors.append({\n                    'type': EventError.NATIVE_INTERNAL_FAILURE,\n                    'frame': frm,\n                    'error': u'frame #%d: %s' % (idx, e),\n                })\n        return rv, errors\n", "path": "src/sentry/lang/native/symbolizer.py"}]}