aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2009-07-30 19:36:50 -0400
committerSteven Rostedt <rostedt@goodmis.org>2009-07-30 22:32:36 -0400
commit3ea3c443b30d2e9d37ce437d36a4747abfbcc83f (patch)
tree56f25e939c73d04f1ccf883e526c5656deebcf17
parent52be6f4f02e94512b830bfae9ae411c50d5696a7 (diff)
Output messages to stderr
This allows capturing data from stdout of the traced command without having trace-cmd messages mixed in. "trace-cmd report" output still goes to stdout. In the process, I simplified the error-handling for splice, taking advantage of die() automatically checking for errno and calling perror. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-cmd.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/trace-cmd.c b/trace-cmd.c
index 6973bba..27fd2c9 100644
--- a/trace-cmd.c
+++ b/trace-cmd.c
@@ -361,7 +361,7 @@ static void enable_event(const char *name)
361 char *path; 361 char *path;
362 int ret; 362 int ret;
363 363
364 printf("enable %s\n", name); 364 fprintf(stderr, "enable %s\n", name);
365 if (strcmp(name, "all") == 0) { 365 if (strcmp(name, "all") == 0) {
366 path = get_tracing_file("events/enable"); 366 path = get_tracing_file("events/enable");
367 fp = fopen(path, "w"); 367 fp = fopen(path, "w");
@@ -550,17 +550,11 @@ static int create_recorder(int cpu)
550 550
551 do { 551 do {
552 ret = splice(in_fd, NULL, brass[1], NULL, page_size, 1 /* SPLICE_F_MOVE */); 552 ret = splice(in_fd, NULL, brass[1], NULL, page_size, 1 /* SPLICE_F_MOVE */);
553 if (ret < 0) { 553 if (ret < 0)
554 perror("in");
555 printf("errno=%d\n", errno);
556 die("splice in"); 554 die("splice in");
557 }
558 ret = splice(brass[0], NULL, out_fd, NULL, page_size, 3 /* and NON_BLOCK */); 555 ret = splice(brass[0], NULL, out_fd, NULL, page_size, 3 /* and NON_BLOCK */);
559 if (ret < 0 && errno != EAGAIN) { 556 if (ret < 0 && errno != EAGAIN)
560 perror("in");
561 printf("errno=%d\n", errno);
562 die("splice out"); 557 die("splice out");
563 }
564 } while (!finished); 558 } while (!finished);
565 559
566 /* splice only reads full pages */ 560 /* splice only reads full pages */
@@ -998,7 +992,7 @@ static void read_thread_data(void)
998 } 992 }
999 993
1000 for (i = 0; i < cpu_count; i++) { 994 for (i = 0; i < cpu_count; i++) {
1001 printf("offset=%llx\n", offsets[i]); 995 fprintf(stderr, "offset=%llx\n", offsets[i]);
1002 ret = lseek64(output_fd, offsets[i], SEEK_SET); 996 ret = lseek64(output_fd, offsets[i], SEEK_SET);
1003 if (ret < 0) 997 if (ret < 0)
1004 die("could not seek to %lld\n", offsets[i]); 998 die("could not seek to %lld\n", offsets[i]);
@@ -1074,7 +1068,7 @@ int main (int argc, char **argv)
1074 if (plugin) 1068 if (plugin)
1075 die("only one plugin allowed"); 1069 die("only one plugin allowed");
1076 plugin = optarg; 1070 plugin = optarg;
1077 printf(" plugin %s\n", plugin); 1071 fprintf(stderr, " plugin %s\n", plugin);
1078 break; 1072 break;
1079 case 'd': 1073 case 'd':
1080 disable = 1; 1074 disable = 1;