From 8d198f2ec0b810a0cc538e3765173bfa2157a512 Mon Sep 17 00:00:00 2001 From: Ioannis J Date: Thu, 27 Nov 2025 19:51:27 +0200 Subject: [PATCH] feat: add ios raw frame --- rust/cymbal/src/frames/mod.rs | 9 +++- rust/cymbal/src/langs/ios.rs | 78 +++++++++++++++++++++++++++++++++++ rust/cymbal/src/langs/mod.rs | 1 + 3 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 rust/cymbal/src/langs/ios.rs diff --git a/rust/cymbal/src/frames/mod.rs b/rust/cymbal/src/frames/mod.rs index 1b03d0e29a287..c1dcc9ee3cf3f 100644 --- a/rust/cymbal/src/frames/mod.rs +++ b/rust/cymbal/src/frames/mod.rs @@ -10,8 +10,8 @@ use crate::{ fingerprinting::{FingerprintBuilder, FingerprintComponent, FingerprintRecordPart}, langs::{ custom::CustomFrame, dart::RawDartFrame, go::RawGoFrame, hermes::RawHermesFrame, - java::RawJavaFrame, js::RawJSFrame, node::RawNodeFrame, python::RawPythonFrame, - ruby::RawRubyFrame, + java::RawJavaFrame, ios::RawIOSFrame, js::RawJSFrame, node::RawNodeFrame, + python::RawPythonFrame, ruby::RawRubyFrame, }, metric_consts::{LEGACY_JS_FRAME_RESOLVED, PER_FRAME_TIME}, sanitize_string, @@ -43,6 +43,8 @@ pub enum RawFrame { Java(RawJavaFrame), #[serde(rename = "dart")] Dart(RawDartFrame), + #[serde(rename = "ios")] + Ios(RawIOSFrame), #[serde(rename = "custom")] Custom(CustomFrame), // TODO - remove once we're happy no clients are using this anymore @@ -71,6 +73,7 @@ impl RawFrame { } RawFrame::Dart(frame) => (to_vec(Ok(frame.into())), "dart"), + RawFrame::Ios(frame) => (to_vec(Ok(frame.into())), "ios"), RawFrame::Python(frame) => (to_vec(Ok(frame.into())), "python"), RawFrame::Ruby(frame) => (to_vec(Ok(frame.into())), "ruby"), RawFrame::Custom(frame) => (to_vec(Ok(frame.into())), "custom"), @@ -109,6 +112,7 @@ impl RawFrame { | RawFrame::Ruby(_) | RawFrame::Go(_) | RawFrame::Dart(_) + | RawFrame::Ios(_) | RawFrame::Custom(_) => None, } } @@ -124,6 +128,7 @@ impl RawFrame { RawFrame::Hermes(raw) => raw.frame_id(), RawFrame::Java(raw) => raw.frame_id(), RawFrame::Dart(raw) => raw.frame_id(), + RawFrame::Ios(raw) => raw.frame_id(), }; RawFrameId::new(hash_id, team_id) diff --git a/rust/cymbal/src/langs/ios.rs b/rust/cymbal/src/langs/ios.rs new file mode 100644 index 0000000000000..705ee43f99429 --- /dev/null +++ b/rust/cymbal/src/langs/ios.rs @@ -0,0 +1,78 @@ +use common_types::error_tracking::FrameId; +use serde::{Deserialize, Serialize}; +use sha2::{Digest, Sha512}; + +use crate::{ + frames::Frame, + langs::{utils::add_raw_to_junk, CommonFrameMetadata}, +}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct RawIOSFrame { + pub instruction_addr: Option, + pub symbol_addr: Option, + pub image_addr: Option, + pub image_uuid: Option, + pub module: Option, + pub function: Option, + pub filename: Option, + pub lineno: Option, + pub colno: Option, + #[serde(flatten)] + pub meta: CommonFrameMetadata, +} + +impl RawIOSFrame { + pub fn frame_id(&self) -> String { + let mut hasher = Sha512::new(); + + if let Some(instruction_addr) = &self.instruction_addr { + hasher.update(instruction_addr.as_bytes()); + } + + if let Some(module) = &self.module { + hasher.update(module.as_bytes()); + } + + if let Some(function) = &self.function { + hasher.update(function.as_bytes()); + } + + if let Some(image_uuid) = &self.image_uuid { + hasher.update(image_uuid.as_bytes()); + } + + format!("{:x}", hasher.finalize()) + } + +} + +impl From<&RawIOSFrame> for Frame { + fn from(raw: &RawIOSFrame) -> Self { + let mut f = Frame { + frame_id: FrameId::placeholder(), + mangled_name: raw.function.clone().unwrap_or_default(), + line: raw.lineno, + column: raw.colno, + source: raw.filename.clone(), + in_app: raw.meta.in_app, + resolved_name: raw.function.clone(), + lang: "ios".to_string(), + resolved: raw.function.is_some(), + resolve_failure: None, + junk_drawer: None, + release: None, + synthetic: raw.meta.synthetic, + context: None, + suspicious: false, + module: raw.module.clone(), + exception_type: None, + code_variables: None, + }; + + // Store raw frame data in junk drawer for debugging/analysis + add_raw_to_junk(&mut f, raw); + f + } +} + diff --git a/rust/cymbal/src/langs/mod.rs b/rust/cymbal/src/langs/mod.rs index 8af814c1c3cb4..8aeb1da574377 100644 --- a/rust/cymbal/src/langs/mod.rs +++ b/rust/cymbal/src/langs/mod.rs @@ -4,6 +4,7 @@ pub mod custom; pub mod dart; pub mod go; pub mod hermes; +pub mod ios; pub mod java; pub mod js; pub mod node;