]> Git Repo - J-linux.git/blob - tools/perf/util/disasm.h
Merge tag 'vfs-6.13-rc7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[J-linux.git] / tools / perf / util / disasm.h
1 // SPDX-License-Identifier: GPL-2.0
2 #ifndef __PERF_UTIL_DISASM_H
3 #define __PERF_UTIL_DISASM_H
4
5 #include "map_symbol.h"
6
7 #ifdef HAVE_LIBDW_SUPPORT
8 #include "dwarf-aux.h"
9 #endif
10
11 struct annotation_options;
12 struct disasm_line;
13 struct ins;
14 struct evsel;
15 struct symbol;
16 struct data_loc_info;
17 struct type_state;
18 struct disasm_line;
19
20 struct arch {
21         const char      *name;
22         struct ins      *instructions;
23         size_t          nr_instructions;
24         size_t          nr_instructions_allocated;
25         struct ins_ops  *(*associate_instruction_ops)(struct arch *arch, const char *name);
26         bool            sorted_instructions;
27         bool            initialized;
28         const char      *insn_suffix;
29         void            *priv;
30         unsigned int    model;
31         unsigned int    family;
32         int             (*init)(struct arch *arch, char *cpuid);
33         bool            (*ins_is_fused)(struct arch *arch, const char *ins1,
34                                         const char *ins2);
35         struct          {
36                 char comment_char;
37                 char skip_functions_char;
38                 char register_char;
39                 char memory_ref_char;
40                 char imm_char;
41         } objdump;
42 #ifdef HAVE_LIBDW_SUPPORT
43         void            (*update_insn_state)(struct type_state *state,
44                                 struct data_loc_info *dloc, Dwarf_Die *cu_die,
45                                 struct disasm_line *dl);
46 #endif
47         /** @e_machine: ELF machine associated with arch. */
48         unsigned int e_machine;
49         /** @e_flags: Optional ELF flags associated with arch. */
50         unsigned int e_flags;
51 };
52
53 struct ins {
54         const char     *name;
55         struct ins_ops *ops;
56 };
57
58 struct ins_operands {
59         char    *raw;
60         struct {
61                 char    *raw;
62                 char    *name;
63                 struct symbol *sym;
64                 u64     addr;
65                 s64     offset;
66                 bool    offset_avail;
67                 bool    outside;
68                 bool    multi_regs;
69                 bool    mem_ref;
70         } target;
71         union {
72                 struct {
73                         char    *raw;
74                         char    *name;
75                         u64     addr;
76                         bool    multi_regs;
77                         bool    mem_ref;
78                 } source;
79                 struct {
80                         struct ins          ins;
81                         struct ins_operands *ops;
82                 } locked;
83                 struct {
84                         char    *raw_comment;
85                         char    *raw_func_start;
86                 } jump;
87         };
88 };
89
90 struct ins_ops {
91         void (*free)(struct ins_operands *ops);
92         int (*parse)(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms,
93                         struct disasm_line *dl);
94         int (*scnprintf)(struct ins *ins, char *bf, size_t size,
95                          struct ins_operands *ops, int max_ins_name);
96 };
97
98 struct annotate_args {
99         struct arch               *arch;
100         struct map_symbol         ms;
101         struct evsel              *evsel;
102         struct annotation_options *options;
103         s64                       offset;
104         char                      *line;
105         int                       line_nr;
106         char                      *fileloc;
107 };
108
109 struct arch *arch__find(const char *name);
110 bool arch__is(struct arch *arch, const char *name);
111
112 struct ins_ops *ins__find(struct arch *arch, const char *name, struct disasm_line *dl);
113 int ins__scnprintf(struct ins *ins, char *bf, size_t size,
114                    struct ins_operands *ops, int max_ins_name);
115
116 bool ins__is_call(const struct ins *ins);
117 bool ins__is_jump(const struct ins *ins);
118 bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2);
119 bool ins__is_nop(const struct ins *ins);
120 bool ins__is_ret(const struct ins *ins);
121 bool ins__is_lock(const struct ins *ins);
122
123 struct disasm_line *disasm_line__new(struct annotate_args *args);
124 void disasm_line__free(struct disasm_line *dl);
125
126 int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size,
127                            bool raw, int max_ins_name);
128
129 int symbol__disassemble(struct symbol *sym, struct annotate_args *args);
130
131 #endif /* __PERF_UTIL_DISASM_H */
This page took 0.033728 seconds and 4 git commands to generate.