From: "Eregon (Benoit Daloze) via ruby-core" Date: 2026-11-30T15:23:44+00:00 Subject: [ruby-core:127768] [Ruby Feature#21539] Export symbols for external profiling of stripped shared Ruby builds Issue #21539 has been updated by Eregon (Benoit Daloze). @ko1 Thank you for your review. ko1 (Koichi Sasada) wrote in #note-14: > * I'm okay to introduce it if we can agree that this symbols are implementation dependent and no guarantee even between teeny version. Yes, I think this is clear enough [in the PR](https://github.com/ruby/ruby/pull/19613/changes): > These names are best-effort debugging aids, not an API, and may change or disappear at any time. But if you'd like different wording feel free to suggest it on the PR :) > * BTW `ruby_debug_current_ec` is difficult for M:N thread scheduler. Should we comment about that? I guess you mean https://bugs.ruby-lang.org/issues/22453, right? That's not a concern when the symbol is read from another process, because then it doesn't matter whether the C compiler caches reads of that TLS, the other process reads the symbol/TLS every time anyway. What I assume is the M:N scheduler always writes to `ruby_current_ec` and it's the source of truth, and the concern is only about cached reads of it, let me know if that's not correct. ---------------------------------------- Feature #21539: Export symbols for external profiling of stripped shared Ruby builds https://bugs.ruby-lang.org/issues/21539#change-120323 * Author: dalehamel (Dale Hamel) * Status: Open ---------------------------------------- ## Motivation External profilers such as [OpenTelemetry's eBPF profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect Ruby stacks from outside the Ruby process. Distribution packages commonly ship shared libruby but strip the full symbol table (`.symtab`) and debug information. Some of the symbols needed to discover Ruby's execution state are currently local symbols, so they disappear when stripped. Public dynamic symbols in `.dynsym` survive normal stripping. I'd like to narrow this proposal to making the necessary discovery symbols available in these stripped shared builds. ## Proposed exports Please export these three existing symbols from shared libruby: | Symbol | Purpose | | --- | --- | | `ruby_current_ec` | Locate the sampled native thread's execution context through TLS, providing access to its Ruby stack. | | `rb_vm_exec` | Identify the function's address range, where native stack unwinding should hand off to Ruby stack unwinding. The profiler does not call this function. | | `ruby_global_symbols` | Resolve Ruby method IDs to names for methods implemented in C. Stack walking can work without this, but those method names become ``. | The profiler also needs `ruby_version`, which is already exported and requires no change. The requested outcome is that these symbols are available through `.dynsym` in installed shared builds, without requiring distributions to retain the full symbol table or users to install debug information just to locate them. ## Scope This is a symbol-visibility request, not a request for a general out-of-process profiling API: - No requirement to stabilize internal struct layouts or make these internals a supported C-extension API. - No additional profiling stack, per-frame bookkeeping, or in-process profiling machinery. - The profiler remains responsible for supporting version-specific layouts and interpreter/JIT behavior. This would address the symbol-discovery obstacle for stripped distribution builds without taking on the broader API design discussed in #19119. Related profiler discussion: https://github.com/open-telemetry/opentelemetry-ebpf-profiler/issues/202 ---Files-------------------------------- protected.patch (1.55 KB) exported.patch (1.21 KB) debug-aliases.patch (1.88 KB) debug-export.patch (1.83 KB) -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/