aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-inject.c3
-rw-r--r--tools/perf/builtin-report.c2
-rw-r--r--tools/perf/builtin-script.c64
-rw-r--r--tools/perf/builtin-trace.c18
-rw-r--r--tools/perf/command-list.txt1
-rw-r--r--tools/perf/pmu-events/arch/arm64/ampere/emag/branch.json23
-rw-r--r--tools/perf/pmu-events/arch/arm64/ampere/emag/bus.json26
-rw-r--r--tools/perf/pmu-events/arch/arm64/ampere/emag/cache.json191
-rw-r--r--tools/perf/pmu-events/arch/arm64/ampere/emag/clock.json20
-rw-r--r--tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json32
-rw-r--r--tools/perf/pmu-events/arch/arm64/ampere/emag/exception.json50
-rw-r--r--tools/perf/pmu-events/arch/arm64/ampere/emag/instruction.json89
-rw-r--r--tools/perf/pmu-events/arch/arm64/ampere/emag/intrinsic.json14
-rw-r--r--tools/perf/pmu-events/arch/arm64/ampere/emag/memory.json29
-rw-r--r--tools/perf/pmu-events/arch/arm64/ampere/emag/pipeline.json50
-rw-r--r--tools/perf/tests/evsel-tp-sched.c4
-rw-r--r--tools/perf/util/auxtrace.h19
-rw-r--r--tools/perf/util/data-convert-bt.c56
-rw-r--r--tools/perf/util/db-export.c22
-rw-r--r--tools/perf/util/evsel.c10
-rw-r--r--tools/perf/util/evsel.h10
-rw-r--r--tools/perf/util/evsel_fprintf.c2
-rw-r--r--tools/perf/util/header.c2
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-decoder.c34
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-decoder.h2
-rw-r--r--tools/perf/util/intel-pt.c5
-rw-r--r--tools/perf/util/python.c20
-rw-r--r--tools/perf/util/scripting-engines/trace-event-perl.c66
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c100
-rw-r--r--tools/perf/util/sort.c22
-rw-r--r--tools/perf/util/thread-stack.c51
-rw-r--r--tools/perf/util/trace-event-parse.c18
-rw-r--r--tools/perf/util/trace-event-read.c4
-rw-r--r--tools/perf/util/trace-event.c8
-rw-r--r--tools/perf/util/trace-event.h20
35 files changed, 832 insertions, 255 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index b4a29f435b06..eda41673c4f3 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -798,7 +798,8 @@ int cmd_inject(int argc, const char **argv)
798 "kallsyms pathname"), 798 "kallsyms pathname"),
799 OPT_BOOLEAN('f', "force", &data.force, "don't complain, do it"), 799 OPT_BOOLEAN('f', "force", &data.force, "don't complain, do it"),
800 OPT_CALLBACK_OPTARG(0, "itrace", &inject.itrace_synth_opts, 800 OPT_CALLBACK_OPTARG(0, "itrace", &inject.itrace_synth_opts,
801 NULL, "opts", "Instruction Tracing options", 801 NULL, "opts", "Instruction Tracing options\n"
802 ITRACE_HELP,
802 itrace_parse_synth_opts), 803 itrace_parse_synth_opts),
803 OPT_BOOLEAN(0, "strip", &inject.strip, 804 OPT_BOOLEAN(0, "strip", &inject.strip,
804 "strip non-synthesized events (use with --itrace)"), 805 "strip non-synthesized events (use with --itrace)"),
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 7507e4d6dce1..c0703979c51d 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1104,7 +1104,7 @@ int cmd_report(int argc, const char **argv)
1104 OPT_CALLBACK(0, "percentage", NULL, "relative|absolute", 1104 OPT_CALLBACK(0, "percentage", NULL, "relative|absolute",
1105 "how to display percentage of filtered entries", parse_filter_percentage), 1105 "how to display percentage of filtered entries", parse_filter_percentage),
1106 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts", 1106 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
1107 "Instruction Tracing options", 1107 "Instruction Tracing options\n" ITRACE_HELP,
1108 itrace_parse_synth_opts), 1108 itrace_parse_synth_opts),
1109 OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename, 1109 OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename,
1110 "Show full source file name path for source lines"), 1110 "Show full source file name path for source lines"),
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 765391b6c88c..4da5e32b9e03 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -406,9 +406,10 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
406 PERF_OUTPUT_WEIGHT)) 406 PERF_OUTPUT_WEIGHT))
407 return -EINVAL; 407 return -EINVAL;
408 408
409 if (PRINT_FIELD(SYM) && !PRINT_FIELD(IP) && !PRINT_FIELD(ADDR)) { 409 if (PRINT_FIELD(SYM) &&
410 !(evsel->attr.sample_type & (PERF_SAMPLE_IP|PERF_SAMPLE_ADDR))) {
410 pr_err("Display of symbols requested but neither sample IP nor " 411 pr_err("Display of symbols requested but neither sample IP nor "
411 "sample address\nis selected. Hence, no addresses to convert " 412 "sample address\navailable. Hence, no addresses to convert "
412 "to symbols.\n"); 413 "to symbols.\n");
413 return -EINVAL; 414 return -EINVAL;
414 } 415 }
@@ -417,10 +418,9 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
417 "selected.\n"); 418 "selected.\n");
418 return -EINVAL; 419 return -EINVAL;
419 } 420 }
420 if (PRINT_FIELD(DSO) && !PRINT_FIELD(IP) && !PRINT_FIELD(ADDR) && 421 if (PRINT_FIELD(DSO) &&
421 !PRINT_FIELD(BRSTACK) && !PRINT_FIELD(BRSTACKSYM) && !PRINT_FIELD(BRSTACKOFF)) { 422 !(evsel->attr.sample_type & (PERF_SAMPLE_IP|PERF_SAMPLE_ADDR))) {
422 pr_err("Display of DSO requested but no address to convert. Select\n" 423 pr_err("Display of DSO requested but no address to convert.\n");
423 "sample IP, sample address, brstack, brstacksym, or brstackoff.\n");
424 return -EINVAL; 424 return -EINVAL;
425 } 425 }
426 if (PRINT_FIELD(SRCLINE) && !PRINT_FIELD(IP)) { 426 if (PRINT_FIELD(SRCLINE) && !PRINT_FIELD(IP)) {
@@ -1115,6 +1115,7 @@ static int perf_sample__fprintf_callindent(struct perf_sample *sample,
1115 const char *name = NULL; 1115 const char *name = NULL;
1116 static int spacing; 1116 static int spacing;
1117 int len = 0; 1117 int len = 0;
1118 int dlen = 0;
1118 u64 ip = 0; 1119 u64 ip = 0;
1119 1120
1120 /* 1121 /*
@@ -1141,6 +1142,12 @@ static int perf_sample__fprintf_callindent(struct perf_sample *sample,
1141 ip = sample->ip; 1142 ip = sample->ip;
1142 } 1143 }
1143 1144
1145 if (PRINT_FIELD(DSO) && !(PRINT_FIELD(IP) || PRINT_FIELD(ADDR))) {
1146 dlen += fprintf(fp, "(");
1147 dlen += map__fprintf_dsoname(al->map, fp);
1148 dlen += fprintf(fp, ")\t");
1149 }
1150
1144 if (name) 1151 if (name)
1145 len = fprintf(fp, "%*s%s", (int)depth * 4, "", name); 1152 len = fprintf(fp, "%*s%s", (int)depth * 4, "", name);
1146 else if (ip) 1153 else if (ip)
@@ -1159,7 +1166,7 @@ static int perf_sample__fprintf_callindent(struct perf_sample *sample,
1159 if (len < spacing) 1166 if (len < spacing)
1160 len += fprintf(fp, "%*s", spacing - len, ""); 1167 len += fprintf(fp, "%*s", spacing - len, "");
1161 1168
1162 return len; 1169 return len + dlen;
1163} 1170}
1164 1171
1165static int perf_sample__fprintf_insn(struct perf_sample *sample, 1172static int perf_sample__fprintf_insn(struct perf_sample *sample,
@@ -1255,6 +1262,18 @@ static struct {
1255 {0, NULL} 1262 {0, NULL}
1256}; 1263};
1257 1264
1265static const char *sample_flags_to_name(u32 flags)
1266{
1267 int i;
1268
1269 for (i = 0; sample_flags[i].name ; i++) {
1270 if (sample_flags[i].flags == flags)
1271 return sample_flags[i].name;
1272 }
1273
1274 return NULL;
1275}
1276
1258static int perf_sample__fprintf_flags(u32 flags, FILE *fp) 1277static int perf_sample__fprintf_flags(u32 flags, FILE *fp)
1259{ 1278{
1260 const char *chars = PERF_IP_FLAG_CHARS; 1279 const char *chars = PERF_IP_FLAG_CHARS;
@@ -1264,11 +1283,20 @@ static int perf_sample__fprintf_flags(u32 flags, FILE *fp)
1264 char str[33]; 1283 char str[33];
1265 int i, pos = 0; 1284 int i, pos = 0;
1266 1285
1267 for (i = 0; sample_flags[i].name ; i++) { 1286 name = sample_flags_to_name(flags & ~PERF_IP_FLAG_IN_TX);
1268 if (sample_flags[i].flags == (flags & ~PERF_IP_FLAG_IN_TX)) { 1287 if (name)
1269 name = sample_flags[i].name; 1288 return fprintf(fp, " %-15s%4s ", name, in_tx ? "(x)" : "");
1270 break; 1289
1271 } 1290 if (flags & PERF_IP_FLAG_TRACE_BEGIN) {
1291 name = sample_flags_to_name(flags & ~(PERF_IP_FLAG_IN_TX | PERF_IP_FLAG_TRACE_BEGIN));
1292 if (name)
1293 return fprintf(fp, " tr strt %-7s%4s ", name, in_tx ? "(x)" : "");
1294 }
1295
1296 if (flags & PERF_IP_FLAG_TRACE_END) {
1297 name = sample_flags_to_name(flags & ~(PERF_IP_FLAG_IN_TX | PERF_IP_FLAG_TRACE_END));
1298 if (name)
1299 return fprintf(fp, " tr end %-7s%4s ", name, in_tx ? "(x)" : "");
1272 } 1300 }
1273 1301
1274 for (i = 0; i < n; i++, flags >>= 1) { 1302 for (i = 0; i < n; i++, flags >>= 1) {
@@ -1281,10 +1309,7 @@ static int perf_sample__fprintf_flags(u32 flags, FILE *fp)
1281 } 1309 }
1282 str[pos] = 0; 1310 str[pos] = 0;
1283 1311
1284 if (name) 1312 return fprintf(fp, " %-19s ", str);
1285 return fprintf(fp, " %-7s%4s ", name, in_tx ? "(x)" : "");
1286
1287 return fprintf(fp, " %-11s ", str);
1288} 1313}
1289 1314
1290struct printer_data { 1315struct printer_data {
@@ -2491,6 +2516,8 @@ parse:
2491 output[j].fields &= ~all_output_options[i].field; 2516 output[j].fields &= ~all_output_options[i].field;
2492 else 2517 else
2493 output[j].fields |= all_output_options[i].field; 2518 output[j].fields |= all_output_options[i].field;
2519 output[j].user_set = true;
2520 output[j].wildcard_set = true;
2494 } 2521 }
2495 } 2522 }
2496 } else { 2523 } else {
@@ -2501,7 +2528,8 @@ parse:
2501 rc = -EINVAL; 2528 rc = -EINVAL;
2502 goto out; 2529 goto out;
2503 } 2530 }
2504 output[type].fields |= all_output_options[i].field; 2531 output[type].user_set = true;
2532 output[type].wildcard_set = true;
2505 } 2533 }
2506 } 2534 }
2507 2535
@@ -3193,7 +3221,7 @@ int cmd_script(int argc, const char **argv)
3193 OPT_BOOLEAN(0, "ns", &nanosecs, 3221 OPT_BOOLEAN(0, "ns", &nanosecs,
3194 "Use 9 decimal places when displaying time"), 3222 "Use 9 decimal places when displaying time"),
3195 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts", 3223 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
3196 "Instruction Tracing options", 3224 "Instruction Tracing options\n" ITRACE_HELP,
3197 itrace_parse_synth_opts), 3225 itrace_parse_synth_opts),
3198 OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename, 3226 OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename,
3199 "Show full source file name path for source lines"), 3227 "Show full source file name path for source lines"),
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 7ce277d22a91..90289f31dd87 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -181,7 +181,7 @@ static int __tp_field__init_uint(struct tp_field *field, int size, int offset, b
181 return 0; 181 return 0;
182} 182}
183 183
184static int tp_field__init_uint(struct tp_field *field, struct format_field *format_field, bool needs_swap) 184static int tp_field__init_uint(struct tp_field *field, struct tep_format_field *format_field, bool needs_swap)
185{ 185{
186 return __tp_field__init_uint(field, format_field->size, format_field->offset, needs_swap); 186 return __tp_field__init_uint(field, format_field->size, format_field->offset, needs_swap);
187} 187}
@@ -198,7 +198,7 @@ static int __tp_field__init_ptr(struct tp_field *field, int offset)
198 return 0; 198 return 0;
199} 199}
200 200
201static int tp_field__init_ptr(struct tp_field *field, struct format_field *format_field) 201static int tp_field__init_ptr(struct tp_field *field, struct tep_format_field *format_field)
202{ 202{
203 return __tp_field__init_ptr(field, format_field->offset); 203 return __tp_field__init_ptr(field, format_field->offset);
204} 204}
@@ -214,7 +214,7 @@ static int perf_evsel__init_tp_uint_field(struct perf_evsel *evsel,
214 struct tp_field *field, 214 struct tp_field *field,
215 const char *name) 215 const char *name)
216{ 216{
217 struct format_field *format_field = perf_evsel__field(evsel, name); 217 struct tep_format_field *format_field = perf_evsel__field(evsel, name);
218 218
219 if (format_field == NULL) 219 if (format_field == NULL)
220 return -1; 220 return -1;
@@ -230,7 +230,7 @@ static int perf_evsel__init_tp_ptr_field(struct perf_evsel *evsel,
230 struct tp_field *field, 230 struct tp_field *field,
231 const char *name) 231 const char *name)
232{ 232{
233 struct format_field *format_field = perf_evsel__field(evsel, name); 233 struct tep_format_field *format_field = perf_evsel__field(evsel, name);
234 234
235 if (format_field == NULL) 235 if (format_field == NULL)
236 return -1; 236 return -1;
@@ -862,12 +862,12 @@ static struct syscall_fmt *syscall_fmt__find(const char *name)
862 * args_size: sum of the sizes of the syscall arguments, anything after that is augmented stuff: pathname for openat, etc. 862 * args_size: sum of the sizes of the syscall arguments, anything after that is augmented stuff: pathname for openat, etc.
863 */ 863 */
864struct syscall { 864struct syscall {
865 struct event_format *tp_format; 865 struct tep_event_format *tp_format;
866 int nr_args; 866 int nr_args;
867 int args_size; 867 int args_size;
868 bool is_exit; 868 bool is_exit;
869 bool is_open; 869 bool is_open;
870 struct format_field *args; 870 struct tep_format_field *args;
871 const char *name; 871 const char *name;
872 struct syscall_fmt *fmt; 872 struct syscall_fmt *fmt;
873 struct syscall_arg_fmt *arg_fmt; 873 struct syscall_arg_fmt *arg_fmt;
@@ -1279,7 +1279,7 @@ static int syscall__alloc_arg_fmts(struct syscall *sc, int nr_args)
1279 1279
1280static int syscall__set_arg_fmts(struct syscall *sc) 1280static int syscall__set_arg_fmts(struct syscall *sc)
1281{ 1281{
1282 struct format_field *field, *last_field = NULL; 1282 struct tep_format_field *field, *last_field = NULL;
1283 int idx = 0, len; 1283 int idx = 0, len;
1284 1284
1285 for (field = sc->args; field; field = field->next, ++idx) { 1285 for (field = sc->args; field; field = field->next, ++idx) {
@@ -1293,7 +1293,7 @@ static int syscall__set_arg_fmts(struct syscall *sc)
1293 strcmp(field->name, "path") == 0 || 1293 strcmp(field->name, "path") == 0 ||
1294 strcmp(field->name, "pathname") == 0)) 1294 strcmp(field->name, "pathname") == 0))
1295 sc->arg_fmt[idx].scnprintf = SCA_FILENAME; 1295 sc->arg_fmt[idx].scnprintf = SCA_FILENAME;
1296 else if (field->flags & FIELD_IS_POINTER) 1296 else if (field->flags & TEP_FIELD_IS_POINTER)
1297 sc->arg_fmt[idx].scnprintf = syscall_arg__scnprintf_hex; 1297 sc->arg_fmt[idx].scnprintf = syscall_arg__scnprintf_hex;
1298 else if (strcmp(field->type, "pid_t") == 0) 1298 else if (strcmp(field->type, "pid_t") == 0)
1299 sc->arg_fmt[idx].scnprintf = SCA_PID; 1299 sc->arg_fmt[idx].scnprintf = SCA_PID;
@@ -1525,7 +1525,7 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size,
1525 ttrace->ret_scnprintf = NULL; 1525 ttrace->ret_scnprintf = NULL;
1526 1526
1527 if (sc->args != NULL) { 1527 if (sc->args != NULL) {
1528 struct format_field *field; 1528 struct tep_format_field *field;
1529 1529
1530 for (field = sc->args; field; 1530 for (field = sc->args; field;
1531 field = field->next, ++arg.idx, bit <<= 1) { 1531 field = field->next, ++arg.idx, bit <<= 1) {
diff --git a/tools/perf/command-list.txt b/tools/perf/command-list.txt
index 2d0caf20ff3a..bc6c585f74fc 100644
--- a/tools/perf/command-list.txt
+++ b/tools/perf/command-list.txt
@@ -30,3 +30,4 @@ perf-test mainporcelain common
30perf-timechart mainporcelain common 30perf-timechart mainporcelain common
31perf-top mainporcelain common 31perf-top mainporcelain common
32perf-trace mainporcelain audit 32perf-trace mainporcelain audit
33perf-version mainporcelain common
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/branch.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/branch.json
new file mode 100644
index 000000000000..abc98b018446
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/branch.json
@@ -0,0 +1,23 @@
1[
2 {
3 "ArchStdEvent": "BR_IMMED_SPEC",
4 },
5 {
6 "ArchStdEvent": "BR_RETURN_SPEC",
7 },
8 {
9 "ArchStdEvent": "BR_INDIRECT_SPEC",
10 },
11 {
12 "PublicDescription": "Mispredicted or not predicted branch speculatively executed",
13 "EventCode": "0x10",
14 "EventName": "BR_MIS_PRED",
15 "BriefDescription": "Branch mispredicted"
16 },
17 {
18 "PublicDescription": "Predictable branch speculatively executed",
19 "EventCode": "0x12",
20 "EventName": "BR_PRED",
21 "BriefDescription": "Predictable branch"
22 },
23]
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/bus.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/bus.json
new file mode 100644
index 000000000000..687b2629e1d1
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/bus.json
@@ -0,0 +1,26 @@
1[
2 {
3 "ArchStdEvent": "BUS_ACCESS_RD",
4 },
5 {
6 "ArchStdEvent": "BUS_ACCESS_WR",
7 },
8 {
9 "ArchStdEvent": "BUS_ACCESS_SHARED",
10 },
11 {
12 "ArchStdEvent": "BUS_ACCESS_NOT_SHARED",
13 },
14 {
15 "ArchStdEvent": "BUS_ACCESS_NORMAL",
16 },
17 {
18 "ArchStdEvent": "BUS_ACCESS_PERIPH",
19 },
20 {
21 "PublicDescription": "Bus access",
22 "EventCode": "0x19",
23 "EventName": "BUS_ACCESS",
24 "BriefDescription": "Bus access"
25 },
26]
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/cache.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/cache.json
new file mode 100644
index 000000000000..df9201434cb6
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/cache.json
@@ -0,0 +1,191 @@
1[
2 {
3 "ArchStdEvent": "L1D_CACHE_RD",
4 },
5 {
6 "ArchStdEvent": "L1D_CACHE_WR",
7 },
8 {
9 "ArchStdEvent": "L1D_CACHE_REFILL_RD",
10 },
11 {
12 "ArchStdEvent": "L1D_CACHE_INVAL",
13 },
14 {
15 "ArchStdEvent": "L1D_TLB_REFILL_RD",
16 },
17 {
18 "ArchStdEvent": "L1D_TLB_REFILL_WR",
19 },
20 {
21 "ArchStdEvent": "L2D_CACHE_RD",
22 },
23 {
24 "ArchStdEvent": "L2D_CACHE_WR",
25 },
26 {
27 "ArchStdEvent": "L2D_CACHE_REFILL_RD",
28 },
29 {
30 "ArchStdEvent": "L2D_CACHE_REFILL_WR",
31 },
32 {
33 "ArchStdEvent": "L2D_CACHE_WB_VICTIM",
34 },
35 {
36 "ArchStdEvent": "L2D_CACHE_WB_CLEAN",
37 },
38 {
39 "ArchStdEvent": "L2D_CACHE_INVAL",
40 },
41 {
42 "PublicDescription": "Level 1 instruction cache refill",
43 "EventCode": "0x01",
44 "EventName": "L1I_CACHE_REFILL",
45 "BriefDescription": "L1I cache refill"
46 },
47 {
48 "PublicDescription": "Level 1 instruction TLB refill",
49 "EventCode": "0x02",
50 "EventName": "L1I_TLB_REFILL",
51 "BriefDescription": "L1I TLB refill"
52 },
53 {
54 "PublicDescription": "Level 1 data cache refill",
55 "EventCode": "0x03",
56 "EventName": "L1D_CACHE_REFILL",
57 "BriefDescription": "L1D cache refill"
58 },
59 {
60 "PublicDescription": "Level 1 data cache access",
61 "EventCode": "0x04",
62 "EventName": "L1D_CACHE_ACCESS",
63 "BriefDescription": "L1D cache access"
64 },
65 {
66 "PublicDescription": "Level 1 data TLB refill",
67 "EventCode": "0x05",
68 "EventName": "L1D_TLB_REFILL",
69 "BriefDescription": "L1D TLB refill"
70 },
71 {
72 "PublicDescription": "Level 1 instruction cache access",
73 "EventCode": "0x14",
74 "EventName": "L1I_CACHE_ACCESS",
75 "BriefDescription": "L1I cache access"
76 },
77 {
78 "PublicDescription": "Level 2 data cache access",
79 "EventCode": "0x16",
80 "EventName": "L2D_CACHE_ACCESS",
81 "BriefDescription": "L2D cache access"
82 },
83 {
84 "PublicDescription": "Level 2 data refill",
85 "EventCode": "0x17",
86 "EventName": "L2D_CACHE_REFILL",
87 "BriefDescription": "L2D cache refill"
88 },
89 {
90 "PublicDescription": "Level 2 data cache, Write-Back",
91 "EventCode": "0x18",
92 "EventName": "L2D_CACHE_WB",
93 "BriefDescription": "L2D cache Write-Back"
94 },
95 {
96 "PublicDescription": "Level 1 data TLB access. This event counts any load or store operation which accesses the data L1 TLB",
97 "EventCode": "0x25",
98 "EventName": "L1D_TLB_ACCESS",
99 "BriefDescription": "L1D TLB access"
100 },
101 {
102 "PublicDescription": "Level 1 instruction TLB access. This event counts any instruction fetch which accesses the instruction L1 TLB",
103 "EventCode": "0x26",
104 "EventName": "L1I_TLB_ACCESS",
105 "BriefDescription": "L1I TLB access"
106 },
107 {
108 "PublicDescription": "Level 2 access to data TLB that caused a page table walk. This event counts on any data access which causes L2D_TLB_REFILL to count",
109 "EventCode": "0x34",
110 "EventName": "L2D_TLB_ACCESS",
111 "BriefDescription": "L2D TLB access"
112 },
113 {
114 "PublicDescription": "Level 2 access to instruciton TLB that caused a page table walk. This event counts on any instruciton access which causes L2I_TLB_REFILL to count",
115 "EventCode": "0x35",
116 "EventName": "L2I_TLB_ACCESS",
117 "BriefDescription": "L2D TLB access"
118 },
119 {
120 "PublicDescription": "Branch target buffer misprediction",
121 "EventCode": "0x102",
122 "EventName": "BTB_MIS_PRED",
123 "BriefDescription": "BTB misprediction"
124 },
125 {
126 "PublicDescription": "ITB miss",
127 "EventCode": "0x103",
128 "EventName": "ITB_MISS",
129 "BriefDescription": "ITB miss"
130 },
131 {
132 "PublicDescription": "DTB miss",
133 "EventCode": "0x104",
134 "EventName": "DTB_MISS",
135 "BriefDescription": "DTB miss"
136 },
137 {
138 "PublicDescription": "Level 1 data cache late miss",
139 "EventCode": "0x105",
140 "EventName": "L1D_CACHE_LATE_MISS",
141 "BriefDescription": "L1D cache late miss"
142 },
143 {
144 "PublicDescription": "Level 1 data cache prefetch request",
145 "EventCode": "0x106",
146 "EventName": "L1D_CACHE_PREFETCH",
147 "BriefDescription": "L1D cache prefetch"
148 },
149 {
150 "PublicDescription": "Level 2 data cache prefetch request",
151 "EventCode": "0x107",
152 "EventName": "L2D_CACHE_PREFETCH",
153 "BriefDescription": "L2D cache prefetch"
154 },
155 {
156 "PublicDescription": "Level 1 stage 2 TLB refill",
157 "EventCode": "0x111",
158 "EventName": "L1_STAGE2_TLB_REFILL",
159 "BriefDescription": "L1 stage 2 TLB refill"
160 },
161 {
162 "PublicDescription": "Page walk cache level-0 stage-1 hit",
163 "EventCode": "0x112",
164 "EventName": "PAGE_WALK_L0_STAGE1_HIT",
165 "BriefDescription": "Page walk, L0 stage-1 hit"
166 },
167 {
168 "PublicDescription": "Page walk cache level-1 stage-1 hit",
169 "EventCode": "0x113",
170 "EventName": "PAGE_WALK_L1_STAGE1_HIT",
171 "BriefDescription": "Page walk, L1 stage-1 hit"
172 },
173 {
174 "PublicDescription": "Page walk cache level-2 stage-1 hit",
175 "EventCode": "0x114",
176 "EventName": "PAGE_WALK_L2_STAGE1_HIT",
177 "BriefDescription": "Page walk, L2 stage-1 hit"
178 },
179 {
180 "PublicDescription": "Page walk cache level-1 stage-2 hit",
181 "EventCode": "0x115",
182 "EventName": "PAGE_WALK_L1_STAGE2_HIT",
183 "BriefDescription": "Page walk, L1 stage-2 hit"
184 },
185 {
186 "PublicDescription": "Page walk cache level-2 stage-2 hit",
187 "EventCode": "0x116",
188 "EventName": "PAGE_WALK_L2_STAGE2_HIT",
189 "BriefDescription": "Page walk, L2 stage-2 hit"
190 },
191]
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/clock.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/clock.json
new file mode 100644
index 000000000000..38cd1f1a70dc
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/clock.json
@@ -0,0 +1,20 @@
1[
2 {
3 "PublicDescription": "The number of core clock cycles",
4 "EventCode": "0x11",
5 "EventName": "CPU_CYCLES",
6 "BriefDescription": "Clock cycles"
7 },
8 {
9 "PublicDescription": "FSU clocking gated off cycle",
10 "EventCode": "0x101",
11 "EventName": "FSU_CLOCK_OFF_CYCLES",
12 "BriefDescription": "FSU clocking gated off cycle"
13 },
14 {
15 "PublicDescription": "Wait state cycle",
16 "EventCode": "0x110",
17 "EventName": "Wait_CYCLES",
18 "BriefDescription": "Wait state cycle"
19 },
20]
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json
deleted file mode 100644
index bc03c06c3918..000000000000
--- a/tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json
+++ /dev/null
@@ -1,32 +0,0 @@
1[
2 {
3 "ArchStdEvent": "L1D_CACHE_RD",
4 },
5 {
6 "ArchStdEvent": "L1D_CACHE_WR",
7 },
8 {
9 "ArchStdEvent": "L1D_CACHE_REFILL_RD",
10 },
11 {
12 "ArchStdEvent": "L1D_CACHE_REFILL_WR",
13 },
14 {
15 "ArchStdEvent": "L1D_TLB_REFILL_RD",
16 },
17 {
18 "ArchStdEvent": "L1D_TLB_REFILL_WR",
19 },
20 {
21 "ArchStdEvent": "L1D_TLB_RD",
22 },
23 {
24 "ArchStdEvent": "L1D_TLB_WR",
25 },
26 {
27 "ArchStdEvent": "BUS_ACCESS_RD",
28 },
29 {
30 "ArchStdEvent": "BUS_ACCESS_WR",
31 }
32]
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/exception.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/exception.json
new file mode 100644
index 000000000000..3720dc28a15f
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/exception.json
@@ -0,0 +1,50 @@
1[
2 {
3 "ArchStdEvent": "EXC_UNDEF",
4 },
5 {
6 "ArchStdEvent": "EXC_SVC",
7 },
8 {
9 "ArchStdEvent": "EXC_PABORT",
10 },
11 {
12 "ArchStdEvent": "EXC_DABORT",
13 },
14 {
15 "ArchStdEvent": "EXC_IRQ",
16 },
17 {
18 "ArchStdEvent": "EXC_FIQ",
19 },
20 {
21 "ArchStdEvent": "EXC_HVC",
22 },
23 {
24 "ArchStdEvent": "EXC_TRAP_PABORT",
25 },
26 {
27 "ArchStdEvent": "EXC_TRAP_DABORT",
28 },
29 {
30 "ArchStdEvent": "EXC_TRAP_OTHER",
31 },
32 {
33 "ArchStdEvent": "EXC_TRAP_IRQ",
34 },
35 {
36 "ArchStdEvent": "EXC_TRAP_FIQ",
37 },
38 {
39 "PublicDescription": "Exception taken",
40 "EventCode": "0x09",
41 "EventName": "EXC_TAKEN",
42 "BriefDescription": "Exception taken"
43 },
44 {
45 "PublicDescription": "Instruction architecturally executed, condition check pass, exception return",
46 "EventCode": "0x0a",
47 "EventName": "EXC_RETURN",
48 "BriefDescription": "Exception return"
49 },
50]
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/instruction.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/instruction.json
new file mode 100644
index 000000000000..82cf753e6472
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/instruction.json
@@ -0,0 +1,89 @@
1[
2 {
3 "ArchStdEvent": "LD_SPEC",
4 },
5 {
6 "ArchStdEvent": "ST_SPEC",
7 },
8 {
9 "ArchStdEvent": "LDST_SPEC",
10 },
11 {
12 "ArchStdEvent": "DP_SPEC",
13 },
14 {
15 "ArchStdEvent": "ASE_SPEC",
16 },
17 {
18 "ArchStdEvent": "VFP_SPEC",
19 },
20 {
21 "ArchStdEvent": "PC_WRITE_SPEC",
22 },
23 {
24 "ArchStdEvent": "CRYPTO_SPEC",
25 },
26 {
27 "ArchStdEvent": "ISB_SPEC",
28 },
29 {
30 "ArchStdEvent": "DSB_SPEC",
31 },
32 {
33 "ArchStdEvent": "DMB_SPEC",
34 },
35 {
36 "ArchStdEvent": "RC_LD_SPEC",
37 },
38 {
39 "ArchStdEvent": "RC_ST_SPEC",
40 },
41 {
42 "PublicDescription": "Instruction architecturally executed, software increment",
43 "EventCode": "0x00",
44 "EventName": "SW_INCR",
45 "BriefDescription": "Software increment"
46 },
47 {
48 "PublicDescription": "Instruction architecturally executed",
49 "EventCode": "0x08",
50 "EventName": "INST_RETIRED",
51 "BriefDescription": "Instruction retired"
52 },
53 {
54 "PublicDescription": "Instruction architecturally executed, condition code check pass, write to CONTEXTIDR",
55 "EventCode": "0x0b",
56 "EventName": "CID_WRITE_RETIRED",
57 "BriefDescription": "Write to CONTEXTIDR"
58 },
59 {
60 "PublicDescription": "Operation speculatively executed",
61 "EventCode": "0x1b",
62 "EventName": "INST_SPEC",
63 "BriefDescription": "Speculatively executed"
64 },
65 {
66 "PublicDescription": "Instruction architecturally executed (condition check pass), write to TTBR",
67 "EventCode": "0x1c",
68 "EventName": "TTBR_WRITE_RETIRED",
69 "BriefDescription": "Instruction executed, TTBR write"
70 },
71 {
72 "PublicDescription": "Instruction architecturally executed, branch. This event counts all branches, taken or not. This excludes exception entries, debug entries and CCFAIL branches",
73 "EventCode": "0x21",
74 "EventName": "BR_RETIRED",
75 "BriefDescription": "Branch retired"
76 },
77 {
78 "PublicDescription": "Instruction architecturally executed, mispredicted branch. This event counts any branch counted by BR_RETIRED which is not correctly predicted and causes a pipeline flush",
79 "EventCode": "0x22",
80 "EventName": "BR_MISPRED_RETIRED",
81 "BriefDescription": "Mispredicted branch retired"
82 },
83 {
84 "PublicDescription": "Operation speculatively executed, NOP",
85 "EventCode": "0x100",
86 "EventName": "NOP_SPEC",
87 "BriefDescription": "Speculatively executed, NOP"
88 },
89]
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/intrinsic.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/intrinsic.json
new file mode 100644
index 000000000000..2aecc5c2347d
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/intrinsic.json
@@ -0,0 +1,14 @@
1[
2 {
3 "ArchStdEvent": "LDREX_SPEC",
4 },
5 {
6 "ArchStdEvent": "STREX_PASS_SPEC",
7 },
8 {
9 "ArchStdEvent": "STREX_FAIL_SPEC",
10 },
11 {
12 "ArchStdEvent": "STREX_SPEC",
13 },
14]
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/memory.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/memory.json
new file mode 100644
index 000000000000..08508697b318
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/memory.json
@@ -0,0 +1,29 @@
1[
2 {
3 "ArchStdEvent": "MEM_ACCESS_RD",
4 },
5 {
6 "ArchStdEvent": "MEM_ACCESS_WR",
7 },
8 {
9 "ArchStdEvent": "UNALIGNED_LD_SPEC",
10 },
11 {
12 "ArchStdEvent": "UNALIGNED_ST_SPEC",
13 },
14 {
15 "ArchStdEvent": "UNALIGNED_LDST_SPEC",
16 },
17 {
18 "PublicDescription": "Data memory access",
19 "EventCode": "0x13",
20 "EventName": "MEM_ACCESS",
21 "BriefDescription": "Memory access"
22 },
23 {
24 "PublicDescription": "Local memory error. This event counts any correctable or uncorrectable memory error (ECC or parity) in the protected core RAMs",
25 "EventCode": "0x1a",
26 "EventName": "MEM_ERROR",
27 "BriefDescription": "Memory error"
28 },
29]
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/pipeline.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/pipeline.json
new file mode 100644
index 000000000000..e2087de586bf
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/pipeline.json
@@ -0,0 +1,50 @@
1[
2 {
3 "PublicDescription": "Decode starved for instruction cycle",
4 "EventCode": "0x108",
5 "EventName": "DECODE_STALL",
6 "BriefDescription": "Decode starved"
7 },
8 {
9 "PublicDescription": "Op dispatch stalled cycle",
10 "EventCode": "0x109",
11 "EventName": "DISPATCH_STALL",
12 "BriefDescription": "Dispatch stalled"
13 },
14 {
15 "PublicDescription": "IXA Op non-issue",
16 "EventCode": "0x10a",
17 "EventName": "IXA_STALL",
18 "BriefDescription": "IXA stalled"
19 },
20 {
21 "PublicDescription": "IXB Op non-issue",
22 "EventCode": "0x10b",
23 "EventName": "IXB_STALL",
24 "BriefDescription": "IXB stalled"
25 },
26 {
27 "PublicDescription": "BX Op non-issue",
28 "EventCode": "0x10c",
29 "EventName": "BX_STALL",
30 "BriefDescription": "BX stalled"
31 },
32 {
33 "PublicDescription": "LX Op non-issue",
34 "EventCode": "0x10d",
35 "EventName": "LX_STALL",
36 "BriefDescription": "LX stalled"
37 },
38 {
39 "PublicDescription": "SX Op non-issue",
40 "EventCode": "0x10e",
41 "EventName": "SX_STALL",
42 "BriefDescription": "SX stalled"
43 },
44 {
45 "PublicDescription": "FX Op non-issue",
46 "EventCode": "0x10f",
47 "EventName": "FX_STALL",
48 "BriefDescription": "FX stalled"
49 },
50]
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
index 699561fa512c..5f8501c68da4 100644
--- a/tools/perf/tests/evsel-tp-sched.c
+++ b/tools/perf/tests/evsel-tp-sched.c
@@ -8,7 +8,7 @@
8static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name, 8static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
9 int size, bool should_be_signed) 9 int size, bool should_be_signed)
10{ 10{
11 struct format_field *field = perf_evsel__field(evsel, name); 11 struct tep_format_field *field = perf_evsel__field(evsel, name);
12 int is_signed; 12 int is_signed;
13 int ret = 0; 13 int ret = 0;
14 14
@@ -17,7 +17,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
17 return -1; 17 return -1;
18 } 18 }
19 19
20 is_signed = !!(field->flags | FIELD_IS_SIGNED); 20 is_signed = !!(field->flags | TEP_FIELD_IS_SIGNED);
21 if (should_be_signed && !is_signed) { 21 if (should_be_signed && !is_signed) {
22 pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n", 22 pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
23 evsel->name, name, is_signed, should_be_signed); 23 evsel->name, name, is_signed, should_be_signed);
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index a86b7eab6673..0a6ce9c4fc11 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -576,6 +576,23 @@ static inline void auxtrace__free(struct perf_session *session)
576 return session->auxtrace->free(session); 576 return session->auxtrace->free(session);
577} 577}
578 578
579#define ITRACE_HELP \
580" i: synthesize instructions events\n" \
581" b: synthesize branches events\n" \
582" c: synthesize branches events (calls only)\n" \
583" r: synthesize branches events (returns only)\n" \
584" x: synthesize transactions events\n" \
585" w: synthesize ptwrite events\n" \
586" p: synthesize power events\n" \
587" e: synthesize error events\n" \
588" d: create a debug log\n" \
589" g[len]: synthesize a call chain (use with i or x)\n" \
590" l[len]: synthesize last branch entries (use with i or x)\n" \
591" sNUMBER: skip initial number of events\n" \
592" PERIOD[ns|us|ms|i|t]: specify period to sample stream\n" \
593" concatenate multiple options. Default is ibxwpe or cewp\n"
594
595
579#else 596#else
580 597
581static inline struct auxtrace_record * 598static inline struct auxtrace_record *
@@ -716,6 +733,8 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
716 struct perf_evlist *evlist, int idx, 733 struct perf_evlist *evlist, int idx,
717 bool per_cpu); 734 bool per_cpu);
718 735
736#define ITRACE_HELP ""
737
719#endif 738#endif
720 739
721#endif 740#endif
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index f75d4aa612c5..2a36fab76994 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -182,20 +182,20 @@ err_put_field:
182} 182}
183 183
184static struct bt_ctf_field_type* 184static struct bt_ctf_field_type*
185get_tracepoint_field_type(struct ctf_writer *cw, struct format_field *field) 185get_tracepoint_field_type(struct ctf_writer *cw, struct tep_format_field *field)
186{ 186{
187 unsigned long flags = field->flags; 187 unsigned long flags = field->flags;
188 188
189 if (flags & FIELD_IS_STRING) 189 if (flags & TEP_FIELD_IS_STRING)
190 return cw->data.string; 190 return cw->data.string;
191 191
192 if (!(flags & FIELD_IS_SIGNED)) { 192 if (!(flags & TEP_FIELD_IS_SIGNED)) {
193 /* unsigned long are mostly pointers */ 193 /* unsigned long are mostly pointers */
194 if (flags & FIELD_IS_LONG || flags & FIELD_IS_POINTER) 194 if (flags & TEP_FIELD_IS_LONG || flags & TEP_FIELD_IS_POINTER)
195 return cw->data.u64_hex; 195 return cw->data.u64_hex;
196 } 196 }
197 197
198 if (flags & FIELD_IS_SIGNED) { 198 if (flags & TEP_FIELD_IS_SIGNED) {
199 if (field->size == 8) 199 if (field->size == 8)
200 return cw->data.s64; 200 return cw->data.s64;
201 else 201 else
@@ -287,7 +287,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
287 struct bt_ctf_event_class *event_class, 287 struct bt_ctf_event_class *event_class,
288 struct bt_ctf_event *event, 288 struct bt_ctf_event *event,
289 struct perf_sample *sample, 289 struct perf_sample *sample,
290 struct format_field *fmtf) 290 struct tep_format_field *fmtf)
291{ 291{
292 struct bt_ctf_field_type *type; 292 struct bt_ctf_field_type *type;
293 struct bt_ctf_field *array_field; 293 struct bt_ctf_field *array_field;
@@ -304,10 +304,10 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
304 name = fmtf->alias; 304 name = fmtf->alias;
305 offset = fmtf->offset; 305 offset = fmtf->offset;
306 len = fmtf->size; 306 len = fmtf->size;
307 if (flags & FIELD_IS_STRING) 307 if (flags & TEP_FIELD_IS_STRING)
308 flags &= ~FIELD_IS_ARRAY; 308 flags &= ~TEP_FIELD_IS_ARRAY;
309 309
310 if (flags & FIELD_IS_DYNAMIC) { 310 if (flags & TEP_FIELD_IS_DYNAMIC) {
311 unsigned long long tmp_val; 311 unsigned long long tmp_val;
312 312
313 tmp_val = tep_read_number(fmtf->event->pevent, 313 tmp_val = tep_read_number(fmtf->event->pevent,
@@ -317,7 +317,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
317 offset &= 0xffff; 317 offset &= 0xffff;
318 } 318 }
319 319
320 if (flags & FIELD_IS_ARRAY) { 320 if (flags & TEP_FIELD_IS_ARRAY) {
321 321
322 type = bt_ctf_event_class_get_field_by_name( 322 type = bt_ctf_event_class_get_field_by_name(
323 event_class, name); 323 event_class, name);
@@ -338,7 +338,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
338 type = get_tracepoint_field_type(cw, fmtf); 338 type = get_tracepoint_field_type(cw, fmtf);
339 339
340 for (i = 0; i < n_items; i++) { 340 for (i = 0; i < n_items; i++) {
341 if (flags & FIELD_IS_ARRAY) 341 if (flags & TEP_FIELD_IS_ARRAY)
342 field = bt_ctf_field_array_get_field(array_field, i); 342 field = bt_ctf_field_array_get_field(array_field, i);
343 else 343 else
344 field = bt_ctf_field_create(type); 344 field = bt_ctf_field_create(type);
@@ -348,7 +348,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
348 return -1; 348 return -1;
349 } 349 }
350 350
351 if (flags & FIELD_IS_STRING) 351 if (flags & TEP_FIELD_IS_STRING)
352 ret = string_set_value(field, data + offset + i * len); 352 ret = string_set_value(field, data + offset + i * len);
353 else { 353 else {
354 unsigned long long value_int; 354 unsigned long long value_int;
@@ -357,7 +357,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
357 fmtf->event->pevent, 357 fmtf->event->pevent,
358 data + offset + i * len, len); 358 data + offset + i * len, len);
359 359
360 if (!(flags & FIELD_IS_SIGNED)) 360 if (!(flags & TEP_FIELD_IS_SIGNED))
361 ret = bt_ctf_field_unsigned_integer_set_value( 361 ret = bt_ctf_field_unsigned_integer_set_value(
362 field, value_int); 362 field, value_int);
363 else 363 else
@@ -369,7 +369,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
369 pr_err("failed to set file value %s\n", name); 369 pr_err("failed to set file value %s\n", name);
370 goto err_put_field; 370 goto err_put_field;
371 } 371 }
372 if (!(flags & FIELD_IS_ARRAY)) { 372 if (!(flags & TEP_FIELD_IS_ARRAY)) {
373 ret = bt_ctf_event_set_payload(event, name, field); 373 ret = bt_ctf_event_set_payload(event, name, field);
374 if (ret) { 374 if (ret) {
375 pr_err("failed to set payload %s\n", name); 375 pr_err("failed to set payload %s\n", name);
@@ -378,7 +378,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
378 } 378 }
379 bt_ctf_field_put(field); 379 bt_ctf_field_put(field);
380 } 380 }
381 if (flags & FIELD_IS_ARRAY) { 381 if (flags & TEP_FIELD_IS_ARRAY) {
382 ret = bt_ctf_event_set_payload(event, name, array_field); 382 ret = bt_ctf_event_set_payload(event, name, array_field);
383 if (ret) { 383 if (ret) {
384 pr_err("Failed add payload array %s\n", name); 384 pr_err("Failed add payload array %s\n", name);
@@ -396,10 +396,10 @@ err_put_field:
396static int add_tracepoint_fields_values(struct ctf_writer *cw, 396static int add_tracepoint_fields_values(struct ctf_writer *cw,
397 struct bt_ctf_event_class *event_class, 397 struct bt_ctf_event_class *event_class,
398 struct bt_ctf_event *event, 398 struct bt_ctf_event *event,
399 struct format_field *fields, 399 struct tep_format_field *fields,
400 struct perf_sample *sample) 400 struct perf_sample *sample)
401{ 401{
402 struct format_field *field; 402 struct tep_format_field *field;
403 int ret; 403 int ret;
404 404
405 for (field = fields; field; field = field->next) { 405 for (field = fields; field; field = field->next) {
@@ -417,8 +417,8 @@ static int add_tracepoint_values(struct ctf_writer *cw,
417 struct perf_evsel *evsel, 417 struct perf_evsel *evsel,
418 struct perf_sample *sample) 418 struct perf_sample *sample)
419{ 419{
420 struct format_field *common_fields = evsel->tp_format->format.common_fields; 420 struct tep_format_field *common_fields = evsel->tp_format->format.common_fields;
421 struct format_field *fields = evsel->tp_format->format.fields; 421 struct tep_format_field *fields = evsel->tp_format->format.fields;
422 int ret; 422 int ret;
423 423
424 ret = add_tracepoint_fields_values(cw, event_class, event, 424 ret = add_tracepoint_fields_values(cw, event_class, event,
@@ -970,7 +970,7 @@ out:
970 970
971static int event_class_add_field(struct bt_ctf_event_class *event_class, 971static int event_class_add_field(struct bt_ctf_event_class *event_class,
972 struct bt_ctf_field_type *type, 972 struct bt_ctf_field_type *type,
973 struct format_field *field) 973 struct tep_format_field *field)
974{ 974{
975 struct bt_ctf_field_type *t = NULL; 975 struct bt_ctf_field_type *t = NULL;
976 char *name; 976 char *name;
@@ -1009,10 +1009,10 @@ static int event_class_add_field(struct bt_ctf_event_class *event_class,
1009} 1009}
1010 1010
1011static int add_tracepoint_fields_types(struct ctf_writer *cw, 1011static int add_tracepoint_fields_types(struct ctf_writer *cw,
1012 struct format_field *fields, 1012 struct tep_format_field *fields,
1013 struct bt_ctf_event_class *event_class) 1013 struct bt_ctf_event_class *event_class)
1014{ 1014{
1015 struct format_field *field; 1015 struct tep_format_field *field;
1016 int ret; 1016 int ret;
1017 1017
1018 for (field = fields; field; field = field->next) { 1018 for (field = fields; field; field = field->next) {
@@ -1030,15 +1030,15 @@ static int add_tracepoint_fields_types(struct ctf_writer *cw,
1030 * type and don't care that it is an array. What we don't 1030 * type and don't care that it is an array. What we don't
1031 * support is an array of strings. 1031 * support is an array of strings.
1032 */ 1032 */
1033 if (flags & FIELD_IS_STRING) 1033 if (flags & TEP_FIELD_IS_STRING)
1034 flags &= ~FIELD_IS_ARRAY; 1034 flags &= ~TEP_FIELD_IS_ARRAY;
1035 1035
1036 if (flags & FIELD_IS_ARRAY) 1036 if (flags & TEP_FIELD_IS_ARRAY)
1037 type = bt_ctf_field_type_array_create(type, field->arraylen); 1037 type = bt_ctf_field_type_array_create(type, field->arraylen);
1038 1038
1039 ret = event_class_add_field(event_class, type, field); 1039 ret = event_class_add_field(event_class, type, field);
1040 1040
1041 if (flags & FIELD_IS_ARRAY) 1041 if (flags & TEP_FIELD_IS_ARRAY)
1042 bt_ctf_field_type_put(type); 1042 bt_ctf_field_type_put(type);
1043 1043
1044 if (ret) { 1044 if (ret) {
@@ -1055,8 +1055,8 @@ static int add_tracepoint_types(struct ctf_writer *cw,
1055 struct perf_evsel *evsel, 1055 struct perf_evsel *evsel,
1056 struct bt_ctf_event_class *class) 1056 struct bt_ctf_event_class *class)
1057{ 1057{
1058 struct format_field *common_fields = evsel->tp_format->format.common_fields; 1058 struct tep_format_field *common_fields = evsel->tp_format->format.common_fields;
1059 struct format_field *fields = evsel->tp_format->format.fields; 1059 struct tep_format_field *fields = evsel->tp_format->format.fields;
1060 int ret; 1060 int ret;
1061 1061
1062 ret = add_tracepoint_fields_types(cw, common_fields, class); 1062 ret = add_tracepoint_fields_types(cw, common_fields, class);
diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index 7123746edcf4..69fbb0a72d0c 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -463,6 +463,28 @@ int db_export__branch_types(struct db_export *dbe)
463 if (err) 463 if (err)
464 break; 464 break;
465 } 465 }
466
467 /* Add trace begin / end variants */
468 for (i = 0; branch_types[i].name ; i++) {
469 const char *name = branch_types[i].name;
470 u32 type = branch_types[i].branch_type;
471 char buf[64];
472
473 if (type == PERF_IP_FLAG_BRANCH ||
474 (type & (PERF_IP_FLAG_TRACE_BEGIN | PERF_IP_FLAG_TRACE_END)))
475 continue;
476
477 snprintf(buf, sizeof(buf), "trace begin / %s", name);
478 err = db_export__branch_type(dbe, type | PERF_IP_FLAG_TRACE_BEGIN, buf);
479 if (err)
480 break;
481
482 snprintf(buf, sizeof(buf), "%s / trace end", name);
483 err = db_export__branch_type(dbe, type | PERF_IP_FLAG_TRACE_END, buf);
484 if (err)
485 break;
486 }
487
466 return err; 488 return err;
467} 489}
468 490
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 4ec909d57e9c..cb7f01059940 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2682,7 +2682,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
2682 return 0; 2682 return 0;
2683} 2683}
2684 2684
2685struct format_field *perf_evsel__field(struct perf_evsel *evsel, const char *name) 2685struct tep_format_field *perf_evsel__field(struct perf_evsel *evsel, const char *name)
2686{ 2686{
2687 return tep_find_field(evsel->tp_format, name); 2687 return tep_find_field(evsel->tp_format, name);
2688} 2688}
@@ -2690,7 +2690,7 @@ struct format_field *perf_evsel__field(struct perf_evsel *evsel, const char *nam
2690void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample, 2690void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample,
2691 const char *name) 2691 const char *name)
2692{ 2692{
2693 struct format_field *field = perf_evsel__field(evsel, name); 2693 struct tep_format_field *field = perf_evsel__field(evsel, name);
2694 int offset; 2694 int offset;
2695 2695
2696 if (!field) 2696 if (!field)
@@ -2698,7 +2698,7 @@ void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample,
2698 2698
2699 offset = field->offset; 2699 offset = field->offset;
2700 2700
2701 if (field->flags & FIELD_IS_DYNAMIC) { 2701 if (field->flags & TEP_FIELD_IS_DYNAMIC) {
2702 offset = *(int *)(sample->raw_data + field->offset); 2702 offset = *(int *)(sample->raw_data + field->offset);
2703 offset &= 0xffff; 2703 offset &= 0xffff;
2704 } 2704 }
@@ -2706,7 +2706,7 @@ void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample,
2706 return sample->raw_data + offset; 2706 return sample->raw_data + offset;
2707} 2707}
2708 2708
2709u64 format_field__intval(struct format_field *field, struct perf_sample *sample, 2709u64 format_field__intval(struct tep_format_field *field, struct perf_sample *sample,
2710 bool needs_swap) 2710 bool needs_swap)
2711{ 2711{
2712 u64 value; 2712 u64 value;
@@ -2748,7 +2748,7 @@ u64 format_field__intval(struct format_field *field, struct perf_sample *sample,
2748u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample, 2748u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample,
2749 const char *name) 2749 const char *name)
2750{ 2750{
2751 struct format_field *field = perf_evsel__field(evsel, name); 2751 struct tep_format_field *field = perf_evsel__field(evsel, name);
2752 2752
2753 if (!field) 2753 if (!field)
2754 return 0; 2754 return 0;
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 4f8430a85531..4107c39f4a54 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -102,7 +102,7 @@ struct perf_evsel {
102 char *name; 102 char *name;
103 double scale; 103 double scale;
104 const char *unit; 104 const char *unit;
105 struct event_format *tp_format; 105 struct tep_event_format *tp_format;
106 off_t id_offset; 106 off_t id_offset;
107 struct perf_stat_evsel *stats; 107 struct perf_stat_evsel *stats;
108 void *priv; 108 void *priv;
@@ -211,7 +211,7 @@ static inline struct perf_evsel *perf_evsel__newtp(const char *sys, const char *
211 211
212struct perf_evsel *perf_evsel__new_cycles(bool precise); 212struct perf_evsel *perf_evsel__new_cycles(bool precise);
213 213
214struct event_format *event_format__new(const char *sys, const char *name); 214struct tep_event_format *event_format__new(const char *sys, const char *name);
215 215
216void perf_evsel__init(struct perf_evsel *evsel, 216void perf_evsel__init(struct perf_evsel *evsel,
217 struct perf_event_attr *attr, int idx); 217 struct perf_event_attr *attr, int idx);
@@ -296,11 +296,11 @@ static inline char *perf_evsel__strval(struct perf_evsel *evsel,
296 return perf_evsel__rawptr(evsel, sample, name); 296 return perf_evsel__rawptr(evsel, sample, name);
297} 297}
298 298
299struct format_field; 299struct tep_format_field;
300 300
301u64 format_field__intval(struct format_field *field, struct perf_sample *sample, bool needs_swap); 301u64 format_field__intval(struct tep_format_field *field, struct perf_sample *sample, bool needs_swap);
302 302
303struct format_field *perf_evsel__field(struct perf_evsel *evsel, const char *name); 303struct tep_format_field *perf_evsel__field(struct perf_evsel *evsel, const char *name);
304 304
305#define perf_evsel__match(evsel, t, c) \ 305#define perf_evsel__match(evsel, t, c) \
306 (evsel->attr.type == PERF_TYPE_##t && \ 306 (evsel->attr.type == PERF_TYPE_##t && \
diff --git a/tools/perf/util/evsel_fprintf.c b/tools/perf/util/evsel_fprintf.c
index 06dfb027879d..0d0a4c6f368b 100644
--- a/tools/perf/util/evsel_fprintf.c
+++ b/tools/perf/util/evsel_fprintf.c
@@ -73,7 +73,7 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
73 } 73 }
74 74
75 if (details->trace_fields) { 75 if (details->trace_fields) {
76 struct format_field *field; 76 struct tep_format_field *field;
77 77
78 if (evsel->attr.type != PERF_TYPE_TRACEPOINT) { 78 if (evsel->attr.type != PERF_TYPE_TRACEPOINT) {
79 printed += comma_fprintf(fp, &first, " (not a tracepoint)"); 79 printed += comma_fprintf(fp, &first, " (not a tracepoint)");
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index c78051ad1fcc..1ec1d9bc2d63 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -3206,7 +3206,7 @@ static int read_attr(int fd, struct perf_header *ph,
3206static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel, 3206static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel,
3207 struct tep_handle *pevent) 3207 struct tep_handle *pevent)
3208{ 3208{
3209 struct event_format *event; 3209 struct tep_event_format *event;
3210 char bf[128]; 3210 char bf[128];
3211 3211
3212 /* already prepared */ 3212 /* already prepared */
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
index d404bed7003a..58f6a9ceb590 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
@@ -1165,7 +1165,7 @@ static int intel_pt_walk_tip(struct intel_pt_decoder *decoder)
1165 decoder->pge = false; 1165 decoder->pge = false;
1166 decoder->continuous_period = false; 1166 decoder->continuous_period = false;
1167 decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; 1167 decoder->pkt_state = INTEL_PT_STATE_IN_SYNC;
1168 decoder->state.to_ip = 0; 1168 decoder->state.type |= INTEL_PT_TRACE_END;
1169 return 0; 1169 return 0;
1170 } 1170 }
1171 if (err == INTEL_PT_RETURN) 1171 if (err == INTEL_PT_RETURN)
@@ -1179,9 +1179,13 @@ static int intel_pt_walk_tip(struct intel_pt_decoder *decoder)
1179 decoder->continuous_period = false; 1179 decoder->continuous_period = false;
1180 decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; 1180 decoder->pkt_state = INTEL_PT_STATE_IN_SYNC;
1181 decoder->state.from_ip = decoder->ip; 1181 decoder->state.from_ip = decoder->ip;
1182 decoder->state.to_ip = 0; 1182 if (decoder->packet.count == 0) {
1183 if (decoder->packet.count != 0) 1183 decoder->state.to_ip = 0;
1184 } else {
1185 decoder->state.to_ip = decoder->last_ip;
1184 decoder->ip = decoder->last_ip; 1186 decoder->ip = decoder->last_ip;
1187 }
1188 decoder->state.type |= INTEL_PT_TRACE_END;
1185 } else { 1189 } else {
1186 decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; 1190 decoder->pkt_state = INTEL_PT_STATE_IN_SYNC;
1187 decoder->state.from_ip = decoder->ip; 1191 decoder->state.from_ip = decoder->ip;
@@ -1208,7 +1212,8 @@ static int intel_pt_walk_tip(struct intel_pt_decoder *decoder)
1208 decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; 1212 decoder->pkt_state = INTEL_PT_STATE_IN_SYNC;
1209 decoder->ip = to_ip; 1213 decoder->ip = to_ip;
1210 decoder->state.from_ip = decoder->ip; 1214 decoder->state.from_ip = decoder->ip;
1211 decoder->state.to_ip = 0; 1215 decoder->state.to_ip = to_ip;
1216 decoder->state.type |= INTEL_PT_TRACE_END;
1212 return 0; 1217 return 0;
1213 } 1218 }
1214 intel_pt_log_at("ERROR: Conditional branch when expecting indirect branch", 1219 intel_pt_log_at("ERROR: Conditional branch when expecting indirect branch",
@@ -1640,14 +1645,15 @@ static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder)
1640 1645
1641 case INTEL_PT_TIP_PGD: 1646 case INTEL_PT_TIP_PGD:
1642 decoder->state.from_ip = decoder->ip; 1647 decoder->state.from_ip = decoder->ip;
1643 decoder->state.to_ip = 0; 1648 if (decoder->packet.count == 0) {
1644 if (decoder->packet.count != 0) { 1649 decoder->state.to_ip = 0;
1650 } else {
1645 intel_pt_set_ip(decoder); 1651 intel_pt_set_ip(decoder);
1646 intel_pt_log("Omitting PGD ip " x64_fmt "\n", 1652 decoder->state.to_ip = decoder->ip;
1647 decoder->ip);
1648 } 1653 }
1649 decoder->pge = false; 1654 decoder->pge = false;
1650 decoder->continuous_period = false; 1655 decoder->continuous_period = false;
1656 decoder->state.type |= INTEL_PT_TRACE_END;
1651 return 0; 1657 return 0;
1652 1658
1653 case INTEL_PT_TIP_PGE: 1659 case INTEL_PT_TIP_PGE:
@@ -1661,6 +1667,7 @@ static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder)
1661 intel_pt_set_ip(decoder); 1667 intel_pt_set_ip(decoder);
1662 decoder->state.to_ip = decoder->ip; 1668 decoder->state.to_ip = decoder->ip;
1663 } 1669 }
1670 decoder->state.type |= INTEL_PT_TRACE_BEGIN;
1664 return 0; 1671 return 0;
1665 1672
1666 case INTEL_PT_TIP: 1673 case INTEL_PT_TIP:
@@ -1739,6 +1746,7 @@ next:
1739 intel_pt_set_ip(decoder); 1746 intel_pt_set_ip(decoder);
1740 decoder->state.from_ip = 0; 1747 decoder->state.from_ip = 0;
1741 decoder->state.to_ip = decoder->ip; 1748 decoder->state.to_ip = decoder->ip;
1749 decoder->state.type |= INTEL_PT_TRACE_BEGIN;
1742 return 0; 1750 return 0;
1743 } 1751 }
1744 1752
@@ -2077,9 +2085,13 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)
2077 decoder->pge = decoder->packet.type != INTEL_PT_TIP_PGD; 2085 decoder->pge = decoder->packet.type != INTEL_PT_TIP_PGD;
2078 if (intel_pt_have_ip(decoder)) 2086 if (intel_pt_have_ip(decoder))
2079 intel_pt_set_ip(decoder); 2087 intel_pt_set_ip(decoder);
2080 if (decoder->ip) 2088 if (!decoder->ip)
2081 return 0; 2089 break;
2082 break; 2090 if (decoder->packet.type == INTEL_PT_TIP_PGE)
2091 decoder->state.type |= INTEL_PT_TRACE_BEGIN;
2092 if (decoder->packet.type == INTEL_PT_TIP_PGD)
2093 decoder->state.type |= INTEL_PT_TRACE_END;
2094 return 0;
2083 2095
2084 case INTEL_PT_FUP: 2096 case INTEL_PT_FUP:
2085 if (intel_pt_have_ip(decoder)) 2097 if (intel_pt_have_ip(decoder))
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
index 51c18d67f4ca..ed088d4726ba 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
@@ -37,6 +37,8 @@ enum intel_pt_sample_type {
37 INTEL_PT_EX_STOP = 1 << 6, 37 INTEL_PT_EX_STOP = 1 << 6,
38 INTEL_PT_PWR_EXIT = 1 << 7, 38 INTEL_PT_PWR_EXIT = 1 << 7,
39 INTEL_PT_CBR_CHG = 1 << 8, 39 INTEL_PT_CBR_CHG = 1 << 8,
40 INTEL_PT_TRACE_BEGIN = 1 << 9,
41 INTEL_PT_TRACE_END = 1 << 10,
40}; 42};
41 43
42enum intel_pt_period_type { 44enum intel_pt_period_type {
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index aec68908d604..48c1d415c6b0 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -908,6 +908,11 @@ static void intel_pt_sample_flags(struct intel_pt_queue *ptq)
908 ptq->insn_len = ptq->state->insn_len; 908 ptq->insn_len = ptq->state->insn_len;
909 memcpy(ptq->insn, ptq->state->insn, INTEL_PT_INSN_BUF_SZ); 909 memcpy(ptq->insn, ptq->state->insn, INTEL_PT_INSN_BUF_SZ);
910 } 910 }
911
912 if (ptq->state->type & INTEL_PT_TRACE_BEGIN)
913 ptq->flags |= PERF_IP_FLAG_TRACE_BEGIN;
914 if (ptq->state->type & INTEL_PT_TRACE_END)
915 ptq->flags |= PERF_IP_FLAG_TRACE_END;
911} 916}
912 917
913static int intel_pt_setup_queue(struct intel_pt *pt, 918static int intel_pt_setup_queue(struct intel_pt *pt,
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index ce501ba14b08..50150dfc0cdf 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -340,7 +340,7 @@ static bool is_tracepoint(struct pyrf_event *pevent)
340} 340}
341 341
342static PyObject* 342static PyObject*
343tracepoint_field(struct pyrf_event *pe, struct format_field *field) 343tracepoint_field(struct pyrf_event *pe, struct tep_format_field *field)
344{ 344{
345 struct tep_handle *pevent = field->event->pevent; 345 struct tep_handle *pevent = field->event->pevent;
346 void *data = pe->sample.raw_data; 346 void *data = pe->sample.raw_data;
@@ -348,28 +348,28 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field)
348 unsigned long long val; 348 unsigned long long val;
349 unsigned int offset, len; 349 unsigned int offset, len;
350 350
351 if (field->flags & FIELD_IS_ARRAY) { 351 if (field->flags & TEP_FIELD_IS_ARRAY) {
352 offset = field->offset; 352 offset = field->offset;
353 len = field->size; 353 len = field->size;
354 if (field->flags & FIELD_IS_DYNAMIC) { 354 if (field->flags & TEP_FIELD_IS_DYNAMIC) {
355 val = tep_read_number(pevent, data + offset, len); 355 val = tep_read_number(pevent, data + offset, len);
356 offset = val; 356 offset = val;
357 len = offset >> 16; 357 len = offset >> 16;
358 offset &= 0xffff; 358 offset &= 0xffff;
359 } 359 }
360 if (field->flags & FIELD_IS_STRING && 360 if (field->flags & TEP_FIELD_IS_STRING &&
361 is_printable_array(data + offset, len)) { 361 is_printable_array(data + offset, len)) {
362 ret = _PyUnicode_FromString((char *)data + offset); 362 ret = _PyUnicode_FromString((char *)data + offset);
363 } else { 363 } else {
364 ret = PyByteArray_FromStringAndSize((const char *) data + offset, len); 364 ret = PyByteArray_FromStringAndSize((const char *) data + offset, len);
365 field->flags &= ~FIELD_IS_STRING; 365 field->flags &= ~TEP_FIELD_IS_STRING;
366 } 366 }
367 } else { 367 } else {
368 val = tep_read_number(pevent, data + field->offset, 368 val = tep_read_number(pevent, data + field->offset,
369 field->size); 369 field->size);
370 if (field->flags & FIELD_IS_POINTER) 370 if (field->flags & TEP_FIELD_IS_POINTER)
371 ret = PyLong_FromUnsignedLong((unsigned long) val); 371 ret = PyLong_FromUnsignedLong((unsigned long) val);
372 else if (field->flags & FIELD_IS_SIGNED) 372 else if (field->flags & TEP_FIELD_IS_SIGNED)
373 ret = PyLong_FromLong((long) val); 373 ret = PyLong_FromLong((long) val);
374 else 374 else
375 ret = PyLong_FromUnsignedLong((unsigned long) val); 375 ret = PyLong_FromUnsignedLong((unsigned long) val);
@@ -383,10 +383,10 @@ get_tracepoint_field(struct pyrf_event *pevent, PyObject *attr_name)
383{ 383{
384 const char *str = _PyUnicode_AsString(PyObject_Str(attr_name)); 384 const char *str = _PyUnicode_AsString(PyObject_Str(attr_name));
385 struct perf_evsel *evsel = pevent->evsel; 385 struct perf_evsel *evsel = pevent->evsel;
386 struct format_field *field; 386 struct tep_format_field *field;
387 387
388 if (!evsel->tp_format) { 388 if (!evsel->tp_format) {
389 struct event_format *tp_format; 389 struct tep_event_format *tp_format;
390 390
391 tp_format = trace_event__tp_format_id(evsel->attr.config); 391 tp_format = trace_event__tp_format_id(evsel->attr.config);
392 if (!tp_format) 392 if (!tp_format)
@@ -1240,7 +1240,7 @@ static struct {
1240static PyObject *pyrf__tracepoint(struct pyrf_evsel *pevsel, 1240static PyObject *pyrf__tracepoint(struct pyrf_evsel *pevsel,
1241 PyObject *args, PyObject *kwargs) 1241 PyObject *args, PyObject *kwargs)
1242{ 1242{
1243 struct event_format *tp_format; 1243 struct tep_event_format *tp_format;
1244 static char *kwlist[] = { "sys", "name", NULL }; 1244 static char *kwlist[] = { "sys", "name", NULL };
1245 char *sys = NULL; 1245 char *sys = NULL;
1246 char *name = NULL; 1246 char *name = NULL;
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index 45484f0f7292..89cb887648f9 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -99,7 +99,7 @@ static void define_symbolic_value(const char *ev_name,
99 LEAVE; 99 LEAVE;
100} 100}
101 101
102static void define_symbolic_values(struct print_flag_sym *field, 102static void define_symbolic_values(struct tep_print_flag_sym *field,
103 const char *ev_name, 103 const char *ev_name,
104 const char *field_name) 104 const char *field_name)
105{ 105{
@@ -157,7 +157,7 @@ static void define_flag_value(const char *ev_name,
157 LEAVE; 157 LEAVE;
158} 158}
159 159
160static void define_flag_values(struct print_flag_sym *field, 160static void define_flag_values(struct tep_print_flag_sym *field,
161 const char *ev_name, 161 const char *ev_name,
162 const char *field_name) 162 const char *field_name)
163{ 163{
@@ -189,62 +189,62 @@ static void define_flag_field(const char *ev_name,
189 LEAVE; 189 LEAVE;
190} 190}
191 191
192static void define_event_symbols(struct event_format *event, 192static void define_event_symbols(struct tep_event_format *event,
193 const char *ev_name, 193 const char *ev_name,
194 struct print_arg *args) 194 struct tep_print_arg *args)
195{ 195{
196 if (args == NULL) 196 if (args == NULL)
197 return; 197 return;
198 198
199 switch (args->type) { 199 switch (args->type) {
200 case PRINT_NULL: 200 case TEP_PRINT_NULL:
201 break; 201 break;
202 case PRINT_ATOM: 202 case TEP_PRINT_ATOM:
203 define_flag_value(ev_name, cur_field_name, "0", 203 define_flag_value(ev_name, cur_field_name, "0",
204 args->atom.atom); 204 args->atom.atom);
205 zero_flag_atom = 0; 205 zero_flag_atom = 0;
206 break; 206 break;
207 case PRINT_FIELD: 207 case TEP_PRINT_FIELD:
208 free(cur_field_name); 208 free(cur_field_name);
209 cur_field_name = strdup(args->field.name); 209 cur_field_name = strdup(args->field.name);
210 break; 210 break;
211 case PRINT_FLAGS: 211 case TEP_PRINT_FLAGS:
212 define_event_symbols(event, ev_name, args->flags.field); 212 define_event_symbols(event, ev_name, args->flags.field);
213 define_flag_field(ev_name, cur_field_name, args->flags.delim); 213 define_flag_field(ev_name, cur_field_name, args->flags.delim);
214 define_flag_values(args->flags.flags, ev_name, cur_field_name); 214 define_flag_values(args->flags.flags, ev_name, cur_field_name);
215 break; 215 break;
216 case PRINT_SYMBOL: 216 case TEP_PRINT_SYMBOL:
217 define_event_symbols(event, ev_name, args->symbol.field); 217 define_event_symbols(event, ev_name, args->symbol.field);
218 define_symbolic_field(ev_name, cur_field_name); 218 define_symbolic_field(ev_name, cur_field_name);
219 define_symbolic_values(args->symbol.symbols, ev_name, 219 define_symbolic_values(args->symbol.symbols, ev_name,
220 cur_field_name); 220 cur_field_name);
221 break; 221 break;
222 case PRINT_HEX: 222 case TEP_PRINT_HEX:
223 case PRINT_HEX_STR: 223 case TEP_PRINT_HEX_STR:
224 define_event_symbols(event, ev_name, args->hex.field); 224 define_event_symbols(event, ev_name, args->hex.field);
225 define_event_symbols(event, ev_name, args->hex.size); 225 define_event_symbols(event, ev_name, args->hex.size);
226 break; 226 break;
227 case PRINT_INT_ARRAY: 227 case TEP_PRINT_INT_ARRAY:
228 define_event_symbols(event, ev_name, args->int_array.field); 228 define_event_symbols(event, ev_name, args->int_array.field);
229 define_event_symbols(event, ev_name, args->int_array.count); 229 define_event_symbols(event, ev_name, args->int_array.count);
230 define_event_symbols(event, ev_name, args->int_array.el_size); 230 define_event_symbols(event, ev_name, args->int_array.el_size);
231 break; 231 break;
232 case PRINT_BSTRING: 232 case TEP_PRINT_BSTRING:
233 case PRINT_DYNAMIC_ARRAY: 233 case TEP_PRINT_DYNAMIC_ARRAY:
234 case PRINT_DYNAMIC_ARRAY_LEN: 234 case TEP_PRINT_DYNAMIC_ARRAY_LEN:
235 case PRINT_STRING: 235 case TEP_PRINT_STRING:
236 case PRINT_BITMASK: 236 case TEP_PRINT_BITMASK:
237 break; 237 break;
238 case PRINT_TYPE: 238 case TEP_PRINT_TYPE:
239 define_event_symbols(event, ev_name, args->typecast.item); 239 define_event_symbols(event, ev_name, args->typecast.item);
240 break; 240 break;
241 case PRINT_OP: 241 case TEP_PRINT_OP:
242 if (strcmp(args->op.op, ":") == 0) 242 if (strcmp(args->op.op, ":") == 0)
243 zero_flag_atom = 1; 243 zero_flag_atom = 1;
244 define_event_symbols(event, ev_name, args->op.left); 244 define_event_symbols(event, ev_name, args->op.left);
245 define_event_symbols(event, ev_name, args->op.right); 245 define_event_symbols(event, ev_name, args->op.right);
246 break; 246 break;
247 case PRINT_FUNC: 247 case TEP_PRINT_FUNC:
248 default: 248 default:
249 pr_err("Unsupported print arg type\n"); 249 pr_err("Unsupported print arg type\n");
250 /* we should warn... */ 250 /* we should warn... */
@@ -338,8 +338,8 @@ static void perl_process_tracepoint(struct perf_sample *sample,
338 struct addr_location *al) 338 struct addr_location *al)
339{ 339{
340 struct thread *thread = al->thread; 340 struct thread *thread = al->thread;
341 struct event_format *event = evsel->tp_format; 341 struct tep_event_format *event = evsel->tp_format;
342 struct format_field *field; 342 struct tep_format_field *field;
343 static char handler[256]; 343 static char handler[256];
344 unsigned long long val; 344 unsigned long long val;
345 unsigned long s, ns; 345 unsigned long s, ns;
@@ -388,9 +388,9 @@ static void perl_process_tracepoint(struct perf_sample *sample,
388 /* common fields other than pid can be accessed via xsub fns */ 388 /* common fields other than pid can be accessed via xsub fns */
389 389
390 for (field = event->format.fields; field; field = field->next) { 390 for (field = event->format.fields; field; field = field->next) {
391 if (field->flags & FIELD_IS_STRING) { 391 if (field->flags & TEP_FIELD_IS_STRING) {
392 int offset; 392 int offset;
393 if (field->flags & FIELD_IS_DYNAMIC) { 393 if (field->flags & TEP_FIELD_IS_DYNAMIC) {
394 offset = *(int *)(data + field->offset); 394 offset = *(int *)(data + field->offset);
395 offset &= 0xffff; 395 offset &= 0xffff;
396 } else 396 } else
@@ -399,7 +399,7 @@ static void perl_process_tracepoint(struct perf_sample *sample,
399 } else { /* FIELD_IS_NUMERIC */ 399 } else { /* FIELD_IS_NUMERIC */
400 val = read_size(event, data + field->offset, 400 val = read_size(event, data + field->offset,
401 field->size); 401 field->size);
402 if (field->flags & FIELD_IS_SIGNED) { 402 if (field->flags & TEP_FIELD_IS_SIGNED) {
403 XPUSHs(sv_2mortal(newSViv(val))); 403 XPUSHs(sv_2mortal(newSViv(val)));
404 } else { 404 } else {
405 XPUSHs(sv_2mortal(newSVuv(val))); 405 XPUSHs(sv_2mortal(newSVuv(val)));
@@ -537,8 +537,8 @@ static int perl_stop_script(void)
537 537
538static int perl_generate_script(struct tep_handle *pevent, const char *outfile) 538static int perl_generate_script(struct tep_handle *pevent, const char *outfile)
539{ 539{
540 struct event_format *event = NULL; 540 struct tep_event_format *event = NULL;
541 struct format_field *f; 541 struct tep_format_field *f;
542 char fname[PATH_MAX]; 542 char fname[PATH_MAX];
543 int not_first, count; 543 int not_first, count;
544 FILE *ofp; 544 FILE *ofp;
@@ -646,11 +646,11 @@ sub print_backtrace\n\
646 count++; 646 count++;
647 647
648 fprintf(ofp, "%s=", f->name); 648 fprintf(ofp, "%s=", f->name);
649 if (f->flags & FIELD_IS_STRING || 649 if (f->flags & TEP_FIELD_IS_STRING ||
650 f->flags & FIELD_IS_FLAG || 650 f->flags & TEP_FIELD_IS_FLAG ||
651 f->flags & FIELD_IS_SYMBOLIC) 651 f->flags & TEP_FIELD_IS_SYMBOLIC)
652 fprintf(ofp, "%%s"); 652 fprintf(ofp, "%%s");
653 else if (f->flags & FIELD_IS_SIGNED) 653 else if (f->flags & TEP_FIELD_IS_SIGNED)
654 fprintf(ofp, "%%d"); 654 fprintf(ofp, "%%d");
655 else 655 else
656 fprintf(ofp, "%%u"); 656 fprintf(ofp, "%%u");
@@ -668,7 +668,7 @@ sub print_backtrace\n\
668 if (++count % 5 == 0) 668 if (++count % 5 == 0)
669 fprintf(ofp, "\n\t "); 669 fprintf(ofp, "\n\t ");
670 670
671 if (f->flags & FIELD_IS_FLAG) { 671 if (f->flags & TEP_FIELD_IS_FLAG) {
672 if ((count - 1) % 5 != 0) { 672 if ((count - 1) % 5 != 0) {
673 fprintf(ofp, "\n\t "); 673 fprintf(ofp, "\n\t ");
674 count = 4; 674 count = 4;
@@ -678,7 +678,7 @@ sub print_backtrace\n\
678 event->name); 678 event->name);
679 fprintf(ofp, "\"%s\", $%s)", f->name, 679 fprintf(ofp, "\"%s\", $%s)", f->name,
680 f->name); 680 f->name);
681 } else if (f->flags & FIELD_IS_SYMBOLIC) { 681 } else if (f->flags & TEP_FIELD_IS_SYMBOLIC) {
682 if ((count - 1) % 5 != 0) { 682 if ((count - 1) % 5 != 0) {
683 fprintf(ofp, "\n\t "); 683 fprintf(ofp, "\n\t ");
684 count = 4; 684 count = 4;
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index dfc6093f118c..69aa93d4ee99 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -193,7 +193,7 @@ static void try_call_object(const char *handler_name, PyObject *args)
193 call_object(handler, args, handler_name); 193 call_object(handler, args, handler_name);
194} 194}
195 195
196static void define_value(enum print_arg_type field_type, 196static void define_value(enum tep_print_arg_type field_type,
197 const char *ev_name, 197 const char *ev_name,
198 const char *field_name, 198 const char *field_name,
199 const char *field_value, 199 const char *field_value,
@@ -204,7 +204,7 @@ static void define_value(enum print_arg_type field_type,
204 unsigned long long value; 204 unsigned long long value;
205 unsigned n = 0; 205 unsigned n = 0;
206 206
207 if (field_type == PRINT_SYMBOL) 207 if (field_type == TEP_PRINT_SYMBOL)
208 handler_name = "define_symbolic_value"; 208 handler_name = "define_symbolic_value";
209 209
210 t = PyTuple_New(4); 210 t = PyTuple_New(4);
@@ -223,8 +223,8 @@ static void define_value(enum print_arg_type field_type,
223 Py_DECREF(t); 223 Py_DECREF(t);
224} 224}
225 225
226static void define_values(enum print_arg_type field_type, 226static void define_values(enum tep_print_arg_type field_type,
227 struct print_flag_sym *field, 227 struct tep_print_flag_sym *field,
228 const char *ev_name, 228 const char *ev_name,
229 const char *field_name) 229 const char *field_name)
230{ 230{
@@ -235,7 +235,7 @@ static void define_values(enum print_arg_type field_type,
235 define_values(field_type, field->next, ev_name, field_name); 235 define_values(field_type, field->next, ev_name, field_name);
236} 236}
237 237
238static void define_field(enum print_arg_type field_type, 238static void define_field(enum tep_print_arg_type field_type,
239 const char *ev_name, 239 const char *ev_name,
240 const char *field_name, 240 const char *field_name,
241 const char *delim) 241 const char *delim)
@@ -244,10 +244,10 @@ static void define_field(enum print_arg_type field_type,
244 PyObject *t; 244 PyObject *t;
245 unsigned n = 0; 245 unsigned n = 0;
246 246
247 if (field_type == PRINT_SYMBOL) 247 if (field_type == TEP_PRINT_SYMBOL)
248 handler_name = "define_symbolic_field"; 248 handler_name = "define_symbolic_field";
249 249
250 if (field_type == PRINT_FLAGS) 250 if (field_type == TEP_PRINT_FLAGS)
251 t = PyTuple_New(3); 251 t = PyTuple_New(3);
252 else 252 else
253 t = PyTuple_New(2); 253 t = PyTuple_New(2);
@@ -256,7 +256,7 @@ static void define_field(enum print_arg_type field_type,
256 256
257 PyTuple_SetItem(t, n++, _PyUnicode_FromString(ev_name)); 257 PyTuple_SetItem(t, n++, _PyUnicode_FromString(ev_name));
258 PyTuple_SetItem(t, n++, _PyUnicode_FromString(field_name)); 258 PyTuple_SetItem(t, n++, _PyUnicode_FromString(field_name));
259 if (field_type == PRINT_FLAGS) 259 if (field_type == TEP_PRINT_FLAGS)
260 PyTuple_SetItem(t, n++, _PyUnicode_FromString(delim)); 260 PyTuple_SetItem(t, n++, _PyUnicode_FromString(delim));
261 261
262 try_call_object(handler_name, t); 262 try_call_object(handler_name, t);
@@ -264,54 +264,54 @@ static void define_field(enum print_arg_type field_type,
264 Py_DECREF(t); 264 Py_DECREF(t);
265} 265}
266 266
267static void define_event_symbols(struct event_format *event, 267static void define_event_symbols(struct tep_event_format *event,
268 const char *ev_name, 268 const char *ev_name,
269 struct print_arg *args) 269 struct tep_print_arg *args)
270{ 270{
271 if (args == NULL) 271 if (args == NULL)
272 return; 272 return;
273 273
274 switch (args->type) { 274 switch (args->type) {
275 case PRINT_NULL: 275 case TEP_PRINT_NULL:
276 break; 276 break;
277 case PRINT_ATOM: 277 case TEP_PRINT_ATOM:
278 define_value(PRINT_FLAGS, ev_name, cur_field_name, "0", 278 define_value(TEP_PRINT_FLAGS, ev_name, cur_field_name, "0",
279 args->atom.atom); 279 args->atom.atom);
280 zero_flag_atom = 0; 280 zero_flag_atom = 0;
281 break; 281 break;
282 case PRINT_FIELD: 282 case TEP_PRINT_FIELD:
283 free(cur_field_name); 283 free(cur_field_name);
284 cur_field_name = strdup(args->field.name); 284 cur_field_name = strdup(args->field.name);
285 break; 285 break;
286 case PRINT_FLAGS: 286 case TEP_PRINT_FLAGS:
287 define_event_symbols(event, ev_name, args->flags.field); 287 define_event_symbols(event, ev_name, args->flags.field);
288 define_field(PRINT_FLAGS, ev_name, cur_field_name, 288 define_field(TEP_PRINT_FLAGS, ev_name, cur_field_name,
289 args->flags.delim); 289 args->flags.delim);
290 define_values(PRINT_FLAGS, args->flags.flags, ev_name, 290 define_values(TEP_PRINT_FLAGS, args->flags.flags, ev_name,
291 cur_field_name); 291 cur_field_name);
292 break; 292 break;
293 case PRINT_SYMBOL: 293 case TEP_PRINT_SYMBOL:
294 define_event_symbols(event, ev_name, args->symbol.field); 294 define_event_symbols(event, ev_name, args->symbol.field);
295 define_field(PRINT_SYMBOL, ev_name, cur_field_name, NULL); 295 define_field(TEP_PRINT_SYMBOL, ev_name, cur_field_name, NULL);
296 define_values(PRINT_SYMBOL, args->symbol.symbols, ev_name, 296 define_values(TEP_PRINT_SYMBOL, args->symbol.symbols, ev_name,
297 cur_field_name); 297 cur_field_name);
298 break; 298 break;
299 case PRINT_HEX: 299 case TEP_PRINT_HEX:
300 case PRINT_HEX_STR: 300 case TEP_PRINT_HEX_STR:
301 define_event_symbols(event, ev_name, args->hex.field); 301 define_event_symbols(event, ev_name, args->hex.field);
302 define_event_symbols(event, ev_name, args->hex.size); 302 define_event_symbols(event, ev_name, args->hex.size);
303 break; 303 break;
304 case PRINT_INT_ARRAY: 304 case TEP_PRINT_INT_ARRAY:
305 define_event_symbols(event, ev_name, args->int_array.field); 305 define_event_symbols(event, ev_name, args->int_array.field);
306 define_event_symbols(event, ev_name, args->int_array.count); 306 define_event_symbols(event, ev_name, args->int_array.count);
307 define_event_symbols(event, ev_name, args->int_array.el_size); 307 define_event_symbols(event, ev_name, args->int_array.el_size);
308 break; 308 break;
309 case PRINT_STRING: 309 case TEP_PRINT_STRING:
310 break; 310 break;
311 case PRINT_TYPE: 311 case TEP_PRINT_TYPE:
312 define_event_symbols(event, ev_name, args->typecast.item); 312 define_event_symbols(event, ev_name, args->typecast.item);
313 break; 313 break;
314 case PRINT_OP: 314 case TEP_PRINT_OP:
315 if (strcmp(args->op.op, ":") == 0) 315 if (strcmp(args->op.op, ":") == 0)
316 zero_flag_atom = 1; 316 zero_flag_atom = 1;
317 define_event_symbols(event, ev_name, args->op.left); 317 define_event_symbols(event, ev_name, args->op.left);
@@ -319,11 +319,11 @@ static void define_event_symbols(struct event_format *event,
319 break; 319 break;
320 default: 320 default:
321 /* gcc warns for these? */ 321 /* gcc warns for these? */
322 case PRINT_BSTRING: 322 case TEP_PRINT_BSTRING:
323 case PRINT_DYNAMIC_ARRAY: 323 case TEP_PRINT_DYNAMIC_ARRAY:
324 case PRINT_DYNAMIC_ARRAY_LEN: 324 case TEP_PRINT_DYNAMIC_ARRAY_LEN:
325 case PRINT_FUNC: 325 case TEP_PRINT_FUNC:
326 case PRINT_BITMASK: 326 case TEP_PRINT_BITMASK:
327 /* we should warn... */ 327 /* we should warn... */
328 return; 328 return;
329 } 329 }
@@ -332,10 +332,10 @@ static void define_event_symbols(struct event_format *event,
332 define_event_symbols(event, ev_name, args->next); 332 define_event_symbols(event, ev_name, args->next);
333} 333}
334 334
335static PyObject *get_field_numeric_entry(struct event_format *event, 335static PyObject *get_field_numeric_entry(struct tep_event_format *event,
336 struct format_field *field, void *data) 336 struct tep_format_field *field, void *data)
337{ 337{
338 bool is_array = field->flags & FIELD_IS_ARRAY; 338 bool is_array = field->flags & TEP_FIELD_IS_ARRAY;
339 PyObject *obj = NULL, *list = NULL; 339 PyObject *obj = NULL, *list = NULL;
340 unsigned long long val; 340 unsigned long long val;
341 unsigned int item_size, n_items, i; 341 unsigned int item_size, n_items, i;
@@ -353,7 +353,7 @@ static PyObject *get_field_numeric_entry(struct event_format *event,
353 353
354 val = read_size(event, data + field->offset + i * item_size, 354 val = read_size(event, data + field->offset + i * item_size,
355 item_size); 355 item_size);
356 if (field->flags & FIELD_IS_SIGNED) { 356 if (field->flags & TEP_FIELD_IS_SIGNED) {
357 if ((long long)val >= LONG_MIN && 357 if ((long long)val >= LONG_MIN &&
358 (long long)val <= LONG_MAX) 358 (long long)val <= LONG_MAX)
359 obj = _PyLong_FromLong(val); 359 obj = _PyLong_FromLong(val);
@@ -790,11 +790,11 @@ static void python_process_tracepoint(struct perf_sample *sample,
790 struct perf_evsel *evsel, 790 struct perf_evsel *evsel,
791 struct addr_location *al) 791 struct addr_location *al)
792{ 792{
793 struct event_format *event = evsel->tp_format; 793 struct tep_event_format *event = evsel->tp_format;
794 PyObject *handler, *context, *t, *obj = NULL, *callchain; 794 PyObject *handler, *context, *t, *obj = NULL, *callchain;
795 PyObject *dict = NULL, *all_entries_dict = NULL; 795 PyObject *dict = NULL, *all_entries_dict = NULL;
796 static char handler_name[256]; 796 static char handler_name[256];
797 struct format_field *field; 797 struct tep_format_field *field;
798 unsigned long s, ns; 798 unsigned long s, ns;
799 unsigned n = 0; 799 unsigned n = 0;
800 int pid; 800 int pid;
@@ -867,22 +867,22 @@ static void python_process_tracepoint(struct perf_sample *sample,
867 unsigned int offset, len; 867 unsigned int offset, len;
868 unsigned long long val; 868 unsigned long long val;
869 869
870 if (field->flags & FIELD_IS_ARRAY) { 870 if (field->flags & TEP_FIELD_IS_ARRAY) {
871 offset = field->offset; 871 offset = field->offset;
872 len = field->size; 872 len = field->size;
873 if (field->flags & FIELD_IS_DYNAMIC) { 873 if (field->flags & TEP_FIELD_IS_DYNAMIC) {
874 val = tep_read_number(scripting_context->pevent, 874 val = tep_read_number(scripting_context->pevent,
875 data + offset, len); 875 data + offset, len);
876 offset = val; 876 offset = val;
877 len = offset >> 16; 877 len = offset >> 16;
878 offset &= 0xffff; 878 offset &= 0xffff;
879 } 879 }
880 if (field->flags & FIELD_IS_STRING && 880 if (field->flags & TEP_FIELD_IS_STRING &&
881 is_printable_array(data + offset, len)) { 881 is_printable_array(data + offset, len)) {
882 obj = _PyUnicode_FromString((char *) data + offset); 882 obj = _PyUnicode_FromString((char *) data + offset);
883 } else { 883 } else {
884 obj = PyByteArray_FromStringAndSize((const char *) data + offset, len); 884 obj = PyByteArray_FromStringAndSize((const char *) data + offset, len);
885 field->flags &= ~FIELD_IS_STRING; 885 field->flags &= ~TEP_FIELD_IS_STRING;
886 } 886 }
887 } else { /* FIELD_IS_NUMERIC */ 887 } else { /* FIELD_IS_NUMERIC */
888 obj = get_field_numeric_entry(event, field, data); 888 obj = get_field_numeric_entry(event, field, data);
@@ -1590,8 +1590,8 @@ static int python_stop_script(void)
1590 1590
1591static int python_generate_script(struct tep_handle *pevent, const char *outfile) 1591static int python_generate_script(struct tep_handle *pevent, const char *outfile)
1592{ 1592{
1593 struct event_format *event = NULL; 1593 struct tep_event_format *event = NULL;
1594 struct format_field *f; 1594 struct tep_format_field *f;
1595 char fname[PATH_MAX]; 1595 char fname[PATH_MAX];
1596 int not_first, count; 1596 int not_first, count;
1597 FILE *ofp; 1597 FILE *ofp;
@@ -1686,12 +1686,12 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile
1686 count++; 1686 count++;
1687 1687
1688 fprintf(ofp, "%s=", f->name); 1688 fprintf(ofp, "%s=", f->name);
1689 if (f->flags & FIELD_IS_STRING || 1689 if (f->flags & TEP_FIELD_IS_STRING ||
1690 f->flags & FIELD_IS_FLAG || 1690 f->flags & TEP_FIELD_IS_FLAG ||
1691 f->flags & FIELD_IS_ARRAY || 1691 f->flags & TEP_FIELD_IS_ARRAY ||
1692 f->flags & FIELD_IS_SYMBOLIC) 1692 f->flags & TEP_FIELD_IS_SYMBOLIC)
1693 fprintf(ofp, "%%s"); 1693 fprintf(ofp, "%%s");
1694 else if (f->flags & FIELD_IS_SIGNED) 1694 else if (f->flags & TEP_FIELD_IS_SIGNED)
1695 fprintf(ofp, "%%d"); 1695 fprintf(ofp, "%%d");
1696 else 1696 else
1697 fprintf(ofp, "%%u"); 1697 fprintf(ofp, "%%u");
@@ -1709,7 +1709,7 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile
1709 if (++count % 5 == 0) 1709 if (++count % 5 == 0)
1710 fprintf(ofp, "\n\t\t"); 1710 fprintf(ofp, "\n\t\t");
1711 1711
1712 if (f->flags & FIELD_IS_FLAG) { 1712 if (f->flags & TEP_FIELD_IS_FLAG) {
1713 if ((count - 1) % 5 != 0) { 1713 if ((count - 1) % 5 != 0) {
1714 fprintf(ofp, "\n\t\t"); 1714 fprintf(ofp, "\n\t\t");
1715 count = 4; 1715 count = 4;
@@ -1719,7 +1719,7 @@ static int python_generate_script(struct tep_handle *pevent, const char *outfile
1719 event->name); 1719 event->name);
1720 fprintf(ofp, "\"%s\", %s)", f->name, 1720 fprintf(ofp, "\"%s\", %s)", f->name,
1721 f->name); 1721 f->name);
1722 } else if (f->flags & FIELD_IS_SYMBOLIC) { 1722 } else if (f->flags & TEP_FIELD_IS_SYMBOLIC) {
1723 if ((count - 1) % 5 != 0) { 1723 if ((count - 1) % 5 != 0) {
1724 fprintf(ofp, "\n\t\t"); 1724 fprintf(ofp, "\n\t\t");
1725 count = 4; 1725 count = 4;
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index b284276ec963..f96c005b3c41 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1884,7 +1884,7 @@ static int __sort_dimension__add_hpp_output(struct sort_dimension *sd,
1884struct hpp_dynamic_entry { 1884struct hpp_dynamic_entry {
1885 struct perf_hpp_fmt hpp; 1885 struct perf_hpp_fmt hpp;
1886 struct perf_evsel *evsel; 1886 struct perf_evsel *evsel;
1887 struct format_field *field; 1887 struct tep_format_field *field;
1888 unsigned dynamic_len; 1888 unsigned dynamic_len;
1889 bool raw_trace; 1889 bool raw_trace;
1890}; 1890};
@@ -1899,7 +1899,7 @@ static int hde_width(struct hpp_dynamic_entry *hde)
1899 if (namelen > len) 1899 if (namelen > len)
1900 len = namelen; 1900 len = namelen;
1901 1901
1902 if (!(hde->field->flags & FIELD_IS_STRING)) { 1902 if (!(hde->field->flags & TEP_FIELD_IS_STRING)) {
1903 /* length for print hex numbers */ 1903 /* length for print hex numbers */
1904 fieldlen = hde->field->size * 2 + 2; 1904 fieldlen = hde->field->size * 2 + 2;
1905 } 1905 }
@@ -1915,7 +1915,7 @@ static void update_dynamic_len(struct hpp_dynamic_entry *hde,
1915 struct hist_entry *he) 1915 struct hist_entry *he)
1916{ 1916{
1917 char *str, *pos; 1917 char *str, *pos;
1918 struct format_field *field = hde->field; 1918 struct tep_format_field *field = hde->field;
1919 size_t namelen; 1919 size_t namelen;
1920 bool last = false; 1920 bool last = false;
1921 1921
@@ -2000,7 +2000,7 @@ static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
2000 struct hpp_dynamic_entry *hde; 2000 struct hpp_dynamic_entry *hde;
2001 size_t len = fmt->user_len; 2001 size_t len = fmt->user_len;
2002 char *str, *pos; 2002 char *str, *pos;
2003 struct format_field *field; 2003 struct tep_format_field *field;
2004 size_t namelen; 2004 size_t namelen;
2005 bool last = false; 2005 bool last = false;
2006 int ret; 2006 int ret;
@@ -2060,7 +2060,7 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
2060 struct hist_entry *a, struct hist_entry *b) 2060 struct hist_entry *a, struct hist_entry *b)
2061{ 2061{
2062 struct hpp_dynamic_entry *hde; 2062 struct hpp_dynamic_entry *hde;
2063 struct format_field *field; 2063 struct tep_format_field *field;
2064 unsigned offset, size; 2064 unsigned offset, size;
2065 2065
2066 hde = container_of(fmt, struct hpp_dynamic_entry, hpp); 2066 hde = container_of(fmt, struct hpp_dynamic_entry, hpp);
@@ -2071,7 +2071,7 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
2071 } 2071 }
2072 2072
2073 field = hde->field; 2073 field = hde->field;
2074 if (field->flags & FIELD_IS_DYNAMIC) { 2074 if (field->flags & TEP_FIELD_IS_DYNAMIC) {
2075 unsigned long long dyn; 2075 unsigned long long dyn;
2076 2076
2077 tep_read_number_field(field, a->raw_data, &dyn); 2077 tep_read_number_field(field, a->raw_data, &dyn);
@@ -2117,7 +2117,7 @@ static void hde_free(struct perf_hpp_fmt *fmt)
2117} 2117}
2118 2118
2119static struct hpp_dynamic_entry * 2119static struct hpp_dynamic_entry *
2120__alloc_dynamic_entry(struct perf_evsel *evsel, struct format_field *field, 2120__alloc_dynamic_entry(struct perf_evsel *evsel, struct tep_format_field *field,
2121 int level) 2121 int level)
2122{ 2122{
2123 struct hpp_dynamic_entry *hde; 2123 struct hpp_dynamic_entry *hde;
@@ -2252,7 +2252,7 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam
2252} 2252}
2253 2253
2254static int __dynamic_dimension__add(struct perf_evsel *evsel, 2254static int __dynamic_dimension__add(struct perf_evsel *evsel,
2255 struct format_field *field, 2255 struct tep_format_field *field,
2256 bool raw_trace, int level) 2256 bool raw_trace, int level)
2257{ 2257{
2258 struct hpp_dynamic_entry *hde; 2258 struct hpp_dynamic_entry *hde;
@@ -2270,7 +2270,7 @@ static int __dynamic_dimension__add(struct perf_evsel *evsel,
2270static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace, int level) 2270static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace, int level)
2271{ 2271{
2272 int ret; 2272 int ret;
2273 struct format_field *field; 2273 struct tep_format_field *field;
2274 2274
2275 field = evsel->tp_format->format.fields; 2275 field = evsel->tp_format->format.fields;
2276 while (field) { 2276 while (field) {
@@ -2305,7 +2305,7 @@ static int add_all_matching_fields(struct perf_evlist *evlist,
2305{ 2305{
2306 int ret = -ESRCH; 2306 int ret = -ESRCH;
2307 struct perf_evsel *evsel; 2307 struct perf_evsel *evsel;
2308 struct format_field *field; 2308 struct tep_format_field *field;
2309 2309
2310 evlist__for_each_entry(evlist, evsel) { 2310 evlist__for_each_entry(evlist, evsel) {
2311 if (evsel->attr.type != PERF_TYPE_TRACEPOINT) 2311 if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
@@ -2327,7 +2327,7 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok,
2327{ 2327{
2328 char *str, *event_name, *field_name, *opt_name; 2328 char *str, *event_name, *field_name, *opt_name;
2329 struct perf_evsel *evsel; 2329 struct perf_evsel *evsel;
2330 struct format_field *field; 2330 struct tep_format_field *field;
2331 bool raw_trace = symbol_conf.raw_trace; 2331 bool raw_trace = symbol_conf.raw_trace;
2332 int ret = 0; 2332 int ret = 0;
2333 2333
diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c
index dd17d6a38d3a..c091635bf7dc 100644
--- a/tools/perf/util/thread-stack.c
+++ b/tools/perf/util/thread-stack.c
@@ -36,6 +36,7 @@
36 * @branch_count: the branch count when the entry was created 36 * @branch_count: the branch count when the entry was created
37 * @cp: call path 37 * @cp: call path
38 * @no_call: a 'call' was not seen 38 * @no_call: a 'call' was not seen
39 * @trace_end: a 'call' but trace ended
39 */ 40 */
40struct thread_stack_entry { 41struct thread_stack_entry {
41 u64 ret_addr; 42 u64 ret_addr;
@@ -44,6 +45,7 @@ struct thread_stack_entry {
44 u64 branch_count; 45 u64 branch_count;
45 struct call_path *cp; 46 struct call_path *cp;
46 bool no_call; 47 bool no_call;
48 bool trace_end;
47}; 49};
48 50
49/** 51/**
@@ -112,7 +114,8 @@ static struct thread_stack *thread_stack__new(struct thread *thread,
112 return ts; 114 return ts;
113} 115}
114 116
115static int thread_stack__push(struct thread_stack *ts, u64 ret_addr) 117static int thread_stack__push(struct thread_stack *ts, u64 ret_addr,
118 bool trace_end)
116{ 119{
117 int err = 0; 120 int err = 0;
118 121
@@ -124,6 +127,7 @@ static int thread_stack__push(struct thread_stack *ts, u64 ret_addr)
124 } 127 }
125 } 128 }
126 129
130 ts->stack[ts->cnt].trace_end = trace_end;
127 ts->stack[ts->cnt++].ret_addr = ret_addr; 131 ts->stack[ts->cnt++].ret_addr = ret_addr;
128 132
129 return err; 133 return err;
@@ -150,6 +154,18 @@ static void thread_stack__pop(struct thread_stack *ts, u64 ret_addr)
150 } 154 }
151} 155}
152 156
157static void thread_stack__pop_trace_end(struct thread_stack *ts)
158{
159 size_t i;
160
161 for (i = ts->cnt; i; ) {
162 if (ts->stack[--i].trace_end)
163 ts->cnt = i;
164 else
165 return;
166 }
167}
168
153static bool thread_stack__in_kernel(struct thread_stack *ts) 169static bool thread_stack__in_kernel(struct thread_stack *ts)
154{ 170{
155 if (!ts->cnt) 171 if (!ts->cnt)
@@ -254,10 +270,19 @@ int thread_stack__event(struct thread *thread, u32 flags, u64 from_ip,
254 ret_addr = from_ip + insn_len; 270 ret_addr = from_ip + insn_len;
255 if (ret_addr == to_ip) 271 if (ret_addr == to_ip)
256 return 0; /* Zero-length calls are excluded */ 272 return 0; /* Zero-length calls are excluded */
257 return thread_stack__push(thread->ts, ret_addr); 273 return thread_stack__push(thread->ts, ret_addr,
258 } else if (flags & PERF_IP_FLAG_RETURN) { 274 flags & PERF_IP_FLAG_TRACE_END);
259 if (!from_ip) 275 } else if (flags & PERF_IP_FLAG_TRACE_BEGIN) {
260 return 0; 276 /*
277 * If the caller did not change the trace number (which would
278 * have flushed the stack) then try to make sense of the stack.
279 * Possibly, tracing began after returning to the current
280 * address, so try to pop that. Also, do not expect a call made
281 * when the trace ended, to return, so pop that.
282 */
283 thread_stack__pop(thread->ts, to_ip);
284 thread_stack__pop_trace_end(thread->ts);
285 } else if ((flags & PERF_IP_FLAG_RETURN) && from_ip) {
261 thread_stack__pop(thread->ts, to_ip); 286 thread_stack__pop(thread->ts, to_ip);
262 } 287 }
263 288
@@ -332,7 +357,7 @@ void call_return_processor__free(struct call_return_processor *crp)
332 357
333static int thread_stack__push_cp(struct thread_stack *ts, u64 ret_addr, 358static int thread_stack__push_cp(struct thread_stack *ts, u64 ret_addr,
334 u64 timestamp, u64 ref, struct call_path *cp, 359 u64 timestamp, u64 ref, struct call_path *cp,
335 bool no_call) 360 bool no_call, bool trace_end)
336{ 361{
337 struct thread_stack_entry *tse; 362 struct thread_stack_entry *tse;
338 int err; 363 int err;
@@ -350,6 +375,7 @@ static int thread_stack__push_cp(struct thread_stack *ts, u64 ret_addr,
350 tse->branch_count = ts->branch_count; 375 tse->branch_count = ts->branch_count;
351 tse->cp = cp; 376 tse->cp = cp;
352 tse->no_call = no_call; 377 tse->no_call = no_call;
378 tse->trace_end = trace_end;
353 379
354 return 0; 380 return 0;
355} 381}
@@ -423,7 +449,7 @@ static int thread_stack__bottom(struct thread *thread, struct thread_stack *ts,
423 return -ENOMEM; 449 return -ENOMEM;
424 450
425 return thread_stack__push_cp(thread->ts, ip, sample->time, ref, cp, 451 return thread_stack__push_cp(thread->ts, ip, sample->time, ref, cp,
426 true); 452 true, false);
427} 453}
428 454
429static int thread_stack__no_call_return(struct thread *thread, 455static int thread_stack__no_call_return(struct thread *thread,
@@ -455,7 +481,7 @@ static int thread_stack__no_call_return(struct thread *thread,
455 if (!cp) 481 if (!cp)
456 return -ENOMEM; 482 return -ENOMEM;
457 return thread_stack__push_cp(ts, 0, sample->time, ref, 483 return thread_stack__push_cp(ts, 0, sample->time, ref,
458 cp, true); 484 cp, true, false);
459 } 485 }
460 } else if (thread_stack__in_kernel(ts) && sample->ip < ks) { 486 } else if (thread_stack__in_kernel(ts) && sample->ip < ks) {
461 /* Return to userspace, so pop all kernel addresses */ 487 /* Return to userspace, so pop all kernel addresses */
@@ -480,7 +506,7 @@ static int thread_stack__no_call_return(struct thread *thread,
480 return -ENOMEM; 506 return -ENOMEM;
481 507
482 err = thread_stack__push_cp(ts, sample->addr, sample->time, ref, cp, 508 err = thread_stack__push_cp(ts, sample->addr, sample->time, ref, cp,
483 true); 509 true, false);
484 if (err) 510 if (err)
485 return err; 511 return err;
486 512
@@ -500,7 +526,7 @@ static int thread_stack__trace_begin(struct thread *thread,
500 526
501 /* Pop trace end */ 527 /* Pop trace end */
502 tse = &ts->stack[ts->cnt - 1]; 528 tse = &ts->stack[ts->cnt - 1];
503 if (tse->cp->sym == NULL && tse->cp->ip == 0) { 529 if (tse->trace_end) {
504 err = thread_stack__call_return(thread, ts, --ts->cnt, 530 err = thread_stack__call_return(thread, ts, --ts->cnt,
505 timestamp, ref, false); 531 timestamp, ref, false);
506 if (err) 532 if (err)
@@ -529,7 +555,7 @@ static int thread_stack__trace_end(struct thread_stack *ts,
529 ret_addr = sample->ip + sample->insn_len; 555 ret_addr = sample->ip + sample->insn_len;
530 556
531 return thread_stack__push_cp(ts, ret_addr, sample->time, ref, cp, 557 return thread_stack__push_cp(ts, ret_addr, sample->time, ref, cp,
532 false); 558 false, true);
533} 559}
534 560
535int thread_stack__process(struct thread *thread, struct comm *comm, 561int thread_stack__process(struct thread *thread, struct comm *comm,
@@ -579,6 +605,7 @@ int thread_stack__process(struct thread *thread, struct comm *comm,
579 ts->last_time = sample->time; 605 ts->last_time = sample->time;
580 606
581 if (sample->flags & PERF_IP_FLAG_CALL) { 607 if (sample->flags & PERF_IP_FLAG_CALL) {
608 bool trace_end = sample->flags & PERF_IP_FLAG_TRACE_END;
582 struct call_path_root *cpr = ts->crp->cpr; 609 struct call_path_root *cpr = ts->crp->cpr;
583 struct call_path *cp; 610 struct call_path *cp;
584 u64 ret_addr; 611 u64 ret_addr;
@@ -596,7 +623,7 @@ int thread_stack__process(struct thread *thread, struct comm *comm,
596 if (!cp) 623 if (!cp)
597 return -ENOMEM; 624 return -ENOMEM;
598 err = thread_stack__push_cp(ts, ret_addr, sample->time, ref, 625 err = thread_stack__push_cp(ts, ret_addr, sample->time, ref,
599 cp, false); 626 cp, false, trace_end);
600 } else if (sample->flags & PERF_IP_FLAG_RETURN) { 627 } else if (sample->flags & PERF_IP_FLAG_RETURN) {
601 if (!sample->ip || !sample->addr) 628 if (!sample->ip || !sample->addr)
602 return 0; 629 return 0;
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index e76214f8d596..a4d7de1c96d1 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -33,8 +33,8 @@ static int get_common_field(struct scripting_context *context,
33 int *offset, int *size, const char *type) 33 int *offset, int *size, const char *type)
34{ 34{
35 struct tep_handle *pevent = context->pevent; 35 struct tep_handle *pevent = context->pevent;
36 struct event_format *event; 36 struct tep_event_format *event;
37 struct format_field *field; 37 struct tep_format_field *field;
38 38
39 if (!*size) { 39 if (!*size) {
40 if (!pevent->events) 40 if (!pevent->events)
@@ -94,9 +94,9 @@ int common_pc(struct scripting_context *context)
94} 94}
95 95
96unsigned long long 96unsigned long long
97raw_field_value(struct event_format *event, const char *name, void *data) 97raw_field_value(struct tep_event_format *event, const char *name, void *data)
98{ 98{
99 struct format_field *field; 99 struct tep_format_field *field;
100 unsigned long long val; 100 unsigned long long val;
101 101
102 field = tep_find_any_field(event, name); 102 field = tep_find_any_field(event, name);
@@ -108,12 +108,12 @@ raw_field_value(struct event_format *event, const char *name, void *data)
108 return val; 108 return val;
109} 109}
110 110
111unsigned long long read_size(struct event_format *event, void *ptr, int size) 111unsigned long long read_size(struct tep_event_format *event, void *ptr, int size)
112{ 112{
113 return tep_read_number(event->pevent, ptr, size); 113 return tep_read_number(event->pevent, ptr, size);
114} 114}
115 115
116void event_format__fprintf(struct event_format *event, 116void event_format__fprintf(struct tep_event_format *event,
117 int cpu, void *data, int size, FILE *fp) 117 int cpu, void *data, int size, FILE *fp)
118{ 118{
119 struct tep_record record; 119 struct tep_record record;
@@ -130,7 +130,7 @@ void event_format__fprintf(struct event_format *event,
130 trace_seq_destroy(&s); 130 trace_seq_destroy(&s);
131} 131}
132 132
133void event_format__print(struct event_format *event, 133void event_format__print(struct tep_event_format *event,
134 int cpu, void *data, int size) 134 int cpu, void *data, int size)
135{ 135{
136 return event_format__fprintf(event, cpu, data, size, stdout); 136 return event_format__fprintf(event, cpu, data, size, stdout);
@@ -188,8 +188,8 @@ int parse_event_file(struct tep_handle *pevent,
188 return tep_parse_event(pevent, buf, size, sys); 188 return tep_parse_event(pevent, buf, size, sys);
189} 189}
190 190
191struct event_format *trace_find_next_event(struct tep_handle *pevent, 191struct tep_event_format *trace_find_next_event(struct tep_handle *pevent,
192 struct event_format *event) 192 struct tep_event_format *event)
193{ 193{
194 static int idx; 194 static int idx;
195 195
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
index 3dfc1db6b25b..b98ee2a2eb44 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -102,7 +102,7 @@ static unsigned int read4(struct tep_handle *pevent)
102 102
103 if (do_read(&data, 4) < 0) 103 if (do_read(&data, 4) < 0)
104 return 0; 104 return 0;
105 return __data2host4(pevent, data); 105 return __tep_data2host4(pevent, data);
106} 106}
107 107
108static unsigned long long read8(struct tep_handle *pevent) 108static unsigned long long read8(struct tep_handle *pevent)
@@ -111,7 +111,7 @@ static unsigned long long read8(struct tep_handle *pevent)
111 111
112 if (do_read(&data, 8) < 0) 112 if (do_read(&data, 8) < 0)
113 return 0; 113 return 0;
114 return __data2host8(pevent, data); 114 return __tep_data2host8(pevent, data);
115} 115}
116 116
117static char *read_string(void) 117static char *read_string(void)
diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c
index 58bb72f266f3..95664b2f771e 100644
--- a/tools/perf/util/trace-event.c
+++ b/tools/perf/util/trace-event.c
@@ -72,12 +72,12 @@ void trace_event__cleanup(struct trace_event *t)
72/* 72/*
73 * Returns pointer with encoded error via <linux/err.h> interface. 73 * Returns pointer with encoded error via <linux/err.h> interface.
74 */ 74 */
75static struct event_format* 75static struct tep_event_format*
76tp_format(const char *sys, const char *name) 76tp_format(const char *sys, const char *name)
77{ 77{
78 char *tp_dir = get_events_file(sys); 78 char *tp_dir = get_events_file(sys);
79 struct tep_handle *pevent = tevent.pevent; 79 struct tep_handle *pevent = tevent.pevent;
80 struct event_format *event = NULL; 80 struct tep_event_format *event = NULL;
81 char path[PATH_MAX]; 81 char path[PATH_MAX];
82 size_t size; 82 size_t size;
83 char *data; 83 char *data;
@@ -102,7 +102,7 @@ tp_format(const char *sys, const char *name)
102/* 102/*
103 * Returns pointer with encoded error via <linux/err.h> interface. 103 * Returns pointer with encoded error via <linux/err.h> interface.
104 */ 104 */
105struct event_format* 105struct tep_event_format*
106trace_event__tp_format(const char *sys, const char *name) 106trace_event__tp_format(const char *sys, const char *name)
107{ 107{
108 if (!tevent_initialized && trace_event__init2()) 108 if (!tevent_initialized && trace_event__init2())
@@ -111,7 +111,7 @@ trace_event__tp_format(const char *sys, const char *name)
111 return tp_format(sys, name); 111 return tp_format(sys, name);
112} 112}
113 113
114struct event_format *trace_event__tp_format_id(int id) 114struct tep_event_format *trace_event__tp_format_id(int id)
115{ 115{
116 if (!tevent_initialized && trace_event__init2()) 116 if (!tevent_initialized && trace_event__init2())
117 return ERR_PTR(-ENOMEM); 117 return ERR_PTR(-ENOMEM);
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index c69d77d7cf55..f024d73bfc40 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -11,28 +11,28 @@ struct perf_sample;
11union perf_event; 11union perf_event;
12struct perf_tool; 12struct perf_tool;
13struct thread; 13struct thread;
14struct plugin_list; 14struct tep_plugin_list;
15 15
16struct trace_event { 16struct trace_event {
17 struct tep_handle *pevent; 17 struct tep_handle *pevent;
18 struct plugin_list *plugin_list; 18 struct tep_plugin_list *plugin_list;
19}; 19};
20 20
21int trace_event__init(struct trace_event *t); 21int trace_event__init(struct trace_event *t);
22void trace_event__cleanup(struct trace_event *t); 22void trace_event__cleanup(struct trace_event *t);
23int trace_event__register_resolver(struct machine *machine, 23int trace_event__register_resolver(struct machine *machine,
24 tep_func_resolver_t *func); 24 tep_func_resolver_t *func);
25struct event_format* 25struct tep_event_format*
26trace_event__tp_format(const char *sys, const char *name); 26trace_event__tp_format(const char *sys, const char *name);
27 27
28struct event_format *trace_event__tp_format_id(int id); 28struct tep_event_format *trace_event__tp_format_id(int id);
29 29
30int bigendian(void); 30int bigendian(void);
31 31
32void event_format__fprintf(struct event_format *event, 32void event_format__fprintf(struct tep_event_format *event,
33 int cpu, void *data, int size, FILE *fp); 33 int cpu, void *data, int size, FILE *fp);
34 34
35void event_format__print(struct event_format *event, 35void event_format__print(struct tep_event_format *event,
36 int cpu, void *data, int size); 36 int cpu, void *data, int size);
37 37
38int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size); 38int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size);
@@ -40,7 +40,7 @@ int parse_event_file(struct tep_handle *pevent,
40 char *buf, unsigned long size, char *sys); 40 char *buf, unsigned long size, char *sys);
41 41
42unsigned long long 42unsigned long long
43raw_field_value(struct event_format *event, const char *name, void *data); 43raw_field_value(struct tep_event_format *event, const char *name, void *data);
44 44
45void parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size); 45void parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size);
46void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size); 46void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size);
@@ -48,9 +48,9 @@ void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int siz
48 48
49ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe); 49ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe);
50 50
51struct event_format *trace_find_next_event(struct tep_handle *pevent, 51struct tep_event_format *trace_find_next_event(struct tep_handle *pevent,
52 struct event_format *event); 52 struct tep_event_format *event);
53unsigned long long read_size(struct event_format *event, void *ptr, int size); 53unsigned long long read_size(struct tep_event_format *event, void *ptr, int size);
54unsigned long long eval_flag(const char *flag); 54unsigned long long eval_flag(const char *flag);
55 55
56int read_tracing_data(int fd, struct list_head *pattrs); 56int read_tracing_data(int fd, struct list_head *pattrs);