Skip to content

Parse .sframe sections as alternative to .eh_frame#471

Draft
jbachorik wants to merge 1 commit intomainfrom
jb/sframe
Draft

Parse .sframe sections as alternative to .eh_frame#471
jbachorik wants to merge 1 commit intomainfrom
jb/sframe

Conversation

@jbachorik
Copy link
Copy Markdown
Collaborator

What does this PR do?:

Add SFrame V2 parsing as a transparent optimization in the native unwind table loading path. When the profiler loads a shared library, parseDwarfInfo() checks for a .sframe section first via PT_GNU_SFRAME. If present and valid, it parses the SFrame data directly into the existing FrameDesc* table. If absent or invalid, it falls back to the existing .eh_frame DWARF path. Walk-time code is completely unchanged.

Motivation:

SFrame is a simpler ELF section format that directly encodes CFA/FP/RA offsets in flat, binary-searchable tables without requiring a DWARF CFI bytecode interpreter. On modern Linux distros (Fedora 43+, glibc 2.42+, binutils 2.40+), libraries ship .sframe sections alongside .eh_frame. Parsing SFrame is faster than interpreting DWARF opcodes at library load time.

Additional Notes:

  • Linux/ELF only. macOS is unaffected (PT_GNU_SFRAME is never found on Mach-O).
  • No new user-visible CStack mode. No changes to StackWalker::walkDwarf() or CodeCache::findFrameDesc().
  • Both x86_64 and aarch64 supported, including aarch64 GCC vs Clang default frame detection.
  • SFrameParser is self-contained (sframe.h/sframe.cpp), depends only on dwarf.h.
  • No external dependencies. No build file changes (Gradle auto-discovers new files).
  • Comprehensive bounds checking on all pointer arithmetic from the SFrame section.

How to test the change?:

  • 20 unit tests in sframe_ut.cpp covering: header validation (magic, version, arch, truncated section, auxhdr_len), FDE loop (empty array, PCMASK skip, empty FDE skip), FRE parsing (SP/FP-based CFA, fixed/per-FRE RA, leaf functions), offset encodings (1B, 2B, 4B), multiple FDEs with sort verification, address translation with non-zero section_offset, FRE bounds overrun recovery, destructor memory safety, and aarch64 default frame detection.
  • ./gradlew ddprof-test:testDebug — new SFrame tests pass, existing DWARF tests unaffected.
  • ./gradlew ddprof-lib:compileRelease — builds on both Linux and macOS.
  • Integration on modern Linux (Fedora 43+): profile a Java app with cstack=dwarf, verify native stacks are collected via the SFrame path.

For Datadog employees:

  • If this PR touches code that signs or publishes builds or packages, or handles
    credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.
  • JIRA: [JIRA-XXXX]

Unsure? Have a question? Request a review!

…tables

Add SFrame V2 parser that transparently loads .sframe ELF sections into the
existing FrameDesc* table format. When parseDwarfInfo() loads a shared library,
it probes PT_GNU_SFRAME first; on success it returns early; on failure it falls
through to the existing DWARF .eh_frame path. Walk-time code is unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jbachorik jbachorik added the AI label Apr 14, 2026
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts bot commented Apr 14, 2026

CI Test Results

Run: #24412572603 | Commit: b0471f1 | Duration: 28m 16s (longest job)

All 32 test jobs passed

Status Overview

JDK glibc-aarch64/debug glibc-amd64/debug musl-aarch64/debug musl-amd64/debug
8 - - -
8-ibm - - -
8-j9 - -
8-librca - -
8-orcl - - -
11 - - -
11-j9 - -
11-librca - -
17 - -
17-graal - -
17-j9 - -
17-librca - -
21 - -
21-graal - -
21-librca - -
25 - -
25-graal - -
25-librca - -

Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled

Summary: Total: 32 | Passed: 32 | Failed: 0


Updated: 2026-04-14 17:41:07 UTC

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant