diff --git a/libmcount/mcount.c b/libmcount/mcount.c index 19ed78fa2..9e014683e 100644 --- a/libmcount/mcount.c +++ b/libmcount/mcount.c @@ -74,6 +74,9 @@ static int __maybe_unused mcount_depth = MCOUNT_DEFAULT_DEPTH; /* boolean flag to turn on/off recording */ static bool __maybe_unused mcount_enabled = true; +/* boolean flag to turn on/off recording, but keep script working */ +bool __maybe_unused record_enabled = true; + /* function filtering mode - inclusive or exclusive */ static enum filter_mode __maybe_unused mcount_filter_mode = FILTER_MODE_NONE; @@ -1641,6 +1644,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) + record_enabled = false; } static __used void mcount_startup(void) diff --git a/libmcount/record.c b/libmcount/record.c index 53bed89b9..7715ccd54 100644 --- a/libmcount/record.c +++ b/libmcount/record.c @@ -24,6 +24,8 @@ #define ARG_STR_MAX 98 +extern bool __maybe_unused record_enabled; + static struct mcount_shmem_buffer *allocate_shmem_buffer(char *sess_id, size_t size, int tid, int idx) { @@ -1016,6 +1018,9 @@ int record_trace_data(struct mcount_thread_data *mtdp, #define SKIP_FLAGS (MCOUNT_FL_NORECORD | MCOUNT_FL_DISABLED) + if (unlikely(!record_enabled)) + return 0; + if (mrstack < mtdp->rstack) return 0; diff --git a/scripts/info.c b/scripts/info.c index c87313179..31ae94679 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_context *sc_ctx)