Skip to content

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

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

feat(variables): add initial version of variables.c test fixture#1038
JoshuaMoelans wants to merge 10 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 44ecf5f

@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/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>
# See README.md for details.
set -eu

gcc -g -gdwarf-5 -O0 -o ../fixtures/linux/variables variables.c

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.

(think about how this changes the DWARF format too + maybe add second test for inlining/ 'USED' , or 'USED' macro or 'volatile'...)

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.

added inlining test in 9e24c3a

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.

and even more coverage, separately, in #1042

Comment on lines +75 to +90
/*
* Inlined functions. `always_inline` forces inlining even at -O0, which is the
* only way this fixture can produce a `DW_TAG_inlined_subroutine`.
*
* The variables of the inlinee are not supported yet: their concrete DIEs
* carry only a location and a `DW_AT_abstract_origin` reference, with name and
* type living on the abstract DIE, which symbolic does not follow for
* variables. Both `param` and `doubled` have plain frame-base locations at
* -O0, so `inlined` rendering with no variables at all in the snapshot is
* purely the missing origin lookup.
*/
static inline __attribute__((always_inline)) int inlined(int param)
{
int doubled = param * 2;
return doubled + 1;
}

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.

(IMO we can keep the fixture itself relatively clean of this slightly noisy type of clanker-aided comments, the PR with comments/intermittent commits can tell the full story if anyone's interested)

Suggested change
/*
* Inlined functions. `always_inline` forces inlining even at -O0, which is the
* only way this fixture can produce a `DW_TAG_inlined_subroutine`.
*
* The variables of the inlinee are not supported yet: their concrete DIEs
* carry only a location and a `DW_AT_abstract_origin` reference, with name and
* type living on the abstract DIE, which symbolic does not follow for
* variables. Both `param` and `doubled` have plain frame-base locations at
* -O0, so `inlined` rendering with no variables at all in the snapshot is
* purely the missing origin lookup.
*/
static inline __attribute__((always_inline)) int inlined(int param)
{
int doubled = param * 2;
return doubled + 1;
}
/*
* Inlined variables are not supported yet; DW_AT_abstract_origin is not followed
* so we don't resolve these for now
*/
static inline __attribute__((always_inline)) int inlined(int param)
{
int doubled = param * 2;
return doubled + 1;
}

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

1 participant