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;
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
23 * This represents a member type in a data type.
25 struct annotated_member {
26 struct list_head node;
27 struct list_head children;
35 * struct type_hist_entry - Histogram entry per offset
36 * @nr_samples: Number of samples
37 * @period: Count of event
39 struct type_hist_entry {
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
53 struct type_hist_entry addr[];
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
63 * This represents a data type accessed by samples in the profile data.
65 struct annotated_data_type {
67 struct annotated_member self;
69 struct type_hist **histograms;
72 extern struct annotated_data_type unknown_type;
73 extern struct annotated_data_type stackop_type;
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
90 struct annotated_data_stat {
104 extern struct annotated_data_stat ann_data_stat;
106 #ifdef HAVE_DWARF_SUPPORT
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);
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);
118 /* Release all data type information in the tree */
119 void annotated_data_type__tree_delete(struct rb_root *root);
121 #else /* HAVE_DWARF_SUPPORT */
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)
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)
141 static inline void annotated_data_type__tree_delete(struct rb_root *root __maybe_unused)
145 #endif /* HAVE_DWARF_SUPPORT */
147 #endif /* _PERF_ANNOTATE_DATA_H */