-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathPerfMap.h
39 lines (31 loc) · 897 Bytes
/
PerfMap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once
#include <cstdint>
#include <functional>
#include <asm/perf_regs.h>
#include <linux/perf_event.h>
#include <linux/hw_breakpoint.h>
struct SampleData {
uint32_t pid;
uint32_t tid;
uint64_t abi;
uint64_t regs[PERF_REG_ARM64_MAX];
};
class PerfMap {
struct PerfInfo {
int pid = 0;
int fd = 0;
void* mmap_addr = nullptr;
size_t mmap_size = 0;
perf_event_mmap_page* mmap_page_metadata = nullptr;
uintptr_t data_addr = 0;
uintptr_t data_size = 0;
int read_data_size = 0;
};
std::vector<PerfInfo> _perf_infos;
public:
int create(const std::vector<int>& pids, uintptr_t bp_addr, int bp_type, size_t bp_len, int buf_size = 0);
void process(const std::function<void(const SampleData&)>& handle, const bool* loop = nullptr);
void enable();
void disable();
void destroy();
};