|
42 | 42 | # Attachment type used for Apple Crash Reports
|
43 | 43 | APPLECRASHREPORT_ATTACHMENT_TYPE = "event.applecrashreport"
|
44 | 44 |
|
| 45 | +# Rules for rewriting the debug file of the first module |
| 46 | +# in an Electron minidump. |
| 47 | +# |
| 48 | +# Such minidumps frequently contain root modules |
| 49 | +# with nonsensical debug file names, which results from packagers like |
| 50 | +# electron-forge. Consequently, the module won't be found on the official |
| 51 | +# Electron symbol source. |
| 52 | +# |
| 53 | +# To fix this, we rewrite the debug file name of the first module |
| 54 | +# according to these rules for Electron minidumps before doing the lookup. |
| 55 | +# The rules are tried in order and only the first that matches is applied. |
| 56 | +# |
| 57 | +# The rewrites we perform are as follows: |
| 58 | +# |
| 59 | +# * /PATH/TO/FILE Framework -> /PATH/TO/Electron Framework |
| 60 | +# * /PATH/TO/FILE Helper (FOOBAR) -> /PATH/TO/Electron Helper (FOOBAR) |
| 61 | +# * /PATH/TO/FILE.exe.pdb -> /PATH/TO/electron.exe.pdb |
| 62 | +# * /PATH/TO/FILE -> /PATH/TO/electron |
| 63 | +# |
| 64 | +# These were determined by examining logs of successful downloads from the Electron symbol |
| 65 | +# source. |
| 66 | +# |
| 67 | +# The rewriting itself is performed by Symbolicator. We can't do it before |
| 68 | +# because we only gain access to the modules contained in the minidump |
| 69 | +# during stackwalking. |
| 70 | +# |
| 71 | +# NOTE: These regexes and replacement strings are written in the syntax the Rust regex crate accepts! |
| 72 | +ELECTRON_FIRST_MODULE_REWRITE_RULES = [ |
| 73 | + {"from": "[^/\\\\]+ (?<suffix>Framework|Helper( \\(.+\\))?)$", "to": "Electron $suffix"}, |
| 74 | + {"from": "[^/\\\\]+\\.exe\\.pdb$", "to": "electron.exe.pdb"}, |
| 75 | + {"from": "[^/\\\\]+$", "to": "electron"}, |
| 76 | +] |
| 77 | + |
45 | 78 |
|
46 | 79 | def _merge_frame(new_frame, symbolicated, platform="native"):
|
47 | 80 | # il2cpp events which have the "csharp" platform have good (C#) names
|
@@ -288,8 +321,17 @@ def process_minidump(symbolicator: Symbolicator, data: Any) -> Any:
|
288 | 321 | logger.error("Missing minidump for minidump event")
|
289 | 322 | return
|
290 | 323 |
|
| 324 | + # We do module rewriting only for Electron minidumps. |
| 325 | + # See the documentation of `ELECTRON_FIRST_MODULE_REWRITE_RULES`. |
| 326 | + if get_path(data, "sdk", "name") == "sentry.javascript.electron": |
| 327 | + rewrite_first_module = ELECTRON_FIRST_MODULE_REWRITE_RULES |
| 328 | + else: |
| 329 | + rewrite_first_module = [] |
| 330 | + |
291 | 331 | metrics.incr("process.native.symbolicate.request")
|
292 |
| - response = symbolicator.process_minidump(data.get("platform"), minidump.data) |
| 332 | + response = symbolicator.process_minidump( |
| 333 | + data.get("platform"), minidump.data, rewrite_first_module |
| 334 | + ) |
293 | 335 |
|
294 | 336 | if _handle_response_status(data, response):
|
295 | 337 | _merge_full_response(data, response)
|
|
0 commit comments