1 // SPDX-License-Identifier: GPL-2.0 1 // SPDX-License-Identifier: GPL-2.0 2 #ifndef __PERF_UTIL_DISASM_H 2 #ifndef __PERF_UTIL_DISASM_H 3 #define __PERF_UTIL_DISASM_H 3 #define __PERF_UTIL_DISASM_H 4 4 5 #include "map_symbol.h" 5 #include "map_symbol.h" 6 6 7 #ifdef HAVE_DWARF_SUPPORT 7 #ifdef HAVE_DWARF_SUPPORT 8 #include "dwarf-aux.h" 8 #include "dwarf-aux.h" 9 #endif 9 #endif 10 10 11 struct annotation_options; 11 struct annotation_options; 12 struct disasm_line; 12 struct disasm_line; 13 struct ins; 13 struct ins; 14 struct evsel; 14 struct evsel; 15 struct symbol; 15 struct symbol; 16 struct data_loc_info; 16 struct data_loc_info; 17 struct type_state; 17 struct type_state; 18 struct disasm_line; 18 struct disasm_line; 19 19 20 struct arch { 20 struct arch { 21 const char *name; 21 const char *name; 22 struct ins *instructions; 22 struct ins *instructions; 23 size_t nr_instructions; 23 size_t nr_instructions; 24 size_t nr_instructions_alloca 24 size_t nr_instructions_allocated; 25 struct ins_ops *(*associate_instructi 25 struct ins_ops *(*associate_instruction_ops)(struct arch *arch, const char *name); 26 bool sorted_instructions; 26 bool sorted_instructions; 27 bool initialized; 27 bool initialized; 28 const char *insn_suffix; 28 const char *insn_suffix; 29 void *priv; 29 void *priv; 30 unsigned int model; 30 unsigned int model; 31 unsigned int family; 31 unsigned int family; 32 int (*init)(struct arch *a 32 int (*init)(struct arch *arch, char *cpuid); 33 bool (*ins_is_fused)(struct 33 bool (*ins_is_fused)(struct arch *arch, const char *ins1, 34 const 34 const char *ins2); 35 struct { 35 struct { 36 char comment_char; 36 char comment_char; 37 char skip_functions_char; 37 char skip_functions_char; 38 char register_char; 38 char register_char; 39 char memory_ref_char; 39 char memory_ref_char; 40 char imm_char; 40 char imm_char; 41 } objdump; 41 } objdump; 42 #ifdef HAVE_DWARF_SUPPORT 42 #ifdef HAVE_DWARF_SUPPORT 43 void (*update_insn_state)(s 43 void (*update_insn_state)(struct type_state *state, 44 struct data_lo 44 struct data_loc_info *dloc, Dwarf_Die *cu_die, 45 struct disasm_ 45 struct disasm_line *dl); 46 #endif 46 #endif 47 }; 47 }; 48 48 49 struct ins { 49 struct ins { 50 const char *name; 50 const char *name; 51 struct ins_ops *ops; 51 struct ins_ops *ops; 52 }; 52 }; 53 53 54 struct ins_operands { 54 struct ins_operands { 55 char *raw; 55 char *raw; 56 struct { 56 struct { 57 char *raw; 57 char *raw; 58 char *name; 58 char *name; 59 struct symbol *sym; 59 struct symbol *sym; 60 u64 addr; 60 u64 addr; 61 s64 offset; 61 s64 offset; 62 bool offset_avail; 62 bool offset_avail; 63 bool outside; 63 bool outside; 64 bool multi_regs; 64 bool multi_regs; 65 bool mem_ref; 65 bool mem_ref; 66 } target; 66 } target; 67 union { 67 union { 68 struct { 68 struct { 69 char *raw; 69 char *raw; 70 char *name; 70 char *name; 71 u64 addr; 71 u64 addr; 72 bool multi_regs; 72 bool multi_regs; 73 bool mem_ref; 73 bool mem_ref; 74 } source; 74 } source; 75 struct { 75 struct { 76 struct ins in 76 struct ins ins; 77 struct ins_operands *o 77 struct ins_operands *ops; 78 } locked; 78 } locked; 79 struct { 79 struct { 80 char *raw_comment; 80 char *raw_comment; 81 char *raw_func_star 81 char *raw_func_start; 82 } jump; 82 } jump; 83 }; 83 }; 84 }; 84 }; 85 85 86 struct ins_ops { 86 struct ins_ops { 87 void (*free)(struct ins_operands *ops) 87 void (*free)(struct ins_operands *ops); 88 int (*parse)(struct arch *arch, struct 88 int (*parse)(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms, 89 struct disasm_line *dl 89 struct disasm_line *dl); 90 int (*scnprintf)(struct ins *ins, char 90 int (*scnprintf)(struct ins *ins, char *bf, size_t size, 91 struct ins_operands * 91 struct ins_operands *ops, int max_ins_name); 92 }; 92 }; 93 93 94 struct annotate_args { 94 struct annotate_args { 95 struct arch *arch; 95 struct arch *arch; 96 struct map_symbol ms; 96 struct map_symbol ms; 97 struct evsel *evsel; 97 struct evsel *evsel; 98 struct annotation_options *options; 98 struct annotation_options *options; 99 s64 offset; 99 s64 offset; 100 char *line; 100 char *line; 101 int line_nr; 101 int line_nr; 102 char *fileloc; 102 char *fileloc; 103 }; 103 }; 104 104 105 struct arch *arch__find(const char *name); 105 struct arch *arch__find(const char *name); 106 bool arch__is(struct arch *arch, const char *n 106 bool arch__is(struct arch *arch, const char *name); 107 107 108 struct ins_ops *ins__find(struct arch *arch, c 108 struct ins_ops *ins__find(struct arch *arch, const char *name, struct disasm_line *dl); 109 int ins__scnprintf(struct ins *ins, char *bf, 109 int ins__scnprintf(struct ins *ins, char *bf, size_t size, 110 struct ins_operands *ops, i 110 struct ins_operands *ops, int max_ins_name); 111 111 112 bool ins__is_call(const struct ins *ins); 112 bool ins__is_call(const struct ins *ins); 113 bool ins__is_jump(const struct ins *ins); 113 bool ins__is_jump(const struct ins *ins); 114 bool ins__is_fused(struct arch *arch, const ch 114 bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2); 115 bool ins__is_nop(const struct ins *ins); 115 bool ins__is_nop(const struct ins *ins); 116 bool ins__is_ret(const struct ins *ins); 116 bool ins__is_ret(const struct ins *ins); 117 bool ins__is_lock(const struct ins *ins); 117 bool ins__is_lock(const struct ins *ins); 118 118 119 struct disasm_line *disasm_line__new(struct an 119 struct disasm_line *disasm_line__new(struct annotate_args *args); 120 void disasm_line__free(struct disasm_line *dl) 120 void disasm_line__free(struct disasm_line *dl); 121 121 122 int disasm_line__scnprintf(struct disasm_line 122 int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, 123 bool raw, int max_i 123 bool raw, int max_ins_name); 124 124 125 int symbol__disassemble(struct symbol *sym, st 125 int symbol__disassemble(struct symbol *sym, struct annotate_args *args); 126 126 127 #endif /* __PERF_UTIL_DISASM_H */ 127 #endif /* __PERF_UTIL_DISASM_H */ 128 128
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.