Skip to content

feat(debug-files): add --il2cpp-mapping for Unity IL2CPP line mappings#1164

Open
BYK wants to merge 2 commits into
byk/feat/debug-files-embedded-ppdbfrom
byk/feat/debug-files-il2cpp-mapping
Open

feat(debug-files): add --il2cpp-mapping for Unity IL2CPP line mappings#1164
BYK wants to merge 2 commits into
byk/feat/debug-files-embedded-ppdbfrom
byk/feat/debug-files-il2cpp-mapping

Conversation

@BYK

@BYK BYK commented Jul 1, 2026

Copy link
Copy Markdown
Member

Stacked on #1163 (embedded Portable PDB extraction). Review that first; GitHub will retarget this PR's base to main automatically once #1163 merges. The diff shown here is only this PR's changes.

What

Adds sentry debug-files upload --il2cpp-mapping: for each scanned object it computes a Unity IL2CPP C++→C# line mapping and uploads it as a separate il2cpp DIF carrying the object's debug id — faithful to legacy sentry-cli's create_il2cpp_mappings.

Consumes the new WASM API from @sentry/symbolic@13.7.0 (getsentry/symbolic#1005):

  • top-level il2cppLineMapping(object, provider)
  • SourceBundleWriter.collectIl2cppSources (present since 13.5.0)

Behavior (matches legacy)

  • The generated C++ source files an object references are read from disk via a provider; IL2CPP //<source_info:File.cs:line> markers are parsed from them. Objects that yield an empty mapping are skipped.
  • The mapping DIF is named <name>.il2cpp and carries the source file's debug id.
  • When combined with --include-sources, the per-file source bundle also collects the referenced C# source files (collectIl2cppSources) — otherwise the source bundle is unchanged.
  • Missing/unreadable sources and mapping failures are swallowed (debug-logged), never aborting the upload.
  • --symbol-maps (BCSymbolMap resolution) remains the only deferred legacy upload option.

Implementation

  • src/lib/dif/index.ts: createIl2cppLineMapping(data, readSource) + a collectIl2cppSources option on createSourceBundle().
  • src/commands/debug-files/upload.ts: --il2cpp-mapping flag; extracted a shared readSourceFile disk-reader used by both the source bundle and the IL2CPP provider.

Tests

  • test/lib/dif/il2cpp.test.tscreateIl2cppLineMapping (mapping JSON, provider-null → null, no-markers → null) and createSourceBundle collectIl2cppSources (C# included only when enabled, verified by unzipping the bundle).
  • test/commands/debug-files/upload.test.ts--il2cpp-mapping queues the .il2cpp DIF, absent without the flag, and is threaded through to uploadDebugFiles.

All text fixtures (Breakpad FILE records + synthetic C++/C#), no binaries.

Verified locally: typecheck, lint, test (358 debug-files/dif/scan tests), check:deps, check:fragments all green.

Adds `debug-files upload --il2cpp-mapping`, which computes a Unity IL2CPP
C++→C# line mapping for each scanned object and uploads it as a separate
`il2cpp` DIF carrying the object's debug id — faithful to legacy
sentry-cli's `create_il2cpp_mappings`.

The generated C++ source files an object references are read from disk via
a provider (IL2CPP `source_info` markers are parsed from them); mappings
that come out empty are skipped. When combined with `--include-sources`,
the per-file source bundle also collects the referenced C# source files
(`SourceBundleWriter.collectIl2cppSources`).

Adds `createIl2cppLineMapping()` and a `collectIl2cppSources` option on
`createSourceBundle()` in the DIF module, consuming the top-level
`il2cppLineMapping(object, provider)` export and the `collectIl2cppSources`
setter from @sentry/symbolic 13.7.0. `--symbol-maps` remains the only
deferred legacy upload option.
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-1164/

Built to branch gh-pages at 2026-07-01 16:12 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

brief:
"Compute and upload Unity IL2CPP line mappings for each scanned file",
optional: true,
default: false,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: For fat archives, filtering by --id can cause the IL2CPP mapping content to be generated from a different object slice than the one specified by the debug ID.
Severity: MEDIUM

Suggested Fix

Pass the filtered list of objects to createIl2cppLineMapping instead of the full, unfiltered archive.objects(). This ensures that the same object slice used to determine the debugId is also used to generate the mapping content, preventing a mismatch.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/commands/debug-files/upload.ts#L588

Potential issue: When uploading IL2CPP mappings for fat archives, such as universal
Mach-O files, using a filter like `--id` can cause a mismatch between the debug ID and
the mapping content. The debug ID for the upload is correctly selected from the filtered
object slice (`file.debugId`). However, the mapping content is generated by
`createIl2cppLineMapping`, which internally uses the full, unfiltered list of objects
from the archive. This results in an uploaded DIF where the debug ID and the mapping
content belong to two different object slices, causing Sentry to associate incorrect C++
to C# line mappings.

Did we get this right? 👍 / 👎 to inform future reviews.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

❌ Patch coverage is 76.92%. Project has 5144 uncovered lines.
❌ Project coverage is 81.48%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
src/commands/debug-files/upload.ts 64.29% ⚠️ 5 Missing and 1 partials
src/lib/dif/index.ts 91.67% ⚠️ 1 Missing and 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    81.49%    81.48%    -0.01%
==========================================
  Files          399       397        -2
  Lines        27744     27774       +30
  Branches     18025     18047       +22
==========================================
+ Hits         22609     22630       +21
- Misses        5135      5144        +9
- Partials      1859      1866        +7

Generated by Codecov Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant