Skip to content

Commit 5bf88a5

Browse files
committed
Don't consider all methods of synthesized classes synthesized
1 parent a008032 commit 5bf88a5

4 files changed

Lines changed: 18 additions & 47 deletions

File tree

src/cache/mod.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl<'data> ProguardCache<'data> {
251251
}) else {
252252
return RemappedFrameIter::empty();
253253
};
254-
RemappedFrameIter::members(self, frame, members.iter(), class.is_synthesized())
254+
RemappedFrameIter::members(self, frame, members.iter())
255255
} else {
256256
let Some(members) = self.get_class_members(class) else {
257257
return RemappedFrameIter::empty();
@@ -269,7 +269,7 @@ impl<'data> ProguardCache<'data> {
269269
return RemappedFrameIter::empty();
270270
};
271271

272-
RemappedFrameIter::members(self, frame, members.iter(), class.is_synthesized())
272+
RemappedFrameIter::members(self, frame, members.iter())
273273
}
274274
}
275275

@@ -418,26 +418,20 @@ pub struct RemappedFrameIter<'r, 'data> {
418418
StackFrame<'data>,
419419
std::slice::Iter<'data, raw::Member>,
420420
)>,
421-
synthesized_class: bool,
422421
}
423422

424423
impl<'data> RemappedFrameIter<'_, 'data> {
425424
fn empty() -> Self {
426-
Self {
427-
inner: None,
428-
synthesized_class: false,
429-
}
425+
Self { inner: None }
430426
}
431427

432428
fn members(
433429
cache: &'data ProguardCache<'data>,
434430
frame: StackFrame<'data>,
435431
members: std::slice::Iter<'data, raw::Member>,
436-
synthesized_class: bool,
437432
) -> Self {
438433
Self {
439434
inner: Some((cache, frame, members)),
440-
synthesized_class,
441435
}
442436
}
443437
}
@@ -448,9 +442,9 @@ impl<'data> Iterator for RemappedFrameIter<'_, 'data> {
448442
fn next(&mut self) -> Option<Self::Item> {
449443
let (cache, frame, members) = self.inner.as_mut()?;
450444
if frame.parameters.is_none() {
451-
iterate_with_lines(cache, frame, members, self.synthesized_class)
445+
iterate_with_lines(cache, frame, members)
452446
} else {
453-
iterate_without_lines(cache, frame, members, self.synthesized_class)
447+
iterate_without_lines(cache, frame, members)
454448
}
455449
}
456450
}
@@ -459,7 +453,6 @@ fn iterate_with_lines<'a>(
459453
cache: &ProguardCache<'a>,
460454
frame: &mut StackFrame<'a>,
461455
members: &mut std::slice::Iter<'_, raw::Member>,
462-
synthesized_class: bool,
463456
) -> Option<StackFrame<'a>> {
464457
for member in members {
465458
// skip any members which do not match our frames line
@@ -510,7 +503,7 @@ fn iterate_with_lines<'a>(
510503
file,
511504
line,
512505
parameters: frame.parameters,
513-
is_synthesized: member.is_synthesized() || synthesized_class,
506+
is_synthesized: member.is_synthesized(),
514507
});
515508
}
516509
None
@@ -520,7 +513,6 @@ fn iterate_without_lines<'a>(
520513
cache: &ProguardCache<'a>,
521514
frame: &mut StackFrame<'a>,
522515
members: &mut std::slice::Iter<'_, raw::Member>,
523-
synthesized_class: bool,
524516
) -> Option<StackFrame<'a>> {
525517
let member = members.next()?;
526518

@@ -536,7 +528,7 @@ fn iterate_without_lines<'a>(
536528
file: None,
537529
line: 0,
538530
parameters: frame.parameters,
539-
is_synthesized: member.is_synthesized() || synthesized_class,
531+
is_synthesized: member.is_synthesized(),
540532
})
541533
}
542534

src/cache/raw.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ pub(crate) struct Class {
5959
/// Whether this class was synthesized by the compiler.
6060
///
6161
/// `0` means `false`, all other values mean `true`.
62+
///
63+
/// Note: It's currently unknown what effect a synthesized
64+
/// class has.
6265
pub(crate) is_synthesized: u8,
6366

6467
/// Reserved space.

src/mapper.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct ClassMapping<'s> {
7777
obfuscated: &'s str,
7878
file_name: Option<&'s str>,
7979
members: HashMap<&'s str, ClassMembers<'s>>,
80+
// Note: It's currently unknown what effect a synthesized class has.
8081
is_synthesized: bool,
8182
}
8283

@@ -86,20 +87,15 @@ type MemberIter<'m> = std::slice::Iter<'m, MemberMapping<'m>>;
8687
#[derive(Clone, Debug, Default)]
8788
pub struct RemappedFrameIter<'m> {
8889
inner: Option<(StackFrame<'m>, MemberIter<'m>)>,
89-
synthesized_class: bool,
9090
}
9191

9292
impl<'m> RemappedFrameIter<'m> {
9393
fn empty() -> Self {
94-
Self {
95-
inner: None,
96-
synthesized_class: false,
97-
}
94+
Self { inner: None }
9895
}
99-
fn members(frame: StackFrame<'m>, members: MemberIter<'m>, synthesized_class: bool) -> Self {
96+
fn members(frame: StackFrame<'m>, members: MemberIter<'m>) -> Self {
10097
Self {
10198
inner: Some((frame, members)),
102-
synthesized_class,
10399
}
104100
}
105101
}
@@ -109,9 +105,9 @@ impl<'m> Iterator for RemappedFrameIter<'m> {
109105
fn next(&mut self) -> Option<Self::Item> {
110106
let (frame, ref mut members) = self.inner.as_mut()?;
111107
if frame.parameters.is_none() {
112-
iterate_with_lines(frame, members, self.synthesized_class)
108+
iterate_with_lines(frame, members)
113109
} else {
114-
iterate_without_lines(frame, members, self.synthesized_class)
110+
iterate_without_lines(frame, members)
115111
}
116112
}
117113
}
@@ -125,7 +121,6 @@ fn extract_class_name(full_path: &str) -> Option<&str> {
125121
fn iterate_with_lines<'a>(
126122
frame: &mut StackFrame<'a>,
127123
members: &mut core::slice::Iter<'_, MemberMapping<'a>>,
128-
synthesized_class: bool,
129124
) -> Option<StackFrame<'a>> {
130125
for member in members {
131126
// skip any members which do not match our frames line
@@ -168,7 +163,7 @@ fn iterate_with_lines<'a>(
168163
file,
169164
line,
170165
parameters: frame.parameters,
171-
is_synthesized: member.is_synthesized || synthesized_class,
166+
is_synthesized: member.is_synthesized,
172167
});
173168
}
174169
None
@@ -177,7 +172,6 @@ fn iterate_with_lines<'a>(
177172
fn iterate_without_lines<'a>(
178173
frame: &mut StackFrame<'a>,
179174
members: &mut core::slice::Iter<'_, MemberMapping<'a>>,
180-
synthesized_class: bool,
181175
) -> Option<StackFrame<'a>> {
182176
let member = members.next()?;
183177

@@ -191,7 +185,7 @@ fn iterate_without_lines<'a>(
191185
file: None,
192186
line: 0,
193187
parameters: frame.parameters,
194-
is_synthesized: member.is_synthesized || synthesized_class,
188+
is_synthesized: member.is_synthesized,
195189
})
196190
}
197191

@@ -447,7 +441,7 @@ impl<'s> ProguardMapper<'s> {
447441
members.all_mappings.iter()
448442
};
449443

450-
RemappedFrameIter::members(frame, mappings, class.is_synthesized)
444+
RemappedFrameIter::members(frame, mappings)
451445
}
452446

453447
/// Remaps a throwable which is the first line of a full stacktrace.

tests/callback.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ fn test_method_matches_callback_mapper() {
1616
28,
1717
));
1818

19-
// The remapped frames should all be synthesized because the class is.
2019
assert_eq!(
2120
mapped.next().unwrap(),
2221
StackFrame::with_file(
@@ -25,7 +24,6 @@ fn test_method_matches_callback_mapper() {
2524
37,
2625
"EditActivity",
2726
)
28-
.with_synthesized(true)
2927
);
3028
assert_eq!(
3129
mapped.next().unwrap(),
@@ -58,7 +56,6 @@ fn test_method_matches_callback_cache() {
5856
28,
5957
));
6058

61-
// The remapped frames should all be synthesized because the class is.
6259
assert_eq!(
6360
mapped.next().unwrap(),
6461
StackFrame::with_file(
@@ -67,7 +64,6 @@ fn test_method_matches_callback_cache() {
6764
37,
6865
"EditActivity",
6966
)
70-
.with_synthesized(true)
7167
);
7268
assert_eq!(
7369
mapped.next().unwrap(),
@@ -95,7 +91,6 @@ fn test_method_matches_callback_extra_class_mapper() {
9591
28,
9692
));
9793

98-
// The remapped frames should all be synthesized because the class is.
9994
assert_eq!(
10095
mapped.next().unwrap(),
10196
StackFrame::with_file(
@@ -104,7 +99,6 @@ fn test_method_matches_callback_extra_class_mapper() {
10499
10,
105100
"TestSourceContext",
106101
)
107-
.with_synthesized(true)
108102
);
109103
assert_eq!(
110104
mapped.next().unwrap(),
@@ -114,7 +108,6 @@ fn test_method_matches_callback_extra_class_mapper() {
114108
6,
115109
"TestSourceContext",
116110
)
117-
.with_synthesized(true)
118111
);
119112
assert_eq!(
120113
mapped.next().unwrap(),
@@ -124,7 +117,6 @@ fn test_method_matches_callback_extra_class_mapper() {
124117
38,
125118
"EditActivity",
126119
)
127-
.with_synthesized(true)
128120
);
129121
assert_eq!(
130122
mapped.next().unwrap(),
@@ -158,7 +150,6 @@ fn test_method_matches_callback_extra_class_cache() {
158150
28,
159151
));
160152

161-
// The remapped frames should all be synthesized because the class is.
162153
assert_eq!(
163154
mapped.next().unwrap(),
164155
StackFrame::with_file(
@@ -167,7 +158,6 @@ fn test_method_matches_callback_extra_class_cache() {
167158
10,
168159
"TestSourceContext",
169160
)
170-
.with_synthesized(true)
171161
);
172162
assert_eq!(
173163
mapped.next().unwrap(),
@@ -177,7 +167,6 @@ fn test_method_matches_callback_extra_class_cache() {
177167
6,
178168
"TestSourceContext",
179169
)
180-
.with_synthesized(true)
181170
);
182171
assert_eq!(
183172
mapped.next().unwrap(),
@@ -187,7 +176,6 @@ fn test_method_matches_callback_extra_class_cache() {
187176
38,
188177
"EditActivity",
189178
)
190-
.with_synthesized(true)
191179
);
192180
assert_eq!(
193181
mapped.next().unwrap(),
@@ -214,7 +202,6 @@ fn test_method_matches_callback_inner_class_mapper() {
214202
28,
215203
));
216204

217-
// The remapped frames should all be synthesized because the class is.
218205
assert_eq!(
219206
mapped.next().unwrap(),
220207
StackFrame::with_file(
@@ -223,7 +210,6 @@ fn test_method_matches_callback_inner_class_mapper() {
223210
19,
224211
"EditActivity",
225212
)
226-
.with_synthesized(true)
227213
);
228214
assert_eq!(
229215
mapped.next().unwrap(),
@@ -233,7 +219,6 @@ fn test_method_matches_callback_inner_class_mapper() {
233219
45,
234220
"EditActivity",
235221
)
236-
.with_synthesized(true)
237222
);
238223
assert_eq!(
239224
mapped.next().unwrap(),
@@ -266,7 +251,6 @@ fn test_method_matches_callback_inner_class_cache() {
266251
28,
267252
));
268253

269-
// The remapped frames should all be synthesized because the class is.
270254
assert_eq!(
271255
mapped.next().unwrap(),
272256
StackFrame::with_file(
@@ -275,7 +259,6 @@ fn test_method_matches_callback_inner_class_cache() {
275259
19,
276260
"EditActivity",
277261
)
278-
.with_synthesized(true)
279262
);
280263
assert_eq!(
281264
mapped.next().unwrap(),
@@ -285,7 +268,6 @@ fn test_method_matches_callback_inner_class_cache() {
285268
45,
286269
"EditActivity",
287270
)
288-
.with_synthesized(true)
289271
);
290272
assert_eq!(
291273
mapped.next().unwrap(),

0 commit comments

Comments
 (0)