hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/tools/perf/util/trace-event-parse.c
....@@ -1,46 +1,30 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2009, Steven Rostedt <srostedt@redhat.com>
3
- *
4
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; version 2 of the License (not later!)
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
- *
19
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
204 */
215 #include <stdio.h>
226 #include <stdlib.h>
237 #include <string.h>
248 #include <errno.h>
259
26
-#include "../perf.h"
2710 #include "debug.h"
2811 #include "trace-event.h"
2912
30
-#include "sane_ctype.h"
13
+#include <linux/ctype.h>
3114
3215 static int get_common_field(struct scripting_context *context,
3316 int *offset, int *size, const char *type)
3417 {
3518 struct tep_handle *pevent = context->pevent;
36
- struct event_format *event;
37
- struct format_field *field;
19
+ struct tep_event *event;
20
+ struct tep_format_field *field;
3821
3922 if (!*size) {
40
- if (!pevent->events)
23
+
24
+ event = tep_get_first_event(pevent);
25
+ if (!event)
4126 return 0;
4227
43
- event = pevent->events[0];
4428 field = tep_find_common_field(event, type);
4529 if (!field)
4630 return 0;
....@@ -94,9 +78,9 @@
9478 }
9579
9680 unsigned long long
97
-raw_field_value(struct event_format *event, const char *name, void *data)
81
+raw_field_value(struct tep_event *event, const char *name, void *data)
9882 {
99
- struct format_field *field;
83
+ struct tep_format_field *field;
10084 unsigned long long val;
10185
10286 field = tep_find_any_field(event, name);
....@@ -108,12 +92,12 @@
10892 return val;
10993 }
11094
111
-unsigned long long read_size(struct event_format *event, void *ptr, int size)
95
+unsigned long long read_size(struct tep_event *event, void *ptr, int size)
11296 {
113
- return tep_read_number(event->pevent, ptr, size);
97
+ return tep_read_number(event->tep, ptr, size);
11498 }
11599
116
-void event_format__fprintf(struct event_format *event,
100
+void event_format__fprintf(struct tep_event *event,
117101 int cpu, void *data, int size, FILE *fp)
118102 {
119103 struct tep_record record;
....@@ -125,12 +109,12 @@
125109 record.data = data;
126110
127111 trace_seq_init(&s);
128
- tep_event_info(&s, event, &record);
112
+ tep_print_event(event->tep, &s, &record, "%s", TEP_PRINT_INFO);
129113 trace_seq_do_fprintf(&s, fp);
130114 trace_seq_destroy(&s);
131115 }
132116
133
-void event_format__print(struct event_format *event,
117
+void event_format__print(struct tep_event *event,
134118 int cpu, void *data, int size)
135119 {
136120 return event_format__fprintf(event, cpu, data, size, stdout);
....@@ -187,33 +171,6 @@
187171 char *buf, unsigned long size, char *sys)
188172 {
189173 return tep_parse_event(pevent, buf, size, sys);
190
-}
191
-
192
-struct event_format *trace_find_next_event(struct tep_handle *pevent,
193
- struct event_format *event)
194
-{
195
- static int idx;
196
-
197
- if (!pevent || !pevent->events)
198
- return NULL;
199
-
200
- if (!event) {
201
- idx = 0;
202
- return pevent->events[0];
203
- }
204
-
205
- if (idx < pevent->nr_events && event == pevent->events[idx]) {
206
- idx++;
207
- if (idx == pevent->nr_events)
208
- return NULL;
209
- return pevent->events[idx];
210
- }
211
-
212
- for (idx = 1; idx < pevent->nr_events; idx++) {
213
- if (event == pevent->events[idx - 1])
214
- return pevent->events[idx];
215
- }
216
- return NULL;
217174 }
218175
219176 struct flag {