1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef _PERF_ANNOTATE_DATA_H |
3 | #define _PERF_ANNOTATE_DATA_H |
4 | |
5 | #include <errno.h> |
6 | #include <linux/compiler.h> |
7 | #include <linux/rbtree.h> |
8 | #include <linux/types.h> |
9 | |
10 | struct annotated_op_loc; |
11 | struct evsel; |
12 | struct map_symbol; |
13 | |
14 | /** |
15 | * struct annotated_member - Type of member field |
16 | * @node: List entry in the parent list |
17 | * @children: List head for child nodes |
18 | * @type_name: Name of the member type |
19 | * @var_name: Name of the member variable |
20 | * @offset: Offset from the outer data type |
21 | * @size: Size of the member field |
22 | * |
23 | * This represents a member type in a data type. |
24 | */ |
25 | struct annotated_member { |
26 | struct list_head node; |
27 | struct list_head children; |
28 | char *type_name; |
29 | char *var_name; |
30 | int offset; |
31 | int size; |
32 | }; |
33 | |
34 | /** |
35 | * struct type_hist_entry - Histogram entry per offset |
36 | * @nr_samples: Number of samples |
37 | * @period: Count of event |
38 | */ |
39 | struct type_hist_entry { |
40 | int nr_samples; |
41 | u64 period; |
42 | }; |
43 | |
44 | /** |
45 | * struct type_hist - Type histogram for each event |
46 | * @nr_samples: Total number of samples in this data type |
47 | * @period: Total count of the event in this data type |
48 | * @offset: Array of histogram entry |
49 | */ |
50 | struct type_hist { |
51 | u64 nr_samples; |
52 | u64 period; |
53 | struct type_hist_entry addr[]; |
54 | }; |
55 | |
56 | /** |
57 | * struct annotated_data_type - Data type to profile |
58 | * @node: RB-tree node for dso->type_tree |
59 | * @self: Actual type information |
60 | * @nr_histogram: Number of histogram entries |
61 | * @histograms: An array of pointers to histograms |
62 | * |
63 | * This represents a data type accessed by samples in the profile data. |
64 | */ |
65 | struct annotated_data_type { |
66 | struct rb_node node; |
67 | struct annotated_member self; |
68 | int nr_histograms; |
69 | struct type_hist **histograms; |
70 | }; |
71 | |
72 | extern struct annotated_data_type unknown_type; |
73 | extern struct annotated_data_type stackop_type; |
74 | |
75 | /** |
76 | * struct annotated_data_stat - Debug statistics |
77 | * @total: Total number of entry |
78 | * @no_sym: No symbol or map found |
79 | * @no_insn: Failed to get disasm line |
80 | * @no_insn_ops: The instruction has no operands |
81 | * @no_mem_ops: The instruction has no memory operands |
82 | * @no_reg: Failed to extract a register from the operand |
83 | * @no_dbginfo: The binary has no debug information |
84 | * @no_cuinfo: Failed to find a compile_unit |
85 | * @no_var: Failed to find a matching variable |
86 | * @no_typeinfo: Failed to get a type info for the variable |
87 | * @invalid_size: Failed to get a size info of the type |
88 | * @bad_offset: The access offset is out of the type |
89 | */ |
90 | struct annotated_data_stat { |
91 | int total; |
92 | int no_sym; |
93 | int no_insn; |
94 | int no_insn_ops; |
95 | int no_mem_ops; |
96 | int no_reg; |
97 | int no_dbginfo; |
98 | int no_cuinfo; |
99 | int no_var; |
100 | int no_typeinfo; |
101 | int invalid_size; |
102 | int bad_offset; |
103 | }; |
104 | extern struct annotated_data_stat ann_data_stat; |
105 | |
106 | #ifdef HAVE_DWARF_SUPPORT |
107 | |
108 | /* Returns data type at the location (ip, reg, offset) */ |
109 | struct annotated_data_type *find_data_type(struct map_symbol *ms, u64 ip, |
110 | struct annotated_op_loc *loc, u64 addr, |
111 | const char *var_name); |
112 | |
113 | /* Update type access histogram at the given offset */ |
114 | int annotated_data_type__update_samples(struct annotated_data_type *adt, |
115 | struct evsel *evsel, int offset, |
116 | int nr_samples, u64 period); |
117 | |
118 | /* Release all data type information in the tree */ |
119 | void annotated_data_type__tree_delete(struct rb_root *root); |
120 | |
121 | #else /* HAVE_DWARF_SUPPORT */ |
122 | |
123 | static inline struct annotated_data_type * |
124 | find_data_type(struct map_symbol *ms __maybe_unused, u64 ip __maybe_unused, |
125 | struct annotated_op_loc *loc __maybe_unused, |
126 | u64 addr __maybe_unused, const char *var_name __maybe_unused) |
127 | { |
128 | return NULL; |
129 | } |
130 | |
131 | static inline int |
132 | annotated_data_type__update_samples(struct annotated_data_type *adt __maybe_unused, |
133 | struct evsel *evsel __maybe_unused, |
134 | int offset __maybe_unused, |
135 | int nr_samples __maybe_unused, |
136 | u64 period __maybe_unused) |
137 | { |
138 | return -1; |
139 | } |
140 | |
141 | static inline void annotated_data_type__tree_delete(struct rb_root *root __maybe_unused) |
142 | { |
143 | } |
144 | |
145 | #endif /* HAVE_DWARF_SUPPORT */ |
146 | |
147 | #endif /* _PERF_ANNOTATE_DATA_H */ |
148 | |