diff options
author | Srikant Patnaik | 2015-01-11 12:28:04 +0530 |
---|---|---|
committer | Srikant Patnaik | 2015-01-11 12:28:04 +0530 |
commit | 871480933a1c28f8a9fed4c4d34d06c439a7a422 (patch) | |
tree | 8718f573808810c2a1e8cb8fb6ac469093ca2784 /tools/perf/util/debug.c | |
parent | 9d40ac5867b9aefe0722bc1f110b965ff294d30d (diff) | |
download | FOSSEE-netbook-kernel-source-871480933a1c28f8a9fed4c4d34d06c439a7a422.tar.gz FOSSEE-netbook-kernel-source-871480933a1c28f8a9fed4c4d34d06c439a7a422.tar.bz2 FOSSEE-netbook-kernel-source-871480933a1c28f8a9fed4c4d34d06c439a7a422.zip |
Moved, renamed, and deleted files
The original directory structure was scattered and unorganized.
Changes are basically to make it look like kernel structure.
Diffstat (limited to 'tools/perf/util/debug.c')
-rw-r--r-- | tools/perf/util/debug.c | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c new file mode 100644 index 00000000..26817daa --- /dev/null +++ b/tools/perf/util/debug.c @@ -0,0 +1,105 @@ +/* For general debugging purposes */ + +#include "../perf.h" + +#include <string.h> +#include <stdarg.h> +#include <stdio.h> + +#include "cache.h" +#include "color.h" +#include "event.h" +#include "debug.h" +#include "util.h" + +int verbose; +bool dump_trace = false, quiet = false; + +int eprintf(int level, const char *fmt, ...) +{ + va_list args; + int ret = 0; + + if (verbose >= level) { + va_start(args, fmt); + if (use_browser > 0) + ret = ui_helpline__show_help(fmt, args); + else + ret = vfprintf(stderr, fmt, args); + va_end(args); + } + + return ret; +} + +int dump_printf(const char *fmt, ...) +{ + va_list args; + int ret = 0; + + if (dump_trace) { + va_start(args, fmt); + ret = vprintf(fmt, args); + va_end(args); + } + + return ret; +} + +#ifdef NO_NEWT_SUPPORT +int ui__warning(const char *format, ...) +{ + va_list args; + + va_start(args, format); + vfprintf(stderr, format, args); + va_end(args); + return 0; +} +#endif + +int ui__error_paranoid(void) +{ + return ui__error("Permission error - are you root?\n" + "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n" + " -1 - Not paranoid at all\n" + " 0 - Disallow raw tracepoint access for unpriv\n" + " 1 - Disallow cpu events for unpriv\n" + " 2 - Disallow kernel profiling for unpriv\n"); +} + +void trace_event(union perf_event *event) +{ + unsigned char *raw_event = (void *)event; + const char *color = PERF_COLOR_BLUE; + int i, j; + + if (!dump_trace) + return; + + printf("."); + color_fprintf(stdout, color, "\n. ... raw event: size %d bytes\n", + event->header.size); + + for (i = 0; i < event->header.size; i++) { + if ((i & 15) == 0) { + printf("."); + color_fprintf(stdout, color, " %04x: ", i); + } + + color_fprintf(stdout, color, " %02x", raw_event[i]); + + if (((i & 15) == 15) || i == event->header.size-1) { + color_fprintf(stdout, color, " "); + for (j = 0; j < 15-(i & 15); j++) + color_fprintf(stdout, color, " "); + for (j = i & ~15; j <= i; j++) { + color_fprintf(stdout, color, "%c", + isprint(raw_event[j]) ? + raw_event[j] : '.'); + } + color_fprintf(stdout, color, "\n"); + } + } + printf(".\n"); +} |