On Mon, Aug 21, 2023 at 02:24:06PM +0200, Francis Laniel wrote:
Hi.
Le dimanche 20 août 2023, 22:34:40 CEST Jiri Olsa a écrit :
quoted
On Sat, Aug 19, 2023 at 10:11:05AM +0900, Masami Hiramatsu wrote:
SNIP
quoted
quoted
quoted
quoted
quoted
quoted
+ func_addr = kallsyms_lookup_name(func);
+ for (i = 0; i < array.size; i++) {
+ struct trace_kprobe *tk_same_name;
+ unsigned long address;
+
+ address = array.addrs[i];
+ /* Skip the function address as we already
registered it. */
quoted
quoted
quoted
quoted
quoted
quoted
quoted
+ if (address == func_addr)
+ continue;
+
+ /*
+ * alloc_trace_kprobe() first considers symbol name,
so we
quoted
quoted
quoted
quoted
quoted
quoted
quoted
set
+ * this to NULL to allocate this kprobe on the given
address.
quoted
quoted
quoted
quoted
quoted
quoted
quoted
+ */
+ tk_same_name =
alloc_trace_kprobe(KPROBE_EVENT_SYSTEM, event,
quoted
quoted
quoted
quoted
quoted
quoted
quoted
+ (void *)address, NULL,
offs,
quoted
quoted
quoted
quoted
quoted
quoted
quoted
+ 0 /* maxactive */,
+ 0 /* nargs */,
is_return);
quoted
quoted
quoted
quoted
quoted
quoted
quoted
+
+ if (IS_ERR(tk_same_name)) {
+ ret = -ENOMEM;
+ goto error_free;
+ }
+
+ init_trace_event_call(tk_same_name);
+
+ if (traceprobe_set_print_fmt(&tk_same_name->tp,
ptype) < 0) {quoted
quoted
quoted
quoted
quoted
quoted
quoted
+ ret = -ENOMEM;
also are we leaking tk_same_name in here?
quoted
quoted
quoted
quoted
quoted
quoted
+ goto error_free;
+ }
+
+ ret = append_trace_kprobe(tk_same_name, tk);
+ if (ret)
and here?
Good catch!
Do you know if the appended probes are automatically freed? If so, can you
please indicate which function handles this?
hum, I don't see the release code going through the list of appended probes,
so I wonder you need to somehow do that in destroy_local_trace_kprobe
jirka