perf tools: Unify debug messages mechanisms
PATCH 1/1 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.
--- tools/perf/builtin-annotate.c | 3 +- tools/perf/builtin-probe.c | 20 +++--- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-report.c | 9 +- tools/perf/builtin-sched.c | 4 +- tools/perf/builtin-timechart.c | 13 ++-- tools/perf/builtin-top.c | 2 +- tools/perf/builtin-trace.c | 4 +- tools/perf/util/callchain.c | 2 +- tools/perf/util/debug.c | 4 +- tools/perf/util/debug.h | 3 +- tools/perf/util/event.h | 3 +- tools/perf/util/header.c | 2 +- tools/perf/util/include/linux/kernel.h | 17 ++++ tools/perf/util/map.c | 17 ++-- tools/perf/util/probe-finder.c | 12 ++-- tools/perf/util/symbol.c | 134 ++++++++++++++------------------ tools/perf/util/symbol.h | 5 +- tools/perf/util/thread.c | 6 +- 19 files changed, 130 insertions(+), 132 deletions(-)
tools/perf/builtin-annotate.c +1 -2
@@ -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",
tools/perf/builtin-probe.c +10 -10
@@ -78,7 +78,7 @@ static int parse_probepoint(const struct option *opt __used,if (!str)/* The end of probe points */ return 0 ; -eprintf ("probe-definition(%d): %s\n" , session.nr_probe, str); +pr_debug ("probe-definition(%d): %s\n" , session.nr_probe, str);if (++session.nr_probe ==MAX_PROBES )semantic_error ("Too many probes" );
@@ -103,7 +103,7 @@ static int parse_probepoint(const struct option *opt __used,die ("strndup" );if (++argc ==MAX_PROBE_ARGS )semantic_error ("Too many arguments" ); -eprintf ("argv[%d]=%s\n" , argc, argv[argc -1 ]); +pr_debug ("argv[%d]=%s\n" , argc, argv[argc -1 ]); } }while (*str !='\0' );if (argc <2 )
@@ -133,7 +133,7 @@ static int parse_probepoint(const struct option *opt __used, pp->line =atoi (ptr);if (!pp->file || !pp->line)semantic_error ("Failed to parse line." ); -eprintf ("file:%s line:%d\n" , pp->file, pp->line); +pr_debug ("file:%s line:%d\n" , pp->file, pp->line); }else {/* Function name */ ptr =strchr (arg,'+' );
@@ -150,8 +150,8 @@ static int parse_probepoint(const struct option *opt __used, pp->file =strdup (ptr); } pp->function =strdup (arg); -eprintf ("symbol:%s file:%s offset:%d\n" , - pp->function, pp->file, pp->offset); +pr_debug ("symbol:%s file:%s offset:%d\n" , + pp->function, pp->file, pp->offset); }free (argv[1 ]);if (pp->file)
@@ -175,7 +175,7 @@ static int parse_probepoint(const struct option *opt __used, session.need_dwarf =1 ; } -eprintf ("%d arguments\n" , pp->nr_args); +pr_debug ("%d arguments\n" , pp->nr_args);return 0 ; }
@@ -188,7 +188,7 @@ static int open_default_vmlinux(void) ret =uname (&uts);if (ret) { -eprintf ("uname() failed.\n" ); +pr_debug ("uname() failed.\n" );return -errno; } session.release = uts.release;
@@ -196,12 +196,12 @@ static int open_default_vmlinux(void) ret =snprintf (fname,MAX_PATH_LEN , default_search_path[i], session.release);if (ret >=MAX_PATH_LEN || ret <0 ) { -eprintf ("Filename(%d,%s) is too long.\n" , i, +pr_debug ("Filename(%d,%s) is too long.\n" , i, uts.release); errno =E2BIG ;return -E2BIG ; } -eprintf ("try to open %s\n" , fname); +pr_debug ("try to open %s\n" , fname); fd =open (fname,O_RDONLY );if (fd >=0 )break ;
@@ -341,7 +341,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) ret =find_probepoint (fd, pp);if (ret <=0 )die ("No probe point found.\n" ); -eprintf ("probe event %s found\n" , session.events[j]); +pr_debug ("probe event %s found\n" , session.events[j]); }close (fd);
tools/perf/builtin-record.c +1 -1
@@ -630,7 +630,7 @@ static int __cmd_record(int argc, const char **argv) param.sched_priority = realtime_prio;if (sched_setscheduler (0 ,SCHED_FIFO , ¶m)) { -printf ("Could not set realtime priority.\n" ); +pr_err ("Could not set realtime priority.\n" );exit (-1 ); } }
tools/perf/builtin-report.c +5 -4
@@ -619,7 +619,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 ; }
@@ -630,7 +631,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 ; }
@@ -668,7 +669,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 ; }
@@ -680,7 +681,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",
tools/perf/builtin-sched.c +2 -2
@@ -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 ; }
tools/perf/builtin-timechart.c +6 -7
@@ -1162,12 +1162,10 @@ more: 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 @@ done: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; }
tools/perf/builtin-top.c +1 -1
@@ -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)
tools/perf/builtin-trace.c +2 -2
@@ -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 ; }
tools/perf/util/callchain.c +1 -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
tools/perf/util/debug.c +2 -2
@@ -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);
tools/perf/util/debug.h +2 -1
@@ -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);
tools/perf/util/event.h +1 -2
@@ -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);
tools/perf/util/header.c +1 -1
@@ -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 ));
tools/perf/util/include/linux/kernel.h +17 -0
@@ -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
tools/perf/util/map.c +8 -9
@@ -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)
tools/perf/util/probe-finder.c +6 -6
@@ -136,7 +136,7 @@ static Dwarf_Unsigned die_get_fileno(Dwarf_Die cu_die, const char *fname)dwarf_dealloc (__dw_debug, srcs,DW_DLA_LIST ); }if (found) -eprintf ("found fno: %d\n" , (int )found); +pr_debug ("found fno: %d\n" , (int )found);return found; }
@@ -442,7 +442,7 @@ static void find_variable(Dwarf_Die sp_die, struct probe_finder *pf)return ; } -eprintf ("Searching '%s' variable in context.\n" , pf->var); +pr_debug ("Searching '%s' variable in context.\n" , pf->var);/* Search child die for local variables and parameters. */ ret =search_die_from_children (sp_die, variable_callback, pf);if (!ret)
@@ -552,7 +552,7 @@ static void find_by_line(Dwarf_Die cu_die, struct probe_finder *pf) ret =dwarf_lineaddr (lines[i], &addr, &__dw_error);DIE_IF (ret !=DW_DLV_OK ); -eprintf ("Probe point found: 0x%llx\n" , addr); +pr_debug ("Probe point found: 0x%llx\n" , addr); pf->addr = addr;/* Search a real subprogram including this line, */ ret =search_die_from_children (cu_die, probeaddr_callback, pf);
@@ -583,8 +583,8 @@ static int probefunc_callback(struct die_link *dlink, void *data) &pf->inl_offs, &__dw_error);DIE_IF (ret !=DW_DLV_OK ); -eprintf ("inline definition offset %lld\n" , - pf->inl_offs); +pr_debug ("inline definition offset %lld\n" , + pf->inl_offs);return 0 ; }/* Get probe address */
@@ -599,7 +599,7 @@ static int probefunc_callback(struct die_link *dlink, void *data)/* Get probe address */ pf->addr =die_get_entrypc (dlink->die); pf->addr += pp->offset; -eprintf ("found inline addr: 0x%llx\n" , pf->addr); +pr_debug ("found inline addr: 0x%llx\n" , pf->addr);/* Inlined function. Get a real subprogram */ for (lk = dlink->parent; lk !=NULL ; lk = lk->parent) { tag =0 ;
tools/perf/util/symbol.c +59 -75
398 lines not on this page · raw message
tools/perf/util/symbol.h +2 -3
@@ -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);
tools/perf/util/thread.c +3 -3
@@ -116,9 +116,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);
Signature · 1 line
1.6.2.5
Quoted 51 lines · Arnaldo Carvalho de Melo
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.
Cc Frederic Weisbecker <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Paul Mackerras <[email protected]>Cc Mike Galbraith <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>--- tools/perf/builtin-annotate.c | 3 +- tools/perf/builtin-probe.c | 20 +++--- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-report.c | 9 +- tools/perf/builtin-sched.c | 4 +- tools/perf/builtin-timechart.c | 13 ++-- tools/perf/builtin-top.c | 2 +- tools/perf/builtin-trace.c | 4 +- tools/perf/util/callchain.c | 2 +- tools/perf/util/debug.c | 4 +- tools/perf/util/debug.h | 3 +- tools/perf/util/event.h | 3 +- tools/perf/util/header.c | 2 +- tools/perf/util/include/linux/kernel.h | 17 ++++ tools/perf/util/map.c | 17 ++-- tools/perf/util/probe-finder.c | 12 ++-- tools/perf/util/symbol.c | 134 ++++++++++++++------------------ tools/perf/util/symbol.h | 5 +- tools/perf/util/thread.c | 6 +- 19 files changed, 130 insertions(+), 132 deletions(-)tools/perf/builtin-annotate.c +1
-2@@ -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",tools/perf/builtin-probe.c +0
-0
tools/perf/builtin-probe.c static int parse_probepoint(const struct option *opt __used, · line 81
Quoted 5 lines
tools/perf/builtin-probe.c +1
-1@@ -78,7 +78,7 @@ static int parse_probepoint(const struct option *opt __used,if (!str)/* The end of probe points */ return 0 ; -eprintf ("probe-definition(%d): %s\n" , session.nr_probe, str); +pr_debug ("probe-definition(%d): %s\n" , session.nr_probe, str);
Very nice! That verbose global/local overlap has always bothered me, thanks for fixing it!
Ingo
Commit-ID: 6beba7adbe092e63dfe8d09fbd1e3ec140474a13 Gitweb: http://git.kernel.org/tip/6beba7adbe092e63dfe8d09fbd1e3ec140474a13 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Wed, 21 Oct 2009 17:34:06 -0200 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 23 Oct 2009 08:22:47 +0200
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.
LKML-Reference: <[email protected]>
--- tools/perf/builtin-annotate.c | 3 +- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-report.c | 9 +- tools/perf/builtin-sched.c | 4 +- tools/perf/builtin-timechart.c | 13 ++-- tools/perf/builtin-top.c | 2 +- tools/perf/builtin-trace.c | 4 +- tools/perf/util/callchain.c | 2 +- tools/perf/util/debug.c | 4 +- tools/perf/util/debug.h | 3 +- tools/perf/util/event.h | 3 +- tools/perf/util/header.c | 2 +- tools/perf/util/include/linux/kernel.h | 17 ++++ tools/perf/util/map.c | 17 ++-- tools/perf/util/symbol.c | 134 ++++++++++++++------------------ tools/perf/util/symbol.h | 5 +- tools/perf/util/thread.c | 6 +- 17 files changed, 114 insertions(+), 116 deletions(-)
tools/perf/builtin-annotate.c +1 -2
@@ -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",
tools/perf/builtin-record.c +1 -1
@@ -630,7 +630,7 @@ static int __cmd_record(int argc, const char **argv) param.sched_priority = realtime_prio;if (sched_setscheduler (0 ,SCHED_FIFO , ¶m)) { -printf ("Could not set realtime priority.\n" ); +pr_err ("Could not set realtime priority.\n" );exit (-1 ); } }
tools/perf/builtin-report.c +5 -4
@@ -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",
tools/perf/builtin-sched.c +2 -2
@@ -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 ; }
tools/perf/builtin-timechart.c +6 -7
@@ -1162,12 +1162,10 @@ more: 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 @@ done: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; }
tools/perf/builtin-top.c +1 -1
@@ -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)
tools/perf/builtin-trace.c +2 -2
@@ -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 ; }
tools/perf/util/callchain.c +1 -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
tools/perf/util/debug.c +2 -2
@@ -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);
tools/perf/util/debug.h +2 -1
@@ -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);
tools/perf/util/event.h +1 -2
@@ -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);
tools/perf/util/header.c +1 -1
@@ -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 ));
tools/perf/util/include/linux/kernel.h +17 -0
@@ -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
tools/perf/util/map.c +8 -9
@@ -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)
tools/perf/util/symbol.c +59 -75
398 lines not on this page · raw message
tools/perf/util/symbol.h +2 -3
@@ -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);
tools/perf/util/thread.c +3 -3
@@ -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);
[tip:branch?] perf probe: Print debug messages using pr_*()
In reply to Arnaldo Carvalho de MeloCommit-ID: b7cb10e790fbd145296e771f789273a875c15719 Gitweb: http://git.kernel.org/tip/b7cb10e790fbd145296e771f789273a875c15719 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Wed, 21 Oct 2009 17:34:06 -0200 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 23 Oct 2009 08:24:21 +0200
perf probe: Print debug messages using pr_*()
Use the new pr_{err,warning,debug,etc} printout methods, just like in the kernel.
LKML-Reference: <[email protected]>
--- tools/perf/builtin-probe.c | 20 ++++++++++---------- tools/perf/util/probe-finder.c | 12 ++++++------ 2 files changed, 16 insertions(+), 16 deletions(-)
tools/perf/builtin-probe.c +10 -10
@@ -78,7 +78,7 @@ static int parse_probepoint(const struct option *opt __used,if (!str)/* The end of probe points */ return 0 ; -eprintf ("probe-definition(%d): %s\n" , session.nr_probe, str); +pr_debug ("probe-definition(%d): %s\n" , session.nr_probe, str);if (++session.nr_probe ==MAX_PROBES )semantic_error ("Too many probes" );
@@ -103,7 +103,7 @@ static int parse_probepoint(const struct option *opt __used,die ("strndup" );if (++argc ==MAX_PROBE_ARGS )semantic_error ("Too many arguments" ); -eprintf ("argv[%d]=%s\n" , argc, argv[argc -1 ]); +pr_debug ("argv[%d]=%s\n" , argc, argv[argc -1 ]); } }while (*str !='\0' );if (argc <2 )
@@ -133,7 +133,7 @@ static int parse_probepoint(const struct option *opt __used, pp->line =atoi (ptr);if (!pp->file || !pp->line)semantic_error ("Failed to parse line." ); -eprintf ("file:%s line:%d\n" , pp->file, pp->line); +pr_debug ("file:%s line:%d\n" , pp->file, pp->line); }else {/* Function name */ ptr =strchr (arg,'+' );
@@ -150,8 +150,8 @@ static int parse_probepoint(const struct option *opt __used, pp->file =strdup (ptr); } pp->function =strdup (arg); -eprintf ("symbol:%s file:%s offset:%d\n" , - pp->function, pp->file, pp->offset); +pr_debug ("symbol:%s file:%s offset:%d\n" , + pp->function, pp->file, pp->offset); }free (argv[1 ]);if (pp->file)
@@ -175,7 +175,7 @@ static int parse_probepoint(const struct option *opt __used, session.need_dwarf =1 ; } -eprintf ("%d arguments\n" , pp->nr_args); +pr_debug ("%d arguments\n" , pp->nr_args);return 0 ; }
@@ -188,7 +188,7 @@ static int open_default_vmlinux(void) ret =uname (&uts);if (ret) { -eprintf ("uname() failed.\n" ); +pr_debug ("uname() failed.\n" );return -errno; } session.release = uts.release;
@@ -196,12 +196,12 @@ static int open_default_vmlinux(void) ret =snprintf (fname,MAX_PATH_LEN , default_search_path[i], session.release);if (ret >=MAX_PATH_LEN || ret <0 ) { -eprintf ("Filename(%d,%s) is too long.\n" , i, +pr_debug ("Filename(%d,%s) is too long.\n" , i, uts.release); errno =E2BIG ;return -E2BIG ; } -eprintf ("try to open %s\n" , fname); +pr_debug ("try to open %s\n" , fname); fd =open (fname,O_RDONLY );if (fd >=0 )break ;
@@ -341,7 +341,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) ret =find_probepoint (fd, pp);if (ret <=0 )die ("No probe point found.\n" ); -eprintf ("probe event %s found\n" , session.events[j]); +pr_debug ("probe event %s found\n" , session.events[j]); }close (fd);
tools/perf/util/probe-finder.c +6 -6
@@ -136,7 +136,7 @@ static Dwarf_Unsigned die_get_fileno(Dwarf_Die cu_die, const char *fname)dwarf_dealloc (__dw_debug, srcs,DW_DLA_LIST ); }if (found) -eprintf ("found fno: %d\n" , (int )found); +pr_debug ("found fno: %d\n" , (int )found);return found; }
@@ -442,7 +442,7 @@ static void find_variable(Dwarf_Die sp_die, struct probe_finder *pf)return ; } -eprintf ("Searching '%s' variable in context.\n" , pf->var); +pr_debug ("Searching '%s' variable in context.\n" , pf->var);/* Search child die for local variables and parameters. */ ret =search_die_from_children (sp_die, variable_callback, pf);if (!ret)
@@ -552,7 +552,7 @@ static void find_by_line(Dwarf_Die cu_die, struct probe_finder *pf) ret =dwarf_lineaddr (lines[i], &addr, &__dw_error);DIE_IF (ret !=DW_DLV_OK ); -eprintf ("Probe point found: 0x%llx\n" , addr); +pr_debug ("Probe point found: 0x%llx\n" , addr); pf->addr = addr;/* Search a real subprogram including this line, */ ret =search_die_from_children (cu_die, probeaddr_callback, pf);
@@ -583,8 +583,8 @@ static int probefunc_callback(struct die_link *dlink, void *data) &pf->inl_offs, &__dw_error);DIE_IF (ret !=DW_DLV_OK ); -eprintf ("inline definition offset %lld\n" , - pf->inl_offs); +pr_debug ("inline definition offset %lld\n" , + pf->inl_offs);return 0 ; }/* Get probe address */
@@ -599,7 +599,7 @@ static int probefunc_callback(struct die_link *dlink, void *data)/* Get probe address */ pf->addr =die_get_entrypc (dlink->die); pf->addr += pp->offset; -eprintf ("found inline addr: 0x%llx\n" , pf->addr); +pr_debug ("found inline addr: 0x%llx\n" , pf->addr);/* Inlined function. Get a real subprogram */ for (lk = dlink->parent; lk !=NULL ; lk = lk->parent) { tag =0 ;