Skip to content

Commit 68b8b1a

Browse files
mujacicaloewenheim
andauthored
feat(srcsrv): Extend symbolic to extract the srcsrv integration name for metrics (#944)
* feat(srcsrv): Update symbolic to extract the srcsrv integration name for metrics --------- Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
1 parent 8d4da3d commit 68b8b1a

File tree

6 files changed

+72
-0
lines changed

6 files changed

+72
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- feat(pdb): Extract the srcsrv integration name for metrics ([#944](https://github.com/getsentry/symbolic/pull/944))
6+
37
## 12.16.3
48

59
- feat(elf): Added support for dynamic symbols when DYNAMIC segment is missing. ([#935](https://github.com/getsentry/symbolic/pull/935))

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

symbolic-debuginfo/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ ms = [
6969
"pdb-addr2line",
7070
"scroll",
7171
"smallvec",
72+
"srcsrv",
7273
]
7374
ppdb = ["symbolic-ppdb"]
7475
# Source bundle creation
@@ -106,6 +107,7 @@ scroll = { workspace = true, optional = true }
106107
serde = { workspace = true }
107108
serde_json = { workspace = true, optional = true }
108109
smallvec = { workspace = true, optional = true }
110+
srcsrv = { version = "0.2", optional = true }
109111
symbolic-common = { version = "12.16.3", path = "../symbolic-common" }
110112
symbolic-ppdb = { version = "12.16.3", path = "../symbolic-ppdb", optional = true }
111113
thiserror = { workspace = true }

symbolic-debuginfo/src/pdb.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use pdb_addr2line::pdb::{
1616
};
1717
use pdb_addr2line::ModuleProvider;
1818
use smallvec::SmallVec;
19+
use srcsrv;
1920
use thiserror::Error;
2021

2122
use symbolic_common::{
@@ -251,6 +252,31 @@ impl<'data> PdbObject<'data> {
251252
false
252253
}
253254

255+
/// Returns the SRCSRV VCS integration name if available.
256+
///
257+
/// This extracts the version control system identifier from the SRCSRV stream,
258+
/// if present. Common values include "perforce", "tfs", "git", etc.
259+
/// Returns `None` if no SRCSRV stream exists or if it cannot be parsed.
260+
pub fn srcsrv_vcs_name(&self) -> Option<String> {
261+
let mut pdb = self.pdb.write();
262+
263+
// Try to open the "srcsrv" named stream
264+
let stream = match pdb.named_stream(b"srcsrv") {
265+
Ok(stream) => stream,
266+
Err(_) => return None,
267+
};
268+
269+
// Parse the stream to extract VCS name
270+
let stream_data = stream.as_slice();
271+
if let Ok(parsed_stream) = srcsrv::SrcSrvStream::parse(stream_data) {
272+
parsed_stream
273+
.version_control_description()
274+
.map(|s| s.to_string())
275+
} else {
276+
None
277+
}
278+
}
279+
254280
/// Determines whether this object is malformed and was only partially parsed
255281
pub fn is_malformed(&self) -> bool {
256282
false
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use symbolic_common::ByteView;
2+
use symbolic_debuginfo::pdb::PdbObject;
3+
use symbolic_testutils::fixture;
4+
5+
type Error = Box<dyn std::error::Error>;
6+
7+
#[test]
8+
fn test_pdb_srcsrv_vcs_name() -> Result<(), Error> {
9+
let view = ByteView::open(fixture("windows/crash_with_srcsrv.pdb"))?;
10+
let pdb = PdbObject::parse(&view)?;
11+
12+
// This PDB file contains Perforce SRCSRV information
13+
let vcs_name = pdb.srcsrv_vcs_name();
14+
assert_eq!(vcs_name, Some("Perforce".to_string()));
15+
16+
Ok(())
17+
}
18+
19+
#[test]
20+
fn test_pdb_without_srcsrv() -> Result<(), Error> {
21+
let view = ByteView::open(fixture("windows/crash.pdb"))?;
22+
let pdb = PdbObject::parse(&view)?;
23+
24+
// This PDB file does not contain SRCSRV information
25+
let vcs_name = pdb.srcsrv_vcs_name();
26+
assert_eq!(vcs_name, None);
27+
28+
Ok(())
29+
}
996 KB
Binary file not shown.

0 commit comments

Comments
 (0)