Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(proguard): Keep track of frame indices #1411

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like an offset rather than an index, but I'm fine with both.

}

/// 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 @@ -265,13 +265,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 @@ -291,6 +293,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 @@ -299,9 +302,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 @@ -310,6 +315,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);
}