Skip to content

feat(variables): add initial version of variables.c test fixture - #1038

Open
JoshuaMoelans wants to merge 13 commits into
masterfrom
joshua/test/variables_fixture
Open

feat(variables): add initial version of variables.c test fixture#1038
JoshuaMoelans wants to merge 13 commits into
masterfrom
joshua/test/variables_fixture

Conversation

@JoshuaMoelans

@JoshuaMoelans JoshuaMoelans commented Aug 5, 2026

Copy link
Copy Markdown
Member
  • build.sh to generate binary(with O0 to avoid optimizing out everything)
  • test_objects__elf_variables.snap for validating
  • updated test_objects with new test_elf_variables
  • smol README with instructions how to run/rebuild binary/refresh the snapshot/add coverage/listing uncovered items

resolves https://linear.app/getsentry/issue/INGEST-1087/dwarf-add-new-test-fixture-for-variables

To be followed up with #1042 (or maybe we merge that one in here, not sure what flows more naturally?)

- build.sh to generate binaryu (with O0 to avoid optimizing out everything)
- .snap for validating
- updated test_objects with new test_elf_variables
- smol README with instructions how to run/rebuild/refresh the snapshot/add coverage/uncovered items

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 1d6eb5a

@JoshuaMoelans JoshuaMoelans changed the title feat(variables) add initial version of test fixture feat(variables) add initial version of variables.c test fixture Aug 5, 2026
Comment thread symbolic-debuginfo/tests/test_objects.rs Outdated
@linear-code

linear-code Bot commented Aug 5, 2026

Copy link
Copy Markdown

INGEST-1087

Comment thread symbolic-testutils/fixtures/linux/variables/build.sh
JoshuaMoelans and others added 2 commits August 12, 2026 16:49
Fold VariablesDebug's duplicate tree walk into FunctionsDebug behind
DebugOptions, and reduce VariablesDebug to a Debug impl for a single
function's variables, replacing write_variables. Snapshots unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Comment thread symbolic-testutils/variables/build.sh Outdated
Comment thread symbolic-testutils/fixtures/linux/variables/variables.c
JoshuaMoelans and others added 4 commits August 13, 2026 13:46
- Pin the Docker image to gcc:14.4.0 (the version the committed fixture
  was built with) instead of the floating gcc:14 tag.
- Drop the false claim that ./build.sh outside Docker gives the same
  result: DW_AT_comp_dir embeds the build directory.
- Fix the garbled rebuild instructions in the README.
- Fix the primitives() comment: the enum is PrimitiveTypeEncoding, and
  Address is deliberately not covered.
- Rebuild the fixture with the pinned image (comment edit shifted line
  numbers in the debug info; snapshot unchanged).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
In relative mode, saturating_sub silently clamped a location address
below the function base to 0x0, which prints as a plausible-looking
whole-function range. A backend emitting wrongly-based addresses (e.g.
module-relative vs. absolute) would produce an accepted snapshot instead
of a failure. checked_sub().expect() makes the violation panic the test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Only two of the eight nominal flag combinations were ever constructed,
and they were fully correlated: variables was always true and lines was
always !relative. A two-variant enum (Full / RelativeVariables) encodes
only the states that exist, deletes the dead variables guard, and
removes the 0-sentinel base field on VariablesDebug.

No output changes; all snapshots unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
cd to the script's own directory before compiling, following the
precedent in fixtures/wasm/emscripten/build.sh (the POSIX-sh form;
the arm64 script's BASH_SOURCE variant is a bashism). Inside the
documented Docker invocation this is a no-op: the working directory
is already the script directory, so DW_AT_comp_dir and the fixture
binary are unchanged (verified byte-identical).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@JoshuaMoelans JoshuaMoelans changed the title feat(variables) add initial version of variables.c test fixture feat(variables): add initial version of variables.c test fixture Aug 14, 2026
@JoshuaMoelans
JoshuaMoelans marked this pull request as ready for review August 14, 2026 11:04
@JoshuaMoelans
JoshuaMoelans requested a review from a team as a code owner August 14, 2026 11:04
Comment on lines +55 to +58
/// Only the variables of each function, with location ranges relative to the start of their
/// function, so a snapshot only changes when variable debug info changes, not when the
/// fixture is merely relinked or relocated. Toolchain changes might still churn the snapshot.
RelativeVariables,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What problem is this trying to solve? Why does a toolchain change not impact the snapshot, variables may now be stored in different locations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@Dav1dde do you mean in general, using the RelativeVariables over the Full DebugMode? Or just the phrasing of the comment?

The last sentence is meant to indicate that toolchain changes do indeed churn the snapshot, but if it doesn't read cleanly I can reword it for sure.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

IIUC the RelativeVariables that I (+ clanker) introduced was just meant to simplify the variable extraction snapshot, but after talking with @szokeasaurusrex about it too, it makes sense to just reuse the existing debug format since we never rewrite the snapshot by hand (and just regenerate it). This simplified the PR quite a bit 008b8d7

Comment thread symbolic-testutils/variables/README.md Outdated
Comment thread symbolic-testutils/variables/README.md Outdated
Comment thread symbolic-testutils/variables/README.md Outdated

To keep remote up-to-date, commit the rebuilt binary together with the updated snapshot.

## Adding coverage

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not sure what this is supposed to tell me other than "prefer to add a new function over changing existing ones". Where this is a fine suggestions, though I don't agree with the reasoning, there is nothing wrong with the fixture changing.

@JoshuaMoelans JoshuaMoelans Sep 1, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do you feel like we should just cut out the reasoning in the paragraph (I think keeping the first sentence as a suggestion by itself is probably enough). It wasn't meant as a "try never to change the existing parts of the fixture", more of a "if you want to keep changes to the fixture minimal, adding functions is self-contained" hint.

Comment thread symbolic-testutils/fixtures/linux/variables/variables.c
JoshuaMoelans and others added 2 commits September 1, 2026 14:36
Store the variables fixture build script and source next to the binary in
fixtures/linux/variables/, matching the other fixtures, and trim the fixture
docs to the essentials. The binary is rebuilt because the embedded
DW_AT_comp_dir follows the new build location.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- we added RelativeVariables to reduce snapshot churn, but tbqh this is unnecessary bc we can regenerate the snapshot anyway. Keep using the normal debug mode like for the other tests

@loewenheim loewenheim 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.

LGTM, assuming the snapshot contains what you expect it to.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants