Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**Breaking changes**:

- Change `DebugSession::source_by_path()` to return `SourceCode` enum with either file content or a URL to fetch it from. ([#758](https://github.com/getsentry/symbolic/pull/758))
- Change `SourceBundleWriter::write_object_with_filter()` filter callback to take `SourceCode`, allowing to include/exclude embedded sources. ([#764](https://github.com/getsentry/symbolic/pull/764))

**Fixes**:

Expand Down
20 changes: 14 additions & 6 deletions symbolic-debuginfo/src/sourcebundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ where
}

/// This controls if source files should be scanned for Il2cpp-specific source annotations,
/// and the referenced C# files should be bundled ups as well.
/// and the referenced C# files should be bundled up as well.
pub fn collect_il2cpp_sources(&mut self, collect_il2cpp: bool) {
self.collect_il2cpp = collect_il2cpp;
}
Expand Down Expand Up @@ -893,7 +893,7 @@ where
O: ObjectLike<'data, 'object, Error = E>,
E: std::error::Error + Send + Sync + 'static,
{
self.write_object_with_filter(object, object_name, |_| true)
self.write_object_with_filter(object, object_name, |_, _| true)
}

/// Writes a single object into the bundle.
Expand All @@ -913,7 +913,7 @@ where
where
O: ObjectLike<'data, 'object, Error = E>,
E: std::error::Error + Send + Sync + 'static,
F: FnMut(&FileEntry) -> bool,
F: FnMut(&FileEntry, &Option<SourceCode<'_>>) -> bool,
{
let mut files_handled = BTreeSet::new();
let mut referenced_files = BTreeSet::new();
Expand All @@ -938,11 +938,19 @@ where
continue;
}

let source = if (filename.starts_with('<') && filename.ends_with('>')) || !filter(&file)
{
let source = if filename.starts_with('<') && filename.ends_with('>') {
None
} else {
std::fs::read(&filename).ok()
let source_from_object = session
.source_by_path(&filename)
.map_err(|e| SourceBundleError::new(SourceBundleErrorKind::BadDebugFile, e))?;
if filter(&file, &source_from_object) {
// Note: we could also use source code directly from the object, but that's not
// what happened here previously - only collected locally present files.
std::fs::read(&filename).ok()
} else {
None
}
};

if let Some(source) = source {
Expand Down