Commit 6beba7ad authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by Ingo Molnar

perf tools: Unify debug messages mechanisms

We were using eprintf in some places, that looks at a global
'verbose' level, and at other places passing a 'v' parameter to
specify the verbosity level, unify it by introducing
pr_{err,warning,debug,etc}, just like in the kernel.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1256153646-10097-1-git-send-email-acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 802da5f2
......@@ -203,8 +203,7 @@ static int
process_mmap_event(event_t *event, unsigned long offset, unsigned long head)
{
struct map *map = map__new(&event->mmap, NULL, 0,
sizeof(struct sym_priv), symbol_filter,
verbose);
sizeof(struct sym_priv), symbol_filter);
struct thread *thread = threads__findnew(event->mmap.pid);
dump_printf("%p [%p]: PERF_RECORD_MMAP %d: [%p(%p) @ %p]: %s\n",
......
......@@ -630,7 +630,7 @@ static int __cmd_record(int argc, const char **argv)
param.sched_priority = realtime_prio;
if (sched_setscheduler(0, SCHED_FIFO, &param)) {
printf("Could not set realtime priority.\n");
pr_err("Could not set realtime priority.\n");
exit(-1);
}
}
......
......@@ -689,7 +689,8 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
dump_printf("... chain: nr:%Lu\n", chain->nr);
if (validate_chain(chain, event) < 0) {
eprintf("call-chain problem with event, skipping it.\n");
pr_debug("call-chain problem with event, "
"skipping it.\n");
return 0;
}
......@@ -700,7 +701,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
}
if (thread == NULL) {
eprintf("problem processing %d event, skipping it.\n",
pr_debug("problem processing %d event, skipping it.\n",
event->header.type);
return -1;
}
......@@ -738,7 +739,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
if (hist_entry__add(thread, map, sym, ip,
chain, level, period)) {
eprintf("problem incrementing symbol count, skipping event\n");
pr_debug("problem incrementing symbol count, skipping event\n");
return -1;
}
......@@ -750,7 +751,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
static int
process_mmap_event(event_t *event, unsigned long offset, unsigned long head)
{
struct map *map = map__new(&event->mmap, cwd, cwdlen, 0, NULL, verbose);
struct map *map = map__new(&event->mmap, cwd, cwdlen, 0, NULL);
struct thread *thread = threads__findnew(event->mmap.pid);
dump_printf("%p [%p]: PERF_RECORD_MMAP %d/%d: [%p(%p) @ %p]: %s\n",
......
......@@ -1666,8 +1666,8 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
(long long)period);
if (thread == NULL) {
eprintf("problem processing %d event, skipping it.\n",
event->header.type);
pr_debug("problem processing %d event, skipping it.\n",
event->header.type);
return -1;
}
......
......@@ -1162,12 +1162,10 @@ static int __cmd_timechart(void)
size = event->header.size;
if (!size || process_event(event) < 0) {
printf("%p [%p]: skipping unknown header type: %d\n",
(void *)(offset + head),
(void *)(long)(event->header.size),
event->header.type);
pr_warning("%p [%p]: skipping unknown header type: %d\n",
(void *)(offset + head),
(void *)(long)(event->header.size),
event->header.type);
/*
* assume we lost track of the stream, check alignment, and
* increment a single u64 in the hope to catch on again 'soon'.
......@@ -1200,7 +1198,8 @@ static int __cmd_timechart(void)
write_svg_file(output_name);
printf("Written %2.1f seconds of trace to %s.\n", (last_time - first_time) / 1000000000.0, output_name);
pr_info("Written %2.1f seconds of trace to %s.\n",
(last_time - first_time) / 1000000000.0, output_name);
return rc;
}
......
......@@ -809,7 +809,7 @@ static int symbol_filter(struct map *map, struct symbol *sym)
static int parse_symbols(void)
{
if (dsos__load_kernel(vmlinux_name, sizeof(struct sym_entry),
symbol_filter, verbose, 1) <= 0)
symbol_filter, 1) <= 0)
return -1;
if (dump_symtab)
......
......@@ -81,8 +81,8 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
(long long)period);
if (thread == NULL) {
eprintf("problem processing %d event, skipping it.\n",
event->header.type);
pr_debug("problem processing %d event, skipping it.\n",
event->header.type);
return -1;
}
......
......@@ -206,7 +206,7 @@ fill_node(struct callchain_node *node, struct ip_callchain *chain,
}
node->val_nr = chain->nr - start;
if (!node->val_nr)
printf("Warning: empty node in callchain tree\n");
pr_warning("Warning: empty node in callchain tree\n");
}
static void
......
......@@ -13,12 +13,12 @@
int verbose = 0;
int dump_trace = 0;
int eprintf(const char *fmt, ...)
int eprintf(int level, const char *fmt, ...)
{
va_list args;
int ret = 0;
if (verbose) {
if (verbose >= level) {
va_start(args, fmt);
ret = vfprintf(stderr, fmt, args);
va_end(args);
......
......@@ -5,7 +5,8 @@
extern int verbose;
extern int dump_trace;
int eprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
int eprintf(int level,
const char *fmt, ...) __attribute__((format(printf, 2, 3)));
int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
void trace_event(event_t *event);
......
......@@ -106,8 +106,7 @@ struct symbol;
typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);
struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen,
unsigned int sym_priv_size, symbol_filter_t filter,
int v);
unsigned int sym_priv_size, symbol_filter_t filter);
struct map *map__clone(struct map *self);
int map__overlap(struct map *l, struct map *r);
size_t map__fprintf(struct map *self, FILE *fp);
......
......@@ -93,7 +93,7 @@ static struct perf_trace_event_type *events;
void perf_header__push_event(u64 id, const char *name)
{
if (strlen(name) > MAX_EVENT_NAME)
printf("Event %s will be truncated\n", name);
pr_warning("Event %s will be truncated\n", name);
if (!events) {
events = malloc(sizeof(struct perf_trace_event_type));
......
......@@ -85,4 +85,21 @@ simple_strtoul(const char *nptr, char **endptr, int base)
return strtoul(nptr, endptr, base);
}
#ifndef pr_fmt
#define pr_fmt(fmt) fmt
#endif
#define pr_err(fmt, ...) \
do { fprintf(stderr, pr_fmt(fmt), ##__VA_ARGS__); } while (0)
#define pr_warning(fmt, ...) \
do { fprintf(stderr, pr_fmt(fmt), ##__VA_ARGS__); } while (0)
#define pr_info(fmt, ...) \
do { fprintf(stderr, pr_fmt(fmt), ##__VA_ARGS__); } while (0)
#define pr_debug(fmt, ...) \
eprintf(1, pr_fmt(fmt), ##__VA_ARGS__)
#define pr_debugN(n, fmt, ...) \
eprintf(n, pr_fmt(fmt), ##__VA_ARGS__)
#define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__)
#define pr_debug3(fmt, ...) pr_debugN(3, pr_fmt(fmt), ##__VA_ARGS__)
#endif
......@@ -21,8 +21,7 @@ static int strcommon(const char *pathname, char *cwd, int cwdlen)
}
struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen,
unsigned int sym_priv_size, symbol_filter_t filter,
int v)
unsigned int sym_priv_size, symbol_filter_t filter)
{
struct map *self = malloc(sizeof(*self));
......@@ -58,16 +57,16 @@ struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen,
goto out_delete;
if (new_dso) {
int nr = dso__load(self->dso, self, filter, v);
int nr = dso__load(self->dso, self, filter);
if (nr < 0)
eprintf("Failed to open %s, continuing "
"without symbols\n",
self->dso->long_name);
pr_warning("Failed to open %s, continuing "
"without symbols\n",
self->dso->long_name);
else if (nr == 0)
eprintf("No symbols found in %s, maybe "
"install a debug package?\n",
self->dso->long_name);
pr_warning("No symbols found in %s, maybe "
"install a debug package?\n",
self->dso->long_name);
}
if (self->dso == vdso || anon)
......
This diff is collapsed.
......@@ -63,11 +63,10 @@ static inline void *dso__sym_priv(struct dso *self, struct symbol *sym)
struct symbol *dso__find_symbol(struct dso *self, u64 ip);
int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size,
symbol_filter_t filter, int verbose, int modules);
symbol_filter_t filter, int modules);
struct dso *dsos__findnew(const char *name, unsigned int sym_priv_size,
bool *is_new);
int dso__load(struct dso *self, struct map *map,
symbol_filter_t filter, int v);
int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
void dsos__fprintf(FILE *fp);
size_t dso__fprintf(struct dso *self, FILE *fp);
......
......@@ -127,9 +127,9 @@ static void thread__remove_overlappings(struct thread *self, struct map *map)
continue;
if (verbose >= 2) {
printf("overlapping maps:\n");
map__fprintf(map, stdout);
map__fprintf(pos, stdout);
fputs("overlapping maps:\n", stderr);
map__fprintf(map, stderr);
map__fprintf(pos, stderr);
}
rb_erase(&pos->rb_node, &self->maps);
......
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