From d052e599ad45a136ae7bd1cda32f8bc2b04cebb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E7=BF=94=E5=AE=87?= Date: Tue, 9 Jul 2024 11:27:46 +0800 Subject: [PATCH] Dynamic addition of kprobe and tracepoint --- userspace/libscap/scap_bpf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/userspace/libscap/scap_bpf.c b/userspace/libscap/scap_bpf.c index 00452512c4..cf1d262c5a 100644 --- a/userspace/libscap/scap_bpf.c +++ b/userspace/libscap/scap_bpf.c @@ -711,7 +711,8 @@ static int32_t load_tracepoint(scap_t* handle, const char *event, struct bpf_ins static bool is_kt_enabled(scap_t *handle, char* event_name){ bool enabled = true; - for(int i = 0; i < handle->m_bpf_prog_real_size; i++){ + int i; + for(i = 0; i < handle->m_bpf_prog_real_size; i++){ if(strcmp(event_name, handle->kt_indices[i].name) == 0){ enabled = handle->kt_indices[i].interest; break; @@ -865,7 +866,8 @@ static int32_t load_bpf_file(scap_t *handle) if(is_kt_enabled(handle, shname)) { bool already_attached = false; - for(int i = 0; i < handle->m_bpf_prog_cnt && !already_attached; i++) + int i; + for(i = 0; i < handle->m_bpf_prog_cnt && !already_attached; i++) { if(strcmp(handle->m_bpf_progs[i].name, shname) == 0) {