:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(cymbal): link native frames to their debug symbol set via debug_id (#64358)
Catalin Irimieafe5eb760aaf
diff --git a/rust/cymbal/src/core/symbolication/symbol/local.rs b/rust/cymbal/src/core/symbolication/symbol/local.rsindex b628c6d01122..996fc5bd1d22 100644--- a/rust/cymbal/src/core/symbolication/symbol/local.rs+++ b/rust/cymbal/src/core/symbolication/symbol/local.rs@@ -156,7 +156,7 @@ impl LocalSymbolResolver {assert!(!resolved.is_empty()); // If this ever happens, we've got a data-dropping bug, and want to crash- let (set, release) = if let Some(set_ref) = frame.symbol_set_ref() {+ let (set, release) = if let Some(set_ref) = frame.symbol_set_ref(debug_images) {let set_fut = SymbolSetRecord::load(&self.pool, raw_id.team_id, &set_ref);let release_fut = async {ReleaseRecord::for_symbol_set_ref(&self.pool, &set_ref, raw_id.team_id)@@ -456,8 +456,8 @@ mod test {.unwrap();assert_eq!(count, 1);- // get the symbol set- let set_ref = frame.symbol_set_ref();+ // get the symbol set (JS frame: debug images are irrelevant)+ let set_ref = frame.symbol_set_ref(&[]);let set = SymbolSetRecord::load(&pool, 0, &set_ref.unwrap()).await.unwrap()diff --git a/rust/cymbal/src/core/types/frames/mod.rs b/rust/cymbal/src/core/types/frames/mod.rsindex 00099e34e7f8..4b7ea3c49abb 100644--- a/rust/cymbal/src/core/types/frames/mod.rs+++ b/rust/cymbal/src/core/types/frames/mod.rs@@ -83,20 +83,25 @@ pub enum RawFrame {}impl RawFrame {- pub fn symbol_set_ref(&self) -> Option<String> {+ pub fn symbol_set_ref(&self, debug_images: &[DebugImage]) -> Option<String> {match self {RawFrame::JavaScriptWeb(frame) | RawFrame::LegacyJS(frame) => frame.symbol_set_ref(),RawFrame::JavaScriptNode(frame) => frame.chunk_id.clone(),RawFrame::Hermes(frame) => frame.symbol_set_ref(),RawFrame::Java(frame) => frame.symbol_set_ref(),+ // Native frames (apple, rust) resolve against an uploaded debug+ // symbol set keyed by the matched debug image's debug_id. Surfacing+ // it as the symbol-set ref links the saved frame records to that+ // set, so release info attaches and a later (re)upload invalidates+ // the cached records.+ RawFrame::Apple(frame) => frame.symbol_set_ref(debug_images),+ RawFrame::Native(frame) => frame.symbol_set_ref(debug_images),// Frames with no symbol setsRawFrame::Python(_)| RawFrame::Php(_)| RawFrame::Ruby(_)| RawFrame::Go(_)| RawFrame::Dart(_)- | RawFrame::Apple(_)- | RawFrame::Native(_)| RawFrame::Custom(_) => None,}}diff --git a/rust/cymbal/src/core/types/langs/apple.rs b/rust/cymbal/src/core/types/langs/apple.rsindex b4eca9526829..7e2abf5c5a35 100644--- a/rust/cymbal/src/core/types/langs/apple.rs+++ b/rust/cymbal/src/core/types/langs/apple.rs@@ -346,6 +346,18 @@ impl RawAppleFrame {frame}+ /// The uploaded dSYM this frame resolves against, identified by the matched+ /// debug image's `debug_id` (the chunk_id used at upload). None when no+ /// debug image matches the address, so there is no symbol set to link.+ pub fn symbol_set_ref(&self, debug_images: &[DebugImage]) -> Option<String> {+ native::launch_invariant_addr(+ self.instruction_addr.as_deref(),+ self.image_addr.as_deref(),+ debug_images,+ )+ .map(|(debug_id, _)| debug_id)+ }+pub fn frame_id(&self, debug_images: &[DebugImage]) -> String {let mut hasher = Sha512::new();@@ -790,6 +802,18 @@ mod test {}}+ #[test]+ fn symbol_set_ref_is_matched_debug_id() {+ let frame = frame_at(0x100004000, 0x100000000);+ let images = [image_at("dsym-uuid-1", 0x100000000)];+ assert_eq!(+ frame.symbol_set_ref(&images),+ Some("dsym-uuid-1".to_string())+ );+ // No matching debug image -> no symbol set to link.+ assert_eq!(frame.symbol_set_ref(&[]), None);+ }+#[test]fn test_frame_id_stable_across_aslr_slides() {// Same logical frame (same image, same relative offset) from two launchesdiff --git a/rust/cymbal/src/core/types/langs/native.rs b/rust/cymbal/src/core/types/langs/native.rsindex 5c4139b07070..3bfd5076b4c9 100644--- a/rust/cymbal/src/core/types/langs/native.rs+++ b/rust/cymbal/src/core/types/langs/native.rs@@ -330,6 +330,19 @@ impl RawNativeFrame {}}+ /// The uploaded debug symbol set this frame resolves against, identified by+ /// the matched debug image's `debug_id` (the chunk_id used at upload). None+ /// when no debug image matches the address, so there is no symbol set to+ /// link — e.g. a JIT or otherwise unmapped frame.+ pub fn symbol_set_ref(&self, debug_images: &[DebugImage]) -> Option<String> {+ launch_invariant_addr(+ self.instruction_addr.as_deref(),+ self.image_addr.as_deref(),+ debug_images,+ )+ .map(|(debug_id, _)| debug_id)+ }+pub fn frame_id(&self, debug_images: &[DebugImage]) -> String {let mut hasher = Sha512::new();@@ -697,6 +710,18 @@ mod test {}}+ #[test]+ fn symbol_set_ref_is_matched_debug_id() {+ let frame = native_frame_at(0x1000_4000, 0x1000_0000);+ let images = [debug_image_at("rust-build-1", 0x1000_0000)];+ assert_eq!(+ frame.symbol_set_ref(&images),+ Some("rust-build-1".to_string())+ );+ // No matching debug image -> no symbol set to link.+ assert_eq!(frame.symbol_set_ref(&[]), None);+ }+// Fixture facts (see tests/static/native/build.sh; constants extracted// from the symcache the same way cymbal builds it):// test_binary_nopie: debug_id 7561847b-1054-7eb3-7763-4415adfaa134,