一,读取eBPF map的android应用程序示例
1.1 C++源码及源码解读
/system/memory/bpfmapparsed/hello_world_map_parser.cpp
//基于aosp android12#define LOG_TAG "BPF_MAP_PARSER"#include <log/log.h>
#include <stdlib.h>
#include <unistd.h>
#include <iostream>
#include <android-base/macros.h>
#include <android-base/properties.h>#include "bpf/BpfMap.h"
#include "bpf/BpfUtils.h"
#include "libbpf_android.h"constexpr const char prog_path[]="/sys/fs/bpf/prog_hello_world_ebpf_tracepoint_sched_sched_switch";
constexpr const char map_path[]="/sys/fs/bpf/map_hello_world_ebpf_cpu_pid_map";static constexpr char traceGroup[]="sched"
static constexpr char tracepoint[]="ched_switch";namespace android{
namespace bpf{class HelloWorldMapParser{private:int mProgFd;public:HelloWorldMapParser(){}~HelloWorldMapParser(){close(mPr