aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/trace-event-read.c
diff options
context:
space:
mode:
authorTom Zanussi <tzanussi@gmail.com>2010-05-01 02:41:20 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-05-02 12:36:56 -0400
commit454c407ec17a0c63e4023ac0877d687945a7df4a (patch)
tree1271299a59a89419c0dd4dcbf29b4492b63555ca /tools/perf/util/trace-event-read.c
parent789688faef5b3ba78065beaf2f3d6f1c839f74a3 (diff)
perf: add perf-inject builtin
Currently, perf 'live mode' writes build-ids at the end of the session, which isn't actually useful for processing live mode events. What would be better would be to have the build-ids sent before any of the samples that reference them, which can be done by processing the event stream and retrieving the build-ids on the first hit. Doing that in perf-record itself, however, is off-limits. This patch introduces perf-inject, which does the same job while leaving perf-record untouched. Normal mode perf still records the build-ids at the end of the session as it should, but for live mode, perf-inject can be injected in between the record and report steps e.g.: perf record -o - ./hackbench 10 | perf inject -v -b | perf report -v -i - perf-inject reads a perf-record event stream and repipes it to stdout. At any point the processing code can inject other events into the event stream - in this case build-ids (-b option) are read and injected as needed into the event stream. Build-ids are just the first user of perf-inject - potentially anything that needs userspace processing to augment the trace stream with additional information could make use of this facility. Cc: Ingo Molnar <mingo@elte.hu> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Frédéric Weisbecker <fweisbec@gmail.com> LKML-Reference: <1272696080-16435-3-git-send-email-tzanussi@gmail.com> Signed-off-by: Tom Zanussi <tzanussi@gmail.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/trace-event-read.c')
-rw-r--r--tools/perf/util/trace-event-read.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
index 44889c9b5630..43f19c1fed3a 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -51,6 +51,7 @@ static int long_size;
51static unsigned long page_size; 51static unsigned long page_size;
52 52
53static ssize_t calc_data_size; 53static ssize_t calc_data_size;
54static bool repipe;
54 55
55static int do_read(int fd, void *buf, int size) 56static int do_read(int fd, void *buf, int size)
56{ 57{
@@ -62,6 +63,13 @@ static int do_read(int fd, void *buf, int size)
62 if (ret <= 0) 63 if (ret <= 0)
63 return -1; 64 return -1;
64 65
66 if (repipe) {
67 int retw = write(STDOUT_FILENO, buf, ret);
68
69 if (retw <= 0 || retw != ret)
70 die("repiping input file");
71 }
72
65 size -= ret; 73 size -= ret;
66 buf += ret; 74 buf += ret;
67 } 75 }
@@ -116,6 +124,13 @@ static char *read_string(void)
116 if (!r) 124 if (!r)
117 die("no data"); 125 die("no data");
118 126
127 if (repipe) {
128 int retw = write(STDOUT_FILENO, &c, 1);
129
130 if (retw <= 0 || retw != r)
131 die("repiping input file string");
132 }
133
119 buf[size++] = c; 134 buf[size++] = c;
120 135
121 if (!c) 136 if (!c)
@@ -454,7 +469,7 @@ struct record *trace_read_data(int cpu)
454 return data; 469 return data;
455} 470}
456 471
457ssize_t trace_report(int fd) 472ssize_t trace_report(int fd, bool __repipe)
458{ 473{
459 char buf[BUFSIZ]; 474 char buf[BUFSIZ];
460 char test[] = { 23, 8, 68 }; 475 char test[] = { 23, 8, 68 };
@@ -465,6 +480,7 @@ ssize_t trace_report(int fd)
465 ssize_t size; 480 ssize_t size;
466 481
467 calc_data_size = 1; 482 calc_data_size = 1;
483 repipe = __repipe;
468 484
469 input_fd = fd; 485 input_fd = fd;
470 486
@@ -499,6 +515,7 @@ ssize_t trace_report(int fd)
499 515
500 size = calc_data_size - 1; 516 size = calc_data_size - 1;
501 calc_data_size = 0; 517 calc_data_size = 0;
518 repipe = false;
502 519
503 if (show_funcs) { 520 if (show_funcs) {
504 print_funcs(); 521 print_funcs();