aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/traceevent/parse-utils.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2012-04-05 18:47:53 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2012-04-25 06:28:28 -0400
commitf7d82350e597d76dc8765a55c7849843395728b0 (patch)
tree6e254dde9c6b30dc9f5dc4fb28d3eeec86382e32 /tools/lib/traceevent/parse-utils.c
parent4ace73eef52c651b8f58415fb4476f4791c95e72 (diff)
tools/events: Add files to create libtraceevent.a
Copy over the files from trace-cmd to the Linux tools directory such that applications like perf and latencytrace can use the more advanced parsing code. Because some of the file names of perf conflict with trace-cmd file names, the trace-cmd files have been renamed as follows: parse-events.c ==> event-parse.c parse-events.h ==> event-parse.h utils.h ==> event-utils.h The files have been updated to handle the changes to the header files but other than that, they are identical to what was in the trace-cmd repository. The history of these files, including authorship is available at the git repo: git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git The Makefile was also copied over, but most of it was removed to focus on the parse-events code first. The parts of the Makefile for the plugins have also been removed, but will be added back when the plugin code is copied over as well. But that may be in its own separate directory. Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Arun Sharma <asharma@fb.com> Cc: Namhyung Kim <namhyung.kim@lge.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'tools/lib/traceevent/parse-utils.c')
-rw-r--r--tools/lib/traceevent/parse-utils.c110
1 files changed, 110 insertions, 0 deletions
diff --git a/tools/lib/traceevent/parse-utils.c b/tools/lib/traceevent/parse-utils.c
new file mode 100644
index 000000000000..f023a133abb6
--- /dev/null
+++ b/tools/lib/traceevent/parse-utils.c
@@ -0,0 +1,110 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <stdarg.h>
5#include <errno.h>
6
7#define __weak __attribute__((weak))
8
9void __vdie(const char *fmt, va_list ap)
10{
11 int ret = errno;
12
13 if (errno)
14 perror("trace-cmd");
15 else
16 ret = -1;
17
18 fprintf(stderr, " ");
19 vfprintf(stderr, fmt, ap);
20
21 fprintf(stderr, "\n");
22 exit(ret);
23}
24
25void __die(const char *fmt, ...)
26{
27 va_list ap;
28
29 va_start(ap, fmt);
30 __vdie(fmt, ap);
31 va_end(ap);
32}
33
34void __weak die(const char *fmt, ...)
35{
36 va_list ap;
37
38 va_start(ap, fmt);
39 __vdie(fmt, ap);
40 va_end(ap);
41}
42
43void __vwarning(const char *fmt, va_list ap)
44{
45 if (errno)
46 perror("trace-cmd");
47 errno = 0;
48
49 fprintf(stderr, " ");
50 vfprintf(stderr, fmt, ap);
51
52 fprintf(stderr, "\n");
53}
54
55void __warning(const char *fmt, ...)
56{
57 va_list ap;
58
59 va_start(ap, fmt);
60 __vwarning(fmt, ap);
61 va_end(ap);
62}
63
64void __weak warning(const char *fmt, ...)
65{
66 va_list ap;
67
68 va_start(ap, fmt);
69 __vwarning(fmt, ap);
70 va_end(ap);
71}
72
73void __vpr_stat(const char *fmt, va_list ap)
74{
75 vprintf(fmt, ap);
76 printf("\n");
77}
78
79void __pr_stat(const char *fmt, ...)
80{
81 va_list ap;
82
83 va_start(ap, fmt);
84 __vpr_stat(fmt, ap);
85 va_end(ap);
86}
87
88void __weak vpr_stat(const char *fmt, va_list ap)
89{
90 __vpr_stat(fmt, ap);
91}
92
93void __weak pr_stat(const char *fmt, ...)
94{
95 va_list ap;
96
97 va_start(ap, fmt);
98 __vpr_stat(fmt, ap);
99 va_end(ap);
100}
101
102void __weak *malloc_or_die(unsigned int size)
103{
104 void *data;
105
106 data = malloc(size);
107 if (!data)
108 die("malloc");
109 return data;
110}