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 Oct 3, 2020
1 parent ab13871 commit cb05efc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libmcount/mcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions libmcount/record.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

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 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 script_context *sc_ctx)
Expand Down

0 comments on commit cb05efc

Please sign in to comment.