aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/probe-event.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2010-03-16 18:06:19 -0400
committerIngo Molnar <mingo@elte.hu>2010-03-17 06:32:32 -0400
commitfb1587d869a399554220e166d4b90b581a8ade01 (patch)
tree64ae42dc601f702f6d8409a74d4c3b2e242cdc93 /tools/perf/util/probe-event.c
parent4235b0454ebeefc2295ad8417e18a8761425b19e (diff)
perf probe: List probes with line number and file name
Improve --list to show current exist probes with line number and file name. This enables user easily to check which line is already probed. for example: ./perf probe --list probe:vfs_read (on vfs_read:8@linux-2.6-tip/fs/read_write.c) Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Cc: systemtap <systemtap@sources.redhat.com> Cc: DLE <dle-develop@lists.sourceforge.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <20100316220619.32050.48702.stgit@localhost6.localdomain6> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/probe-event.c')
-rw-r--r--tools/perf/util/probe-event.c55
1 files changed, 42 insertions, 13 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index b44ddfb030d7..4e3c1aea7892 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -70,7 +70,6 @@ static int e_snprintf(char *str, size_t size, const char *format, ...)
70 return ret; 70 return ret;
71} 71}
72 72
73
74static struct map_groups kmap_groups; 73static struct map_groups kmap_groups;
75static struct map *kmaps[MAP__NR_TYPES]; 74static struct map *kmaps[MAP__NR_TYPES];
76 75
@@ -357,27 +356,39 @@ void parse_kprobe_trace_command(const char *cmd, struct kprobe_trace_event *tev)
357/* Compose only probe point (not argument) */ 356/* Compose only probe point (not argument) */
358static char *synthesize_perf_probe_point(struct perf_probe_point *pp) 357static char *synthesize_perf_probe_point(struct perf_probe_point *pp)
359{ 358{
360 char *buf; 359 char *buf, *tmp;
361 char offs[64] = "", line[64] = ""; 360 char offs[32] = "", line[32] = "", file[32] = "";
362 int ret; 361 int ret, len;
363 362
364 buf = xzalloc(MAX_CMDLEN); 363 buf = xzalloc(MAX_CMDLEN);
365 if (pp->offset) { 364 if (pp->offset) {
366 ret = e_snprintf(offs, 64, "+%lu", pp->offset); 365 ret = e_snprintf(offs, 32, "+%lu", pp->offset);
367 if (ret <= 0) 366 if (ret <= 0)
368 goto error; 367 goto error;
369 } 368 }
370 if (pp->line) { 369 if (pp->line) {
371 ret = e_snprintf(line, 64, ":%d", pp->line); 370 ret = e_snprintf(line, 32, ":%d", pp->line);
371 if (ret <= 0)
372 goto error;
373 }
374 if (pp->file) {
375 len = strlen(pp->file) - 32;
376 if (len < 0)
377 len = 0;
378 tmp = strchr(pp->file + len, '/');
379 if (!tmp)
380 tmp = pp->file + len - 1;
381 ret = e_snprintf(file, 32, "@%s", tmp + 1);
372 if (ret <= 0) 382 if (ret <= 0)
373 goto error; 383 goto error;
374 } 384 }
375 385
376 if (pp->function) 386 if (pp->function)
377 ret = e_snprintf(buf, MAX_CMDLEN, "%s%s%s%s", pp->function, 387 ret = e_snprintf(buf, MAX_CMDLEN, "%s%s%s%s%s", pp->function,
378 offs, pp->retprobe ? "%return" : "", line); 388 offs, pp->retprobe ? "%return" : "", line,
389 file);
379 else 390 else
380 ret = e_snprintf(buf, MAX_CMDLEN, "%s%s", pp->file, line); 391 ret = e_snprintf(buf, MAX_CMDLEN, "%s%s", file, line);
381 if (ret <= 0) 392 if (ret <= 0)
382 goto error; 393 goto error;
383 394
@@ -511,15 +522,32 @@ void convert_to_perf_probe_event(struct kprobe_trace_event *tev,
511{ 522{
512 char buf[64]; 523 char buf[64];
513 int i; 524 int i;
525#ifndef NO_DWARF_SUPPORT
526 struct symbol *sym;
527 int fd, ret = 0;
514 528
515 pev->event = xstrdup(tev->event); 529 sym = map__find_symbol_by_name(kmaps[MAP__FUNCTION],
516 pev->group = xstrdup(tev->group); 530 tev->point.symbol, NULL);
517 531 if (sym) {
532 fd = open_vmlinux();
533 ret = find_perf_probe_point(fd, sym->start + tev->point.offset,
534 &pev->point);
535 close(fd);
536 }
537 if (ret <= 0) {
538 pev->point.function = xstrdup(tev->point.symbol);
539 pev->point.offset = tev->point.offset;
540 }
541#else
518 /* Convert trace_point to probe_point */ 542 /* Convert trace_point to probe_point */
519 pev->point.function = xstrdup(tev->point.symbol); 543 pev->point.function = xstrdup(tev->point.symbol);
520 pev->point.offset = tev->point.offset; 544 pev->point.offset = tev->point.offset;
545#endif
521 pev->point.retprobe = tev->point.retprobe; 546 pev->point.retprobe = tev->point.retprobe;
522 547
548 pev->event = xstrdup(tev->event);
549 pev->group = xstrdup(tev->group);
550
523 /* Convert trace_arg to probe_arg */ 551 /* Convert trace_arg to probe_arg */
524 pev->nargs = tev->nargs; 552 pev->nargs = tev->nargs;
525 pev->args = xzalloc(sizeof(struct perf_probe_arg) * pev->nargs); 553 pev->args = xzalloc(sizeof(struct perf_probe_arg) * pev->nargs);
@@ -650,7 +678,7 @@ static void show_perf_probe_event(struct perf_probe_event *pev)
650 ret = e_snprintf(buf, 128, "%s:%s", pev->group, pev->event); 678 ret = e_snprintf(buf, 128, "%s:%s", pev->group, pev->event);
651 if (ret < 0) 679 if (ret < 0)
652 die("Failed to copy event: %s", strerror(-ret)); 680 die("Failed to copy event: %s", strerror(-ret));
653 printf(" %-40s (on %s", buf, place); 681 printf(" %-20s (on %s", buf, place);
654 682
655 if (pev->nargs > 0) { 683 if (pev->nargs > 0) {
656 printf(" with"); 684 printf(" with");
@@ -671,6 +699,7 @@ void show_perf_probe_events(void)
671 struct str_node *ent; 699 struct str_node *ent;
672 700
673 setup_pager(); 701 setup_pager();
702 init_vmlinux();
674 703
675 memset(&tev, 0, sizeof(tev)); 704 memset(&tev, 0, sizeof(tev));
676 memset(&pev, 0, sizeof(pev)); 705 memset(&pev, 0, sizeof(pev));