SourceFilePath

Struct SourceFilePath 

Source
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

Source

pub fn new(raw_path: String, mapped_path: Option<MappedPath>) -> Self

Create a new SourceFilePath.

Source

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.

Source

pub fn display_path(&self) -> String

A short, display-friendly version of this path.

Source

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.

Source

pub fn into_raw_path(self) -> String

Returns the raw path while consuming this SourceFilePath.

Source

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 srcsrv stream of a PDB file or because we recognize a path of the form /rustc/<rust-revision>/, then we create a mapped path of the form MappedPath::Git.
Source

pub fn into_mapped_path(self) -> Option<MappedPath>

Returns the mapped path while consuming this SourceFilePath.

Trait Implementations§

Source§

impl Clone for SourceFilePath

Source§

fn clone(&self) -> SourceFilePath

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SourceFilePath

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SourceFilePath

Source§

fn eq(&self, other: &SourceFilePath) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for SourceFilePath

Source§

impl StructuralPartialEq for SourceFilePath

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,