Skip to content

Commit

Permalink
script: Make native script disable uftrace record
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
honggyukim committed Feb 20, 2023
1 parent 58bcbca commit 6494fc0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libmcount/mcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions scripts/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6494fc0

Please sign in to comment.