Commit 227b5b99 authored by Derek's avatar Derek

enum bpf_probe_attach_type to CAPITAL

parent a112514c
...@@ -51,23 +51,23 @@ public: ...@@ -51,23 +51,23 @@ public:
StatusTuple attach_kprobe( StatusTuple attach_kprobe(
const std::string& kernel_func, const std::string& probe_func, const std::string& kernel_func, const std::string& probe_func,
bpf_probe_attach_type = probe_entry, bpf_probe_attach_type = BPF_PROBE_ENTRY,
pid_t pid = -1, int cpu = 0, int group_fd = -1, pid_t pid = -1, int cpu = 0, int group_fd = -1,
perf_reader_cb cb = nullptr, void* cb_cookie = nullptr); perf_reader_cb cb = nullptr, void* cb_cookie = nullptr);
StatusTuple detach_kprobe( StatusTuple detach_kprobe(
const std::string& kernel_func, const std::string& kernel_func,
bpf_probe_attach_type attach_type = probe_entry); bpf_probe_attach_type attach_type = BPF_PROBE_ENTRY);
StatusTuple attach_uprobe( StatusTuple attach_uprobe(
const std::string& binary_path, const std::string& symbol, const std::string& binary_path, const std::string& symbol,
const std::string& probe_func, uint64_t symbol_addr = 0, const std::string& probe_func, uint64_t symbol_addr = 0,
bpf_probe_attach_type attach_type = probe_entry, bpf_probe_attach_type attach_type = BPF_PROBE_ENTRY,
pid_t pid = -1, int cpu = 0, int group_fd = -1, pid_t pid = -1, int cpu = 0, int group_fd = -1,
perf_reader_cb cb = nullptr, void* cb_cookie = nullptr); perf_reader_cb cb = nullptr, void* cb_cookie = nullptr);
StatusTuple detach_uprobe( StatusTuple detach_uprobe(
const std::string& binary_path, const std::string& symbol, const std::string& binary_path, const std::string& symbol,
uint64_t symbol_addr = 0, uint64_t symbol_addr = 0,
bpf_probe_attach_type attach_type = probe_entry); bpf_probe_attach_type attach_type = BPF_PROBE_ENTRY);
StatusTuple attach_usdt(const USDT& usdt, pid_t pid = -1, int cpu = 0, StatusTuple attach_usdt(const USDT& usdt, pid_t pid = -1, int cpu = 0,
int group_fd = -1); int group_fd = -1);
StatusTuple detach_usdt(const USDT& usdt); StatusTuple detach_usdt(const USDT& usdt);
...@@ -118,9 +118,9 @@ private: ...@@ -118,9 +118,9 @@ private:
std::string attach_type_debug(bpf_probe_attach_type type) { std::string attach_type_debug(bpf_probe_attach_type type) {
switch (type) { switch (type) {
case probe_entry: case BPF_PROBE_ENTRY:
return ""; return "";
case probe_return: case BPF_PROBE_RETURN:
return "return "; return "return ";
} }
return "ERROR"; return "ERROR";
...@@ -128,9 +128,9 @@ private: ...@@ -128,9 +128,9 @@ private:
std::string attach_type_prefix(bpf_probe_attach_type type) { std::string attach_type_prefix(bpf_probe_attach_type type) {
switch (type) { switch (type) {
case probe_entry: case BPF_PROBE_ENTRY:
return "p"; return "p";
case probe_return: case BPF_PROBE_RETURN:
return "r"; return "r";
} }
return "ERROR"; return "ERROR";
......
...@@ -362,7 +362,7 @@ void * bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type, con ...@@ -362,7 +362,7 @@ void * bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type, con
goto error; goto error;
} }
snprintf(buf, sizeof(buf), "%c:%ss/%s %s", attach_type==probe_entry ? 'p' : 'r', snprintf(buf, sizeof(buf), "%c:%ss/%s %s", attach_type==BPF_PROBE_ENTRY ? 'p' : 'r',
event_type, new_name, fn_name); event_type, new_name, fn_name);
if (write(kfd, buf, strlen(buf)) < 0) { if (write(kfd, buf, strlen(buf)) < 0) {
if (errno == EINVAL) if (errno == EINVAL)
...@@ -420,7 +420,7 @@ void * bpf_attach_uprobe(int progfd, enum bpf_probe_attach_type attach_type, con ...@@ -420,7 +420,7 @@ void * bpf_attach_uprobe(int progfd, enum bpf_probe_attach_type attach_type, con
goto error; goto error;
} }
n = snprintf(buf, sizeof(buf), "%c:%ss/%s %s:0x%lx", attach_type==probe_entry ? 'p' : 'r', n = snprintf(buf, sizeof(buf), "%c:%ss/%s %s:0x%lx", attach_type==BPF_PROBE_ENTRY ? 'p' : 'r',
event_type, new_name, binary_path, offset); event_type, new_name, binary_path, offset);
if (n >= sizeof(buf)) { if (n >= sizeof(buf)) {
close(kfd); close(kfd);
......
...@@ -25,8 +25,8 @@ extern "C" { ...@@ -25,8 +25,8 @@ extern "C" {
#endif #endif
enum bpf_probe_attach_type { enum bpf_probe_attach_type {
probe_entry, BPF_PROBE_ENTRY,
probe_return BPF_PROBE_RETURN
}; };
int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size, int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment