* [PATCH 1/5] perf tools: Remove verbose from functions prototypes
2014-07-14 21:46 [PATCHv2 0/4] perf tools: Add support for more debug variables Jiri Olsa
@ 2014-07-14 21:46 ` Jiri Olsa
2014-07-18 4:27 ` [tip:perf/core] " tip-bot for Jiri Olsa
2014-07-14 21:46 ` [PATCH 2/5] perf tools: Move pr_* debug macros into debug object Jiri Olsa
` (3 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Jiri Olsa @ 2014-07-14 21:46 UTC (permalink / raw)
To: linux-kernel
Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras,
Peter Zijlstra
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.
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
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(-)
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 90122abd3721..40af0acb4fe9 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -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);
}
}
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 25c571f4cba6..49f5f37e0fe3 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -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);
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 7758c72522ef..b57d49a6fef3 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -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);
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 2fde0d5e40b5..200f499293ca 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -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);
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [tip:perf/core] perf tools: Remove verbose from functions prototypes
2014-07-14 21:46 ` [PATCH 1/5] perf tools: Remove verbose from functions prototypes Jiri Olsa
@ 2014-07-18 4:27 ` tip-bot for Jiri Olsa
0 siblings, 0 replies; 16+ messages in thread
From: tip-bot for Jiri Olsa @ 2014-07-18 4:27 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, paulus, hpa, mingo, jolsa, a.p.zijlstra,
namhyung, fweisbec, dsahern, tglx, cjashfor
Commit-ID: acebd408bef17169fbf79079b96f0264b535916c
Gitweb: http://git.kernel.org/tip/acebd408bef17169fbf79079b96f0264b535916c
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 14 Jul 2014 23:46:47 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 17 Jul 2014 11:04:42 -0300
perf tools: Remove verbose from functions prototypes
And use verbose as an global object in following functions:
__map_groups__fprintf_maps
__map_groups__fprintf_removed_maps
map_groups__fprintf_maps
map_groups__fprintf
Also making map_groups__fprintf_maps static.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1405374411-29012-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
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(-)
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 90122ab..40af0ac 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -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);
}
}
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 7af1480..845f627 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -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] = {
@@ -568,8 +569,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;
@@ -587,17 +588,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;
@@ -614,23 +614,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);
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 5806a90..22d13a2 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -142,8 +142,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);
@@ -153,8 +153,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);
@@ -211,7 +210,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);
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index b9c36ef..9692c06 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -129,12 +129,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);
}
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/5] perf tools: Move pr_* debug macros into debug object
2014-07-14 21:46 [PATCHv2 0/4] perf tools: Add support for more debug variables Jiri Olsa
2014-07-14 21:46 ` [PATCH 1/5] perf tools: Remove verbose from functions prototypes Jiri Olsa
@ 2014-07-14 21:46 ` Jiri Olsa
2014-07-17 14:07 ` Arnaldo Carvalho de Melo
2014-07-18 4:27 ` [tip:perf/core] " tip-bot for Jiri Olsa
2014-07-14 21:46 ` [PATCH 3/5] perf tools: Factor eprintf to allow different debug variables Jiri Olsa
` (2 subsequent siblings)
4 siblings, 2 replies; 16+ messages in thread
From: Jiri Olsa @ 2014-07-14 21:46 UTC (permalink / raw)
To: linux-kernel
Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras,
Peter Zijlstra
Moving 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.
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
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(-)
diff --git a/tools/perf/arch/x86/tests/dwarf-unwind.c b/tools/perf/arch/x86/tests/dwarf-unwind.c
index 9f89f899ccc7..d8bbf7ad1681 100644
--- a/tools/perf/arch/x86/tests/dwarf-unwind.c
+++ b/tools/perf/arch/x86/tests/dwarf-unwind.c
@@ -3,6 +3,7 @@
#include "thread.h"
#include "map.h"
#include "event.h"
+#include "debug.h"
#include "tests/tests.h"
#define STACK_SIZE 8192
diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c b/tools/perf/arch/x86/util/unwind-libunwind.c
index 3261f68c6a7c..db25e93d989c 100644
--- a/tools/perf/arch/x86/util/unwind-libunwind.c
+++ b/tools/perf/arch/x86/util/unwind-libunwind.c
@@ -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)
diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
index c99e0de7e54a..66e12f55c052 100644
--- a/tools/perf/builtin-evlist.c
+++ b/tools/perf/builtin-evlist.c
@@ -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)
{
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 178b88ae3d2f..0384d930480b 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -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;
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 04c9c53becad..2f1a5220c090 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -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
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c
index 630808cd7cc2..caaf37f079b1 100644
--- a/tools/perf/tests/dso-data.c
+++ b/tools/perf/tests/dso-data.c
@@ -10,6 +10,7 @@
#include "machine.h"
#include "symbol.h"
#include "tests.h"
+#include "debug.h"
static char *test_file(int size)
{
diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c
index 465cdbc345cf..b8d8341b383e 100644
--- a/tools/perf/tests/evsel-roundtrip-name.c
+++ b/tools/perf/tests/evsel-roundtrip-name.c
@@ -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)
{
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
index 35d7fdb2328d..52162425c969 100644
--- a/tools/perf/tests/evsel-tp-sched.c
+++ b/tools/perf/tests/evsel-tp-sched.c
@@ -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)
diff --git a/tools/perf/tests/open-syscall-tp-fields.c b/tools/perf/tests/open-syscall-tp-fields.c
index c505ef2af245..0785b64ffd6c 100644
--- a/tools/perf/tests/open-syscall-tp-fields.c
+++ b/tools/perf/tests/open-syscall-tp-fields.c
@@ -3,6 +3,7 @@
#include "evsel.h"
#include "thread_map.h"
#include "tests.h"
+#include "debug.h"
int test__syscall_open_tp_fields(void)
{
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index deba66955f8c..5941927a4b7f 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -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 | \
diff --git a/tools/perf/tests/parse-no-sample-id-all.c b/tools/perf/tests/parse-no-sample-id-all.c
index 905019f9b740..2c63ea658541 100644
--- a/tools/perf/tests/parse-no-sample-id-all.c
+++ b/tools/perf/tests/parse-no-sample-id-all.c
@@ -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)
{
diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c
index 7ae8d17db3d9..ca292f9a4ae2 100644
--- a/tools/perf/tests/sample-parsing.c
+++ b/tools/perf/tests/sample-parsing.c
@@ -4,6 +4,7 @@
#include "util.h"
#include "event.h"
#include "evsel.h"
+#include "debug.h"
#include "tests.h"
diff --git a/tools/perf/tests/thread-mg-share.c b/tools/perf/tests/thread-mg-share.c
index 2b2e0dbe114f..b028499dd3cf 100644
--- a/tools/perf/tests/thread-mg-share.c
+++ b/tools/perf/tests/thread-mg-share.c
@@ -2,6 +2,7 @@
#include "machine.h"
#include "thread.h"
#include "map.h"
+#include "debug.h"
int test__thread_mg_share(void)
{
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index 55de44ecebef..34cc8fe8852b 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -7,6 +7,7 @@
#include "data.h"
#include "util.h"
+#include "debug.h"
static bool check_pipe(struct perf_data_file *file)
{
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index 443694c36b03..8a8ceb3ccde9 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -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 */
diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h
index 9844c31b7c2b..09e8e7aea7c6 100644
--- a/tools/perf/util/include/linux/kernel.h
+++ b/tools/perf/util/include/linux/kernel.h
@@ -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
diff --git a/tools/perf/util/pstack.c b/tools/perf/util/pstack.c
index daa17aeb6c63..a126e6cc6e73 100644
--- a/tools/perf/util/pstack.c
+++ b/tools/perf/util/pstack.c
@@ -6,6 +6,7 @@
#include "util.h"
#include "pstack.h"
+#include "debug.h"
#include <linux/kernel.h>
#include <stdlib.h>
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index af7da565a750..b2dba9c0a3a1 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -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);
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index 7e6fcfe8b438..a92d2437f3ee 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -40,6 +40,7 @@
#include "trace-event.h"
#include <api/fs/debugfs.h>
#include "evsel.h"
+#include "debug.h"
#define VERSION "0.5"
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
index e113e180c48f..ea3fd7fc6f5c 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -36,6 +36,7 @@
#include "../perf.h"
#include "util.h"
#include "trace-event.h"
+#include "debug.h"
static int input_fd;
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index 25578b98f5c5..92b56db52471 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -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,
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 95aefa78bb07..7d9a1e97ce8c 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -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
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c
index 0ddb3b8a89ec..290582452da3 100644
--- a/tools/perf/util/vdso.c
+++ b/tools/perf/util/vdso.c
@@ -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";
--
1.8.3.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 2/5] perf tools: Move pr_* debug macros into debug object
2014-07-14 21:46 ` [PATCH 2/5] perf tools: Move pr_* debug macros into debug object Jiri Olsa
@ 2014-07-17 14:07 ` Arnaldo Carvalho de Melo
2014-07-18 4:27 ` [tip:perf/core] " tip-bot for Jiri Olsa
1 sibling, 0 replies; 16+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-07-17 14:07 UTC (permalink / raw)
To: Jiri Olsa
Cc: linux-kernel, Corey Ashford, David Ahern, Frederic Weisbecker,
Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra
Em Mon, Jul 14, 2014 at 11:46:48PM +0200, Jiri Olsa escreveu:
> Moving 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.
CC /home/acme/git/build/perf/ui/gtk/util.o
util/scripting-engines/trace-event-python.c: In function ‘python_process_callchain’:
util/scripting-engines/trace-event-python.c:299:3: error: implicit declaration of function ‘pr_err’ [-Werror=implicit-function-declaration]
util/scripting-engines/trace-event-python.c:299:3: error: nested extern declaration of ‘pr_err’ [-Werror=nested-externs]
cc1: all warnings being treated as errors
make[1]: *** [/home/acme/git/build/perf/util/scripting-engines/trace-event-python.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [install] Error 2
make: Leaving directory `/home/acme/git/linux/tools/perf'
[acme@ssdandy linux]$
Nevermind, I'll fix it.
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> 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(-)
>
> diff --git a/tools/perf/arch/x86/tests/dwarf-unwind.c b/tools/perf/arch/x86/tests/dwarf-unwind.c
> index 9f89f899ccc7..d8bbf7ad1681 100644
> --- a/tools/perf/arch/x86/tests/dwarf-unwind.c
> +++ b/tools/perf/arch/x86/tests/dwarf-unwind.c
> @@ -3,6 +3,7 @@
> #include "thread.h"
> #include "map.h"
> #include "event.h"
> +#include "debug.h"
> #include "tests/tests.h"
>
> #define STACK_SIZE 8192
> diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c b/tools/perf/arch/x86/util/unwind-libunwind.c
> index 3261f68c6a7c..db25e93d989c 100644
> --- a/tools/perf/arch/x86/util/unwind-libunwind.c
> +++ b/tools/perf/arch/x86/util/unwind-libunwind.c
> @@ -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)
> diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
> index c99e0de7e54a..66e12f55c052 100644
> --- a/tools/perf/builtin-evlist.c
> +++ b/tools/perf/builtin-evlist.c
> @@ -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)
> {
> diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
> index 178b88ae3d2f..0384d930480b 100644
> --- a/tools/perf/builtin-help.c
> +++ b/tools/perf/builtin-help.c
> @@ -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;
> diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
> index 04c9c53becad..2f1a5220c090 100644
> --- a/tools/perf/builtin-timechart.c
> +++ b/tools/perf/builtin-timechart.c
> @@ -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
> diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c
> index 630808cd7cc2..caaf37f079b1 100644
> --- a/tools/perf/tests/dso-data.c
> +++ b/tools/perf/tests/dso-data.c
> @@ -10,6 +10,7 @@
> #include "machine.h"
> #include "symbol.h"
> #include "tests.h"
> +#include "debug.h"
>
> static char *test_file(int size)
> {
> diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c
> index 465cdbc345cf..b8d8341b383e 100644
> --- a/tools/perf/tests/evsel-roundtrip-name.c
> +++ b/tools/perf/tests/evsel-roundtrip-name.c
> @@ -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)
> {
> diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
> index 35d7fdb2328d..52162425c969 100644
> --- a/tools/perf/tests/evsel-tp-sched.c
> +++ b/tools/perf/tests/evsel-tp-sched.c
> @@ -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)
> diff --git a/tools/perf/tests/open-syscall-tp-fields.c b/tools/perf/tests/open-syscall-tp-fields.c
> index c505ef2af245..0785b64ffd6c 100644
> --- a/tools/perf/tests/open-syscall-tp-fields.c
> +++ b/tools/perf/tests/open-syscall-tp-fields.c
> @@ -3,6 +3,7 @@
> #include "evsel.h"
> #include "thread_map.h"
> #include "tests.h"
> +#include "debug.h"
>
> int test__syscall_open_tp_fields(void)
> {
> diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
> index deba66955f8c..5941927a4b7f 100644
> --- a/tools/perf/tests/parse-events.c
> +++ b/tools/perf/tests/parse-events.c
> @@ -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 | \
> diff --git a/tools/perf/tests/parse-no-sample-id-all.c b/tools/perf/tests/parse-no-sample-id-all.c
> index 905019f9b740..2c63ea658541 100644
> --- a/tools/perf/tests/parse-no-sample-id-all.c
> +++ b/tools/perf/tests/parse-no-sample-id-all.c
> @@ -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)
> {
> diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c
> index 7ae8d17db3d9..ca292f9a4ae2 100644
> --- a/tools/perf/tests/sample-parsing.c
> +++ b/tools/perf/tests/sample-parsing.c
> @@ -4,6 +4,7 @@
> #include "util.h"
> #include "event.h"
> #include "evsel.h"
> +#include "debug.h"
>
> #include "tests.h"
>
> diff --git a/tools/perf/tests/thread-mg-share.c b/tools/perf/tests/thread-mg-share.c
> index 2b2e0dbe114f..b028499dd3cf 100644
> --- a/tools/perf/tests/thread-mg-share.c
> +++ b/tools/perf/tests/thread-mg-share.c
> @@ -2,6 +2,7 @@
> #include "machine.h"
> #include "thread.h"
> #include "map.h"
> +#include "debug.h"
>
> int test__thread_mg_share(void)
> {
> diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
> index 55de44ecebef..34cc8fe8852b 100644
> --- a/tools/perf/util/data.c
> +++ b/tools/perf/util/data.c
> @@ -7,6 +7,7 @@
>
> #include "data.h"
> #include "util.h"
> +#include "debug.h"
>
> static bool check_pipe(struct perf_data_file *file)
> {
> diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
> index 443694c36b03..8a8ceb3ccde9 100644
> --- a/tools/perf/util/debug.h
> +++ b/tools/perf/util/debug.h
> @@ -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 */
> diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h
> index 9844c31b7c2b..09e8e7aea7c6 100644
> --- a/tools/perf/util/include/linux/kernel.h
> +++ b/tools/perf/util/include/linux/kernel.h
> @@ -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
> diff --git a/tools/perf/util/pstack.c b/tools/perf/util/pstack.c
> index daa17aeb6c63..a126e6cc6e73 100644
> --- a/tools/perf/util/pstack.c
> +++ b/tools/perf/util/pstack.c
> @@ -6,6 +6,7 @@
>
> #include "util.h"
> #include "pstack.h"
> +#include "debug.h"
> #include <linux/kernel.h>
> #include <stdlib.h>
>
> diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
> index af7da565a750..b2dba9c0a3a1 100644
> --- a/tools/perf/util/scripting-engines/trace-event-perl.c
> +++ b/tools/perf/util/scripting-engines/trace-event-perl.c
> @@ -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);
> diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
> index 7e6fcfe8b438..a92d2437f3ee 100644
> --- a/tools/perf/util/trace-event-info.c
> +++ b/tools/perf/util/trace-event-info.c
> @@ -40,6 +40,7 @@
> #include "trace-event.h"
> #include <api/fs/debugfs.h>
> #include "evsel.h"
> +#include "debug.h"
>
> #define VERSION "0.5"
>
> diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
> index e113e180c48f..ea3fd7fc6f5c 100644
> --- a/tools/perf/util/trace-event-read.c
> +++ b/tools/perf/util/trace-event-read.c
> @@ -36,6 +36,7 @@
> #include "../perf.h"
> #include "util.h"
> #include "trace-event.h"
> +#include "debug.h"
>
> static int input_fd;
>
> diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
> index 25578b98f5c5..92b56db52471 100644
> --- a/tools/perf/util/unwind-libunwind.c
> +++ b/tools/perf/util/unwind-libunwind.c
> @@ -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,
> diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
> index 95aefa78bb07..7d9a1e97ce8c 100644
> --- a/tools/perf/util/util.c
> +++ b/tools/perf/util/util.c
> @@ -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
> diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c
> index 0ddb3b8a89ec..290582452da3 100644
> --- a/tools/perf/util/vdso.c
> +++ b/tools/perf/util/vdso.c
> @@ -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";
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [tip:perf/core] perf tools: Move pr_* debug macros into debug object
2014-07-14 21:46 ` [PATCH 2/5] perf tools: Move pr_* debug macros into debug object Jiri Olsa
2014-07-17 14:07 ` Arnaldo Carvalho de Melo
@ 2014-07-18 4:27 ` tip-bot for Jiri Olsa
1 sibling, 0 replies; 16+ messages in thread
From: tip-bot for Jiri Olsa @ 2014-07-18 4:27 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, paulus, hpa, mingo, jolsa, a.p.zijlstra,
namhyung, fweisbec, dsahern, tglx, cjashfor
Commit-ID: 84f5d36f486609277801e827241396334185d11c
Gitweb: http://git.kernel.org/tip/84f5d36f486609277801e827241396334185d11c
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 14 Jul 2014 23:46:48 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 17 Jul 2014 12:58:39 -0300
perf tools: Move pr_* debug macros into debug object
Moving 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.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1405374411-29012-3-git-send-email-jolsa@kernel.org
[ Add missing debug.h include in python scripting glue and in the libdw unwind lib ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
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 +
.../util/scripting-engines/trace-event-python.c | 1 +
tools/perf/util/trace-event-info.c | 1 +
tools/perf/util/trace-event-read.c | 1 +
tools/perf/util/unwind-libdw.c | 1 +
tools/perf/util/unwind-libunwind.c | 1 +
tools/perf/util/util.c | 1 +
tools/perf/util/vdso.c | 1 +
25 files changed, 43 insertions(+), 21 deletions(-)
diff --git a/tools/perf/arch/x86/tests/dwarf-unwind.c b/tools/perf/arch/x86/tests/dwarf-unwind.c
index 9f89f89..d8bbf7a 100644
--- a/tools/perf/arch/x86/tests/dwarf-unwind.c
+++ b/tools/perf/arch/x86/tests/dwarf-unwind.c
@@ -3,6 +3,7 @@
#include "thread.h"
#include "map.h"
#include "event.h"
+#include "debug.h"
#include "tests/tests.h"
#define STACK_SIZE 8192
diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c b/tools/perf/arch/x86/util/unwind-libunwind.c
index 3261f68..db25e93 100644
--- a/tools/perf/arch/x86/util/unwind-libunwind.c
+++ b/tools/perf/arch/x86/util/unwind-libunwind.c
@@ -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)
diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
index c99e0de..66e12f5 100644
--- a/tools/perf/builtin-evlist.c
+++ b/tools/perf/builtin-evlist.c
@@ -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)
{
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 178b88a..0384d93 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -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;
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 04c9c53..2f1a522 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -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
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c
index 630808c..caaf37f 100644
--- a/tools/perf/tests/dso-data.c
+++ b/tools/perf/tests/dso-data.c
@@ -10,6 +10,7 @@
#include "machine.h"
#include "symbol.h"
#include "tests.h"
+#include "debug.h"
static char *test_file(int size)
{
diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c
index 465cdbc..b8d8341 100644
--- a/tools/perf/tests/evsel-roundtrip-name.c
+++ b/tools/perf/tests/evsel-roundtrip-name.c
@@ -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)
{
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
index 35d7fdb..5216242 100644
--- a/tools/perf/tests/evsel-tp-sched.c
+++ b/tools/perf/tests/evsel-tp-sched.c
@@ -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)
diff --git a/tools/perf/tests/open-syscall-tp-fields.c b/tools/perf/tests/open-syscall-tp-fields.c
index c505ef2..0785b64 100644
--- a/tools/perf/tests/open-syscall-tp-fields.c
+++ b/tools/perf/tests/open-syscall-tp-fields.c
@@ -3,6 +3,7 @@
#include "evsel.h"
#include "thread_map.h"
#include "tests.h"
+#include "debug.h"
int test__syscall_open_tp_fields(void)
{
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index deba669..5941927 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -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 | \
diff --git a/tools/perf/tests/parse-no-sample-id-all.c b/tools/perf/tests/parse-no-sample-id-all.c
index 905019f..2c63ea6 100644
--- a/tools/perf/tests/parse-no-sample-id-all.c
+++ b/tools/perf/tests/parse-no-sample-id-all.c
@@ -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)
{
diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c
index 7ae8d17..ca292f9 100644
--- a/tools/perf/tests/sample-parsing.c
+++ b/tools/perf/tests/sample-parsing.c
@@ -4,6 +4,7 @@
#include "util.h"
#include "event.h"
#include "evsel.h"
+#include "debug.h"
#include "tests.h"
diff --git a/tools/perf/tests/thread-mg-share.c b/tools/perf/tests/thread-mg-share.c
index 2b2e0db..b028499 100644
--- a/tools/perf/tests/thread-mg-share.c
+++ b/tools/perf/tests/thread-mg-share.c
@@ -2,6 +2,7 @@
#include "machine.h"
#include "thread.h"
#include "map.h"
+#include "debug.h"
int test__thread_mg_share(void)
{
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index ee370a7f..29d720c 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -7,6 +7,7 @@
#include "data.h"
#include "util.h"
+#include "debug.h"
static bool check_pipe(struct perf_data_file *file)
{
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index 443694c..8a8ceb3 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -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 */
diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h
index 9844c31..09e8e7a 100644
--- a/tools/perf/util/include/linux/kernel.h
+++ b/tools/perf/util/include/linux/kernel.h
@@ -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
diff --git a/tools/perf/util/pstack.c b/tools/perf/util/pstack.c
index daa17ae..a126e6c 100644
--- a/tools/perf/util/pstack.c
+++ b/tools/perf/util/pstack.c
@@ -6,6 +6,7 @@
#include "util.h"
#include "pstack.h"
+#include "debug.h"
#include <linux/kernel.h>
#include <stdlib.h>
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index af7da56..b2dba9c 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -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);
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index b366b48..cbce254 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -27,6 +27,7 @@
#include <errno.h>
#include "../../perf.h"
+#include "../debug.h"
#include "../evsel.h"
#include "../util.h"
#include "../event.h"
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index c3bba88..eb72716 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -40,6 +40,7 @@
#include "trace-event.h"
#include <api/fs/debugfs.h>
#include "evsel.h"
+#include "debug.h"
#define VERSION "0.5"
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
index e113e18..ea3fd7f 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -36,6 +36,7 @@
#include "../perf.h"
#include "util.h"
#include "trace-event.h"
+#include "debug.h"
static int input_fd;
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index 5ec80a5..7419768 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -3,6 +3,7 @@
#include <elfutils/libdwfl.h>
#include <inttypes.h>
#include <errno.h>
+#include "debug.h"
#include "unwind.h"
#include "unwind-libdw.h"
#include "machine.h"
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index 25578b9..92b56db 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -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,
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index e4132ae..e52e746 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -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
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c
index 0ddb3b8..2905824 100644
--- a/tools/perf/util/vdso.c
+++ b/tools/perf/util/vdso.c
@@ -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";
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/5] perf tools: Factor eprintf to allow different debug variables
2014-07-14 21:46 [PATCHv2 0/4] perf tools: Add support for more debug variables Jiri Olsa
2014-07-14 21:46 ` [PATCH 1/5] perf tools: Remove verbose from functions prototypes Jiri Olsa
2014-07-14 21:46 ` [PATCH 2/5] perf tools: Move pr_* debug macros into debug object Jiri Olsa
@ 2014-07-14 21:46 ` Jiri Olsa
2014-07-18 4:27 ` [tip:perf/core] " tip-bot for Jiri Olsa
2014-07-14 21:46 ` [PATCH 4/5] perf tools: Add --debug optionto set debug variable Jiri Olsa
2014-07-14 21:46 ` [PATCH 5/5] perf tools: Remove getopt.h includes Jiri Olsa
4 siblings, 1 reply; 16+ messages in thread
From: Jiri Olsa @ 2014-07-14 21:46 UTC (permalink / raw)
To: linux-kernel
Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras,
Peter Zijlstra
This way we can easily reuse current debug functions for
another debug variables other than verbose.
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
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(-)
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 299b55586502..c208d6f56e63 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -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, ...)
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index 8a8ceb3ccde9..1cb808123242 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -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 */
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 122669c18ff4..12aa9b0d0ba1 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -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);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [tip:perf/core] perf tools: Factor eprintf to allow different debug variables
2014-07-14 21:46 ` [PATCH 3/5] perf tools: Factor eprintf to allow different debug variables Jiri Olsa
@ 2014-07-18 4:27 ` tip-bot for Jiri Olsa
0 siblings, 0 replies; 16+ messages in thread
From: tip-bot for Jiri Olsa @ 2014-07-18 4:27 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, paulus, hpa, mingo, jolsa, a.p.zijlstra,
namhyung, fweisbec, dsahern, tglx, cjashfor
Commit-ID: c95688aac7723c17b2badc23233706b2f02e58ed
Gitweb: http://git.kernel.org/tip/c95688aac7723c17b2badc23233706b2f02e58ed
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 14 Jul 2014 23:46:49 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 17 Jul 2014 12:58:59 -0300
perf tools: Factor eprintf to allow different debug variables
This way we can easily reuse current debug functions for another debug
variables other than verbose.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1405374411-29012-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
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(-)
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 299b555..c208d6f 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -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, ...)
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index 8a8ceb3..1cb8081 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -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 */
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 122669c..12aa9b0 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -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);
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 4/5] perf tools: Add --debug optionto set debug variable
2014-07-14 21:46 [PATCHv2 0/4] perf tools: Add support for more debug variables Jiri Olsa
` (2 preceding siblings ...)
2014-07-14 21:46 ` [PATCH 3/5] perf tools: Factor eprintf to allow different debug variables Jiri Olsa
@ 2014-07-14 21:46 ` Jiri Olsa
2014-07-17 8:15 ` Namhyung Kim
2014-07-14 21:46 ` [PATCH 5/5] perf tools: Remove getopt.h includes Jiri Olsa
4 siblings, 1 reply; 16+ messages in thread
From: Jiri Olsa @ 2014-07-14 21:46 UTC (permalink / raw)
To: linux-kernel
Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras,
Peter Zijlstra
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 --debug verbose ...
$ perf --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.
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/Documentation/perf-report.txt | 6 +++++
tools/perf/Documentation/perf.txt | 10 +++++++-
tools/perf/perf.c | 13 +++++++++-
tools/perf/util/debug.c | 44 ++++++++++++++++++++++++++++++++
tools/perf/util/debug.h | 2 ++
5 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index d2b59af62bc0..53b6ad8e4d4d 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -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
diff --git a/tools/perf/Documentation/perf.txt b/tools/perf/Documentation/perf.txt
index 0eeb247dc7d2..c75a42822c53 100644
--- a/tools/perf/Documentation/perf.txt
+++ b/tools/perf/Documentation/perf.txt
@@ -8,7 +8,15 @@ perf - Performance analysis tools for Linux
SYNOPSIS
--------
[verse]
-'perf' [--version] [--help] COMMAND [ARGS]
+'perf' [--version] [--debug variable[=VALUE]] [--help] COMMAND [ARGS]
+
+OPTIONS
+-------
+--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
DESCRIPTION
-----------
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 95c58fc15284..eed3fb2a3af0 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -13,11 +13,12 @@
#include "util/quote.h"
#include "util/run-command.h"
#include "util/parse-events.h"
+#include "util/debug.h"
#include <api/fs/debugfs.h>
#include <pthread.h>
const char perf_usage_string[] =
- "perf [--version] [--help] COMMAND [ARGS]";
+ "perf [--version] [--debug variable[=VALUE]] [--help] COMMAND [ARGS]";
const char perf_more_info_string[] =
"See 'perf help COMMAND' for more information on a specific command.";
@@ -212,6 +213,16 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
printf("%s ", p->cmd);
}
exit(0);
+ } else if (!strcmp(cmd, "--debug")) {
+ if (*argc < 2) {
+ fprintf(stderr, "No variable specified for --debug.\n");
+ usage(perf_usage_string);
+ }
+ if (perf_debug_option((*argv)[1]))
+ usage(perf_usage_string);
+
+ (*argv)++;
+ (*argc)--;
} else {
fprintf(stderr, "Unknown option: %s\n", cmd);
usage(perf_usage_string);
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index c208d6f56e63..71d419362634 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -105,3 +105,47 @@ void trace_event(union perf_event *event)
}
printf(".\n");
}
+
+static struct debug_variable {
+ const char *name;
+ int *ptr;
+} debug_variables[] = {
+ { .name = "verbose", .ptr = &verbose },
+ { .name = NULL, }
+};
+
+int perf_debug_option(const char *str)
+{
+ struct debug_variable *var = &debug_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;
+}
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index 1cb808123242..89fb6b0f7ab2 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -39,4 +39,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 char *str);
+
#endif /* __PERF_DEBUG_H */
--
1.8.3.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 4/5] perf tools: Add --debug optionto set debug variable
2014-07-14 21:46 ` [PATCH 4/5] perf tools: Add --debug optionto set debug variable Jiri Olsa
@ 2014-07-17 8:15 ` Namhyung Kim
2014-07-17 10:55 ` [PATCHv3 " Jiri Olsa
0 siblings, 1 reply; 16+ messages in thread
From: Namhyung Kim @ 2014-07-17 8:15 UTC (permalink / raw)
To: Jiri Olsa
Cc: linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
David Ahern, Frederic Weisbecker, Ingo Molnar, Paul Mackerras,
Peter Zijlstra
Hi Jiri,
On Mon, 14 Jul 2014 23:46:50 +0200, Jiri Olsa wrote:
> 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 --debug verbose ...
> $ perf --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.
>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> tools/perf/Documentation/perf-report.txt | 6 +++++
> tools/perf/Documentation/perf.txt | 10 +++++++-
> tools/perf/perf.c | 13 +++++++++-
> tools/perf/util/debug.c | 44 ++++++++++++++++++++++++++++++++
> tools/perf/util/debug.h | 2 ++
> 5 files changed, 73 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
> index d2b59af62bc0..53b6ad8e4d4d 100644
> --- a/tools/perf/Documentation/perf-report.txt
> +++ b/tools/perf/Documentation/perf-report.txt
> @@ -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
> diff --git a/tools/perf/Documentation/perf.txt b/tools/perf/Documentation/perf.txt
> index 0eeb247dc7d2..c75a42822c53 100644
> --- a/tools/perf/Documentation/perf.txt
> +++ b/tools/perf/Documentation/perf.txt
> @@ -8,7 +8,15 @@ perf - Performance analysis tools for Linux
> SYNOPSIS
> --------
> [verse]
> -'perf' [--version] [--help] COMMAND [ARGS]
> +'perf' [--version] [--debug variable[=VALUE]] [--help] COMMAND [ARGS]
Hmm.. is this really needed? Also, there're other options might be
added here. What about just saying
'perf' [--version] [--help] [OPTIONS] COMMAND [ARGS]
?
Thanks,
Namhyung
> +
> +OPTIONS
> +-------
> +--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
>
> DESCRIPTION
> -----------
> diff --git a/tools/perf/perf.c b/tools/perf/perf.c
> index 95c58fc15284..eed3fb2a3af0 100644
> --- a/tools/perf/perf.c
> +++ b/tools/perf/perf.c
> @@ -13,11 +13,12 @@
> #include "util/quote.h"
> #include "util/run-command.h"
> #include "util/parse-events.h"
> +#include "util/debug.h"
> #include <api/fs/debugfs.h>
> #include <pthread.h>
>
> const char perf_usage_string[] =
> - "perf [--version] [--help] COMMAND [ARGS]";
> + "perf [--version] [--debug variable[=VALUE]] [--help] COMMAND [ARGS]";
>
> const char perf_more_info_string[] =
> "See 'perf help COMMAND' for more information on a specific command.";
> @@ -212,6 +213,16 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
> printf("%s ", p->cmd);
> }
> exit(0);
> + } else if (!strcmp(cmd, "--debug")) {
> + if (*argc < 2) {
> + fprintf(stderr, "No variable specified for --debug.\n");
> + usage(perf_usage_string);
> + }
> + if (perf_debug_option((*argv)[1]))
> + usage(perf_usage_string);
> +
> + (*argv)++;
> + (*argc)--;
> } else {
> fprintf(stderr, "Unknown option: %s\n", cmd);
> usage(perf_usage_string);
> diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
> index c208d6f56e63..71d419362634 100644
> --- a/tools/perf/util/debug.c
> +++ b/tools/perf/util/debug.c
> @@ -105,3 +105,47 @@ void trace_event(union perf_event *event)
> }
> printf(".\n");
> }
> +
> +static struct debug_variable {
> + const char *name;
> + int *ptr;
> +} debug_variables[] = {
> + { .name = "verbose", .ptr = &verbose },
> + { .name = NULL, }
> +};
> +
> +int perf_debug_option(const char *str)
> +{
> + struct debug_variable *var = &debug_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;
> +}
> diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
> index 1cb808123242..89fb6b0f7ab2 100644
> --- a/tools/perf/util/debug.h
> +++ b/tools/perf/util/debug.h
> @@ -39,4 +39,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 char *str);
> +
> #endif /* __PERF_DEBUG_H */
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCHv3 4/5] perf tools: Add --debug optionto set debug variable
2014-07-17 8:15 ` Namhyung Kim
@ 2014-07-17 10:55 ` Jiri Olsa
2014-07-18 4:28 ` [tip:perf/core] " tip-bot for Jiri Olsa
2014-07-18 5:04 ` [PATCHv3 4/5] " Namhyung Kim
0 siblings, 2 replies; 16+ messages in thread
From: Jiri Olsa @ 2014-07-17 10:55 UTC (permalink / raw)
To: Namhyung Kim
Cc: Jiri Olsa, linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
David Ahern, Frederic Weisbecker, Ingo Molnar, Paul Mackerras,
Peter Zijlstra
On Thu, Jul 17, 2014 at 05:15:49PM +0900, Namhyung Kim wrote:
SNIP
> > index 0eeb247dc7d2..c75a42822c53 100644
> > --- a/tools/perf/Documentation/perf.txt
> > +++ b/tools/perf/Documentation/perf.txt
> > @@ -8,7 +8,15 @@ perf - Performance analysis tools for Linux
> > SYNOPSIS
> > --------
> > [verse]
> > -'perf' [--version] [--help] COMMAND [ARGS]
> > +'perf' [--version] [--debug variable[=VALUE]] [--help] COMMAND [ARGS]
>
> Hmm.. is this really needed? Also, there're other options might be
> added here. What about just saying
>
> 'perf' [--version] [--help] [OPTIONS] COMMAND [ARGS]
>
> ?
>
yep, it's better, v3 attached
thanks,
jirka
---
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 --debug verbose ...
$ perf --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.
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/Documentation/perf.txt | 10 ++++++++-
tools/perf/perf.c | 13 +++++++++++-
tools/perf/util/debug.c | 44 +++++++++++++++++++++++++++++++++++++++
tools/perf/util/debug.h | 2 ++
4 files changed, 67 insertions(+), 2 deletions(-)
diff --git a/tools/perf/Documentation/perf.txt b/tools/perf/Documentation/perf.txt
index 0eeb247dc7d2..d240bb2e5b22 100644
--- a/tools/perf/Documentation/perf.txt
+++ b/tools/perf/Documentation/perf.txt
@@ -8,7 +8,15 @@ perf - Performance analysis tools for Linux
SYNOPSIS
--------
[verse]
-'perf' [--version] [--help] COMMAND [ARGS]
+'perf' [--version] [--help] [OPTIONS] COMMAND [ARGS]
+
+OPTIONS
+-------
+--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
DESCRIPTION
-----------
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 95c58fc15284..eed3fb2a3af0 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -13,11 +13,12 @@
#include "util/quote.h"
#include "util/run-command.h"
#include "util/parse-events.h"
+#include "util/debug.h"
#include <api/fs/debugfs.h>
#include <pthread.h>
const char perf_usage_string[] =
- "perf [--version] [--help] COMMAND [ARGS]";
+ "perf [--version] [--debug variable[=VALUE]] [--help] COMMAND [ARGS]";
const char perf_more_info_string[] =
"See 'perf help COMMAND' for more information on a specific command.";
@@ -212,6 +213,16 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
printf("%s ", p->cmd);
}
exit(0);
+ } else if (!strcmp(cmd, "--debug")) {
+ if (*argc < 2) {
+ fprintf(stderr, "No variable specified for --debug.\n");
+ usage(perf_usage_string);
+ }
+ if (perf_debug_option((*argv)[1]))
+ usage(perf_usage_string);
+
+ (*argv)++;
+ (*argc)--;
} else {
fprintf(stderr, "Unknown option: %s\n", cmd);
usage(perf_usage_string);
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index c208d6f56e63..71d419362634 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -105,3 +105,47 @@ void trace_event(union perf_event *event)
}
printf(".\n");
}
+
+static struct debug_variable {
+ const char *name;
+ int *ptr;
+} debug_variables[] = {
+ { .name = "verbose", .ptr = &verbose },
+ { .name = NULL, }
+};
+
+int perf_debug_option(const char *str)
+{
+ struct debug_variable *var = &debug_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;
+}
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index 1cb808123242..89fb6b0f7ab2 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -39,4 +39,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 char *str);
+
#endif /* __PERF_DEBUG_H */
--
1.8.3.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [tip:perf/core] perf tools: Add --debug optionto set debug variable
2014-07-17 10:55 ` [PATCHv3 " Jiri Olsa
@ 2014-07-18 4:28 ` tip-bot for Jiri Olsa
2014-07-18 5:04 ` [PATCHv3 4/5] " Namhyung Kim
1 sibling, 0 replies; 16+ messages in thread
From: tip-bot for Jiri Olsa @ 2014-07-18 4:28 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, paulus, hpa, mingo, jolsa, a.p.zijlstra,
namhyung, namhyung, jolsa, fweisbec, dsahern, tglx, cjashfor
Commit-ID: bbb2cea7e8dd496b41558df1a0ec9205497b7ebf
Gitweb: http://git.kernel.org/tip/bbb2cea7e8dd496b41558df1a0ec9205497b7ebf
Author: Jiri Olsa <jolsa@redhat.com>
AuthorDate: Thu, 17 Jul 2014 12:55:00 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 17 Jul 2014 12:58:59 -0300
perf tools: Add --debug optionto set debug variable
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 --debug verbose ...
$ perf --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.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20140717105500.GG516@krava.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Documentation/perf.txt | 10 ++++++++-
tools/perf/perf.c | 13 +++++++++++-
tools/perf/util/debug.c | 44 +++++++++++++++++++++++++++++++++++++++
tools/perf/util/debug.h | 2 ++
4 files changed, 67 insertions(+), 2 deletions(-)
diff --git a/tools/perf/Documentation/perf.txt b/tools/perf/Documentation/perf.txt
index 0eeb247..d240bb2 100644
--- a/tools/perf/Documentation/perf.txt
+++ b/tools/perf/Documentation/perf.txt
@@ -8,7 +8,15 @@ perf - Performance analysis tools for Linux
SYNOPSIS
--------
[verse]
-'perf' [--version] [--help] COMMAND [ARGS]
+'perf' [--version] [--help] [OPTIONS] COMMAND [ARGS]
+
+OPTIONS
+-------
+--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
DESCRIPTION
-----------
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 95c58fc..eed3fb2 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -13,11 +13,12 @@
#include "util/quote.h"
#include "util/run-command.h"
#include "util/parse-events.h"
+#include "util/debug.h"
#include <api/fs/debugfs.h>
#include <pthread.h>
const char perf_usage_string[] =
- "perf [--version] [--help] COMMAND [ARGS]";
+ "perf [--version] [--debug variable[=VALUE]] [--help] COMMAND [ARGS]";
const char perf_more_info_string[] =
"See 'perf help COMMAND' for more information on a specific command.";
@@ -212,6 +213,16 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
printf("%s ", p->cmd);
}
exit(0);
+ } else if (!strcmp(cmd, "--debug")) {
+ if (*argc < 2) {
+ fprintf(stderr, "No variable specified for --debug.\n");
+ usage(perf_usage_string);
+ }
+ if (perf_debug_option((*argv)[1]))
+ usage(perf_usage_string);
+
+ (*argv)++;
+ (*argc)--;
} else {
fprintf(stderr, "Unknown option: %s\n", cmd);
usage(perf_usage_string);
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index c208d6f..71d4193 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -105,3 +105,47 @@ void trace_event(union perf_event *event)
}
printf(".\n");
}
+
+static struct debug_variable {
+ const char *name;
+ int *ptr;
+} debug_variables[] = {
+ { .name = "verbose", .ptr = &verbose },
+ { .name = NULL, }
+};
+
+int perf_debug_option(const char *str)
+{
+ struct debug_variable *var = &debug_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;
+}
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index 1cb8081..89fb6b0 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -39,4 +39,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 char *str);
+
#endif /* __PERF_DEBUG_H */
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCHv3 4/5] perf tools: Add --debug optionto set debug variable
2014-07-17 10:55 ` [PATCHv3 " Jiri Olsa
2014-07-18 4:28 ` [tip:perf/core] " tip-bot for Jiri Olsa
@ 2014-07-18 5:04 ` Namhyung Kim
2014-07-18 6:57 ` Jiri Olsa
1 sibling, 1 reply; 16+ messages in thread
From: Namhyung Kim @ 2014-07-18 5:04 UTC (permalink / raw)
To: Jiri Olsa
Cc: Jiri Olsa, linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
David Ahern, Frederic Weisbecker, Ingo Molnar, Paul Mackerras,
Peter Zijlstra
Hi Jiri,
On Thu, 17 Jul 2014 12:55:00 +0200, Jiri Olsa wrote:
> yep, it's better, v3 attached
[SNIP]
> --- a/tools/perf/Documentation/perf.txt
> +++ b/tools/perf/Documentation/perf.txt
> @@ -8,7 +8,15 @@ perf - Performance analysis tools for Linux
> SYNOPSIS
> --------
> [verse]
> -'perf' [--version] [--help] COMMAND [ARGS]
> +'perf' [--version] [--help] [OPTIONS] COMMAND [ARGS]
> +
> +OPTIONS
> +-------
> +--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
>
> DESCRIPTION
> -----------
> diff --git a/tools/perf/perf.c b/tools/perf/perf.c
> index 95c58fc15284..eed3fb2a3af0 100644
> --- a/tools/perf/perf.c
> +++ b/tools/perf/perf.c
> @@ -13,11 +13,12 @@
> #include "util/quote.h"
> #include "util/run-command.h"
> #include "util/parse-events.h"
> +#include "util/debug.h"
> #include <api/fs/debugfs.h>
> #include <pthread.h>
>
> const char perf_usage_string[] =
> - "perf [--version] [--help] COMMAND [ARGS]";
> + "perf [--version] [--debug variable[=VALUE]] [--help] COMMAND [ARGS]";
You missed to update here.. ;-)
Thanks,
Namhyung
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCHv3 4/5] perf tools: Add --debug optionto set debug variable
2014-07-18 5:04 ` [PATCHv3 4/5] " Namhyung Kim
@ 2014-07-18 6:57 ` Jiri Olsa
0 siblings, 0 replies; 16+ messages in thread
From: Jiri Olsa @ 2014-07-18 6:57 UTC (permalink / raw)
To: Namhyung Kim
Cc: Jiri Olsa, linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
David Ahern, Frederic Weisbecker, Ingo Molnar, Paul Mackerras,
Peter Zijlstra
On Fri, Jul 18, 2014 at 02:04:51PM +0900, Namhyung Kim wrote:
SNIP
> > #include "util/quote.h"
> > #include "util/run-command.h"
> > #include "util/parse-events.h"
> > +#include "util/debug.h"
> > #include <api/fs/debugfs.h>
> > #include <pthread.h>
> >
> > const char perf_usage_string[] =
> > - "perf [--version] [--help] COMMAND [ARGS]";
> > + "perf [--version] [--debug variable[=VALUE]] [--help] COMMAND [ARGS]";
>
> You missed to update here.. ;-)
ouch, I'll fix that in following patchset
thanks,
jirka
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 5/5] perf tools: Remove getopt.h includes
2014-07-14 21:46 [PATCHv2 0/4] perf tools: Add support for more debug variables Jiri Olsa
` (3 preceding siblings ...)
2014-07-14 21:46 ` [PATCH 4/5] perf tools: Add --debug optionto set debug variable Jiri Olsa
@ 2014-07-14 21:46 ` Jiri Olsa
2014-07-18 4:28 ` [tip:perf/core] perf tools: Remove needless " tip-bot for Jiri Olsa
4 siblings, 1 reply; 16+ messages in thread
From: Jiri Olsa @ 2014-07-14 21:46 UTC (permalink / raw)
To: linux-kernel
Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras,
Peter Zijlstra
We don't use getopt.h interfaces.
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/probe-finder.c | 1 -
tools/perf/util/trace-event-read.c | 1 -
2 files changed, 2 deletions(-)
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 98e304766416..dca9145d704c 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -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>
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
index ea3fd7fc6f5c..54d9e9b548a8 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -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>
--
1.8.3.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [tip:perf/core] perf tools: Remove needless getopt.h includes
2014-07-14 21:46 ` [PATCH 5/5] perf tools: Remove getopt.h includes Jiri Olsa
@ 2014-07-18 4:28 ` tip-bot for Jiri Olsa
0 siblings, 0 replies; 16+ messages in thread
From: tip-bot for Jiri Olsa @ 2014-07-18 4:28 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, paulus, hpa, mingo, jolsa, a.p.zijlstra,
namhyung, fweisbec, dsahern, tglx, cjashfor
Commit-ID: ff527bccd469067a64f4ae9747b9045914667d34
Gitweb: http://git.kernel.org/tip/ff527bccd469067a64f4ae9747b9045914667d34
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 14 Jul 2014 23:46:51 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 17 Jul 2014 12:59:00 -0300
perf tools: Remove needless getopt.h includes
We don't use getopt.h interfaces.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1405374411-29012-6-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-finder.c | 1 -
tools/perf/util/trace-event-read.c | 1 -
2 files changed, 2 deletions(-)
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 98e3047..dca9145 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -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>
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
index ea3fd7f..54d9e9b 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -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>
^ permalink raw reply related [flat|nested] 16+ messages in thread