Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Send on SymbolMap. #82

Merged
merged 1 commit into from
Dec 14, 2023
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
71 changes: 46 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions samply-symbols/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ features = ["std", "read_core", "archive", "elf", "macho", "pe", "unaligned", "c
version = "0.30.2"

[dependencies]
# pdb-addr2line = { path = "../../pdb-addr2line" }
pdb-addr2line = "0.10.0"
#pdb-addr2line = { path = "../../pdb-addr2line" }
pdb-addr2line = "0.11.0"
uuid = "1.0.0"
thiserror = "1.0.26"
cpp_demangle = "0.4.0"
Expand Down
4 changes: 3 additions & 1 deletion samply-symbols/src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ impl<T: FileContents> ElfSymbolMapData<T> {
}

impl<T: FileContents + 'static> SymbolMapDataOuterTrait for ElfSymbolMapData<T> {
fn make_symbol_map_data_mid(&self) -> Result<Box<dyn SymbolMapDataMidTrait + '_>, Error> {
fn make_symbol_map_data_mid(
&self,
) -> Result<Box<dyn SymbolMapDataMidTrait + Send + '_>, Error> {
let object =
File::parse(&self.file_data).map_err(|e| Error::ObjectParseError(self.file_kind, e))?;
let supplementary_object = match self.supplementary_file_data.as_ref() {
Expand Down
12 changes: 9 additions & 3 deletions samply-symbols/src/macho.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ impl<T: FileContents + 'static> DyldCacheFileData<T> {
}

impl<T: FileContents + 'static> SymbolMapDataOuterTrait for DyldCacheFileData<T> {
fn make_symbol_map_data_mid(&self) -> Result<Box<dyn SymbolMapDataMidTrait + '_>, Error> {
fn make_symbol_map_data_mid(
&self,
) -> Result<Box<dyn SymbolMapDataMidTrait + Send + '_>, Error> {
let ObjectAndMachOData { object, macho_data } = self.make_object()?;
let arch = macho_data.get_arch();
let function_addresses_computer = MachOFunctionAddressesComputer { macho_data };
Expand Down Expand Up @@ -388,7 +390,9 @@ impl<T: FileContents> MachSymbolMapData<T> {
}

impl<T: FileContents + 'static> SymbolMapDataOuterTrait for MachSymbolMapData<T> {
fn make_symbol_map_data_mid(&self) -> Result<Box<dyn SymbolMapDataMidTrait + '_>, Error> {
fn make_symbol_map_data_mid(
&self,
) -> Result<Box<dyn SymbolMapDataMidTrait + Send + '_>, Error> {
let macho_file = File::parse(&self.file_data).map_err(Error::MachOHeaderParseError)?;
let macho_data = MachOData::new(&self.file_data, 0, macho_file.is_64());
let arch = macho_data.get_arch();
Expand Down Expand Up @@ -440,7 +444,9 @@ impl<T: FileContents> MachOFatArchiveMemberData<T> {
}

impl<T: FileContents + 'static> SymbolMapDataOuterTrait for MachOFatArchiveMemberData<T> {
fn make_symbol_map_data_mid(&self) -> Result<Box<dyn SymbolMapDataMidTrait + '_>, Error> {
fn make_symbol_map_data_mid(
&self,
) -> Result<Box<dyn SymbolMapDataMidTrait + Send + '_>, Error> {
let range_data = self.data();
let macho_file = File::parse(range_data).map_err(Error::MachOHeaderParseError)?;
let macho_data = MachOData::new(range_data, 0, macho_file.is_64());
Expand Down
11 changes: 6 additions & 5 deletions samply-symbols/src/symbol_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use crate::{shared::AddressInfo, Error, FileLocation};

pub struct SymbolMap<FL: FileLocation> {
debug_file_location: FL,
pub(crate) inner: Box<dyn SymbolMapTrait>,
pub(crate) inner: Box<dyn SymbolMapTrait + Send>,
}

impl<FL: FileLocation> SymbolMap<FL> {
pub(crate) fn new(debug_file_location: FL, inner: Box<dyn SymbolMapTrait>) -> Self {
pub(crate) fn new(debug_file_location: FL, inner: Box<dyn SymbolMapTrait + Send>) -> Self {
Self {
debug_file_location,
inner,
Expand Down Expand Up @@ -60,15 +60,16 @@ pub trait SymbolMapTrait {
}

pub trait SymbolMapDataOuterTrait {
fn make_symbol_map_data_mid(&self) -> Result<Box<dyn SymbolMapDataMidTrait + '_>, Error>;
fn make_symbol_map_data_mid(&self)
-> Result<Box<dyn SymbolMapDataMidTrait + Send + '_>, Error>;
}

pub trait SymbolMapDataMidTrait {
fn make_symbol_map_inner(&self) -> Result<SymbolMapInnerWrapper<'_>, Error>;
}

#[derive(Yokeable)]
pub struct SymbolMapDataMidWrapper<'data>(Box<dyn SymbolMapDataMidTrait + 'data>);
pub struct SymbolMapDataMidWrapper<'data>(Box<dyn SymbolMapDataMidTrait + Send + 'data>);

struct SymbolMapDataOuterAndMid<SMDO: SymbolMapDataOuterTrait>(
Yoke<SymbolMapDataMidWrapper<'static>, Box<SMDO>>,
Expand Down Expand Up @@ -102,7 +103,7 @@ impl<SMDO: SymbolMapDataOuterTrait> GenericSymbolMap<SMDO> {
}

#[derive(Yokeable)]
pub struct SymbolMapInnerWrapper<'data>(pub Box<dyn SymbolMapTrait + 'data>);
pub struct SymbolMapInnerWrapper<'data>(pub Box<dyn SymbolMapTrait + Send + 'data>);

impl<SMDO: SymbolMapDataOuterTrait> SymbolMapTrait for GenericSymbolMap<SMDO> {
fn debug_id(&self) -> debugid::DebugId {
Expand Down
4 changes: 2 additions & 2 deletions samply-symbols/src/symbol_map_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ impl<'data, R: ReadRef<'data>, FAC: FunctionAddressesComputer<'data>>
}
}

impl<'data, R: ReadRef<'data>, FAC: FunctionAddressesComputer<'data>> SymbolMapDataMidTrait
for ObjectSymbolMapDataMid<'data, R, FAC>
impl<'data, R: ReadRef<'data> + Send + Sync, FAC: FunctionAddressesComputer<'data>>
SymbolMapDataMidTrait for ObjectSymbolMapDataMid<'data, R, FAC>
{
fn make_symbol_map_inner(&self) -> Result<SymbolMapInnerWrapper<'_>, Error> {
let (function_starts, function_ends) = self
Expand Down
20 changes: 12 additions & 8 deletions samply-symbols/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ impl<T: FileContents> PeSymbolMapData<T> {
}

impl<T: FileContents + 'static> SymbolMapDataOuterTrait for PeSymbolMapData<T> {
fn make_symbol_map_data_mid(&self) -> Result<Box<dyn SymbolMapDataMidTrait + '_>, Error> {
fn make_symbol_map_data_mid(
&self,
) -> Result<Box<dyn SymbolMapDataMidTrait + Send + '_>, Error> {
let object =
File::parse(&self.file_data).map_err(|e| Error::ObjectParseError(self.file_kind, e))?;
let debug_id = debug_id_for_object(&object)
Expand Down Expand Up @@ -145,7 +147,7 @@ pub fn is_pdb_file<F: FileContents>(file: &FileContentsWrapper<F>) -> bool {
struct PdbObject<'data, FC: FileContents + 'static> {
context_data: pdb_addr2line::ContextPdbData<'data, 'data, &'data FileContentsWrapper<FC>>,
debug_id: DebugId,
srcsrv_stream: Option<Box<dyn Deref<Target = [u8]> + 'data>>,
srcsrv_stream: Option<Box<dyn Deref<Target = [u8]> + Send + 'data>>,
}

impl<'data, FC: FileContents + 'static> SymbolMapDataMidTrait for PdbObject<'data, FC> {
Expand All @@ -172,7 +174,7 @@ impl<'data, FC: FileContents + 'static> SymbolMapDataMidTrait for PdbObject<'dat
impl<'data, FC: FileContents + 'static> PdbObject<'data, FC> {
fn make_context<'object>(
&'object self,
) -> Result<Box<dyn PdbAddr2lineContextTrait + 'object>, Error> {
) -> Result<Box<dyn PdbAddr2lineContextTrait + Send + 'object>, Error> {
let context = self.context_data.make_context().context("make_context()")?;
Ok(Box::new(context))
}
Expand Down Expand Up @@ -205,7 +207,7 @@ impl<'a, 's> PdbAddr2lineContextTrait for pdb_addr2line::Context<'a, 's> {
}

struct PdbSymbolMapInner<'object> {
context: Box<dyn PdbAddr2lineContextTrait + 'object>,
context: Box<dyn PdbAddr2lineContextTrait + Send + 'object>,
debug_id: DebugId,
path_mapper: Mutex<PathMapper<SrcSrvPathMapper<'object>>>,
}
Expand Down Expand Up @@ -281,17 +283,19 @@ impl<'object> SymbolMapTrait for PdbSymbolMapInner<'object> {
}
}

