Skip to content

Commit 3558907

Browse files
committed
Remove unused PathMapper struct and arguments.
1 parent abe75d8 commit 3558907

File tree

6 files changed

+20
-88
lines changed

6 files changed

+20
-88
lines changed

samply-symbols/src/dwarf.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,22 @@ use gimli::{DwarfPackage, EndianSlice, Reader, RunTimeEndian, SectionId};
77
use object::read::ReadRef;
88
use object::CompressionFormat;
99

10-
use crate::path_mapper::PathMapper;
1110
use crate::shared::FrameDebugInfo;
1211
use crate::{demangle, Error, SourceFilePath};
1312

1413
pub fn get_frames<R: Reader>(
1514
address: u64,
1615
context: Option<&addr2line::Context<R>>,
17-
path_mapper: &mut PathMapper<()>,
1816
) -> Option<Vec<FrameDebugInfo>> {
1917
let frame_iter = context?.find_frames(address).skip_all_loads().ok()?;
20-
convert_frames(frame_iter, path_mapper)
18+
convert_frames(frame_iter)
2119
}
2220

2321
pub fn convert_frames<'a, R: gimli::Reader>(
2422
frame_iter: impl FallibleIterator<Item = addr2line::Frame<'a, R>>,
25-
path_mapper: &mut PathMapper<()>,
2623
) -> Option<Vec<FrameDebugInfo>> {
2724
let frames: Vec<_> = frame_iter
28-
.map(|f| Ok(convert_stack_frame(f, &mut *path_mapper)))
25+
.map(|f| Ok(convert_stack_frame(f)))
2926
.collect()
3027
.ok()?;
3128

@@ -36,10 +33,7 @@ pub fn convert_frames<'a, R: gimli::Reader>(
3633
}
3734
}
3835

39-
pub fn convert_stack_frame<R: gimli::Reader>(
40-
frame: addr2line::Frame<R>,
41-
path_mapper: &mut PathMapper<()>,
42-
) -> FrameDebugInfo {
36+
pub fn convert_stack_frame<R: gimli::Reader>(frame: addr2line::Frame<R>) -> FrameDebugInfo {
4337
let function = match frame.function {
4438
Some(function_name) => {
4539
if let Ok(name) = function_name.raw_name() {
@@ -50,10 +44,11 @@ pub fn convert_stack_frame<R: gimli::Reader>(
5044
}
5145
None => None,
5246
};
53-
let file_path = frame.location.as_ref().and_then(|l| l.file).map(|file| {
54-
let _mapped_path = path_mapper.map_path(file); // TODO: remove path mapper everywhere
55-
SourceFilePath::RawPath(file.into())
56-
});
47+
let file_path = frame
48+
.location
49+
.as_ref()
50+
.and_then(|l| l.file)
51+
.map(|file| SourceFilePath::RawPath(file.into()));
5752

5853
FrameDebugInfo {
5954
function,

samply-symbols/src/external_file.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use yoke_derive::Yokeable;
88

99
use crate::dwarf::{get_frames, Addr2lineContextData};
1010
use crate::error::Error;
11-
use crate::path_mapper::PathMapper;
1211
use crate::shared::{
1312
ExternalFileAddressInFileRef, FileAndPathHelper, FileContents, FileContentsWrapper,
1413
FrameDebugInfo,
@@ -118,7 +117,6 @@ impl<F: FileContents> ExternalFileOuter<F> {
118117
Ok(ExternalFileInner {
119118
external_file: self,
120119
member_contexts,
121-
path_mapper: Mutex::new(PathMapper::new()),
122120
})
123121
}
124122
}
@@ -145,23 +143,21 @@ trait ExternalFileInnerTrait {
145143
struct ExternalFileInner<'a, T: FileContents> {
146144
external_file: &'a ExternalFileOuter<T>,
147145
member_contexts: ExternalFileMemberContexts<'a>,
148-
path_mapper: Mutex<PathMapper<()>>,
149146
}
150147

151148
impl<F: FileContents> ExternalFileInnerTrait for ExternalFileInner<'_, F> {
152149
fn lookup(
153150
&self,
154151
external_file_address: &ExternalFileAddressInFileRef,
155152
) -> Option<Vec<FrameDebugInfo>> {
156-
let mut path_mapper = self.path_mapper.lock().unwrap();
157153
match (&self.member_contexts, external_file_address) {
158154
(
159155
ExternalFileMemberContexts::SingleObject(context),
160156
ExternalFileAddressInFileRef::MachoOsoObject {
161157
symbol_name,
162158
offset_from_symbol,
163159
},
164-
) => context.lookup(symbol_name, *offset_from_symbol, &mut path_mapper),
160+
) => context.lookup(symbol_name, *offset_from_symbol),
165161
(
166162
ExternalFileMemberContexts::Archive {
167163
member_ranges,
@@ -175,18 +171,12 @@ impl<F: FileContents> ExternalFileInnerTrait for ExternalFileInner<'_, F> {
175171
) => {
176172
let mut member_contexts = contexts.lock().unwrap();
177173
match member_contexts.get(name_in_archive) {
178-
Some(member_context) => {
179-
member_context.lookup(symbol_name, *offset_from_symbol, &mut path_mapper)
180-
}
174+
Some(member_context) => member_context.lookup(symbol_name, *offset_from_symbol),
181175
None => {
182176
let range = *member_ranges.get(name_in_archive.as_bytes())?;
183177
// .ok_or_else(|| Error::FileNotInArchive(name_in_archive.to_owned()))?;
184178
let member_context = self.external_file.make_member_context(range).ok()?;
185-
let res = member_context.lookup(
186-
symbol_name,
187-
*offset_from_symbol,
188-
&mut path_mapper,
189-
);
179+
let res = member_context.lookup(symbol_name, *offset_from_symbol);
190180
member_contexts.insert(name_in_archive.to_string(), member_context);
191181
res
192182
}
@@ -215,11 +205,10 @@ impl ExternalFileMemberContext<'_> {
215205
&self,
216206
symbol_name: &[u8],
217207
offset_from_symbol: u32,
218-
path_mapper: &mut PathMapper<()>,
219208
) -> Option<Vec<FrameDebugInfo>> {
220209
let symbol_address = self.symbol_addresses.get(symbol_name)?;
221210
let address = symbol_address + offset_from_symbol as u64;
222-
get_frames(address, self.context.as_ref(), path_mapper)
211+
get_frames(address, self.context.as_ref())
223212
}
224213
}
225214

samply-symbols/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ mod external_file;
229229
mod jitdump;
230230
mod macho;
231231
mod mapped_path;
232-
mod path_mapper;
233232
mod shared;
234233
mod symbol_map;
235234
mod symbol_map_object;

samply-symbols/src/path_mapper.rs

Lines changed: 0 additions & 36 deletions
This file was deleted.

samply-symbols/src/symbol_map_object.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use yoke::Yoke;
1313
use yoke_derive::Yokeable;
1414

1515
use crate::dwarf::convert_frames;
16-
use crate::path_mapper::PathMapper;
1716
use crate::shared::{
1817
relative_address_base, ExternalFileAddressInFileRef, ExternalFileAddressRef, ExternalFileRef,
1918
FramesLookupResult, LookupAddress, SymbolInfo,
@@ -353,7 +352,6 @@ impl std::fmt::Debug for SvmaFileRange {
353352
pub struct ObjectSymbolMapInner<'a, Symbol, FC: FileContents + 'static, DDM> {
354353
list: SymbolList<'a, Symbol>,
355354
debug_id: DebugId,
356-
path_mapper: Mutex<PathMapper<()>>,
357355
object_map: ObjectMap<'a>,
358356
context: Option<Mutex<addr2line::Context<gimli::EndianSlice<'a, gimli::RunTimeEndian>>>>,
359357
dwp_package:
@@ -480,9 +478,7 @@ where
480478
continue;
481479
}
482480
LookupResult::Output(Ok(frame_iter)) => {
483-
let mut path_mapper = self.path_mapper.lock().unwrap();
484-
convert_frames(frame_iter, &mut path_mapper)
485-
.map(FramesLookupResult::Available)
481+
convert_frames(frame_iter).map(FramesLookupResult::Available)
486482
}
487483
LookupResult::Output(Err(_)) => None,
488484
};
@@ -564,9 +560,7 @@ where
564560
))
565561
}
566562
LookupResult::Output(Ok(frame_iter)) => {
567-
let mut path_mapper = self.path_mapper.lock().unwrap();
568-
convert_frames(frame_iter, &mut path_mapper)
569-
.map(FramesLookupResult::Available)
563+
convert_frames(frame_iter).map(FramesLookupResult::Available)
570564
}
571565
LookupResult::Output(Err(_)) => {
572566
drop(lookup_result);
@@ -677,7 +671,6 @@ impl<'a, FC: FileContents + 'static> ObjectSymbolMapInnerWrapper<'a, FC> {
677671
let inner = ObjectSymbolMapInner {
678672
list,
679673
debug_id,
680-
path_mapper: Mutex::new(PathMapper::new()),
681674
object_map: object_file.object_map(),
682675
context: addr2line_context.map(Mutex::new),
683676
dwp_package,

samply-symbols/src/windows.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use crate::debugid_util::debug_id_for_object;
1414
use crate::dwarf::Addr2lineContextData;
1515
use crate::error::{Context, Error};
1616
use crate::mapped_path::UnparsedMappedPath;
17-
use crate::path_mapper::{ExtraPathMapper, PathMapper};
1817
use crate::shared::{
1918
FileAndPathHelper, FileContents, FileContentsWrapper, FileLocation, FrameDebugInfo,
2019
FramesLookupResult, LookupAddress, SourceFilePath, SymbolInfo,
@@ -181,7 +180,6 @@ impl<FC: FileContents + 'static> PdbObjectTrait for PdbObject<'_, FC> {
181180
)?)),
182181
None => None,
183182
};
184-
let path_mapper = PathMapper::new_with_maybe_extra_mapper(path_mapper);
185183

186184
let symbol_map = PdbSymbolMapInner {
187185
context,
@@ -233,7 +231,7 @@ pub struct PdbSymbolMapInnerWrapper<'data>(Box<dyn SymbolMapTrait + Send + 'data
233231
struct PdbSymbolMapInner<'object> {
234232
context: Box<dyn PdbAddr2lineContextTrait + Send + 'object>,
235233
debug_id: DebugId,
236-
path_mapper: Mutex<PathMapper<SrcSrvPathMapper<'object>>>,
234+
path_mapper: Mutex<Option<SrcSrvPathMapper<'object>>>,
237235
}
238236

239237
impl SymbolMapTrait for PdbSymbolMapInner<'_> {
@@ -288,16 +286,12 @@ impl SymbolMapTrait for PdbSymbolMapInner<'_> {
288286
let frames = if has_debug_info(&function_frames) {
289287
let mut path_mapper = self.path_mapper.lock().unwrap();
290288
let mut map_path = |path: Cow<str>| {
291-
let mapped_path = path_mapper.map_path(&path);
292-
match mapped_path {
293-
UnparsedMappedPath::Url(url) => {
294-
SourceFilePath::RawPathAndUrl(path.into_owned(), url)
289+
if let Some(path_mapper) = &mut *path_mapper {
290+
if let Some(UnparsedMappedPath::Url(url)) = path_mapper.map_path(&path) {
291+
return SourceFilePath::RawPathAndUrl(path.into_owned(), url);
295292
}
296-
UnparsedMappedPath::BreakpadSpecialPath(_) => unreachable!(
297-
"path_mapper should never UnparsedMappedPath::BreakpadSpecialPath"
298-
),
299-
UnparsedMappedPath::RawPath(_) => SourceFilePath::RawPath(path.into_owned()),
300293
}
294+
SourceFilePath::RawPath(path.into_owned())
301295
};
302296
let frames: Vec<_> = function_frames
303297
.frames
@@ -441,7 +435,7 @@ struct SrcSrvPathMapper<'a> {
441435
command_is_file_download_with_url_in_var4_and_uncompress_function_in_var5: bool,
442436
}
443437

444-
impl ExtraPathMapper for SrcSrvPathMapper<'_> {
438+
impl<'a> SrcSrvPathMapper<'a> {
445439
fn map_path(&mut self, path: &str) -> Option<UnparsedMappedPath> {
446440
if let Some(value) = self.cache.get(path) {
447441
return value.clone();
@@ -464,9 +458,7 @@ impl ExtraPathMapper for SrcSrvPathMapper<'_> {
464458
self.cache.insert(path.to_string(), value.clone());
465459
value
466460
}
467-
}
468461

469-
impl<'a> SrcSrvPathMapper<'a> {
470462
pub fn new(srcsrv_stream: srcsrv::SrcSrvStream<'a>) -> Self {
471463
let command_is_file_download_with_url_in_var4_and_uncompress_function_in_var5 =
472464
Self::matches_chrome_gitiles_workaround(&srcsrv_stream);

0 commit comments

Comments
 (0)