aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorTzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>2018-08-28 18:50:38 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-08-30 14:52:20 -0400
commit266b851cc2874774a59f04a7b3b059ca0f26569b (patch)
treea960f91ceac76be5ea6dea17daae77a2906e039b /tools
parent766e0618e49490bf67a35542880bcecbcee2e5fa (diff)
tools lib traceevent, perf tools: Split trace-seq related APIs in a separate header file
In order to make libtraceevent into a proper library, all its APIs should be defined in corresponding header files. This patch splits trace-seq related APIs in a separate header file: trace-seq.h Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/20180828185038.2dcb2743@gandalf.local.home Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/traceevent/event-parse.c1
-rw-r--r--tools/lib/traceevent/event-parse.h46
-rw-r--r--tools/lib/traceevent/event-plugin.c1
-rw-r--r--tools/lib/traceevent/plugin_function.c1
-rw-r--r--tools/lib/traceevent/plugin_hrtimer.c1
-rw-r--r--tools/lib/traceevent/plugin_jbd2.c1
-rw-r--r--tools/lib/traceevent/plugin_kmem.c1
-rw-r--r--tools/lib/traceevent/plugin_kvm.c1
-rw-r--r--tools/lib/traceevent/plugin_mac80211.c1
-rw-r--r--tools/lib/traceevent/plugin_sched_switch.c1
-rw-r--r--tools/lib/traceevent/plugin_scsi.c1
-rw-r--r--tools/lib/traceevent/plugin_xen.c1
-rw-r--r--tools/lib/traceevent/trace-seq.c2
-rw-r--r--tools/lib/traceevent/trace-seq.h55
-rw-r--r--tools/perf/util/trace-event.h1
15 files changed, 71 insertions, 44 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index ce1e20227c64..70a42bec6931 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -24,6 +24,7 @@
24#include <netinet/in.h> 24#include <netinet/in.h>
25#include "event-parse.h" 25#include "event-parse.h"
26#include "event-utils.h" 26#include "event-utils.h"
27#include "trace-seq.h"
27 28
28static const char *input_buf; 29static const char *input_buf;
29static unsigned long long input_buf_ptr; 30static unsigned long long input_buf_ptr;
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 44b7c2d41f9f..fa665c66bfa4 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -26,17 +26,12 @@
26#include <regex.h> 26#include <regex.h>
27#include <string.h> 27#include <string.h>
28 28
29#include "trace-seq.h"
30
29#ifndef __maybe_unused 31#ifndef __maybe_unused
30#define __maybe_unused __attribute__((unused)) 32#define __maybe_unused __attribute__((unused))
31#endif 33#endif
32 34
33/* ----------------------- trace_seq ----------------------- */
34
35
36#ifndef TRACE_SEQ_BUF_SIZE
37#define TRACE_SEQ_BUF_SIZE 4096
38#endif
39
40#ifndef DEBUG_RECORD 35#ifndef DEBUG_RECORD
41#define DEBUG_RECORD 0 36#define DEBUG_RECORD 0
42#endif 37#endif
@@ -59,43 +54,6 @@ struct tep_record {
59#endif 54#endif
60}; 55};
61 56
62enum trace_seq_fail {
63 TRACE_SEQ__GOOD,
64 TRACE_SEQ__BUFFER_POISONED,
65 TRACE_SEQ__MEM_ALLOC_FAILED,
66};
67
68/*
69 * Trace sequences are used to allow a function to call several other functions
70 * to create a string of data to use (up to a max of PAGE_SIZE).
71 */
72
73struct trace_seq {
74 char *buffer;
75 unsigned int buffer_size;
76 unsigned int len;
77 unsigned int readpos;
78 enum trace_seq_fail state;
79};
80
81void trace_seq_init(struct trace_seq *s);
82void trace_seq_reset(struct trace_seq *s);
83void trace_seq_destroy(struct trace_seq *s);
84
85extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
86 __attribute__ ((format (printf, 2, 3)));
87extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args)
88 __attribute__ ((format (printf, 2, 0)));
89
90extern int trace_seq_puts(struct trace_seq *s, const char *str);
91extern int trace_seq_putc(struct trace_seq *s, unsigned char c);
92
93extern void trace_seq_terminate(struct trace_seq *s);
94
95extern int trace_seq_do_fprintf(struct trace_seq *s, FILE *fp);
96extern int trace_seq_do_printf(struct trace_seq *s);
97
98
99/* ----------------------- pevent ----------------------- */ 57/* ----------------------- pevent ----------------------- */
100 58
101struct tep_handle; 59struct tep_handle;
diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c
index f17e25097e1e..ec16a103c0cc 100644
--- a/tools/lib/traceevent/event-plugin.c
+++ b/tools/lib/traceevent/event-plugin.c
@@ -15,6 +15,7 @@
15#include <dirent.h> 15#include <dirent.h>
16#include "event-parse.h" 16#include "event-parse.h"
17#include "event-utils.h" 17#include "event-utils.h"
18#include "trace-seq.h"
18 19
19#define LOCAL_PLUGIN_DIR ".traceevent/plugins" 20#define LOCAL_PLUGIN_DIR ".traceevent/plugins"
20 21
diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c
index 424747475d37..2919042e7dc2 100644
--- a/tools/lib/traceevent/plugin_function.c
+++ b/tools/lib/traceevent/plugin_function.c
@@ -23,6 +23,7 @@
23 23
24#include "event-parse.h" 24#include "event-parse.h"
25#include "event-utils.h" 25#include "event-utils.h"
26#include "trace-seq.h"
26 27
27static struct func_stack { 28static struct func_stack {
28 int size; 29 int size;
diff --git a/tools/lib/traceevent/plugin_hrtimer.c b/tools/lib/traceevent/plugin_hrtimer.c
index b43bfec565d8..29b608076ea0 100644
--- a/tools/lib/traceevent/plugin_hrtimer.c
+++ b/tools/lib/traceevent/plugin_hrtimer.c
@@ -23,6 +23,7 @@
23#include <string.h> 23#include <string.h>
24 24
25#include "event-parse.h" 25#include "event-parse.h"
26#include "trace-seq.h"
26 27
27static int timer_expire_handler(struct trace_seq *s, 28static int timer_expire_handler(struct trace_seq *s,
28 struct tep_record *record, 29 struct tep_record *record,
diff --git a/tools/lib/traceevent/plugin_jbd2.c b/tools/lib/traceevent/plugin_jbd2.c
index 45a9acd19640..a5e34135dd6a 100644
--- a/tools/lib/traceevent/plugin_jbd2.c
+++ b/tools/lib/traceevent/plugin_jbd2.c
@@ -22,6 +22,7 @@
22#include <string.h> 22#include <string.h>
23 23
24#include "event-parse.h" 24#include "event-parse.h"
25#include "trace-seq.h"
25 26
26#define MINORBITS 20 27#define MINORBITS 20
27#define MINORMASK ((1U << MINORBITS) - 1) 28#define MINORMASK ((1U << MINORBITS) - 1)
diff --git a/tools/lib/traceevent/plugin_kmem.c b/tools/lib/traceevent/plugin_kmem.c
index 73966b05abce..a7a162575e2c 100644
--- a/tools/lib/traceevent/plugin_kmem.c
+++ b/tools/lib/traceevent/plugin_kmem.c
@@ -22,6 +22,7 @@
22#include <string.h> 22#include <string.h>
23 23
24#include "event-parse.h" 24#include "event-parse.h"
25#include "trace-seq.h"
25 26
26static int call_site_handler(struct trace_seq *s, struct tep_record *record, 27static int call_site_handler(struct trace_seq *s, struct tep_record *record,
27 struct event_format *event, void *context) 28 struct event_format *event, void *context)
diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c
index 1d0d15906225..a0dfd3d0f197 100644
--- a/tools/lib/traceevent/plugin_kvm.c
+++ b/tools/lib/traceevent/plugin_kvm.c
@@ -23,6 +23,7 @@
23#include <stdint.h> 23#include <stdint.h>
24 24
25#include "event-parse.h" 25#include "event-parse.h"
26#include "trace-seq.h"
26 27
27#ifdef HAVE_UDIS86 28#ifdef HAVE_UDIS86
28 29
diff --git a/tools/lib/traceevent/plugin_mac80211.c b/tools/lib/traceevent/plugin_mac80211.c
index de50a5316203..0b7779444b63 100644
--- a/tools/lib/traceevent/plugin_mac80211.c
+++ b/tools/lib/traceevent/plugin_mac80211.c
@@ -22,6 +22,7 @@
22#include <string.h> 22#include <string.h>
23 23
24#include "event-parse.h" 24#include "event-parse.h"
25#include "trace-seq.h"
25 26
26#define INDENT 65 27#define INDENT 65
27 28
diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c
index eecb4bd95c11..582d3be2849b 100644
--- a/tools/lib/traceevent/plugin_sched_switch.c
+++ b/tools/lib/traceevent/plugin_sched_switch.c
@@ -22,6 +22,7 @@
22#include <string.h> 22#include <string.h>
23 23
24#include "event-parse.h" 24#include "event-parse.h"
25#include "trace-seq.h"
25 26
26static void write_state(struct trace_seq *s, int val) 27static void write_state(struct trace_seq *s, int val)
27{ 28{
diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c
index 5ec346f6b842..4eba25cc1431 100644
--- a/tools/lib/traceevent/plugin_scsi.c
+++ b/tools/lib/traceevent/plugin_scsi.c
@@ -3,6 +3,7 @@
3#include <string.h> 3#include <string.h>
4#include <inttypes.h> 4#include <inttypes.h>
5#include "event-parse.h" 5#include "event-parse.h"
6#include "trace-seq.h"
6 7
7typedef unsigned long sector_t; 8typedef unsigned long sector_t;
8typedef uint64_t u64; 9typedef uint64_t u64;
diff --git a/tools/lib/traceevent/plugin_xen.c b/tools/lib/traceevent/plugin_xen.c
index b2acbd6e9c86..bc0496e4c296 100644
--- a/tools/lib/traceevent/plugin_xen.c
+++ b/tools/lib/traceevent/plugin_xen.c
@@ -3,6 +3,7 @@
3#include <stdlib.h> 3#include <stdlib.h>
4#include <string.h> 4#include <string.h>
5#include "event-parse.h" 5#include "event-parse.h"
6#include "trace-seq.h"
6 7
7#define __HYPERVISOR_set_trap_table 0 8#define __HYPERVISOR_set_trap_table 0
8#define __HYPERVISOR_mmu_update 1 9#define __HYPERVISOR_mmu_update 1
diff --git a/tools/lib/traceevent/trace-seq.c b/tools/lib/traceevent/trace-seq.c
index e3bac4543d3b..8ff1d55954d1 100644
--- a/tools/lib/traceevent/trace-seq.c
+++ b/tools/lib/traceevent/trace-seq.c
@@ -3,6 +3,8 @@
3 * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> 3 * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
4 * 4 *
5 */ 5 */
6#include "trace-seq.h"
7
6#include <stdio.h> 8#include <stdio.h>
7#include <stdlib.h> 9#include <stdlib.h>
8#include <string.h> 10#include <string.h>
diff --git a/tools/lib/traceevent/trace-seq.h b/tools/lib/traceevent/trace-seq.h
new file mode 100644
index 000000000000..d68ec69f8d1a
--- /dev/null
+++ b/tools/lib/traceevent/trace-seq.h
@@ -0,0 +1,55 @@
1// SPDX-License-Identifier: LGPL-2.1
2/*
3 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
4 *
5 */
6
7#ifndef _TRACE_SEQ_H
8#define _TRACE_SEQ_H
9
10#include <stdarg.h>
11#include <stdio.h>
12
13/* ----------------------- trace_seq ----------------------- */
14
15#ifndef TRACE_SEQ_BUF_SIZE
16#define TRACE_SEQ_BUF_SIZE 4096
17#endif
18
19enum trace_seq_fail {
20 TRACE_SEQ__GOOD,
21 TRACE_SEQ__BUFFER_POISONED,
22 TRACE_SEQ__MEM_ALLOC_FAILED,
23};
24
25/*
26 * Trace sequences are used to allow a function to call several other functions
27 * to create a string of data to use (up to a max of PAGE_SIZE).
28 */
29
30struct trace_seq {
31 char *buffer;
32 unsigned int buffer_size;
33 unsigned int len;
34 unsigned int readpos;
35 enum trace_seq_fail state;
36};
37
38void trace_seq_init(struct trace_seq *s);
39void trace_seq_reset(struct trace_seq *s);
40void trace_seq_destroy(struct trace_seq *s);
41
42extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
43 __attribute__ ((format (printf, 2, 3)));
44extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args)
45 __attribute__ ((format (printf, 2, 0)));
46
47extern int trace_seq_puts(struct trace_seq *s, const char *str);
48extern int trace_seq_putc(struct trace_seq *s, unsigned char c);
49
50extern void trace_seq_terminate(struct trace_seq *s);
51
52extern int trace_seq_do_fprintf(struct trace_seq *s, FILE *fp);
53extern int trace_seq_do_printf(struct trace_seq *s);
54
55#endif /* _TRACE_SEQ_H */
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index 40204ec3a7a2..c69d77d7cf55 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -3,6 +3,7 @@
3#define _PERF_UTIL_TRACE_EVENT_H 3#define _PERF_UTIL_TRACE_EVENT_H
4 4
5#include <traceevent/event-parse.h> 5#include <traceevent/event-parse.h>
6#include <traceevent/trace-seq.h>
6#include "parse-events.h" 7#include "parse-events.h"
7 8
8struct machine; 9struct machine;