lkml.org 
[lkml]   [2017]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] trace-cmd record: Add --quiet (-q) option
Date
trace-cmd record will output information about the
number of missed trace events, the size of the data
written to the data file from events on each CPU,
etc. When tracing programs that rely on specific
output from a command, this output can cause mis-
matches that cause failures. This is particularly
true for SPEC.

When run with the --quiet (-q) option, trace-cmd
record squelches this extraneous output.

Signed-off-by: Will Hawkins <hawkinsw@borlaugic.com>
---
trace-cmd-local.h | 2 ++
trace-cmd.c | 1 +
trace-local.h | 1 +
trace-output.c | 9 ++++++---
trace-record.c | 17 +++++++++++++----
trace-usage.c | 4 +++-
6 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/trace-cmd-local.h b/trace-cmd-local.h
index 9412f9d..b9425ee 100644
--- a/trace-cmd-local.h
+++ b/trace-cmd-local.h
@@ -25,6 +25,8 @@
#include "trace-cmd.h"
#include "event-utils.h"

+extern int quiet;
+
static ssize_t __do_write(int fd, const void *data, size_t size)
{
ssize_t tot = 0;
diff --git a/trace-cmd.c b/trace-cmd.c
index 0f71e12..5a10605 100644
--- a/trace-cmd.c
+++ b/trace-cmd.c
@@ -31,6 +31,7 @@ int silence_warnings;
int show_status;

int debug;
+int quiet;

void warning(const char *fmt, ...)
{
diff --git a/trace-local.h b/trace-local.h
index fa987bc..87635a0 100644
--- a/trace-local.h
+++ b/trace-local.h
@@ -27,6 +27,7 @@
#include "event-utils.h"

extern int debug;
+extern int quiet;

/* fix stupid glib guint64 typecasts and printf formats */
typedef unsigned long long u64;
diff --git a/trace-output.c b/trace-output.c
index e2ab0db..bfe6331 100644
--- a/trace-output.c
+++ b/trace-output.c
@@ -1146,8 +1146,9 @@ static int __tracecmd_append_cpu_data(struct tracecmd_output *handle,
goto out_free;

for (i = 0; i < cpus; i++) {
- fprintf(stderr, "CPU%d data recorded at offset=0x%llx\n",
- i, (unsigned long long) offsets[i]);
+ if (!quiet)
+ fprintf(stderr, "CPU%d data recorded at offset=0x%llx\n",
+ i, (unsigned long long) offsets[i]);
offset = lseek64(handle->fd, offsets[i], SEEK_SET);
if (offset == (off64_t)-1) {
warning("could not seek to %lld\n", offsets[i]);
@@ -1160,7 +1161,9 @@ static int __tracecmd_append_cpu_data(struct tracecmd_output *handle,
check_size, sizes[i]);
goto out_free;
}
- fprintf(stderr, " %llu bytes in size\n", (unsigned long long)check_size);
+ if (!quiet)
+ fprintf(stderr, " %llu bytes in size\n",
+ (unsigned long long)check_size);
}

free(offsets);
diff --git a/trace-record.c b/trace-record.c
index 1b55043..1f4eef4 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -2983,10 +2983,12 @@ static void print_stat(struct buffer_instance *instance)
int cpu;

if (!is_top_instance(instance))
- printf("\nBuffer: %s\n\n", instance->name);
+ if (!quiet)
+ printf("\nBuffer: %s\n\n", instance->name);

for (cpu = 0; cpu < cpu_count; cpu++)
- trace_seq_do_printf(&instance->s_print[cpu]);
+ if (!quiet)
+ trace_seq_do_printf(&instance->s_print[cpu]);
}

enum {
@@ -3742,7 +3744,8 @@ static void check_plugin(const char *plugin)
}
die ("Plugin '%s' does not exist", plugin);
out:
- fprintf(stderr, " plugin '%s'\n", plugin);
+ if (!quiet)
+ fprintf(stderr, " plugin '%s'\n", plugin);
free(buf);
}

@@ -4158,6 +4161,7 @@ void update_first_instance(struct buffer_instance *instance, int topt)

enum {

+ OPT_quiet = 246,
OPT_debug = 247,
OPT_max_graph_depth = 248,
OPT_tsoffset = 249,
@@ -4369,6 +4373,7 @@ void trace_record (int argc, char **argv)
{"ts-offset", required_argument, NULL, OPT_tsoffset},
{"max-graph-depth", required_argument, NULL, OPT_max_graph_depth},
{"debug", no_argument, NULL, OPT_debug},
+ {"quiet", no_argument, NULL, OPT_quiet},
{"help", no_argument, NULL, '?'},
{NULL, 0, NULL, 0}
};
@@ -4376,7 +4381,7 @@ void trace_record (int argc, char **argv)
if (extract)
opts = "+haf:Fp:co:O:sr:g:l:n:P:N:tb:B:ksiT";
else
- opts = "+hae:f:Fp:cC:dDGo:O:s:r:vg:l:n:P:N:tb:R:B:ksSiTm:M:H:";
+ opts = "+hae:f:Fp:cC:dDGo:O:s:r:vg:l:n:P:N:tb:R:B:ksSiTm:M:H:q";
c = getopt_long (argc-1, argv+1, opts, long_options, &option_index);
if (c == -1)
break;
@@ -4641,6 +4646,10 @@ void trace_record (int argc, char **argv)
case OPT_debug:
debug = 1;
break;
+ case OPT_quiet:
+ case 'q':
+ quiet = 1;
+ break;
default:
usage(argv);
}
diff --git a/trace-usage.c b/trace-usage.c
index 5b314a6..be21d8c 100644
--- a/trace-usage.c
+++ b/trace-usage.c
@@ -17,7 +17,7 @@ static struct usage_help usage_help[] = {
"record",
"record a trace into a trace.dat file",
" %s record [-v][-e event [-f filter]][-p plugin][-F][-d][-D][-o file] \\\n"
- " [-s usecs][-O option ][-l func][-g func][-n func] \\\n"
+ " [-q][-s usecs][-O option ][-l func][-g func][-n func] \\\n"
" [-P pid][-N host:port][-t][-r prio][-b size][-B buf][command ...]\n"
" [-m max][-C clock]\n"
" -e run command with event enabled\n"
@@ -48,11 +48,13 @@ static struct usage_help usage_help[] = {
" -B create sub buffer and folling events will be enabled here\n"
" -k do not reset the buffers after tracing.\n"
" -i do not fail if an event is not found\n"
+ " -q print no output to the screen\n"
" --by-comm used with --profile, merge events for related comms\n"
" --profile enable tracing options needed for report --profile\n"
" --func-stack perform a stack trace for function tracer\n"
" (use with caution)\n"
" --max-graph-depth limit function_graph depth\n"
+ " --quiet print no output to the screen\n"
},
{
"start",
--
1.9.1
\
 
 \ /
  Last update: 2017-07-19 20:24    [W:0.034 / U:1.608 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site