Skip to content
Open
Show file tree
Hide file tree
Changes from 14 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

**Features**

- Extract srcsrv data from PDB for file mapping ([#943](https://github.com/getsentry/symbolic/pull/943))

## 12.17.0

- feat(pdb): Extract the srcsrv integration name for metrics ([#944](https://github.com/getsentry/symbolic/pull/944))
Expand Down
37 changes: 35 additions & 2 deletions symbolic-debuginfo/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,19 @@ pub struct FileInfo<'data> {
name: Cow<'data, [u8]>,
/// Path to the file.
dir: Cow<'data, [u8]>,
/// The optional VCS revision (e.g., Perforce changelist, git commit hash).
revision: Option<Cow<'data, str>>,
}

impl<'data> FileInfo<'data> {
/// Creates a `FileInfo` with a given directory and the file name.
#[cfg(feature = "dwarf")]
pub fn new(dir: Cow<'data, [u8]>, name: Cow<'data, [u8]>) -> Self {
FileInfo { name, dir }
FileInfo {
name,
dir,
revision: None,
}
}

/// Creates a `FileInfo` from a joined path by trying to split it.
Expand All @@ -470,12 +476,12 @@ impl<'data> FileInfo<'data> {
Some(dir) => Cow::Borrowed(dir),
None => Cow::default(),
},
revision: None,
}
}

/// Creates a `FileInfo` from a joined path by trying to split it.
/// Unlike from_path(), copies the given data instead of referencing it.
#[cfg(feature = "ppdb")]
pub(crate) fn from_path_owned(path: &[u8]) -> Self {
let (dir, name) = symbolic_common::split_path_bytes(path);

Expand All @@ -485,6 +491,22 @@ impl<'data> FileInfo<'data> {
Some(dir) => Cow::Owned(dir.to_vec()),
None => Cow::default(),
},
revision: None,
}
}

/// Creates a `FileInfo` from a joined path and revision by trying to split the path.
/// Unlike from_path(), copies the given data instead of referencing it.
pub(crate) fn from_path_and_revision_owned(path: &[u8], revision: Option<String>) -> Self {
let (dir, name) = symbolic_common::split_path_bytes(path);

FileInfo {
name: Cow::Owned(name.to_vec()),
dir: match dir {
Some(dir) => Cow::Owned(dir.to_vec()),
None => Cow::default(),
},
revision: revision.map(Cow::Owned),
}
}

Expand All @@ -493,6 +515,7 @@ impl<'data> FileInfo<'data> {
FileInfo {
name: Cow::Borrowed(name),
dir: Cow::default(),
revision: None,
}
}

Expand All @@ -511,6 +534,16 @@ impl<'data> FileInfo<'data> {
let joined = join_path(&self.dir_str(), &self.name_str());
clean_path(&joined).into_owned()
}

/// The optional VCS revision (e.g., Perforce changelist, git commit hash).
pub fn revision(&self) -> Option<&str> {
self.revision.as_deref()
}

/// Sets the VCS revision for this file.
pub(crate) fn set_revision(&mut self, revision: Option<String>) {
self.revision = revision.map(Cow::Owned);
}
}

#[allow(clippy::ptr_arg)] // false positive https://github.com/rust-lang/rust-clippy/issues/9218
Expand Down
Loading
Loading