Skip to content

feat(debug-files): add print-sources command#1138

Merged
BYK merged 5 commits into
mainfrom
byk/feat/debug-files-print-sources
Jun 24, 2026
Merged

feat(debug-files): add print-sources command#1138
BYK merged 5 commits into
mainfrom
byk/feat/debug-files-print-sources

Conversation

@BYK

@BYK BYK commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

Adds sentry debug-files print-sources — a local-only command that lists the source files a debug information file references, reporting for each whether the source is embedded in the debug file, available via a source link, or present on the local disk. It is a read-only preview of what bundle-sources would collect and always exits zero on a parseable file.

sentry debug-files print-sources ./libexample.so
sentry debug-files print-sources ./app.pdb --json

Like check, bundle-sources, and bundle-jvm, it makes no network requests — it parses the object in-process (Mach-O/dSYM, ELF, PE/PDB, Portable PDB, WebAssembly, Breakpad, source bundles) via the bundled symbolic WASM module.

Details

  • New source enumeration in src/lib/dif/index.ts (listSources) built on ObjectFile.debugSession()session.files() / session.sourceByPath() exposed by @sentry/symbolic 13.5.0 (getsentry/symbolic#997). Bumps the dependency 13.4.0 → 13.5.0.
  • Per referenced file only cheap descriptor metadata is read (type, url, debugId, sourceMappingUrl). The full source contents is intentionally not copied across the wasm/JS boundary for a listing — avoiding a per-file Rust-UTF-8 → JS-UTF-16 re-encode that the preview never needs.
  • Human output classifies each reference (source link / embedded / not embedded but available locally / missing); --json emits a structured envelope.

Test plan

  • test/commands/debug-files/print-sources.test.ts — 6 cases (local source present/missing, no referenced sources, --json shape, validation errors for missing path and non-debug file).
  • test/lib/dif/index.test.tslistSources unit coverage updated for the new type field.
  • Verified against the published @sentry/symbolic@13.5.0: pnpm vitest run test/lib/dif test/commands/debug-files → 41 passed; typecheck and lint clean.

List the source files a debug information file references, reporting for each
whether the source is embedded, available via a source link, or present on the
local disk -- a read-only preview of what bundle-sources would collect.

- dif: add listSources() on the new ObjectFile.debugSession() /
  DebugSession.files() / sourceByPath() wasm API (getsentry/symbolic#997).
- command: src/commands/debug-files/print-sources.ts (local-only, auth:false).
- tests for the dif primitive and the command; docs + skill regenerated.

Depends on the debugSession() API from getsentry/symbolic#997. The dep bump to
the published @sentry/symbolic (dev-tested here against a local build) is the
only step remaining before this can open as a PR.
@github-actions github-actions Bot added the risk: high PR risk score: high label Jun 24, 2026
@github-actions

github-actions Bot commented Jun 24, 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-1138/

Built to branch gh-pages at 2026-06-24 13:14 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Comment thread src/commands/debug-files/print-sources.ts
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 82.54%. Project has 5058 uncovered lines.
✅ Project coverage is 81.44%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
src/commands/debug-files/print-sources.ts 82.22% ⚠️ 8 Missing and 9 partials
src/lib/dif/index.ts 83.33% ⚠️ 3 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.43%    81.44%    +0.01%
==========================================
  Files          392       393        +1
  Lines        27191     27254       +63
  Branches     17659     17699       +40
==========================================
+ Hits         22142     22196       +54
- Misses        5049      5058        +9
- Partials      1839      1847        +8

Generated by Codecov Action

`print-sources` lists referenced sources for every object in the archive,
but `bundle-sources` only bundles one slice (first with debug info, else
first). On fat Mach-O the preview could list sources that `bundle-sources`
never collects without saying so.

Centralize the slice-selection rule in `selectBundledObject` (shared by
`createSourceBundle` and `print-sources`), expose `hasDebugInfo` on
`listSources` output, and warn — mirroring `bundle-sources` — naming the
exact slice that would be bundled when an archive has multiple objects.
Comment thread src/commands/debug-files/print-sources.ts
Comment thread src/commands/debug-files/print-sources.ts
Comment thread src/lib/dif/index.ts
…nt-sources

Address review feedback on the multi-slice handling:

- Expose `hasDebugInfo` on each `print-sources` output object so `--json`
  consumers can apply the same `selectBundledObject` rule as `bundle-sources`
  (the slice warning was previously stderr-only).
- Record per-object `enumerationError` in `listSources` so a failed debug
  session is no longer indistinguishable from an object that genuinely
  references no sources; print-sources now warns and renders it distinctly.
- Differentiate the footer hint between an archive with no objects, one whose
  source reads all failed, and a genuine "no referenced sources" result.
Comment thread src/lib/dif/index.ts
Comment thread src/commands/debug-files/print-sources.ts
If `session.files()` throws partway through a slice, drop any entries already
collected so `files` stays empty when `enumerationError` is set, honoring the
`DifObjectSources` contract and avoiding a partial list in `--json` that the
human formatter would hide.

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7455bf1. Configure here.

Comment thread src/commands/debug-files/print-sources.ts
…rces hint

When no sources are listed but at least one slice failed to enumerate (even if
other slices genuinely reference none), the footer hint now reports a read
error instead of "no referenced sources found", so it no longer contradicts
the per-slice enumeration warnings.
@BYK BYK merged commit eadff28 into main Jun 24, 2026
29 checks passed
@BYK BYK deleted the byk/feat/debug-files-print-sources branch June 24, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant