Skip to content
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
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion proto/psh.proto
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ message LineProtocolData {

message ElfFile {
string filename = 1;
bytes build_id = 2;
optional string build_id = 2;
string arch = 3; // use for disasm
bytes bytes = 4;
}
18 changes: 16 additions & 2 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ impl From<perf_event_rs::sampling::record::mmap::Body> for MMapEvent {
}
}

pub fn build_id_to_str(build_id: [u8; 20]) -> String {
use std::fmt::Write;

let mut string = String::with_capacity(40);
for ele in build_id {
write!(string, "{ele:02x}").unwrap();
}
string
}

impl From<perf_event_rs::sampling::record::mmap2::Body> for MMapEvent {
fn from(body: perf_event_rs::sampling::record::mmap2::Body) -> Self {
let (maj, min, ino, ino_generation, build_id) = match body.anon_enum {
Expand All @@ -94,8 +104,12 @@ impl From<perf_event_rs::sampling::record::mmap2::Body> for MMapEvent {
ino_generation,
} => (Some(maj), Some(min), Some(ino), Some(ino_generation), None),
perf_event_rs::sampling::record::mmap2::AnonEnum::BuildId(items) => {
let build_id = String::from_utf8(items).ok();
(None, None, None, None, build_id)
let mut bid = [0; 20];
for (i, &ele) in items.iter().enumerate() {
bid[i] = ele;
}
let build_id: String = build_id_to_str(bid);
(None, None, None, None, build_id.into())
}
};
MMapEvent {
Expand Down
Loading