perf tools: Add support for more debug variables
Jiri Olsa
reviewercover perf tools: Add support for more debug variables
hi,
adding support for more debug variables and --debug option as a way to setup debug variables. Starting with support for verbose, more will come.
It's possible to use it now with report command:
$ perf report --debug verbose $ perf report --debug verbose=2
I need this for ordered events object debug outputs.
thanks,
jirka
---
Jiri Olsa (4):
perf tools: Remove verbose from functions prototypes perf tools: Move pr_* debug macros into debug object perf tools: Factor eprintf to allow different debug variables perf tools: Add --debug optionto set debug variable
tools/perf/Documentation/perf-report.txt | 6 ++++++ tools/perf/arch/x86/tests/dwarf-unwind.c | 1 + tools/perf/arch/x86/util/unwind-libunwind.c | 1 + tools/perf/builtin-evlist.c | 1 + tools/perf/builtin-help.c | 1 + tools/perf/builtin-report.c | 2 ++ tools/perf/builtin-timechart.c | 1 + tools/perf/tests/dso-data.c | 1 + tools/perf/tests/evsel-roundtrip-name.c | 1 + tools/perf/tests/evsel-tp-sched.c | 1 + tools/perf/tests/open-syscall-tp-fields.c | 1 + tools/perf/tests/parse-events.c | 1 + tools/perf/tests/parse-no-sample-id-all.c | 1 + tools/perf/tests/sample-parsing.c | 1 + tools/perf/tests/thread-mg-share.c | 1 + tools/perf/ui/stdio/hist.c | 2 +- tools/perf/util/data.c | 1 + tools/perf/util/debug.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++------ tools/perf/util/debug.h | 23 +++++++++++++++++++++ tools/perf/util/include/linux/kernel.h | 21 ------------------- tools/perf/util/map.c | 24 +++++++++++----------- tools/perf/util/map.h | 9 ++++----- tools/perf/util/probe-finder.c | 1 - tools/perf/util/pstack.c | 1 + tools/perf/util/python.c | 4 ++-- tools/perf/util/scripting-engines/trace-event-perl.c | 1 + tools/perf/util/thread.c | 4 ++-- tools/perf/util/trace-event-info.c | 1 + tools/perf/util/trace-event-read.c | 2 +- tools/perf/util/unwind-libunwind.c | 1 + tools/perf/util/util.c | 1 + tools/perf/util/vdso.c | 1 + 32 files changed, 124 insertions(+), 51 deletions(-)
Jiri Olsa
reviewerPATCH 1/4 perf tools: Remove verbose from functions prototypes
And use verbose as an global object in following fuunctions:
__map_groups__fprintf_maps __map_groups__fprintf_removed_maps map_groups__fprintf_maps
map_groups__fprintf
Also making map_groups__fprintf_maps static.
--- tools/perf/ui/stdio/hist.c | 2 +- tools/perf/util/map.c | 24 ++++++++++++------------ tools/perf/util/map.h | 9 ++++----- tools/perf/util/thread.c | 4 ++-- 4 files changed, 19 insertions(+), 20 deletions(-)
tools/perf/ui/stdio/hist.c +1 -1
@@ -479,7 +479,7 @@ print_entries:if (h->ms.map ==NULL && verbose >1 ) {__map_groups__fprintf_maps (h->thread->mg, -MAP__FUNCTION , verbose, fp); +MAP__FUNCTION , fp);fprintf (fp,"%.10s end\n" , graph_dotted_line); } }
tools/perf/util/map.c +12 -12
@@ -12,6 +12,7 @@#include "vdso.h" #include "build-id.h" #include "util.h" +#include "debug.h" #include <linux/string.h> const char *map_type__name[MAP__NR_TYPES ] = {
@@ -554,8 +555,8 @@ int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter)return ams->sym ?0 :-1 ; } -size_t __map_groups__fprintf_maps (struct map_groups *mg, -enum map_type type,int verbose,FILE *fp) +size_t __map_groups__fprintf_maps (struct map_groups *mg,enum map_type type, +FILE *fp) {size_t printed =fprintf (fp,"%s:\n" , map_type__name[type]);struct rb_node *nd;
@@ -573,17 +574,16 @@ size_t __map_groups__fprintf_maps(struct map_groups *mg,return printed; } -size_t map_groups__fprintf_maps (struct map_groups *mg,int verbose,FILE *fp) +static size_t map_groups__fprintf_maps (struct map_groups *mg,FILE *fp) {size_t printed =0 , i;for (i =0 ; i <MAP__NR_TYPES ; ++i) - printed +=__map_groups__fprintf_maps (mg, i, verbose, fp); + printed +=__map_groups__fprintf_maps (mg, i, fp);return printed; }static size_t __map_groups__fprintf_removed_maps (struct map_groups *mg, -enum map_type type, -int verbose,FILE *fp) +enum map_type type,FILE *fp) {struct map *pos;size_t printed =0 ;
@@ -600,23 +600,23 @@ static size_t __map_groups__fprintf_removed_maps(struct map_groups *mg, }static size_t map_groups__fprintf_removed_maps (struct map_groups *mg, -int verbose,FILE *fp) +FILE *fp) {size_t printed =0 , i;for (i =0 ; i <MAP__NR_TYPES ; ++i) - printed +=__map_groups__fprintf_removed_maps (mg, i, verbose, fp); + printed +=__map_groups__fprintf_removed_maps (mg, i, fp);return printed; } -size_t map_groups__fprintf (struct map_groups *mg,int verbose,FILE *fp) +size_t map_groups__fprintf (struct map_groups *mg,FILE *fp) { -size_t printed =map_groups__fprintf_maps (mg, verbose, fp); +size_t printed =map_groups__fprintf_maps (mg, fp); printed +=fprintf (fp,"Removed maps:\n" ); -return printed +map_groups__fprintf_removed_maps (mg, verbose, fp); +return printed +map_groups__fprintf_removed_maps (mg, fp); }int map_groups__fixup_overlappings (struct map_groups *mg,struct map *map, -int verbose,FILE *fp) +FILE *fp) {struct rb_root *root = &mg->maps[map->type];struct rb_node *next =rb_first (root);
tools/perf/util/map.h +4 -5
@@ -141,8 +141,8 @@ void map__fixup_end(struct map *map);void map__reloc_vmlinux (struct map *map); -size_t __map_groups__fprintf_maps (struct map_groups *mg, -enum map_type type,int verbose,FILE *fp); +size_t __map_groups__fprintf_maps (struct map_groups *mg,enum map_type type, +FILE *fp);void maps__insert (struct rb_root *maps,struct map *map);void maps__remove (struct rb_root *maps,struct map *map);struct map *maps__find (struct rb_root *maps,u64 addr);
@@ -152,8 +152,7 @@ void map_groups__init(struct map_groups *mg);void map_groups__exit (struct map_groups *mg);int map_groups__clone (struct map_groups *mg,struct map_groups *parent,enum map_type type); -size_t map_groups__fprintf (struct map_groups *mg,int verbose,FILE *fp); -size_t map_groups__fprintf_maps (struct map_groups *mg,int verbose,FILE *fp); +size_t map_groups__fprintf (struct map_groups *mg,FILE *fp);int maps__set_kallsyms_ref_reloc_sym (struct map **maps,const char *symbol_name,u64 addr);
@@ -210,7 +209,7 @@ struct symbol *map_groups__find_function_by_name(struct map_groups *mg, }int map_groups__fixup_overlappings (struct map_groups *mg,struct map *map, -int verbose,FILE *fp); +FILE *fp);struct map *map_groups__find_by_name (struct map_groups *mg,enum map_type type,const char *name);
tools/perf/util/thread.c +2 -2
@@ -127,12 +127,12 @@ int thread__comm_len(struct thread *thread)size_t thread__fprintf (struct thread *thread,FILE *fp) {return fprintf (fp,"Thread %d %s\n" , thread->tid,thread__comm_str (thread)) + -map_groups__fprintf (thread->mg, verbose, fp); +map_groups__fprintf (thread->mg, fp); }void thread__insert_map (struct thread *thread,struct map *map) { -map_groups__fixup_overlappings (thread->mg, map, verbose, stderr); +map_groups__fixup_overlappings (thread->mg, map, stderr);map_groups__insert (thread->mg, map); }
Signature · 1 line
1.8.3.1
Jiri Olsa
reviewerPATCH 2/4 perf tools: Move pr_* debug macros into debug object
In reply to Jiri OlsaMoving pr_* debug macros to have it with in same object as debug variables, becase we will change them to use verbose variable in next patch.
--- tools/perf/arch/x86/tests/dwarf-unwind.c | 1 + tools/perf/arch/x86/util/unwind-libunwind.c | 1 + tools/perf/builtin-evlist.c | 1 + tools/perf/builtin-help.c | 1 + tools/perf/builtin-timechart.c | 1 + tools/perf/tests/dso-data.c | 1 + tools/perf/tests/evsel-roundtrip-name.c | 1 + tools/perf/tests/evsel-tp-sched.c | 1 + tools/perf/tests/open-syscall-tp-fields.c | 1 + tools/perf/tests/parse-events.c | 1 + tools/perf/tests/parse-no-sample-id-all.c | 1 + tools/perf/tests/sample-parsing.c | 1 + tools/perf/tests/thread-mg-share.c | 1 + tools/perf/util/data.c | 1 + tools/perf/util/debug.h | 20 ++++++++++++++++++++ tools/perf/util/include/linux/kernel.h | 21 --------------------- tools/perf/util/pstack.c | 1 + .../perf/util/scripting-engines/trace-event-perl.c | 1 + tools/perf/util/trace-event-info.c | 1 + tools/perf/util/trace-event-read.c | 1 + tools/perf/util/unwind-libunwind.c | 1 + tools/perf/util/util.c | 1 + tools/perf/util/vdso.c | 1 + 23 files changed, 41 insertions(+), 21 deletions(-)
tools/perf/arch/x86/tests/dwarf-unwind.c +1 -0
@@ -3,6 +3,7 @@#include "thread.h" #include "map.h" #include "event.h" +#include "debug.h" #include "tests/tests.h" #define STACK_SIZE 8192
tools/perf/arch/x86/util/unwind-libunwind.c +1 -0
@@ -3,6 +3,7 @@#include <libunwind.h> #include "perf_regs.h" #include "../../util/unwind.h" +#include "../../util/debug.h" #ifdef HAVE_ARCH_X86_64_SUPPORT int libunwind__arch_reg_id (int regnum)
tools/perf/builtin-evlist.c +1 -0
@@ -15,6 +15,7 @@#include "util/parse-options.h" #include "util/session.h" #include "util/data.h" +#include "util/debug.h" static int __cmd_evlist (const char *file_name,struct perf_attr_details *details) {
tools/perf/builtin-help.c +1 -0
@@ -11,6 +11,7 @@#include "util/parse-options.h" #include "util/run-command.h" #include "util/help.h" +#include "util/debug.h" static struct man_viewer_list { struct man_viewer_list *next;
tools/perf/builtin-timechart.c +1 -0
@@ -37,6 +37,7 @@#include "util/svghelper.h" #include "util/tool.h" #include "util/data.h" +#include "util/debug.h" #define SUPPORT_OLD_POWER_EVENTS 1#define PWR_EVENT_EXIT -1
tools/perf/tests/dso-data.c +1 -0
@@ -10,6 +10,7 @@#include "machine.h" #include "symbol.h" #include "tests.h" +#include "debug.h" static char *test_file (int size) {
tools/perf/tests/evsel-roundtrip-name.c +1 -0
@@ -2,6 +2,7 @@#include "evsel.h" #include "parse-events.h" #include "tests.h" +#include "debug.h" static int perf_evsel__roundtrip_cache_name_test (void ) {
tools/perf/tests/evsel-tp-sched.c +1 -0
@@ -1,6 +1,7 @@#include <traceevent/event-parse.h> #include "evsel.h" #include "tests.h" +#include "debug.h" static int perf_evsel__test_field (struct perf_evsel *evsel,const char *name,int size,bool should_be_signed)
tools/perf/tests/open-syscall-tp-fields.c +1 -0
@@ -3,6 +3,7 @@#include "evsel.h" #include "thread_map.h" #include "tests.h" +#include "debug.h" int test__syscall_open_tp_fields (void ) {
tools/perf/tests/parse-events.c +1 -0
@@ -5,6 +5,7 @@#include <api/fs/fs.h> #include <api/fs/debugfs.h> #include "tests.h" +#include "debug.h" #include <linux/hw_breakpoint.h> #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
tools/perf/tests/parse-no-sample-id-all.c +1 -0
@@ -7,6 +7,7 @@#include "evlist.h" #include "header.h" #include "util.h" +#include "debug.h" static int process_event (struct perf_evlist **pevlist,union perf_event *event) {
tools/perf/tests/sample-parsing.c +1 -0
@@ -4,6 +4,7 @@#include "util.h" #include "event.h" #include "evsel.h" +#include "debug.h" #include "tests.h"
tools/perf/tests/thread-mg-share.c +1 -0
@@ -2,6 +2,7 @@#include "machine.h" #include "thread.h" #include "map.h" +#include "debug.h" int test__thread_mg_share (void ) {
tools/perf/util/data.c +1 -0
@@ -7,6 +7,7 @@#include "data.h" #include "util.h" +#include "debug.h" static bool check_pipe (struct perf_data_file *file) {
tools/perf/util/debug.h +20 -0
@@ -11,6 +11,24 @@extern int verbose;extern bool quiet, dump_trace; +#ifndef pr_fmt +#define pr_fmt (fmt) fmt +#endif + +#define pr_err (fmt, ...) \ + eprintf(0, pr_fmt(fmt), ##__VA_ARGS__) +#define pr_warning (fmt, ...) \ + eprintf(0, pr_fmt(fmt), ##__VA_ARGS__) +#define pr_info (fmt, ...) \ + eprintf(0, pr_fmt(fmt), ##__VA_ARGS__) +#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__) +#define pr_debug4 (fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__) +int dump_printf (const char *fmt, ...) __attribute__((format (printf,1 ,2 )));void trace_event (union perf_event *event);
@@ -19,4 +37,6 @@ int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));void pr_stat (const char *fmt, ...); +int eprintf (int level,const char *fmt, ...) __attribute__((format (printf,2 ,3 ))); +#endif /* __PERF_DEBUG_H */
tools/perf/util/include/linux/kernel.h +0 -21
@@ -94,27 +94,6 @@ static inline int scnprintf(char * buf, size_t size, const char * fmt, ...)return (i >= ssize) ? (ssize -1 ) : i; } -int eprintf (int level, -const char *fmt, ...) __attribute__((format (printf,2 ,3 ))); - -#ifndef pr_fmt -#define pr_fmt (fmt) fmt -#endif - -#define pr_err (fmt, ...) \ - eprintf(0, pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warning (fmt, ...) \ - eprintf(0, pr_fmt(fmt), ##__VA_ARGS__) -#define pr_info (fmt, ...) \ - eprintf(0, pr_fmt(fmt), ##__VA_ARGS__) -#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__) -#define pr_debug4 (fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__) -/* * This looks more complex than it should be. But we need to * get the type for the ~ right in round_down (it needs to be
tools/perf/util/pstack.c +1 -0
@@ -6,6 +6,7 @@#include "util.h" #include "pstack.h" +#include "debug.h" #include <linux/kernel.h> #include <stdlib.h>
tools/perf/util/scripting-engines/trace-event-perl.c +1 -0
@@ -34,6 +34,7 @@#include "../event.h" #include "../trace-event.h" #include "../evsel.h" +#include "../debug.h" void boot_Perf__Trace__Context(pTHX_ CV *cv); void boot_DynaLoader(pTHX_ CV *cv);
tools/perf/util/trace-event-info.c +1 -0
@@ -40,6 +40,7 @@#include "trace-event.h" #include <api/fs/debugfs.h> #include "evsel.h" +#include "debug.h" #define VERSION "0.5"
tools/perf/util/trace-event-read.c +1 -0
@@ -36,6 +36,7 @@#include "../perf.h" #include "util.h" #include "trace-event.h" +#include "debug.h" static int input_fd;
tools/perf/util/unwind-libunwind.c +1 -0
@@ -30,6 +30,7 @@#include "unwind.h" #include "symbol.h" #include "util.h" +#include "debug.h" extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
tools/perf/util/util.c +1 -0
@@ -1,5 +1,6 @@#include "../perf.h" #include "util.h" +#include "debug.h" #include <api/fs/fs.h> #include <sys/mman.h> #ifdef HAVE_BACKTRACE_SUPPORT
tools/perf/util/vdso.c +1 -0
@@ -12,6 +12,7 @@#include "util.h" #include "symbol.h" #include "linux/string.h" +#include "debug.h" static bool vdso_found;static char vdso_file[] ="/tmp/perf-vdso.so-XXXXXX" ;
Signature · 1 line
1.8.3.1
Jiri Olsa
reviewerPATCH 3/4 perf tools: Factor eprintf to allow different debug variables
In reply to Jiri OlsaThis way we can easily reuse current debug functions for another debug variables other than verbose.
--- tools/perf/util/debug.c | 12 ++++++------ tools/perf/util/debug.h | 12 ++++++------ tools/perf/util/python.c | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-)
tools/perf/util/debug.c +6 -6
@@ -16,11 +16,11 @@int verbose;bool dump_trace = false, quiet = false; -static int _eprintf (int level,const char *fmt,va_list args) +static int _eprintf (int level,int var,const char *fmt,va_list args) {int ret =0 ; -if (verbose >= level) { +if (var >= level) {if (use_browser >=1 )ui_helpline__vshow (fmt, args);else
@@ -30,13 +30,13 @@ static int _eprintf(int level, const char *fmt, va_list args)return ret; } -int eprintf (int level,const char *fmt, ...) +int eprintf (int level,int var,const char *fmt, ...) {va_list args;int ret;va_start (args, fmt); - ret =_eprintf (level, fmt, args); + ret =_eprintf (level, var, fmt, args);va_end (args);return ret;
@@ -51,9 +51,9 @@ void pr_stat(const char *fmt, ...)va_list args;va_start (args, fmt); -_eprintf (1 , fmt, args); +_eprintf (1 , verbose, fmt, args);va_end (args); -eprintf (1 ,"\n" ); +eprintf (1 , verbose,"\n" ); }int dump_printf (const char *fmt, ...)
tools/perf/util/debug.h +6 -6
@@ -16,15 +16,15 @@ extern bool quiet, dump_trace;#endif #define pr_err (fmt, ...) \ - eprintf(0, pr_fmt(fmt), ##__VA_ARGS__) + eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)#define pr_warning (fmt, ...) \ - eprintf(0, pr_fmt(fmt), ##__VA_ARGS__) + eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)#define pr_info (fmt, ...) \ - eprintf(0, pr_fmt(fmt), ##__VA_ARGS__) + eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)#define pr_debug (fmt, ...) \ - eprintf(1, pr_fmt(fmt), ##__VA_ARGS__) + eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__)#define pr_debugN (n, fmt, ...) \ - eprintf(n, pr_fmt(fmt), ##__VA_ARGS__) + eprintf(n, verbose, 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__)#define pr_debug4 (fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__)
@@ -37,6 +37,6 @@ int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));void pr_stat (const char *fmt, ...); -int eprintf (int level,const char *fmt, ...) __attribute__((format (printf,2 ,3 ))); +int eprintf (int level,int var,const char *fmt, ...) __attribute__((format (printf,3 ,4 )));#endif /* __PERF_DEBUG_H */
tools/perf/util/python.c +2 -2
@@ -14,12 +14,12 @@*/ int verbose; -int eprintf (int level,const char *fmt, ...) +int eprintf (int level,int var,const char *fmt, ...) {va_list args;int ret =0 ; -if (verbose >= level) { +if (var >= level) {va_start (args, fmt); ret =vfprintf (stderr, fmt, args);va_end (args);
Signature · 1 line
1.8.3.1
Jiri Olsa
reviewerPATCH 4/4 perf tools: Add --debug optionto set debug variable
In reply to Jiri OlsaAdding --debug option as a way to setup debug variables. Starting with support for verbose, more will come.
It's possible to use it now with report command:
$ perf report --debug verbose $ perf report --debug verbose=2
I'll need this support to add separated debug variable for ordered events change in order to separate debug output out of standard verbose stream.
Also removing unneeded getopt.h includes.
--- tools/perf/Documentation/perf-report.txt | 6 +++++ tools/perf/builtin-report.c | 2 ++ tools/perf/util/debug.c | 45 ++++++++++++++++++++++++++++++++ tools/perf/util/debug.h | 3 +++ tools/perf/util/probe-finder.c | 1 - tools/perf/util/trace-event-read.c | 1 - 6 files changed, 56 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-report.txt +6 -0
@@ -25,6 +25,12 @@ OPTIONS --verbose:: Be more verbose. (show symbol address, etc) +--debug:: + Setup debug variable (just verbose for now) in value + range (0, 10). Use like: + --debug verbose # sets verbose = 1 + --debug verbose=2 # sets verbose = 2 + -n:: --show-nr-samples:: Show the number of samples for each symbol
tools/perf/builtin-report.c +2 -0
@@ -679,6 +679,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) "Don't show entries under that percent", parse_percent_limit),OPT_CALLBACK (0 ,"percentage" ,NULL ,"relative|absolute" ,"how to display percentage of filtered entries" , parse_filter_percentage), +OPT_CALLBACK (0 ,"debug" ,NULL ,"variable[=VALUE]" , +"set debug variable (verbose)" , perf_debug_option),OPT_END () }; struct perf_data_file file = {
tools/perf/util/debug.c +45 -0
48 lines not on this page · raw message
tools/perf/util/debug.h +3 -0
@@ -7,6 +7,7 @@#include "../ui/helpline.h" #include "../ui/progress.h" #include "../ui/util.h" +#include "parse-options.h" extern int verbose;extern bool quiet, dump_trace;
@@ -39,4 +40,6 @@ void pr_stat(const char *fmt, ...);int eprintf (int level,int var,const char *fmt, ...) __attribute__((format (printf,3 ,4 ))); +int perf_debug_option (const struct option *opt,const char *str,int unset); +#endif /* __PERF_DEBUG_H */
tools/perf/util/probe-finder.c +0 -1
@@ -26,7 +26,6 @@#include <errno.h> #include <stdio.h> #include <unistd.h> -#include <getopt.h> #include <stdlib.h> #include <string.h> #include <stdarg.h>
tools/perf/util/trace-event-read.c +0 -1
@@ -22,7 +22,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <getopt.h> #include <stdarg.h> #include <sys/types.h> #include <sys/stat.h>
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 4/4] perf tools: Add --debug optionto set debug variable
Hi Jiri,
Quoted 10 lines · Jiri Olsa
Adding --debug option as a way to setup debug variables. Starting with support for verbose, more will come.
It's possible to use it now with report command:
$ perf report --debug verbose $ perf report --debug verbose=2I'll need this support to add separated debug variable for ordered events change in order to separate debug output out of standard verbose stream.
Hmm.. okay. I think there'll be more users for this.
Quoted 2 lines
Also removing unneeded
getopt.hincludes.
I guess Arnaldo wants to see it as a separate change ;-)
tools/perf/util/debug.c void trace_event(union perf_event *event) · line 112
Quoted 4 lines
tools/perf/util/debug.c +4
-0+static struct variables_t { +const char *name; +int *ptr; +} variables[] = {
This is a too general name. How about debug_variable or debug_domain?
Thanks,
Namhyung
Quoted 83 lines
tools/perf/util/debug.c +40
-0+ { .name = "verbose", .ptr = &verbose }, + { .name = NULL, } +}; + +int perf_debug_option (const struct option *opt__maybe_unused ,const char *str, +int unset__maybe_unused ) +{ +struct variables_t *var = &variables[0 ]; +char *vstr, *s =strdup (str); +int v =1 ; + + vstr =strchr (s,'=' ); +if (vstr) + *vstr++ =0 ; + +while (var->name) { +if (!strcmp (s, var->name)) +break ; + var++; + } + +if (!var->name) { +pr_err ("Unknown debug variable name '%s'\n" , s); +free (s); +return -1 ; + } + +if (vstr) { + v =atoi (vstr); +/* +* Allow only values in range (0, 10), +* otherwise set 0. +*/ + v = (v <0 ) || (v >10 ) ?0 : v; + } + + *var->ptr = v; +free (s); +return 0 ; +}tools/perf/util/debug.h +3
-0@@ -7,6 +7,7 @@#include "../ui/helpline.h" #include "../ui/progress.h" #include "../ui/util.h" +#include "parse-options.h" extern int verbose;extern bool quiet, dump_trace;@@ -39,4 +40,6 @@ void pr_stat(const char *fmt, ...);int eprintf (int level,int var,const char *fmt, ...) __attribute__((format (printf,3 ,4 ))); +int perf_debug_option (const struct option *opt,const char *str,int unset); +#endif /* __PERF_DEBUG_H */ tools/perf/util/probe-finder.c +0
-1@@ -26,7 +26,6 @@#include <errno.h> #include <stdio.h> #include <unistd.h> -#include <getopt.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> tools/perf/util/trace-event-read.c +0
-1@@ -22,7 +22,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <getopt.h> #include <stdarg.h> #include <sys/types.h> #include <sys/stat.h>
Re: [PATCH 4/4] perf tools: Add --debug optionto set debug variable
Quoted 14 lines · Namhyung Kim
Hi Jiri,
Quoted 10 lines · Jiri Olsa
Adding --debug option as a way to setup debug variables. Starting with support for verbose, more will come.
It's possible to use it now with report command:
$ perf report --debug verbose $ perf report --debug verbose=2I'll need this support to add separated debug variable for ordered events change in order to separate debug output out of standard verbose stream.
Quoted 7 lines
Hmm.. okay. I think there'll be more users for this.
Quoted 2 lines
Also removing unneeded
getopt.hincludes.I guess Arnaldo wants to see it as a separate change ;-)
maybe ;-) I hit an issue with this by adding #include "parse-options.h" into debug.h ... we have a some name clashes with getopt.h
Quoted 8 lines
tools/perf/util/debug.c void trace_event(union perf_event *event) · line 112
Quoted 6 lines
tools/perf/util/debug.c +4
-0+static struct variables_t { +const char *name; +int *ptr; +} variables[] = {This is a too general name. How about
debug_variableordebug_domain?
debug_variable sounds good to me, will change
thanks,
jirka