aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2021-06-27 16:18:12 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2021-07-01 16:14:37 -0300
commit3d032a251605740b75decd3381dc9d496a245ca0 (patch)
tree918201b7c7b8adc4ce17e53f923685eafbd85fc4 /tools/perf/util
parentperf script: Add option to list dlfilters (diff)
downloadlinux-dev-3d032a251605740b75decd3381dc9d496a245ca0.tar.xz
linux-dev-3d032a251605740b75decd3381dc9d496a245ca0.zip
perf script: Add option to pass arguments to dlfilters
Add option --dlarg to pass arguments to dlfilters. The --dlarg option can be repeated to pass more than 1 argument. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20210627131818.810-5-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/dlfilter.c45
-rw-r--r--tools/perf/util/dlfilter.h6
-rw-r--r--tools/perf/util/perf_dlfilter.h4
3 files changed, 46 insertions, 9 deletions
diff --git a/tools/perf/util/dlfilter.c b/tools/perf/util/dlfilter.c
index 288a2b57378c..eaa3cea49178 100644
--- a/tools/perf/util/dlfilter.c
+++ b/tools/perf/util/dlfilter.c
@@ -133,9 +133,26 @@ static const struct perf_dlfilter_al *dlfilter__resolve_addr(void *ctx)
return d_addr_al;
}
+static char **dlfilter__args(void *ctx, int *dlargc)
+{
+ struct dlfilter *d = (struct dlfilter *)ctx;
+
+ if (dlargc)
+ *dlargc = 0;
+ else
+ return NULL;
+
+ if (!d->ctx_valid && !d->in_start && !d->in_stop)
+ return NULL;
+
+ *dlargc = d->dlargc;
+ return d->dlargv;
+}
+
static const struct perf_dlfilter_fns perf_dlfilter_fns = {
.resolve_ip = dlfilter__resolve_ip,
.resolve_addr = dlfilter__resolve_addr,
+ .args = dlfilter__args,
};
static char *find_dlfilter(const char *file)
@@ -169,7 +186,7 @@ out:
#define CHECK_FLAG(x) BUILD_BUG_ON((u64)PERF_DLFILTER_FLAG_ ## x != (u64)PERF_IP_FLAG_ ## x)
-static int dlfilter__init(struct dlfilter *d, const char *file)
+static int dlfilter__init(struct dlfilter *d, const char *file, int dlargc, char **dlargv)
{
CHECK_FLAG(BRANCH);
CHECK_FLAG(CALL);
@@ -189,6 +206,8 @@ static int dlfilter__init(struct dlfilter *d, const char *file)
d->file = find_dlfilter(file);
if (!d->file)
return -1;
+ d->dlargc = dlargc;
+ d->dlargv = dlargv;
return 0;
}
@@ -219,14 +238,14 @@ static int dlfilter__close(struct dlfilter *d)
return dlclose(d->handle);
}
-struct dlfilter *dlfilter__new(const char *file)
+struct dlfilter *dlfilter__new(const char *file, int dlargc, char **dlargv)
{
struct dlfilter *d = malloc(sizeof(*d));
if (!d)
return NULL;
- if (dlfilter__init(d, file))
+ if (dlfilter__init(d, file, dlargc, dlargv))
goto err_free;
if (dlfilter__open(d))
@@ -253,16 +272,28 @@ int dlfilter__start(struct dlfilter *d, struct perf_session *session)
{
if (d) {
d->session = session;
- if (d->start)
- return d->start(&d->data, d);
+ if (d->start) {
+ int ret;
+
+ d->in_start = true;
+ ret = d->start(&d->data, d);
+ d->in_start = false;
+ return ret;
+ }
}
return 0;
}
static int dlfilter__stop(struct dlfilter *d)
{
- if (d && d->stop)
- return d->stop(d->data, d);
+ if (d && d->stop) {
+ int ret;
+
+ d->in_stop = true;
+ ret = d->stop(d->data, d);
+ d->in_stop = false;
+ return ret;
+ }
return 0;
}
diff --git a/tools/perf/util/dlfilter.h b/tools/perf/util/dlfilter.h
index a1ed38da3ce6..505980442360 100644
--- a/tools/perf/util/dlfilter.h
+++ b/tools/perf/util/dlfilter.h
@@ -23,6 +23,10 @@ struct dlfilter {
void *data;
struct perf_session *session;
bool ctx_valid;
+ bool in_start;
+ bool in_stop;
+ int dlargc;
+ char **dlargv;
union perf_event *event;
struct perf_sample *sample;
@@ -47,7 +51,7 @@ struct dlfilter {
struct perf_dlfilter_fns *fns;
};
-struct dlfilter *dlfilter__new(const char *file);
+struct dlfilter *dlfilter__new(const char *file, int dlargc, char **dlargv);
int dlfilter__start(struct dlfilter *d, struct perf_session *session);
diff --git a/tools/perf/util/perf_dlfilter.h b/tools/perf/util/perf_dlfilter.h
index 31ad4c100181..35e03aa41a7f 100644
--- a/tools/perf/util/perf_dlfilter.h
+++ b/tools/perf/util/perf_dlfilter.h
@@ -90,8 +90,10 @@ struct perf_dlfilter_fns {
const struct perf_dlfilter_al *(*resolve_ip)(void *ctx);
/* Return information about addr (if addr_correlates_sym) */
const struct perf_dlfilter_al *(*resolve_addr)(void *ctx);
+ /* Return arguments from --dlarg option */
+ char **(*args)(void *ctx, int *dlargc);
/* Reserved */
- void *(*reserved[126])(void *);
+ void *(*reserved[125])(void *);
};
/*