Currently libtraceevent emits warning on unsupported event formats.
However it'd be better to see them only -v option is given. To do that,
it needs to override the warning() function which is used in the
libtracevent. Thus add set_warning_routine() same as set_die_routine()
and check the verbose flag in our warning routine.
Before:
# perf test 5
5: parse events tests :
Warning: [kvmmmu:kvm_mmu_get_page] bad op token {
Warning: [kvmmmu:kvm_mmu_sync_page] bad op token {
Warning: [kvmmmu:kvm_mmu_unsync_page] bad op token {
Warning: [kvmmmu:kvm_mmu_prepare_zap_page] bad op token {
Warning: [kvmmmu:fast_page_fault] function is_writable_pte not defined
...
Ok
After:
# perf test 5
5: parse events tests : Ok
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1445268229-1601-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
#include <api/fs/fs.h>
#include "tests.h"
#include "debug.h"
+#include "util.h"
#include <linux/hw_breakpoint.h>
#include <api/fs/fs.h>
return ret;
}
+static void debug_warn(const char *warn, va_list params)
+{
+ char msg[1024];
+
+ if (!verbose)
+ return;
+
+ vsnprintf(msg, sizeof(msg), warn, params);
+ fprintf(stderr, " Warning: %s\n", msg);
+}
+
int test__parse_events(void)
{
int ret1, ret2 = 0;
ret2 = ret1; \
} while (0)
+ set_warning_routine(debug_warn);
+
TEST_EVENTS(test__events);
if (test_pmu())
die_routine = routine;
}
+void set_warning_routine(void (*routine)(const char *err, va_list params))
+{
+ warn_routine = routine;
+}
+
void usage(const char *err)
{
usage_routine(err);
extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN);
+extern void set_warning_routine(void (*routine)(const char *err, va_list params));
extern int prefixcmp(const char *str, const char *prefix);
extern void set_buildid_dir(const char *dir);