Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils: enable @k as an abbreviated form of @kernel #631

Merged
merged 1 commit into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libmcount/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int mcount_setup_events(char *dirname, char *event_str,
if (sep) {
*sep++ = '\0';

kernel = strstr(sep, "@kernel");
kernel = has_kernel_filter(sep);
if (kernel)
continue;

Expand Down
8 changes: 4 additions & 4 deletions utils/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ static void setup_trigger(char *filter_str, struct symtabs *symtabs,
goto next;

/* skip unintended kernel symbols */
if (module && !strcasecmp(module, "kernel") &&
if (module && has_kernel_opt(module) &&
!setting->allow_kernel)
goto next;

Expand Down Expand Up @@ -997,7 +997,7 @@ static void setup_trigger(char *filter_str, struct symtabs *symtabs,
&symtabs->dinfo,
setting);
}
else if (!strcasecmp(module, "kernel")) {
else if (has_kernel_opt(module)) {
ret = add_trigger_entry(root, get_kernel_symtab(),
&patt, &tr,
&symtabs->dinfo,
Expand Down Expand Up @@ -1195,13 +1195,13 @@ char * uftrace_clear_kernel(char *filter_str)
if (filter_str == NULL)
return NULL;

if (strstr(filter_str, "@kernel") == NULL)
if (has_kernel_filter(filter_str) == NULL)
return xstrdup(filter_str);

strv_split(&filters, filter_str, ";");

strv_for_each(&filters, pos, j) {
if (strstr(pos, "@kernel") == NULL)
if (has_kernel_filter(pos) == NULL)
ret = strjoin(ret, pos, ";");
}
strv_free(&filters);
Expand Down
4 changes: 2 additions & 2 deletions utils/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ static void build_kernel_filter(struct uftrace_kernel_writer *kernel,
strv_for_each(&strv, name, j) {
struct uftrace_pattern patt;

pos = strstr(name, "@kernel");
pos = has_kernel_filter(name);
if (pos == NULL)
continue;
*pos = '\0';
Expand Down Expand Up @@ -430,7 +430,7 @@ static void build_kernel_event(struct uftrace_kernel_writer *kernel,
strv_for_each(&strv, name, j) {
struct uftrace_pattern patt;

pos = strstr(name, "@kernel");
pos = has_kernel_filter(name);
if (pos == NULL)
continue;
*pos = '\0';
Expand Down
3 changes: 2 additions & 1 deletion utils/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define UFTRACE_KERNEL_H

#include "libtraceevent/event-parse.h"
#include "utils/utils.h"

#define KERNEL_NOP_TRACER "nop"
#define KERNEL_GRAPH_TRACER "function_graph"
Expand Down Expand Up @@ -76,7 +77,7 @@ static inline bool has_kernel_data(struct uftrace_kernel_reader *kernel)

static inline bool has_kernel_event(char *events)
{
return events && strstr(events, "@kernel");
return events && has_kernel_filter(events);
}

bool check_kernel_pid_filter(void);
Expand Down
25 changes: 25 additions & 0 deletions utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,31 @@ static inline bool host_is_lp64(void)
return get_elf_class() == ELFCLASS64;
}

static inline char* has_kernel_opt(char *buf)
{
int idx = 0;

if (!strncasecmp(buf, "kernel", 6))
idx = 6;
else if (!strncasecmp(buf, "k", 1))
idx = 1;

if (idx && (buf[idx] == '\0' || buf[idx] == ','))
return buf;

return NULL;
}

static inline char* has_kernel_filter(char *buf)
{
char *opt = strchr(buf, '@');

if (opt && has_kernel_opt(opt + 1))
return opt;

return NULL;
}

struct uftrace_time_range {
uint64_t first;
uint64_t start;
Expand Down