diff options
Diffstat (limited to 'tools/perf/util/debug.c')
-rw-r--r-- | tools/perf/util/debug.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 71d419362634..ba357f3226c6 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c | |||
@@ -13,8 +13,12 @@ | |||
13 | #include "util.h" | 13 | #include "util.h" |
14 | #include "target.h" | 14 | #include "target.h" |
15 | 15 | ||
16 | #define NSECS_PER_SEC 1000000000ULL | ||
17 | #define NSECS_PER_USEC 1000ULL | ||
18 | |||
16 | int verbose; | 19 | int verbose; |
17 | bool dump_trace = false, quiet = false; | 20 | bool dump_trace = false, quiet = false; |
21 | int debug_ordered_events; | ||
18 | 22 | ||
19 | static int _eprintf(int level, int var, const char *fmt, va_list args) | 23 | static int _eprintf(int level, int var, const char *fmt, va_list args) |
20 | { | 24 | { |
@@ -42,6 +46,35 @@ int eprintf(int level, int var, const char *fmt, ...) | |||
42 | return ret; | 46 | return ret; |
43 | } | 47 | } |
44 | 48 | ||
49 | static int __eprintf_time(u64 t, const char *fmt, va_list args) | ||
50 | { | ||
51 | int ret = 0; | ||
52 | u64 secs, usecs, nsecs = t; | ||
53 | |||
54 | secs = nsecs / NSECS_PER_SEC; | ||
55 | nsecs -= secs * NSECS_PER_SEC; | ||
56 | usecs = nsecs / NSECS_PER_USEC; | ||
57 | |||
58 | ret = fprintf(stderr, "[%13" PRIu64 ".%06" PRIu64 "] ", | ||
59 | secs, usecs); | ||
60 | ret += vfprintf(stderr, fmt, args); | ||
61 | return ret; | ||
62 | } | ||
63 | |||
64 | int eprintf_time(int level, int var, u64 t, const char *fmt, ...) | ||
65 | { | ||
66 | int ret = 0; | ||
67 | va_list args; | ||
68 | |||
69 | if (var >= level) { | ||
70 | va_start(args, fmt); | ||
71 | ret = __eprintf_time(t, fmt, args); | ||
72 | va_end(args); | ||
73 | } | ||
74 | |||
75 | return ret; | ||
76 | } | ||
77 | |||
45 | /* | 78 | /* |
46 | * Overloading libtraceevent standard info print | 79 | * Overloading libtraceevent standard info print |
47 | * function, display with -v in perf. | 80 | * function, display with -v in perf. |
@@ -110,7 +143,8 @@ static struct debug_variable { | |||
110 | const char *name; | 143 | const char *name; |
111 | int *ptr; | 144 | int *ptr; |
112 | } debug_variables[] = { | 145 | } debug_variables[] = { |
113 | { .name = "verbose", .ptr = &verbose }, | 146 | { .name = "verbose", .ptr = &verbose }, |
147 | { .name = "ordered-events", .ptr = &debug_ordered_events}, | ||
114 | { .name = NULL, } | 148 | { .name = NULL, } |
115 | }; | 149 | }; |
116 | 150 | ||