hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/tools/perf/util/evsel_fprintf.c
....@@ -4,6 +4,8 @@
44 #include <stdbool.h>
55 #include <traceevent/event-parse.h>
66 #include "evsel.h"
7
+#include "util/evsel_fprintf.h"
8
+#include "util/event.h"
79 #include "callchain.h"
810 #include "map.h"
911 #include "strlist.h"
....@@ -33,49 +35,48 @@
3335 return comma_fprintf(fp, (bool *)priv, " %s: %s", name, val);
3436 }
3537
36
-int perf_evsel__fprintf(struct perf_evsel *evsel,
37
- struct perf_attr_details *details, FILE *fp)
38
+int evsel__fprintf(struct evsel *evsel, struct perf_attr_details *details, FILE *fp)
3839 {
3940 bool first = true;
4041 int printed = 0;
4142
4243 if (details->event_group) {
43
- struct perf_evsel *pos;
44
+ struct evsel *pos;
4445
45
- if (!perf_evsel__is_group_leader(evsel))
46
+ if (!evsel__is_group_leader(evsel))
4647 return 0;
4748
48
- if (evsel->nr_members > 1)
49
+ if (evsel->core.nr_members > 1)
4950 printed += fprintf(fp, "%s{", evsel->group_name ?: "");
5051
51
- printed += fprintf(fp, "%s", perf_evsel__name(evsel));
52
+ printed += fprintf(fp, "%s", evsel__name(evsel));
5253 for_each_group_member(pos, evsel)
53
- printed += fprintf(fp, ",%s", perf_evsel__name(pos));
54
+ printed += fprintf(fp, ",%s", evsel__name(pos));
5455
55
- if (evsel->nr_members > 1)
56
+ if (evsel->core.nr_members > 1)
5657 printed += fprintf(fp, "}");
5758 goto out;
5859 }
5960
60
- printed += fprintf(fp, "%s", perf_evsel__name(evsel));
61
+ printed += fprintf(fp, "%s", evsel__name(evsel));
6162
6263 if (details->verbose) {
63
- printed += perf_event_attr__fprintf(fp, &evsel->attr,
64
+ printed += perf_event_attr__fprintf(fp, &evsel->core.attr,
6465 __print_attr__fprintf, &first);
6566 } else if (details->freq) {
6667 const char *term = "sample_freq";
6768
68
- if (!evsel->attr.freq)
69
+ if (!evsel->core.attr.freq)
6970 term = "sample_period";
7071
7172 printed += comma_fprintf(fp, &first, " %s=%" PRIu64,
72
- term, (u64)evsel->attr.sample_freq);
73
+ term, (u64)evsel->core.attr.sample_freq);
7374 }
7475
7576 if (details->trace_fields) {
76
- struct format_field *field;
77
+ struct tep_format_field *field;
7778
78
- if (evsel->attr.type != PERF_TYPE_TRACEPOINT) {
79
+ if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) {
7980 printed += comma_fprintf(fp, &first, " (not a tracepoint)");
8081 goto out;
8182 }
....@@ -101,7 +102,7 @@
101102
102103 int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
103104 unsigned int print_opts, struct callchain_cursor *cursor,
104
- FILE *fp)
105
+ struct strlist *bt_stop_list, FILE *fp)
105106 {
106107 int printed = 0;
107108 struct callchain_cursor_node *node;
....@@ -123,13 +124,18 @@
123124 callchain_cursor_commit(cursor);
124125
125126 while (1) {
127
+ struct symbol *sym;
128
+ struct map *map;
126129 u64 addr = 0;
127130
128131 node = callchain_cursor_current(cursor);
129132 if (!node)
130133 break;
131134
132
- if (node->sym && node->sym->ignore && print_skip_ignored)
135
+ sym = node->ms.sym;
136
+ map = node->ms.map;
137
+
138
+ if (sym && sym->ignore && print_skip_ignored)
133139 goto next;
134140
135141 printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
....@@ -140,43 +146,42 @@
140146 if (print_ip)
141147 printed += fprintf(fp, "%c%16" PRIx64, s, node->ip);
142148
143
- if (node->map)
144
- addr = node->map->map_ip(node->map, node->ip);
149
+ if (map)
150
+ addr = map->map_ip(map, node->ip);
145151
146152 if (print_sym) {
147153 printed += fprintf(fp, " ");
148154 node_al.addr = addr;
149
- node_al.map = node->map;
155
+ node_al.map = map;
150156
151157 if (print_symoffset) {
152
- printed += __symbol__fprintf_symname_offs(node->sym, &node_al,
158
+ printed += __symbol__fprintf_symname_offs(sym, &node_al,
153159 print_unknown_as_addr,
154160 true, fp);
155161 } else {
156
- printed += __symbol__fprintf_symname(node->sym, &node_al,
162
+ printed += __symbol__fprintf_symname(sym, &node_al,
157163 print_unknown_as_addr, fp);
158164 }
159165 }
160166
161
- if (print_dso && (!node->sym || !node->sym->inlined)) {
167
+ if (print_dso && (!sym || !sym->inlined)) {
162168 printed += fprintf(fp, " (");
163
- printed += map__fprintf_dsoname(node->map, fp);
169
+ printed += map__fprintf_dsoname(map, fp);
164170 printed += fprintf(fp, ")");
165171 }
166172
167173 if (print_srcline)
168
- printed += map__fprintf_srcline(node->map, addr, "\n ", fp);
174
+ printed += map__fprintf_srcline(map, addr, "\n ", fp);
169175
170
- if (node->sym && node->sym->inlined)
176
+ if (sym && sym->inlined)
171177 printed += fprintf(fp, " (inlined)");
172178
173179 if (!print_oneline)
174180 printed += fprintf(fp, "\n");
175181
176
- if (symbol_conf.bt_stop_list &&
177
- node->sym &&
178
- strlist__has_entry(symbol_conf.bt_stop_list,
179
- node->sym->name)) {
182
+ /* Add srccode here too? */
183
+ if (bt_stop_list && sym &&
184
+ strlist__has_entry(bt_stop_list, sym->name)) {
180185 break;
181186 }
182187
....@@ -191,7 +196,7 @@
191196
192197 int sample__fprintf_sym(struct perf_sample *sample, struct addr_location *al,
193198 int left_alignment, unsigned int print_opts,
194
- struct callchain_cursor *cursor, FILE *fp)
199
+ struct callchain_cursor *cursor, struct strlist *bt_stop_list, FILE *fp)
195200 {
196201 int printed = 0;
197202 int print_ip = print_opts & EVSEL__PRINT_IP;
....@@ -202,8 +207,8 @@
202207 int print_unknown_as_addr = print_opts & EVSEL__PRINT_UNKNOWN_AS_ADDR;
203208
204209 if (cursor != NULL) {
205
- printed += sample__fprintf_callchain(sample, left_alignment,
206
- print_opts, cursor, fp);
210
+ printed += sample__fprintf_callchain(sample, left_alignment, print_opts,
211
+ cursor, bt_stop_list, fp);
207212 } else {
208213 printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
209214