1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _PERF_ANNOTATE_DATA_H
3 #define _PERF_ANNOTATE_DATA_H
6 #include <linux/compiler.h>
7 #include <linux/rbtree.h>
8 #include <linux/types.h>
10 struct annotated_op_loc;
13 struct hist_browser_timer;
19 * struct annotated_member - Type of member field
20 * @node: List entry in the parent list
21 * @children: List head for child nodes
22 * @type_name: Name of the member type
23 * @var_name: Name of the member variable
24 * @offset: Offset from the outer data type
25 * @size: Size of the member field
27 * This represents a member type in a data type.
29 struct annotated_member {
30 struct list_head node;
31 struct list_head children;
39 * struct type_hist_entry - Histogram entry per offset
40 * @nr_samples: Number of samples
41 * @period: Count of event
43 struct type_hist_entry {
49 * struct type_hist - Type histogram for each event
50 * @nr_samples: Total number of samples in this data type
51 * @period: Total count of the event in this data type
52 * @offset: Array of histogram entry
57 struct type_hist_entry addr[];
61 * struct annotated_data_type - Data type to profile
62 * @node: RB-tree node for dso->type_tree
63 * @self: Actual type information
64 * @nr_histogram: Number of histogram entries
65 * @histograms: An array of pointers to histograms
67 * This represents a data type accessed by samples in the profile data.
69 struct annotated_data_type {
71 struct annotated_member self;
73 struct type_hist **histograms;
76 extern struct annotated_data_type unknown_type;
77 extern struct annotated_data_type stackop_type;
78 extern struct annotated_data_type canary_type;
81 * struct data_loc_info - Data location information
82 * @arch: CPU architecture info
83 * @thread: Thread info
84 * @ms: Map and Symbol info
85 * @ip: Instruction address
86 * @var_addr: Data address (for global variables)
87 * @cpumode: CPU execution mode
88 * @op: Instruction operand location (regs and offset)
90 * @fbreg: Frame base register
91 * @fb_cfa: Whether the frame needs to check CFA
92 * @type_offset: Final offset in the type
94 struct data_loc_info {
95 /* These are input field, should be filled by caller */
97 struct thread *thread;
98 struct map_symbol *ms;
102 struct annotated_op_loc *op;
104 /* These are used internally */
105 struct debuginfo *di;
109 /* This is for the result */
114 * struct annotated_data_stat - Debug statistics
115 * @total: Total number of entry
116 * @no_sym: No symbol or map found
117 * @no_insn: Failed to get disasm line
118 * @no_insn_ops: The instruction has no operands
119 * @no_mem_ops: The instruction has no memory operands
120 * @no_reg: Failed to extract a register from the operand
121 * @no_dbginfo: The binary has no debug information
122 * @no_cuinfo: Failed to find a compile_unit
123 * @no_var: Failed to find a matching variable
124 * @no_typeinfo: Failed to get a type info for the variable
125 * @invalid_size: Failed to get a size info of the type
126 * @bad_offset: The access offset is out of the type
128 struct annotated_data_stat {
143 extern struct annotated_data_stat ann_data_stat;
145 #ifdef HAVE_DWARF_SUPPORT
147 /* Returns data type at the location (ip, reg, offset) */
148 struct annotated_data_type *find_data_type(struct data_loc_info *dloc);
150 /* Update type access histogram at the given offset */
151 int annotated_data_type__update_samples(struct annotated_data_type *adt,
152 struct evsel *evsel, int offset,
153 int nr_samples, u64 period);
155 /* Release all data type information in the tree */
156 void annotated_data_type__tree_delete(struct rb_root *root);
158 /* Release all global variable information in the tree */
159 void global_var_type__tree_delete(struct rb_root *root);
161 int hist_entry__annotate_data_tty(struct hist_entry *he, struct evsel *evsel);
163 #else /* HAVE_DWARF_SUPPORT */
165 static inline struct annotated_data_type *
166 find_data_type(struct data_loc_info *dloc __maybe_unused)
172 annotated_data_type__update_samples(struct annotated_data_type *adt __maybe_unused,
173 struct evsel *evsel __maybe_unused,
174 int offset __maybe_unused,
175 int nr_samples __maybe_unused,
176 u64 period __maybe_unused)
181 static inline void annotated_data_type__tree_delete(struct rb_root *root __maybe_unused)
185 static inline void global_var_type__tree_delete(struct rb_root *root __maybe_unused)
189 static inline int hist_entry__annotate_data_tty(struct hist_entry *he __maybe_unused,
190 struct evsel *evsel __maybe_unused)
195 #endif /* HAVE_DWARF_SUPPORT */
197 #ifdef HAVE_SLANG_SUPPORT
198 int hist_entry__annotate_data_tui(struct hist_entry *he, struct evsel *evsel,
199 struct hist_browser_timer *hbt);
201 static inline int hist_entry__annotate_data_tui(struct hist_entry *he __maybe_unused,
202 struct evsel *evsel __maybe_unused,
203 struct hist_browser_timer *hbt __maybe_unused)
207 #endif /* HAVE_SLANG_SUPPORT */
209 #endif /* _PERF_ANNOTATE_DATA_H */