diff options
Diffstat (limited to 'tools/lib/traceevent/event-parse-api.c')
-rw-r--r-- | tools/lib/traceevent/event-parse-api.c | 106 |
1 files changed, 102 insertions, 4 deletions
diff --git a/tools/lib/traceevent/event-parse-api.c b/tools/lib/traceevent/event-parse-api.c index 3716a9142aef..2ac8b44854ce 100644 --- a/tools/lib/traceevent/event-parse-api.c +++ b/tools/lib/traceevent/event-parse-api.c | |||
@@ -9,6 +9,22 @@ | |||
9 | #include "event-utils.h" | 9 | #include "event-utils.h" |
10 | 10 | ||
11 | /** | 11 | /** |
12 | * tep_get_event - returns the event with the given index | ||
13 | * @tep: a handle to the tep_handle | ||
14 | * @index: index of the requested event, in the range 0 .. nr_events | ||
15 | * | ||
16 | * This returns pointer to the element of the events array with the given index | ||
17 | * If @tep is NULL, or @index is not in the range 0 .. nr_events, NULL is returned. | ||
18 | */ | ||
19 | struct tep_event *tep_get_event(struct tep_handle *tep, int index) | ||
20 | { | ||
21 | if (tep && tep->events && index < tep->nr_events) | ||
22 | return tep->events[index]; | ||
23 | |||
24 | return NULL; | ||
25 | } | ||
26 | |||
27 | /** | ||
12 | * tep_get_first_event - returns the first event in the events array | 28 | * tep_get_first_event - returns the first event in the events array |
13 | * @tep: a handle to the tep_handle | 29 | * @tep: a handle to the tep_handle |
14 | * | 30 | * |
@@ -17,10 +33,7 @@ | |||
17 | */ | 33 | */ |
18 | struct tep_event *tep_get_first_event(struct tep_handle *tep) | 34 | struct tep_event *tep_get_first_event(struct tep_handle *tep) |
19 | { | 35 | { |
20 | if (tep && tep->events) | 36 | return tep_get_event(tep, 0); |
21 | return tep->events[0]; | ||
22 | |||
23 | return NULL; | ||
24 | } | 37 | } |
25 | 38 | ||
26 | /** | 39 | /** |
@@ -51,6 +64,34 @@ void tep_set_flag(struct tep_handle *tep, int flag) | |||
51 | tep->flags |= flag; | 64 | tep->flags |= flag; |
52 | } | 65 | } |
53 | 66 | ||
67 | /** | ||
68 | * tep_clear_flag - clear event parser flag | ||
69 | * @tep: a handle to the tep_handle | ||
70 | * @flag: flag to be cleared | ||
71 | * | ||
72 | * This clears a tep flag | ||
73 | */ | ||
74 | void tep_clear_flag(struct tep_handle *tep, enum tep_flag flag) | ||
75 | { | ||
76 | if (tep) | ||
77 | tep->flags &= ~flag; | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * tep_test_flag - check the state of event parser flag | ||
82 | * @tep: a handle to the tep_handle | ||
83 | * @flag: flag to be checked | ||
84 | * | ||
85 | * This returns the state of the requested tep flag. | ||
86 | * Returns: true if the flag is set, false otherwise. | ||
87 | */ | ||
88 | bool tep_test_flag(struct tep_handle *tep, enum tep_flag flag) | ||
89 | { | ||
90 | if (tep) | ||
91 | return (tep->flags & flag); | ||
92 | return false; | ||
93 | } | ||
94 | |||
54 | unsigned short tep_data2host2(struct tep_handle *pevent, unsigned short data) | 95 | unsigned short tep_data2host2(struct tep_handle *pevent, unsigned short data) |
55 | { | 96 | { |
56 | unsigned short swap; | 97 | unsigned short swap; |
@@ -114,6 +155,20 @@ int tep_get_header_page_size(struct tep_handle *pevent) | |||
114 | } | 155 | } |
115 | 156 | ||
116 | /** | 157 | /** |
158 | * tep_get_header_timestamp_size - get size of the time stamp in the header page | ||
159 | * @tep: a handle to the tep_handle | ||
160 | * | ||
161 | * This returns size of the time stamp in the header page | ||
162 | * If @tep is NULL, 0 is returned. | ||
163 | */ | ||
164 | int tep_get_header_timestamp_size(struct tep_handle *tep) | ||
165 | { | ||
166 | if (tep) | ||
167 | return tep->header_page_ts_size; | ||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | /** | ||
117 | * tep_get_cpus - get the number of CPUs | 172 | * tep_get_cpus - get the number of CPUs |
118 | * @pevent: a handle to the tep_handle | 173 | * @pevent: a handle to the tep_handle |
119 | * | 174 | * |
@@ -273,3 +328,46 @@ void tep_set_latency_format(struct tep_handle *pevent, int lat) | |||
273 | if (pevent) | 328 | if (pevent) |
274 | pevent->latency_format = lat; | 329 | pevent->latency_format = lat; |
275 | } | 330 | } |
331 | |||
332 | /** | ||
333 | * tep_is_old_format - get if an old kernel is used | ||
334 | * @tep: a handle to the tep_handle | ||
335 | * | ||
336 | * This returns true, if an old kernel is used to generate the tracing events or | ||
337 | * false if a new kernel is used. Old kernels did not have header page info. | ||
338 | * If @tep is NULL, false is returned. | ||
339 | */ | ||
340 | bool tep_is_old_format(struct tep_handle *tep) | ||
341 | { | ||
342 | if (tep) | ||
343 | return !!(tep->old_format); | ||
344 | return false; | ||
345 | } | ||
346 | |||
347 | /** | ||
348 | * tep_set_print_raw - set a flag to force print in raw format | ||
349 | * @tep: a handle to the tep_handle | ||
350 | * @print_raw: the new value of the print_raw flag | ||
351 | * | ||
352 | * This sets a flag to force print in raw format | ||
353 | */ | ||
354 | void tep_set_print_raw(struct tep_handle *tep, int print_raw) | ||
355 | { | ||
356 | if (tep) | ||
357 | tep->print_raw = print_raw; | ||
358 | } | ||
359 | |||
360 | /** | ||
361 | * tep_set_test_filters - set a flag to test a filter string | ||
362 | * @tep: a handle to the tep_handle | ||
363 | * @test_filters: the new value of the test_filters flag | ||
364 | * | ||
365 | * This sets a flag to test a filter string. If this flag is set, when | ||
366 | * tep_filter_add_filter_str() API as called,it will print the filter string | ||
367 | * instead of adding it. | ||
368 | */ | ||
369 | void tep_set_test_filters(struct tep_handle *tep, int test_filters) | ||
370 | { | ||
371 | if (tep) | ||
372 | tep->test_filters = test_filters; | ||
373 | } | ||