fn box_stream<'data, T>(stream: T) -> Box<dyn Deref<Target = [u8]> + 'data>
fn box_stream<'data, T>(stream: T) -> Box<dyn Deref<Target = [u8]> + Send + 'data>
where
T: Deref<Target = [u8]> + 'data,
T: Deref<Target = [u8]> + Send + 'data,
{
Box::new(stream)
}

struct PdbSymbolData<T: FileContents + 'static>(FileContentsWrapper<T>);

impl<T: FileContents + 'static> SymbolMapDataOuterTrait for PdbSymbolData<T> {
fn make_symbol_map_data_mid(&self) -> Result<Box<dyn SymbolMapDataMidTrait + '_>, Error> {
fn make_symbol_map_data_mid(
&self,
) -> Result<Box<dyn SymbolMapDataMidTrait + Send + '_>, Error> {
let mut pdb = PDB::open(&self.0)?;
let info = pdb.pdb_information().context("pdb_information")?;
let dbi = pdb.debug_information()?;
Expand Down Expand Up @@ -464,7 +468,7 @@ impl<'s, F: FileContents> pdb::Source<'s> for &'s FileContentsWrapper<F> {
fn view(
&mut self,
slices: &[pdb::SourceSlice],
) -> std::result::Result<Box<dyn pdb::SourceView<'s>>, std::io::Error> {
) -> std::result::Result<Box<dyn pdb::SourceView<'s> + Send + Sync>, std::io::Error> {
let len = slices.iter().fold(0, |acc, s| acc + s.size);

let mut bytes = Vec::with_capacity(len);
Expand Down
Loading