From d0f6d49a8d73a85cf87251658f97abf104a36d77 Mon Sep 17 00:00:00 2001 From: Vijayanand Jitta Date: Sun, 13 Sep 2020 23:28:11 +0530 Subject: [PATCH] tracing: Add CONFIG_KPROBES_DEBUG config Add CONFIG_KPROBES_DEBUG which exports the required function and structures used by the kprobe module to search for a synthetic event and aid in debugging. Change-Id: Iea395b012d3ad8b40ace1f6e19dc9bf74c5fb5c8 Signed-off-by: Vijayanand Jitta --- include/linux/trace_events.h | 38 ++++++++++++++++++++++++++++++++ kernel/trace/Kconfig | 12 ++++++++++ kernel/trace/trace_dynevent.h | 5 +++++ kernel/trace/trace_events_hist.c | 9 ++++++++ 4 files changed, 64 insertions(+) diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index 72ae37a5b9e4..cb7db7b9480f 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -442,6 +442,44 @@ enum event_trigger_type { ETT_HIST_ENABLE = (1 << 5), }; +#ifdef CONFIG_KPROBES_DEBUG +struct dyn_event_operations; + +/** + * struct dyn_event - Dynamic event list header + * + * The dyn_event structure encapsulates a list and a pointer to the operators + * for making a global list of dynamic events. + * User must includes this in each event structure, so that those events can + * be added/removed via dynamic_events interface. + */ +struct dyn_event { + struct list_head list; + struct dyn_event_operations *ops; +}; + +struct synth_field { + char *type; + char *name; + size_t size; + bool is_signed; + bool is_string; +}; + +struct synth_event { + struct dyn_event devent; + int ref; + char *name; + struct synth_field **fields; + unsigned int n_fields; + unsigned int n_u64; + struct trace_event_class class; + struct trace_event_call call; + struct tracepoint *tp; +}; +extern struct synth_event *find_synth_event(const char *name); +#endif + extern int filter_match_preds(struct event_filter *filter, void *rec); extern enum event_trigger_type diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index b075c9cf7c7d..70b5d6beeaf2 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -533,6 +533,18 @@ config KPROBE_EVENTS_ON_NOTRACE If unsure, say N. +config KPROBES_DEBUG + bool "support bug on kprobe events" + depends on KPROBE_EVENTS + select HIST_TRIGGERS + default n + help + This exports the required function and structures to + allow the kprobe module to search for and use synthetic + events which will aid in debugging. + + If unsure, say N. + config UPROBE_EVENTS bool "Enable uprobes-based dynamic events" depends on ARCH_SUPPORTS_UPROBES diff --git a/kernel/trace/trace_dynevent.h b/kernel/trace/trace_dynevent.h index 46898138d2df..83202403041f 100644 --- a/kernel/trace/trace_dynevent.h +++ b/kernel/trace/trace_dynevent.h @@ -10,6 +10,9 @@ #include #include #include +#ifdef CONFIG_KPROBES_DEBUG +#include +#endif #include "trace.h" @@ -50,6 +53,7 @@ struct dyn_event_operations { /* Register new dyn_event type -- must be called at first */ int dyn_event_register(struct dyn_event_operations *ops); +#ifndef CONFIG_KPROBES_DEBUG /** * struct dyn_event - Dynamic event list header * @@ -62,6 +66,7 @@ struct dyn_event { struct list_head list; struct dyn_event_operations *ops; }; +#endif extern struct list_head dyn_event_list; diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 2cfe62531993..b84724e73795 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -390,6 +390,7 @@ static struct dyn_event_operations synth_event_ops = { .match = synth_event_match, }; +#ifndef CONFIG_KPROBES_DEBUG struct synth_field { char *type; char *name; @@ -409,6 +410,7 @@ struct synth_event { struct trace_event_call call; struct tracepoint *tp; }; +#endif static bool is_synth_event(struct dyn_event *ev) { @@ -1170,7 +1172,11 @@ static inline void trace_synth(struct synth_event *event, u64 *var_ref_vals, } } +#ifdef CONFIG_KPROBES_DEBUG +struct synth_event *find_synth_event(const char *name) +#else static struct synth_event *find_synth_event(const char *name) +#endif { struct dyn_event *pos; struct synth_event *event; @@ -1185,6 +1191,9 @@ static struct synth_event *find_synth_event(const char *name) return NULL; } +#ifdef CONFIG_KPROBES_DEBUG +EXPORT_SYMBOL(find_synth_event); +#endif static int register_synth_event(struct synth_event *event) {