pub struct SourceFilePath { /* private fields */ }Expand description
The path of a source file, as found in the debug info.
This contains both the raw path and an optional “mapped path”. The raw path can refer to a file on this machine or on a different machine (i.e. the original build machine). The mapped path is something like a permalink which potentially allows obtaining the source file from a source server or a public hosted repository.
Implementations§
Source§impl SourceFilePath
impl SourceFilePath
Sourcepub fn new(raw_path: String, mapped_path: Option<MappedPath>) -> Self
pub fn new(raw_path: String, mapped_path: Option<MappedPath>) -> Self
Create a new SourceFilePath.
Sourcepub fn from_breakpad_path(raw_path: String) -> Self
pub fn from_breakpad_path(raw_path: String) -> Self
Create a SourceFilePath from a path in a Breakpad .sym file. Such files can
contain the “special path” serialization of a mapped path, but they can
also contain absolute paths.
Sourcepub fn display_path(&self) -> String
pub fn display_path(&self) -> String
A short, display-friendly version of this path.
Sourcepub fn raw_path(&self) -> &str
pub fn raw_path(&self) -> &str
The raw path to the source file, as written down in the debug file. This is usually an absolute path.
Examples:
"/Users/mstange/code/samply/samply-symbols/src/shared.rs""/Users/mstange/code/mozilla/widget/cocoa/nsNativeThemeCocoa.mm""./csu/../csu/libc-start.c""/rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/ptr/const_ptr.rs"r#"D:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl"#
If the debug file was produced by compiling code on this machine, then the path
usually refers to a file on this machine. (An exception to this is debug info
from the Rust stdlib, which has fake /rustc/<rev>/... paths even if the when
compiling Rust code locally.)
If the code was compiled on a different machine, then the raw path does not refer to a file on this machine.
Sometimes this path is a relative path. One such case was observed when the
“debug file” was a synthetic .so file which was generated by perf inject --jit
based on a JITDUMP file which included relative paths. You could argue
that the application which emitted relative paths into the JITDUMP file was
creating bad data and should have written out absolute paths. However, the perf
infrastructure worked fine on this file, because the relative paths happened to
be relative to the working directory, and because perf / objdump were resolving
those relative paths relative to the current working directory.
Sourcepub fn into_raw_path(self) -> String
pub fn into_raw_path(self) -> String
Returns the raw path while consuming this SourceFilePath.
Sourcepub fn mapped_path(&self) -> Option<&MappedPath>
pub fn mapped_path(&self) -> Option<&MappedPath>
A variant of the path which may allow obtaining the source code for this file from the web.
Examples:
- If the source file is from a Rust dependency from crates.io, we detect the
cargo cache directory in the raw path and create a mapped path of the form
MappedPath::Cargo. - If the source file can be obtained from a github URL, and we know this either
from the
srcsrvstream of a PDB file or because we recognize a path of the form/rustc/<rust-revision>/, then we create a mapped path of the formMappedPath::Git.
Sourcepub fn into_mapped_path(self) -> Option<MappedPath>
pub fn into_mapped_path(self) -> Option<MappedPath>
Returns the mapped path while consuming this SourceFilePath.
Trait Implementations§
Source§impl Clone for SourceFilePath
impl Clone for SourceFilePath
Source§fn clone(&self) -> SourceFilePath
fn clone(&self) -> SourceFilePath
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more