Skip to content

Commit

Permalink
Aha, partialeq/eq _was_ needed, missed that.
Browse files Browse the repository at this point in the history
  • Loading branch information
afranchuk committed Jan 19, 2024
1 parent d64331b commit 9da1633
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
55 changes: 46 additions & 9 deletions samply/src/mac/proc_maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,62 @@ pub struct ThreadInfo {
pub backtrace: Option<Vec<u64>>,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DyldInfo {
pub is_executable: bool,
pub file: String,
pub base_avma: u64,
pub vmsize: u64,
pub module_info: framehop::ExplicitModuleSectionInfo<UnwindSectionBytes>,
pub module_info: ModuleInfo,
pub debug_id: Option<DebugId>,
pub code_id: Option<CodeId>,
pub arch: Option<&'static str>,
pub unwind_sections: UnwindSectionInfo,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ModuleInfo {
pub base_svma: u64,
pub text_svma: Option<Range<u64>>,
pub stubs_svma: Option<Range<u64>>,
pub stub_helper_svma: Option<Range<u64>>,
pub got_svma: Option<Range<u64>>,
pub eh_frame_svma: Option<Range<u64>>,
pub eh_frame_hdr_svma: Option<Range<u64>>,
pub text_segment_file_range: Option<Range<u64>>,
}

impl ModuleInfo {
pub fn framehop_section_info(&self) -> framehop::ExplicitModuleSectionInfo<UnwindSectionBytes> {
let ModuleInfo {
base_svma,
text_svma,
stubs_svma,
stub_helper_svma,
got_svma,
eh_frame_svma,
eh_frame_hdr_svma,
text_segment_file_range,
} = self.clone();
framehop::ExplicitModuleSectionInfo {
base_svma,
text_svma,
text: None,
stubs_svma,
stub_helper_svma,
got_svma,
unwind_info: None,
eh_frame_svma,
eh_frame: None,
eh_frame_hdr_svma,
eh_frame_hdr: None,
debug_frame: None,
text_segment_file_range,
text_segment: None,
}
}
}

/// These are SVMAs.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UnwindSectionInfo {
Expand Down Expand Up @@ -313,21 +356,15 @@ fn get_dyld_image_info(
file: filename,
base_avma,
vmsize,
module_info: framehop::ExplicitModuleSectionInfo {
module_info: ModuleInfo {
base_svma,
text_svma: section_svma_range(b"__text"),
text: None,
stubs_svma: section_svma_range(b"__stubs"),
stub_helper_svma: section_svma_range(b"__stub_helper"),
got_svma: section_svma_range(b"__got"),
unwind_info: None,
eh_frame_svma: section_svma_range(b"__eh_frame"),
eh_frame: None,
eh_frame_hdr_svma: section_svma_range(b"__eh_frame_hdr"),
eh_frame_hdr: None,
debug_frame: None,
text_segment_file_range,
text_segment: None,
},
debug_id: uuid.map(DebugId::from_uuid),
code_id: uuid.map(CodeId::MachoUuid),
Expand Down
2 changes: 1 addition & 1 deletion samply/src/mac/task_profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ impl TaskProfiler {
}

fn add_lib_to_unwinder_and_ensure_debug_id(&mut self, lib: &mut DyldInfo) {
let mut module_section_info = lib.module_info.clone();
let mut module_section_info = lib.module_info.framehop_section_info();
let base_svma = module_section_info.base_svma;
let base_avma = lib.base_avma;
let unwind_info_data = lib
Expand Down

0 comments on commit 9da1633

Please sign in to comment.