Commit 0e60836b authored by Srikar Dronamraju's avatar Srikar Dronamraju Committed by Arnaldo Carvalho de Melo

perf probe: Rename common fields/functions from kprobe to probe.

As a precursor for perf to support uprobes, rename fields/functions
that had kprobe in their name but can be shared across perf-kprobes
and perf-uprobes to probe.

Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: "Frank Ch. Eigler" <fche@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jim Keniston <jkenisto@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Wielaard <mjw@redhat.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Naren A Devaiah <naren.devaiah@in.ibm.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Randy Dunlap <rdunlap@xenotime.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <20100729141351.GG21723@linux.vnet.ibm.com>
Signed-off-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 73ae8f85
...@@ -267,4 +267,3 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) ...@@ -267,4 +267,3 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
} }
return 0; return 0;
} }
/* /*
* probe-event.c : perf-probe definition to kprobe_events format converter * probe-event.c : perf-probe definition to probe_events format converter
* *
* Written by Masami Hiramatsu <mhiramat@redhat.com> * Written by Masami Hiramatsu <mhiramat@redhat.com>
* *
...@@ -120,8 +120,11 @@ static int open_vmlinux(void) ...@@ -120,8 +120,11 @@ static int open_vmlinux(void)
return open(machine.vmlinux_maps[MAP__FUNCTION]->dso->long_name, O_RDONLY); return open(machine.vmlinux_maps[MAP__FUNCTION]->dso->long_name, O_RDONLY);
} }
/* Convert trace point to probe point with debuginfo */ /*
static int convert_to_perf_probe_point(struct kprobe_trace_point *tp, * Convert trace point to probe point with debuginfo
* Currently only handles kprobes.
*/
static int kprobe_convert_to_perf_probe(struct probe_trace_point *tp,
struct perf_probe_point *pp) struct perf_probe_point *pp)
{ {
struct symbol *sym; struct symbol *sym;
...@@ -151,8 +154,8 @@ static int convert_to_perf_probe_point(struct kprobe_trace_point *tp, ...@@ -151,8 +154,8 @@ static int convert_to_perf_probe_point(struct kprobe_trace_point *tp,
} }
/* Try to find perf_probe_event with debuginfo */ /* Try to find perf_probe_event with debuginfo */
static int try_to_find_kprobe_trace_events(struct perf_probe_event *pev, static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
struct kprobe_trace_event **tevs, struct probe_trace_event **tevs,
int max_tevs) int max_tevs)
{ {
bool need_dwarf = perf_probe_event_need_dwarf(pev); bool need_dwarf = perf_probe_event_need_dwarf(pev);
...@@ -169,11 +172,11 @@ static int try_to_find_kprobe_trace_events(struct perf_probe_event *pev, ...@@ -169,11 +172,11 @@ static int try_to_find_kprobe_trace_events(struct perf_probe_event *pev,
} }
/* Searching trace events corresponding to probe event */ /* Searching trace events corresponding to probe event */
ntevs = find_kprobe_trace_events(fd, pev, tevs, max_tevs); ntevs = find_probe_trace_events(fd, pev, tevs, max_tevs);
close(fd); close(fd);
if (ntevs > 0) { /* Succeeded to find trace events */ if (ntevs > 0) { /* Succeeded to find trace events */
pr_debug("find %d kprobe_trace_events.\n", ntevs); pr_debug("find %d probe_trace_events.\n", ntevs);
return ntevs; return ntevs;
} }
...@@ -377,8 +380,8 @@ int show_line_range(struct line_range *lr) ...@@ -377,8 +380,8 @@ int show_line_range(struct line_range *lr)
#else /* !DWARF_SUPPORT */ #else /* !DWARF_SUPPORT */
static int convert_to_perf_probe_point(struct kprobe_trace_point *tp, static int kprobe_convert_to_perf_probe(struct probe_trace_point *tp,
struct perf_probe_point *pp) struct perf_probe_point *pp)
{ {
pp->function = strdup(tp->symbol); pp->function = strdup(tp->symbol);
if (pp->function == NULL) if (pp->function == NULL)
...@@ -389,8 +392,8 @@ static int convert_to_perf_probe_point(struct kprobe_trace_point *tp, ...@@ -389,8 +392,8 @@ static int convert_to_perf_probe_point(struct kprobe_trace_point *tp,
return 0; return 0;
} }
static int try_to_find_kprobe_trace_events(struct perf_probe_event *pev, static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
struct kprobe_trace_event **tevs __unused, struct probe_trace_event **tevs __unused,
int max_tevs __unused) int max_tevs __unused)
{ {
if (perf_probe_event_need_dwarf(pev)) { if (perf_probe_event_need_dwarf(pev)) {
...@@ -781,16 +784,17 @@ bool perf_probe_event_need_dwarf(struct perf_probe_event *pev) ...@@ -781,16 +784,17 @@ bool perf_probe_event_need_dwarf(struct perf_probe_event *pev)
return false; return false;
} }
/* Parse kprobe_events event into struct probe_point */ /* Parse probe_events event into struct probe_point */
int parse_kprobe_trace_command(const char *cmd, struct kprobe_trace_event *tev) static int parse_probe_trace_command(const char *cmd,
struct probe_trace_event *tev)
{ {
struct kprobe_trace_point *tp = &tev->point; struct probe_trace_point *tp = &tev->point;
char pr; char pr;
char *p; char *p;
int ret, i, argc; int ret, i, argc;
char **argv; char **argv;
pr_debug("Parsing kprobe_events: %s\n", cmd); pr_debug("Parsing probe_events: %s\n", cmd);
argv = argv_split(cmd, &argc); argv = argv_split(cmd, &argc);
if (!argv) { if (!argv) {
pr_debug("Failed to split arguments.\n"); pr_debug("Failed to split arguments.\n");
...@@ -822,7 +826,7 @@ int parse_kprobe_trace_command(const char *cmd, struct kprobe_trace_event *tev) ...@@ -822,7 +826,7 @@ int parse_kprobe_trace_command(const char *cmd, struct kprobe_trace_event *tev)
tp->offset = 0; tp->offset = 0;
tev->nargs = argc - 2; tev->nargs = argc - 2;
tev->args = zalloc(sizeof(struct kprobe_trace_arg) * tev->nargs); tev->args = zalloc(sizeof(struct probe_trace_arg) * tev->nargs);
if (tev->args == NULL) { if (tev->args == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
...@@ -968,13 +972,13 @@ char *synthesize_perf_probe_command(struct perf_probe_event *pev) ...@@ -968,13 +972,13 @@ char *synthesize_perf_probe_command(struct perf_probe_event *pev)
} }
#endif #endif
static int __synthesize_kprobe_trace_arg_ref(struct kprobe_trace_arg_ref *ref, static int __synthesize_probe_trace_arg_ref(struct probe_trace_arg_ref *ref,
char **buf, size_t *buflen, char **buf, size_t *buflen,
int depth) int depth)
{ {
int ret; int ret;
if (ref->next) { if (ref->next) {
depth = __synthesize_kprobe_trace_arg_ref(ref->next, buf, depth = __synthesize_probe_trace_arg_ref(ref->next, buf,
buflen, depth + 1); buflen, depth + 1);
if (depth < 0) if (depth < 0)
goto out; goto out;
...@@ -992,10 +996,10 @@ static int __synthesize_kprobe_trace_arg_ref(struct kprobe_trace_arg_ref *ref, ...@@ -992,10 +996,10 @@ static int __synthesize_kprobe_trace_arg_ref(struct kprobe_trace_arg_ref *ref,
} }
static int synthesize_kprobe_trace_arg(struct kprobe_trace_arg *arg, static int synthesize_probe_trace_arg(struct probe_trace_arg *arg,
char *buf, size_t buflen) char *buf, size_t buflen)
{ {
struct kprobe_trace_arg_ref *ref = arg->ref; struct probe_trace_arg_ref *ref = arg->ref;
int ret, depth = 0; int ret, depth = 0;
char *tmp = buf; char *tmp = buf;
...@@ -1015,7 +1019,7 @@ static int synthesize_kprobe_trace_arg(struct kprobe_trace_arg *arg, ...@@ -1015,7 +1019,7 @@ static int synthesize_kprobe_trace_arg(struct kprobe_trace_arg *arg,
/* Dereferencing arguments */ /* Dereferencing arguments */
if (ref) { if (ref) {
depth = __synthesize_kprobe_trace_arg_ref(ref, &buf, depth = __synthesize_probe_trace_arg_ref(ref, &buf,
&buflen, 1); &buflen, 1);
if (depth < 0) if (depth < 0)
return depth; return depth;
...@@ -1051,9 +1055,9 @@ static int synthesize_kprobe_trace_arg(struct kprobe_trace_arg *arg, ...@@ -1051,9 +1055,9 @@ static int synthesize_kprobe_trace_arg(struct kprobe_trace_arg *arg,
return buf - tmp; return buf - tmp;
} }
char *synthesize_kprobe_trace_command(struct kprobe_trace_event *tev) char *synthesize_probe_trace_command(struct probe_trace_event *tev)
{ {
struct kprobe_trace_point *tp = &tev->point; struct probe_trace_point *tp = &tev->point;
char *buf; char *buf;
int i, len, ret; int i, len, ret;
...@@ -1069,7 +1073,7 @@ char *synthesize_kprobe_trace_command(struct kprobe_trace_event *tev) ...@@ -1069,7 +1073,7 @@ char *synthesize_kprobe_trace_command(struct kprobe_trace_event *tev)
goto error; goto error;
for (i = 0; i < tev->nargs; i++) { for (i = 0; i < tev->nargs; i++) {
ret = synthesize_kprobe_trace_arg(&tev->args[i], buf + len, ret = synthesize_probe_trace_arg(&tev->args[i], buf + len,
MAX_CMDLEN - len); MAX_CMDLEN - len);
if (ret <= 0) if (ret <= 0)
goto error; goto error;
...@@ -1082,7 +1086,7 @@ char *synthesize_kprobe_trace_command(struct kprobe_trace_event *tev) ...@@ -1082,7 +1086,7 @@ char *synthesize_kprobe_trace_command(struct kprobe_trace_event *tev)
return NULL; return NULL;
} }
int convert_to_perf_probe_event(struct kprobe_trace_event *tev, static int convert_to_perf_probe_event(struct probe_trace_event *tev,
struct perf_probe_event *pev) struct perf_probe_event *pev)
{ {
char buf[64] = ""; char buf[64] = "";
...@@ -1095,7 +1099,7 @@ int convert_to_perf_probe_event(struct kprobe_trace_event *tev, ...@@ -1095,7 +1099,7 @@ int convert_to_perf_probe_event(struct kprobe_trace_event *tev,
return -ENOMEM; return -ENOMEM;
/* Convert trace_point to probe_point */ /* Convert trace_point to probe_point */
ret = convert_to_perf_probe_point(&tev->point, &pev->point); ret = kprobe_convert_to_perf_probe(&tev->point, &pev->point);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1108,7 +1112,7 @@ int convert_to_perf_probe_event(struct kprobe_trace_event *tev, ...@@ -1108,7 +1112,7 @@ int convert_to_perf_probe_event(struct kprobe_trace_event *tev,
if (tev->args[i].name) if (tev->args[i].name)
pev->args[i].name = strdup(tev->args[i].name); pev->args[i].name = strdup(tev->args[i].name);
else { else {
ret = synthesize_kprobe_trace_arg(&tev->args[i], ret = synthesize_probe_trace_arg(&tev->args[i],
buf, 64); buf, 64);
pev->args[i].name = strdup(buf); pev->args[i].name = strdup(buf);
} }
...@@ -1159,9 +1163,9 @@ void clear_perf_probe_event(struct perf_probe_event *pev) ...@@ -1159,9 +1163,9 @@ void clear_perf_probe_event(struct perf_probe_event *pev)
memset(pev, 0, sizeof(*pev)); memset(pev, 0, sizeof(*pev));
} }
void clear_kprobe_trace_event(struct kprobe_trace_event *tev) static void clear_probe_trace_event(struct probe_trace_event *tev)
{ {
struct kprobe_trace_arg_ref *ref, *next; struct probe_trace_arg_ref *ref, *next;
int i; int i;
if (tev->event) if (tev->event)
...@@ -1222,7 +1226,7 @@ static int open_kprobe_events(bool readwrite) ...@@ -1222,7 +1226,7 @@ static int open_kprobe_events(bool readwrite)
} }
/* Get raw string list of current kprobe_events */ /* Get raw string list of current kprobe_events */
static struct strlist *get_kprobe_trace_command_rawlist(int fd) static struct strlist *get_probe_trace_command_rawlist(int fd)
{ {
int ret, idx; int ret, idx;
FILE *fp; FILE *fp;
...@@ -1290,7 +1294,7 @@ static int show_perf_probe_event(struct perf_probe_event *pev) ...@@ -1290,7 +1294,7 @@ static int show_perf_probe_event(struct perf_probe_event *pev)
int show_perf_probe_events(void) int show_perf_probe_events(void)
{ {
int fd, ret; int fd, ret;
struct kprobe_trace_event tev; struct probe_trace_event tev;
struct perf_probe_event pev; struct perf_probe_event pev;
struct strlist *rawlist; struct strlist *rawlist;
struct str_node *ent; struct str_node *ent;
...@@ -1307,20 +1311,20 @@ int show_perf_probe_events(void) ...@@ -1307,20 +1311,20 @@ int show_perf_probe_events(void)
if (fd < 0) if (fd < 0)
return fd; return fd;
rawlist = get_kprobe_trace_command_rawlist(fd); rawlist = get_probe_trace_command_rawlist(fd);
close(fd); close(fd);
if (!rawlist) if (!rawlist)
return -ENOENT; return -ENOENT;
strlist__for_each(ent, rawlist) { strlist__for_each(ent, rawlist) {
ret = parse_kprobe_trace_command(ent->s, &tev); ret = parse_probe_trace_command(ent->s, &tev);
if (ret >= 0) { if (ret >= 0) {
ret = convert_to_perf_probe_event(&tev, &pev); ret = convert_to_perf_probe_event(&tev, &pev);
if (ret >= 0) if (ret >= 0)
ret = show_perf_probe_event(&pev); ret = show_perf_probe_event(&pev);
} }
clear_perf_probe_event(&pev); clear_perf_probe_event(&pev);
clear_kprobe_trace_event(&tev); clear_probe_trace_event(&tev);
if (ret < 0) if (ret < 0)
break; break;
} }
...@@ -1330,20 +1334,19 @@ int show_perf_probe_events(void) ...@@ -1330,20 +1334,19 @@ int show_perf_probe_events(void)
} }
/* Get current perf-probe event names */ /* Get current perf-probe event names */
static struct strlist *get_kprobe_trace_event_names(int fd, bool include_group) static struct strlist *get_probe_trace_event_names(int fd, bool include_group)
{ {
char buf[128]; char buf[128];
struct strlist *sl, *rawlist; struct strlist *sl, *rawlist;
struct str_node *ent; struct str_node *ent;
struct kprobe_trace_event tev; struct probe_trace_event tev;
int ret = 0; int ret = 0;
memset(&tev, 0, sizeof(tev)); memset(&tev, 0, sizeof(tev));
rawlist = get_probe_trace_command_rawlist(fd);
rawlist = get_kprobe_trace_command_rawlist(fd);
sl = strlist__new(true, NULL); sl = strlist__new(true, NULL);
strlist__for_each(ent, rawlist) { strlist__for_each(ent, rawlist) {
ret = parse_kprobe_trace_command(ent->s, &tev); ret = parse_probe_trace_command(ent->s, &tev);
if (ret < 0) if (ret < 0)
break; break;
if (include_group) { if (include_group) {
...@@ -1353,7 +1356,7 @@ static struct strlist *get_kprobe_trace_event_names(int fd, bool include_group) ...@@ -1353,7 +1356,7 @@ static struct strlist *get_kprobe_trace_event_names(int fd, bool include_group)
ret = strlist__add(sl, buf); ret = strlist__add(sl, buf);
} else } else
ret = strlist__add(sl, tev.event); ret = strlist__add(sl, tev.event);
clear_kprobe_trace_event(&tev); clear_probe_trace_event(&tev);
if (ret < 0) if (ret < 0)
break; break;
} }
...@@ -1366,13 +1369,13 @@ static struct strlist *get_kprobe_trace_event_names(int fd, bool include_group) ...@@ -1366,13 +1369,13 @@ static struct strlist *get_kprobe_trace_event_names(int fd, bool include_group)
return sl; return sl;
} }
static int write_kprobe_trace_event(int fd, struct kprobe_trace_event *tev) static int write_probe_trace_event(int fd, struct probe_trace_event *tev)
{ {
int ret = 0; int ret = 0;
char *buf = synthesize_kprobe_trace_command(tev); char *buf = synthesize_probe_trace_command(tev);
if (!buf) { if (!buf) {
pr_debug("Failed to synthesize kprobe trace event.\n"); pr_debug("Failed to synthesize probe trace event.\n");
return -EINVAL; return -EINVAL;
} }
...@@ -1425,12 +1428,12 @@ static int get_new_event_name(char *buf, size_t len, const char *base, ...@@ -1425,12 +1428,12 @@ static int get_new_event_name(char *buf, size_t len, const char *base,
return ret; return ret;
} }
static int __add_kprobe_trace_events(struct perf_probe_event *pev, static int __add_probe_trace_events(struct perf_probe_event *pev,
struct kprobe_trace_event *tevs, struct probe_trace_event *tevs,
int ntevs, bool allow_suffix) int ntevs, bool allow_suffix)
{ {
int i, fd, ret; int i, fd, ret;
struct kprobe_trace_event *tev = NULL; struct probe_trace_event *tev = NULL;
char buf[64]; char buf[64];
const char *event, *group; const char *event, *group;
struct strlist *namelist; struct strlist *namelist;
...@@ -1439,7 +1442,7 @@ static int __add_kprobe_trace_events(struct perf_probe_event *pev, ...@@ -1439,7 +1442,7 @@ static int __add_kprobe_trace_events(struct perf_probe_event *pev,
if (fd < 0) if (fd < 0)
return fd; return fd;
/* Get current event names */ /* Get current event names */
namelist = get_kprobe_trace_event_names(fd, false); namelist = get_probe_trace_event_names(fd, false);
if (!namelist) { if (!namelist) {
pr_debug("Failed to get current event list.\n"); pr_debug("Failed to get current event list.\n");
return -EIO; return -EIO;
...@@ -1474,7 +1477,7 @@ static int __add_kprobe_trace_events(struct perf_probe_event *pev, ...@@ -1474,7 +1477,7 @@ static int __add_kprobe_trace_events(struct perf_probe_event *pev,
ret = -ENOMEM; ret = -ENOMEM;
break; break;
} }
ret = write_kprobe_trace_event(fd, tev); ret = write_probe_trace_event(fd, tev);
if (ret < 0) if (ret < 0)
break; break;
/* Add added event name to namelist */ /* Add added event name to namelist */
...@@ -1511,21 +1514,21 @@ static int __add_kprobe_trace_events(struct perf_probe_event *pev, ...@@ -1511,21 +1514,21 @@ static int __add_kprobe_trace_events(struct perf_probe_event *pev,
return ret; return ret;
} }
static int convert_to_kprobe_trace_events(struct perf_probe_event *pev, static int convert_to_probe_trace_events(struct perf_probe_event *pev,
struct kprobe_trace_event **tevs, struct probe_trace_event **tevs,
int max_tevs) int max_tevs)
{ {
struct symbol *sym; struct symbol *sym;
int ret = 0, i; int ret = 0, i;
struct kprobe_trace_event *tev; struct probe_trace_event *tev;
/* Convert perf_probe_event with debuginfo */ /* Convert perf_probe_event with debuginfo */
ret = try_to_find_kprobe_trace_events(pev, tevs, max_tevs); ret = try_to_find_probe_trace_events(pev, tevs, max_tevs);
if (ret != 0) if (ret != 0)
return ret; return ret;
/* Allocate trace event buffer */ /* Allocate trace event buffer */
tev = *tevs = zalloc(sizeof(struct kprobe_trace_event)); tev = *tevs = zalloc(sizeof(struct probe_trace_event));
if (tev == NULL) if (tev == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -1538,7 +1541,7 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev, ...@@ -1538,7 +1541,7 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev,
tev->point.offset = pev->point.offset; tev->point.offset = pev->point.offset;
tev->nargs = pev->nargs; tev->nargs = pev->nargs;
if (tev->nargs) { if (tev->nargs) {
tev->args = zalloc(sizeof(struct kprobe_trace_arg) tev->args = zalloc(sizeof(struct probe_trace_arg)
* tev->nargs); * tev->nargs);
if (tev->args == NULL) { if (tev->args == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -1579,7 +1582,7 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev, ...@@ -1579,7 +1582,7 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev,
return 1; return 1;
error: error:
clear_kprobe_trace_event(tev); clear_probe_trace_event(tev);
free(tev); free(tev);
*tevs = NULL; *tevs = NULL;
return ret; return ret;
...@@ -1587,7 +1590,7 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev, ...@@ -1587,7 +1590,7 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev,
struct __event_package { struct __event_package {
struct perf_probe_event *pev; struct perf_probe_event *pev;
struct kprobe_trace_event *tevs; struct probe_trace_event *tevs;
int ntevs; int ntevs;
}; };
...@@ -1610,7 +1613,7 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs, ...@@ -1610,7 +1613,7 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
for (i = 0; i < npevs; i++) { for (i = 0; i < npevs; i++) {
pkgs[i].pev = &pevs[i]; pkgs[i].pev = &pevs[i];
/* Convert with or without debuginfo */ /* Convert with or without debuginfo */
ret = convert_to_kprobe_trace_events(pkgs[i].pev, ret = convert_to_probe_trace_events(pkgs[i].pev,
&pkgs[i].tevs, max_tevs); &pkgs[i].tevs, max_tevs);
if (ret < 0) if (ret < 0)
goto end; goto end;
...@@ -1619,24 +1622,24 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs, ...@@ -1619,24 +1622,24 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
/* Loop 2: add all events */ /* Loop 2: add all events */
for (i = 0; i < npevs && ret >= 0; i++) for (i = 0; i < npevs && ret >= 0; i++)
ret = __add_kprobe_trace_events(pkgs[i].pev, pkgs[i].tevs, ret = __add_probe_trace_events(pkgs[i].pev, pkgs[i].tevs,
pkgs[i].ntevs, force_add); pkgs[i].ntevs, force_add);
end: end:
/* Loop 3: cleanup trace events */ /* Loop 3: cleanup trace events */
for (i = 0; i < npevs; i++) for (i = 0; i < npevs; i++)
for (j = 0; j < pkgs[i].ntevs; j++) for (j = 0; j < pkgs[i].ntevs; j++)
clear_kprobe_trace_event(&pkgs[i].tevs[j]); clear_probe_trace_event(&pkgs[i].tevs[j]);
return ret; return ret;
} }
static int __del_trace_kprobe_event(int fd, struct str_node *ent) static int __del_trace_probe_event(int fd, struct str_node *ent)
{ {
char *p; char *p;
char buf[128]; char buf[128];
int ret; int ret;
/* Convert from perf-probe event to trace-kprobe event */ /* Convert from perf-probe event to trace-probe event */
ret = e_snprintf(buf, 128, "-:%s", ent->s); ret = e_snprintf(buf, 128, "-:%s", ent->s);
if (ret < 0) if (ret < 0)
goto error; goto error;
...@@ -1662,7 +1665,7 @@ static int __del_trace_kprobe_event(int fd, struct str_node *ent) ...@@ -1662,7 +1665,7 @@ static int __del_trace_kprobe_event(int fd, struct str_node *ent)
return ret; return ret;
} }
static int del_trace_kprobe_event(int fd, const char *group, static int del_trace_probe_event(int fd, const char *group,
const char *event, struct strlist *namelist) const char *event, struct strlist *namelist)
{ {
char buf[128]; char buf[128];
...@@ -1679,7 +1682,7 @@ static int del_trace_kprobe_event(int fd, const char *group, ...@@ -1679,7 +1682,7 @@ static int del_trace_kprobe_event(int fd, const char *group,
strlist__for_each_safe(ent, n, namelist) strlist__for_each_safe(ent, n, namelist)
if (strglobmatch(ent->s, buf)) { if (strglobmatch(ent->s, buf)) {
found++; found++;
ret = __del_trace_kprobe_event(fd, ent); ret = __del_trace_probe_event(fd, ent);
if (ret < 0) if (ret < 0)
break; break;
strlist__remove(namelist, ent); strlist__remove(namelist, ent);
...@@ -1688,7 +1691,7 @@ static int del_trace_kprobe_event(int fd, const char *group, ...@@ -1688,7 +1691,7 @@ static int del_trace_kprobe_event(int fd, const char *group,
ent = strlist__find(namelist, buf); ent = strlist__find(namelist, buf);
if (ent) { if (ent) {
found++; found++;
ret = __del_trace_kprobe_event(fd, ent); ret = __del_trace_probe_event(fd, ent);
if (ret >= 0) if (ret >= 0)
strlist__remove(namelist, ent); strlist__remove(namelist, ent);
} }
...@@ -1712,7 +1715,7 @@ int del_perf_probe_events(struct strlist *dellist) ...@@ -1712,7 +1715,7 @@ int del_perf_probe_events(struct strlist *dellist)
return fd; return fd;
/* Get current event names */ /* Get current event names */
namelist = get_kprobe_trace_event_names(fd, true); namelist = get_probe_trace_event_names(fd, true);
if (namelist == NULL) if (namelist == NULL)
return -EINVAL; return -EINVAL;
...@@ -1733,7 +1736,7 @@ int del_perf_probe_events(struct strlist *dellist) ...@@ -1733,7 +1736,7 @@ int del_perf_probe_events(struct strlist *dellist)
event = str; event = str;
} }
pr_debug("Group: %s, Event: %s\n", group, event); pr_debug("Group: %s, Event: %s\n", group, event);
ret = del_trace_kprobe_event(fd, group, event, namelist); ret = del_trace_probe_event(fd, group, event, namelist);
free(str); free(str);
if (ret < 0) if (ret < 0)
break; break;
......
...@@ -7,33 +7,33 @@ ...@@ -7,33 +7,33 @@
extern bool probe_event_dry_run; extern bool probe_event_dry_run;
/* kprobe-tracer tracing point */ /* kprobe-tracer tracing point */
struct kprobe_trace_point { struct probe_trace_point {
char *symbol; /* Base symbol */ char *symbol; /* Base symbol */
unsigned long offset; /* Offset from symbol */ unsigned long offset; /* Offset from symbol */
bool retprobe; /* Return probe flag */ bool retprobe; /* Return probe flag */
}; };
/* kprobe-tracer tracing argument referencing offset */ /* probe-tracer tracing argument referencing offset */
struct kprobe_trace_arg_ref { struct probe_trace_arg_ref {
struct kprobe_trace_arg_ref *next; /* Next reference */ struct probe_trace_arg_ref *next; /* Next reference */
long offset; /* Offset value */ long offset; /* Offset value */
}; };
/* kprobe-tracer tracing argument */ /* kprobe-tracer tracing argument */
struct kprobe_trace_arg { struct probe_trace_arg {
char *name; /* Argument name */ char *name; /* Argument name */
char *value; /* Base value */ char *value; /* Base value */
char *type; /* Type name */ char *type; /* Type name */
struct kprobe_trace_arg_ref *ref; /* Referencing offset */ struct probe_trace_arg_ref *ref; /* Referencing offset */
}; };
/* kprobe-tracer tracing event (point + arg) */ /* kprobe-tracer tracing event (point + arg) */
struct kprobe_trace_event { struct probe_trace_event {
char *event; /* Event name */ char *event; /* Event name */
char *group; /* Group name */ char *group; /* Group name */
struct kprobe_trace_point point; /* Trace point */ struct probe_trace_point point; /* Trace point */
int nargs; /* Number of args */ int nargs; /* Number of args */
struct kprobe_trace_arg *args; /* Arguments */ struct probe_trace_arg *args; /* Arguments */
}; };
/* Perf probe probing point */ /* Perf probe probing point */
...@@ -93,25 +93,18 @@ struct line_range { ...@@ -93,25 +93,18 @@ struct line_range {
/* Command string to events */ /* Command string to events */
extern int parse_perf_probe_command(const char *cmd, extern int parse_perf_probe_command(const char *cmd,
struct perf_probe_event *pev); struct perf_probe_event *pev);
extern int parse_kprobe_trace_command(const char *cmd,
struct kprobe_trace_event *tev);
/* Events to command string */ /* Events to command string */
extern char *synthesize_perf_probe_command(struct perf_probe_event *pev); extern char *synthesize_perf_probe_command(struct perf_probe_event *pev);
extern char *synthesize_kprobe_trace_command(struct kprobe_trace_event *tev); extern char *synthesize_probe_trace_command(struct probe_trace_event *tev);
extern int synthesize_perf_probe_arg(struct perf_probe_arg *pa, char *buf, extern int synthesize_perf_probe_arg(struct perf_probe_arg *pa, char *buf,
size_t len); size_t len);
/* Check the perf_probe_event needs debuginfo */ /* Check the perf_probe_event needs debuginfo */
extern bool perf_probe_event_need_dwarf(struct perf_probe_event *pev); extern bool perf_probe_event_need_dwarf(struct perf_probe_event *pev);
/* Convert from kprobe_trace_event to perf_probe_event */
extern int convert_to_perf_probe_event(struct kprobe_trace_event *tev,
struct perf_probe_event *pev);
/* Release event contents */ /* Release event contents */
extern void clear_perf_probe_event(struct perf_probe_event *pev); extern void clear_perf_probe_event(struct perf_probe_event *pev);
extern void clear_kprobe_trace_event(struct kprobe_trace_event *tev);
/* Command string to line-range */ /* Command string to line-range */
extern int parse_line_range_desc(const char *cmd, struct line_range *lr); extern int parse_line_range_desc(const char *cmd, struct line_range *lr);
......
...@@ -366,10 +366,10 @@ static Dwarf_Die *die_find_member(Dwarf_Die *st_die, const char *name, ...@@ -366,10 +366,10 @@ static Dwarf_Die *die_find_member(Dwarf_Die *st_die, const char *name,
* Probe finder related functions * Probe finder related functions
*/ */
static struct kprobe_trace_arg_ref *alloc_trace_arg_ref(long offs) static struct probe_trace_arg_ref *alloc_trace_arg_ref(long offs)
{ {
struct kprobe_trace_arg_ref *ref; struct probe_trace_arg_ref *ref;
ref = zalloc(sizeof(struct kprobe_trace_arg_ref)); ref = zalloc(sizeof(struct probe_trace_arg_ref));
if (ref != NULL) if (ref != NULL)
ref->offset = offs; ref->offset = offs;
return ref; return ref;
...@@ -385,7 +385,7 @@ static int convert_variable_location(Dwarf_Die *vr_die, struct probe_finder *pf) ...@@ -385,7 +385,7 @@ static int convert_variable_location(Dwarf_Die *vr_die, struct probe_finder *pf)
Dwarf_Word offs = 0; Dwarf_Word offs = 0;
bool ref = false; bool ref = false;
const char *regs; const char *regs;
struct kprobe_trace_arg *tvar = pf->tvar; struct probe_trace_arg *tvar = pf->tvar;
int ret; int ret;
/* TODO: handle more than 1 exprs */ /* TODO: handle more than 1 exprs */
...@@ -459,10 +459,10 @@ static int convert_variable_location(Dwarf_Die *vr_die, struct probe_finder *pf) ...@@ -459,10 +459,10 @@ static int convert_variable_location(Dwarf_Die *vr_die, struct probe_finder *pf)
} }
static int convert_variable_type(Dwarf_Die *vr_die, static int convert_variable_type(Dwarf_Die *vr_die,
struct kprobe_trace_arg *tvar, struct probe_trace_arg *tvar,
const char *cast) const char *cast)
{ {
struct kprobe_trace_arg_ref **ref_ptr = &tvar->ref; struct probe_trace_arg_ref **ref_ptr = &tvar->ref;
Dwarf_Die type; Dwarf_Die type;
char buf[16]; char buf[16];
int ret; int ret;
...@@ -500,7 +500,7 @@ static int convert_variable_type(Dwarf_Die *vr_die, ...@@ -500,7 +500,7 @@ static int convert_variable_type(Dwarf_Die *vr_die,
while (*ref_ptr) while (*ref_ptr)
ref_ptr = &(*ref_ptr)->next; ref_ptr = &(*ref_ptr)->next;
/* Add new reference with offset +0 */ /* Add new reference with offset +0 */
*ref_ptr = zalloc(sizeof(struct kprobe_trace_arg_ref)); *ref_ptr = zalloc(sizeof(struct probe_trace_arg_ref));
if (*ref_ptr == NULL) { if (*ref_ptr == NULL) {
pr_warning("Out of memory error\n"); pr_warning("Out of memory error\n");
return -ENOMEM; return -ENOMEM;
...@@ -545,10 +545,10 @@ static int convert_variable_type(Dwarf_Die *vr_die, ...@@ -545,10 +545,10 @@ static int convert_variable_type(Dwarf_Die *vr_die,
static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname, static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
struct perf_probe_arg_field *field, struct perf_probe_arg_field *field,
struct kprobe_trace_arg_ref **ref_ptr, struct probe_trace_arg_ref **ref_ptr,
Dwarf_Die *die_mem) Dwarf_Die *die_mem)
{ {
struct kprobe_trace_arg_ref *ref = *ref_ptr; struct probe_trace_arg_ref *ref = *ref_ptr;
Dwarf_Die type; Dwarf_Die type;
Dwarf_Word offs; Dwarf_Word offs;
int ret, tag; int ret, tag;
...@@ -574,7 +574,7 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname, ...@@ -574,7 +574,7 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
pr_debug2("Array real type: (%x)\n", pr_debug2("Array real type: (%x)\n",
(unsigned)dwarf_dieoffset(&type)); (unsigned)dwarf_dieoffset(&type));
if (tag == DW_TAG_pointer_type) { if (tag == DW_TAG_pointer_type) {
ref = zalloc(sizeof(struct kprobe_trace_arg_ref)); ref = zalloc(sizeof(struct probe_trace_arg_ref));
if (ref == NULL) if (ref == NULL)
return -ENOMEM; return -ENOMEM;
if (*ref_ptr) if (*ref_ptr)
...@@ -605,7 +605,7 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname, ...@@ -605,7 +605,7 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
return -EINVAL; return -EINVAL;
} }
ref = zalloc(sizeof(struct kprobe_trace_arg_ref)); ref = zalloc(sizeof(struct probe_trace_arg_ref));
if (ref == NULL) if (ref == NULL)
return -ENOMEM; return -ENOMEM;
if (*ref_ptr) if (*ref_ptr)
...@@ -738,7 +738,7 @@ static int find_variable(Dwarf_Die *sp_die, struct probe_finder *pf) ...@@ -738,7 +738,7 @@ static int find_variable(Dwarf_Die *sp_die, struct probe_finder *pf)
/* Show a probe point to output buffer */ /* Show a probe point to output buffer */
static int convert_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf) static int convert_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf)
{ {
struct kprobe_trace_event *tev; struct probe_trace_event *tev;
Dwarf_Addr eaddr; Dwarf_Addr eaddr;
Dwarf_Die die_mem; Dwarf_Die die_mem;
const char *name; const char *name;
...@@ -803,7 +803,7 @@ static int convert_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf) ...@@ -803,7 +803,7 @@ static int convert_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf)
/* Find each argument */ /* Find each argument */
tev->nargs = pf->pev->nargs; tev->nargs = pf->pev->nargs;
tev->args = zalloc(sizeof(struct kprobe_trace_arg) * tev->nargs); tev->args = zalloc(sizeof(struct probe_trace_arg) * tev->nargs);
if (tev->args == NULL) if (tev->args == NULL)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < pf->pev->nargs; i++) { for (i = 0; i < pf->pev->nargs; i++) {
...@@ -1060,9 +1060,9 @@ static int find_probe_point_by_func(struct probe_finder *pf) ...@@ -1060,9 +1060,9 @@ static int find_probe_point_by_func(struct probe_finder *pf)
return _param.retval; return _param.retval;
} }
/* Find kprobe_trace_events specified by perf_probe_event from debuginfo */ /* Find probe_trace_events specified by perf_probe_event from debuginfo */
int find_kprobe_trace_events(int fd, struct perf_probe_event *pev, int find_probe_trace_events(int fd, struct perf_probe_event *pev,
struct kprobe_trace_event **tevs, int max_tevs) struct probe_trace_event **tevs, int max_tevs)
{ {
struct probe_finder pf = {.pev = pev, .max_tevs = max_tevs}; struct probe_finder pf = {.pev = pev, .max_tevs = max_tevs};
struct perf_probe_point *pp = &pev->point; struct perf_probe_point *pp = &pev->point;
...@@ -1072,7 +1072,7 @@ int find_kprobe_trace_events(int fd, struct perf_probe_event *pev, ...@@ -1072,7 +1072,7 @@ int find_kprobe_trace_events(int fd, struct perf_probe_event *pev,
Dwarf *dbg; Dwarf *dbg;
int ret = 0; int ret = 0;
pf.tevs = zalloc(sizeof(struct kprobe_trace_event) * max_tevs); pf.tevs = zalloc(sizeof(struct probe_trace_event) * max_tevs);
if (pf.tevs == NULL) if (pf.tevs == NULL)
return -ENOMEM; return -ENOMEM;
*tevs = pf.tevs; *tevs = pf.tevs;
......
...@@ -16,9 +16,9 @@ static inline int is_c_varname(const char *name) ...@@ -16,9 +16,9 @@ static inline int is_c_varname(const char *name)
} }
#ifdef DWARF_SUPPORT #ifdef DWARF_SUPPORT
/* Find kprobe_trace_events specified by perf_probe_event from debuginfo */ /* Find probe_trace_events specified by perf_probe_event from debuginfo */
extern int find_kprobe_trace_events(int fd, struct perf_probe_event *pev, extern int find_probe_trace_events(int fd, struct perf_probe_event *pev,
struct kprobe_trace_event **tevs, struct probe_trace_event **tevs,
int max_tevs); int max_tevs);
/* Find a perf_probe_point from debuginfo */ /* Find a perf_probe_point from debuginfo */
...@@ -33,7 +33,7 @@ extern int find_line_range(int fd, struct line_range *lr); ...@@ -33,7 +33,7 @@ extern int find_line_range(int fd, struct line_range *lr);
struct probe_finder { struct probe_finder {
struct perf_probe_event *pev; /* Target probe event */ struct perf_probe_event *pev; /* Target probe event */
struct kprobe_trace_event *tevs; /* Result trace events */ struct probe_trace_event *tevs; /* Result trace events */
int ntevs; /* Number of trace events */ int ntevs; /* Number of trace events */
int max_tevs; /* Max number of trace events */ int max_tevs; /* Max number of trace events */
...@@ -50,7 +50,7 @@ struct probe_finder { ...@@ -50,7 +50,7 @@ struct probe_finder {
#endif #endif
Dwarf_Op *fb_ops; /* Frame base attribute */ Dwarf_Op *fb_ops; /* Frame base attribute */
struct perf_probe_arg *pvar; /* Current target variable */ struct perf_probe_arg *pvar; /* Current target variable */
struct kprobe_trace_arg *tvar; /* Current result variable */ struct probe_trace_arg *tvar; /* Current result variable */
}; };
struct line_finder { struct line_finder {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment