Skip to content

Commit

Permalink
ref(proguard): Keep track of frame indices (#1411)
Browse files Browse the repository at this point in the history
Symbolication can expand one raw JVM frame into multiple frames. When we return the symbolicated stacktraces, we want it to be possible to tell which symbolicated frames came from which raw frames. To this end, we add an index to frames that you need to pass in and that gets copied to the symbolicated frames.
  • Loading branch information
loewenheim committed Mar 21, 2024
1 parent 30e83b5 commit acd9b39
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Various fixes & improvements

- proguard: Added a mandatory `index` field to `JvmFrame` (#1411) by @loewenheim

## 24.3.0

### Various fixes & improvements
Expand Down
6 changes: 6 additions & 0 deletions crates/symbolicator-proguard/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ pub struct JvmFrame {
/// Whether the frame is related to app-code (rather than libraries/dependencies).
#[serde(skip_serializing_if = "Option::is_none")]
pub in_app: Option<bool>,

/// The index of the frame in the stacktrace before filtering and sending to Symbolicator.
///
/// When returning frames in a `CompletedJvmSymbolicationResponse`, all frames that were
/// expanded from the frame with index `i` will also have index `i`.
pub index: usize,
}

/// An exception in a JVM event.
Expand Down
6 changes: 6 additions & 0 deletions crates/symbolicator-proguard/src/symbolication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,15 @@ io.sentry.sample.MainActivity -> io.sentry.sample.MainActivity:
function: "onClick".to_owned(),
module: "e.a.c.a".to_owned(),
lineno: 2,
index: 0,
..Default::default()
},
JvmFrame {
function: "t".to_owned(),
module: "io.sentry.sample.MainActivity".to_owned(),
filename: Some("MainActivity.java".to_owned()),
lineno: 1,
index: 1,
..Default::default()
},
];
Expand All @@ -292,6 +294,7 @@ io.sentry.sample.MainActivity -> io.sentry.sample.MainActivity:
mapped_frames[0].module,
"io.sentry.sample.-$$Lambda$r3Avcbztes2hicEObh02jjhQqd4"
);
assert_eq!(mapped_frames[0].index, 0);

assert_eq!(
mapped_frames[1].filename,
Expand All @@ -300,9 +303,11 @@ io.sentry.sample.MainActivity -> io.sentry.sample.MainActivity:
assert_eq!(mapped_frames[1].module, "io.sentry.sample.MainActivity");
assert_eq!(mapped_frames[1].function, "onClickHandler");
assert_eq!(mapped_frames[1].lineno, 40);
assert_eq!(mapped_frames[1].index, 1);

assert_eq!(mapped_frames[2].function, "foo");
assert_eq!(mapped_frames[2].lineno, 44);
assert_eq!(mapped_frames[2].index, 1);

assert_eq!(mapped_frames[3].function, "bar");
assert_eq!(mapped_frames[3].lineno, 54);
Expand All @@ -311,6 +316,7 @@ io.sentry.sample.MainActivity -> io.sentry.sample.MainActivity:
Some("MainActivity.java".to_owned())
);
assert_eq!(mapped_frames[3].module, "io.sentry.sample.MainActivity");
assert_eq!(mapped_frames[3].index, 1);
}

// based on the Python test `test_sets_inapp_after_resolving`.
Expand Down
9 changes: 9 additions & 0 deletions crates/symbolicator-proguard/tests/integration/proguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,15 @@ async fn test_resolving_inline() {
function: "onClick".into(),
module: "e.a.c.a".into(),
lineno: 2,
index: 0,
..Default::default()
},
JvmFrame {
function: "t".into(),
module: "io.sentry.sample.MainActivity".into(),
filename: Some("MainActivity.java".into()),
lineno: 1,
index: 1,
..Default::default()
},
],
Expand All @@ -183,14 +185,21 @@ async fn test_resolving_inline() {
frames[0].module,
"io.sentry.sample.-$$Lambda$r3Avcbztes2hicEObh02jjhQqd4"
);
assert_eq!(frames[0].index, 0);

assert_eq!(frames[1].filename, Some("MainActivity.java".into()));
assert_eq!(frames[1].module, "io.sentry.sample.MainActivity");
assert_eq!(frames[1].function, "onClickHandler");
assert_eq!(frames[1].lineno, 40);
assert_eq!(frames[1].index, 1);

assert_eq!(frames[2].function, "foo");
assert_eq!(frames[2].lineno, 44);
assert_eq!(frames[2].index, 1);

assert_eq!(frames[3].function, "bar");
assert_eq!(frames[3].lineno, 54);
assert_eq!(frames[3].filename, Some("MainActivity.java".into()));
assert_eq!(frames[3].module, "io.sentry.sample.MainActivity");
assert_eq!(frames[3].index, 1);
}

0 comments on commit acd9b39

Please sign in to comment.