From 6494fc020f48e32ac21e62c25602053a1887a48b Mon Sep 17 00:00:00 2001 From: Honggyu Kim Date: Sun, 24 Jan 2021 23:50:29 +0000 Subject: [PATCH] script: Make native script disable uftrace record This patch makes the given script to disable the actual uftrace record to shared memory. It allows the script control the behavior of uftrace. Signed-off-by: Honggyu Kim --- libmcount/mcount.c | 5 ++++- scripts/info.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libmcount/mcount.c b/libmcount/mcount.c index a659abc60..6cfcba57f 100644 --- a/libmcount/mcount.c +++ b/libmcount/mcount.c @@ -1135,7 +1135,7 @@ void mcount_exit_filter_record(struct mcount_thread_data *mtdp, struct mcount_re mtdp->record_idx--; if (!mcount_enabled) - return; + goto out; if (!(rstack->flags & MCOUNT_FL_RETVAL)) retval = NULL; @@ -1179,6 +1179,7 @@ void mcount_exit_filter_record(struct mcount_thread_data *mtdp, struct mcount_re mtdp->nr_events = k; /* invalidate sync events */ } +out: /* script hooking for function exit */ if (script_str) script_hook_exit(mtdp, rstack); @@ -1755,6 +1756,8 @@ static void mcount_script_init(enum uftrace_pattern_type patt_type) if (script_init(&info, patt_type) < 0) script_str = NULL; + else if (!info.record) + mcount_enabled = false; } static int agent_init(struct sockaddr_un *addr) diff --git a/scripts/info.c b/scripts/info.c index e8d508623..10440f7f5 100644 --- a/scripts/info.c +++ b/scripts/info.c @@ -9,6 +9,9 @@ void uftrace_begin(struct uftrace_script_info *sc_info) printf("%s\n", sc_info->version); printf("%s\n", sc_info->name); printf("%s\n", sc_info->cmds); + + /* disable actual data record by uftrace */ + sc_info->record = false; } void uftrace_entry(struct uftrace_script_base_ctx *sc_ctx)