From 5f9ae1f415c53ca30725d42e4b007f99efb774c2 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 1 Mar 2022 10:34:37 -0500 Subject: [PATCH] kprobe: Introduce lttng_kprobes_match_check Signed-off-by: Mathieu Desnoyers Change-Id: Iffc9dba158f9802db9f877fabeec288d5072a84c --- include/lttng/events-internal.h | 7 +++++++ src/lttng-kprobes.c | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/lttng/events-internal.h b/include/lttng/events-internal.h index 14ad198c..550c8e45 100644 --- a/include/lttng/events-internal.h +++ b/include/lttng/events-internal.h @@ -1033,6 +1033,8 @@ int lttng_kprobes_register_event(const char *name, struct lttng_kernel_event_common *event); void lttng_kprobes_unregister_event(struct lttng_kernel_event_common *event); void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_common *event); +int lttng_kprobes_match_check(const char *symbol_name, uint64_t offset, uint64_t addr); + #else static inline int lttng_kprobes_register_event(const char *name, @@ -1053,6 +1055,11 @@ static inline void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_common *event) { } +static inline +int lttng_kprobes_match_check(const char *symbol_name, uint64_t offset, uint64_t addr) +{ + return -ENOENT; +} #endif int lttng_event_add_callsite(struct lttng_kernel_event_common *event, diff --git a/src/lttng-kprobes.c b/src/lttng-kprobes.c index 11d1d35c..b2e96635 100644 --- a/src/lttng-kprobes.c +++ b/src/lttng-kprobes.c @@ -227,6 +227,21 @@ void lttng_kprobes_unregister_event(struct lttng_kernel_event_common *event) unregister_kprobe(&event->priv->u.kprobe.kp); } +int lttng_kprobes_match_check(const char *symbol_name, uint64_t offset, uint64_t addr) +{ + struct lttng_kprobe lttng_kp; + int ret; + + memset(<tng_kp, 0, sizeof(lttng_kp)); + ret = _lttng_kprobes_register(symbol_name, offset, addr, <tng_kp, NULL); + if (ret) + return -ENOENT; + unregister_kprobe(<tng_kp.kp); + kfree(lttng_kp.symbol_name); + return 0; + +} + void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_common *event) { kfree(event->priv->u.kprobe.symbol_name); -- 2.34.1