|
@@ -2,15 +2,12 @@ from __future__ import absolute_import
|
|
|
|
|
|
import six
|
|
|
|
|
|
-from symbolic import ProguardMappingView
|
|
|
+from symbolic import ProguardMapper
|
|
|
from sentry.plugins.base.v2 import Plugin2
|
|
|
from sentry.stacktraces.processing import StacktraceProcessor
|
|
|
from sentry.models import ProjectDebugFile, EventError
|
|
|
from sentry.reprocessing import report_processing_issue
|
|
|
from sentry.utils.safe import get_path
|
|
|
-from sentry.utils.compat import map
|
|
|
-
|
|
|
-FRAME_CACHE_VERSION = 2
|
|
|
|
|
|
|
|
|
def is_valid_image(image):
|
|
@@ -32,16 +29,6 @@ class JavaStacktraceProcessor(StacktraceProcessor):
|
|
|
platform = frame.get("platform") or self.data.get("platform")
|
|
|
return platform == "java" and self.available and "function" in frame and "module" in frame
|
|
|
|
|
|
- def preprocess_frame(self, processable_frame):
|
|
|
- processable_frame.set_cache_key_from_values(
|
|
|
- (
|
|
|
- FRAME_CACHE_VERSION,
|
|
|
- processable_frame.frame["module"],
|
|
|
- processable_frame.frame["function"],
|
|
|
- )
|
|
|
- + tuple(sorted(map(six.text_type, self.images)))
|
|
|
- )
|
|
|
-
|
|
|
def preprocess_step(self, processing_task):
|
|
|
if not self.available:
|
|
|
return False
|
|
@@ -58,7 +45,7 @@ class JavaStacktraceProcessor(StacktraceProcessor):
|
|
|
if dif_path is None:
|
|
|
error_type = EventError.PROGUARD_MISSING_MAPPING
|
|
|
else:
|
|
|
- view = ProguardMappingView.open(dif_path)
|
|
|
+ view = ProguardMapper.open(dif_path)
|
|
|
if not view.has_line_info:
|
|
|
error_type = EventError.PROGUARD_MISSING_LINENO
|
|
|
else:
|
|
@@ -92,9 +79,9 @@ class JavaStacktraceProcessor(StacktraceProcessor):
|
|
|
key = "%s.%s" % (mod, ty)
|
|
|
|
|
|
for view in self.mapping_views:
|
|
|
- original = view.lookup(key)
|
|
|
- if original != key:
|
|
|
- new_module, new_cls = original.rsplit(".", 1)
|
|
|
+ mapped = view.remap_class(key)
|
|
|
+ if mapped:
|
|
|
+ new_module, new_cls = mapped.rsplit(".", 1)
|
|
|
exception["module"] = new_module
|
|
|
exception["type"] = new_cls
|
|
|
return True
|
|
@@ -102,33 +89,43 @@ class JavaStacktraceProcessor(StacktraceProcessor):
|
|
|
return False
|
|
|
|
|
|
def process_frame(self, processable_frame, processing_task):
|
|
|
- new_module = None
|
|
|
- new_function = None
|
|
|
frame = processable_frame.frame
|
|
|
+ raw_frame = dict(frame)
|
|
|
|
|
|
- if processable_frame.cache_value is None:
|
|
|
- alias = "%s:%s" % (frame["module"], frame["function"])
|
|
|
- for view in self.mapping_views:
|
|
|
- original = view.lookup(alias, frame.get("lineno"))
|
|
|
- if original != alias:
|
|
|
- new_module, new_function = original.split(":", 1)
|
|
|
- break
|
|
|
+ # first, try to remap complete frames
|
|
|
+ for view in self.mapping_views:
|
|
|
+ mapped = view.remap_frame(frame["module"], frame["function"], frame.get("lineno") or 0)
|
|
|
|
|
|
- if new_module and new_function:
|
|
|
- processable_frame.set_cache_value([new_module, new_function])
|
|
|
+ if len(mapped) > 0:
|
|
|
+ new_frames = []
|
|
|
+ bottom_class = mapped[-1].class_name
|
|
|
|
|
|
- else:
|
|
|
- new_module, new_function = processable_frame.cache_value
|
|
|
+ # sentry expects stack traces in reverse order
|
|
|
+ for new_frame in reversed(mapped):
|
|
|
+ frame = dict(raw_frame)
|
|
|
+ frame["module"] = new_frame.class_name
|
|
|
+ frame["function"] = new_frame.method
|
|
|
+ frame["lineno"] = new_frame.line
|
|
|
|
|
|
- if not new_module or not new_function:
|
|
|
- return
|
|
|
+ # clear the filename for all *foreign* classes
|
|
|
+ if frame["module"] != bottom_class:
|
|
|
+ frame.pop("filename", None)
|
|
|
+ frame.pop("abs_path", None)
|
|
|
|
|
|
- raw_frame = dict(frame)
|
|
|
- new_frame = dict(frame)
|
|
|
- new_frame["module"] = new_module
|
|
|
- new_frame["function"] = new_function
|
|
|
+ new_frames.append(frame)
|
|
|
+
|
|
|
+ return new_frames, [raw_frame], []
|
|
|
+
|
|
|
+ # second, if that is not possible, try to re-map only the class-name
|
|
|
+ for view in self.mapping_views:
|
|
|
+ mapped = view.remap_class(frame["module"])
|
|
|
+
|
|
|
+ if mapped:
|
|
|
+ new_frame = dict(raw_frame)
|
|
|
+ new_frame["module"] = mapped
|
|
|
+ return [new_frame], [raw_frame], []
|
|
|
|
|
|
- return [new_frame], [raw_frame], []
|
|
|
+ return
|
|
|
|
|
|
|
|
|
class JavaPlugin(Plugin2):
|