Debian Codegraph @

arch/BPF/BPFInstPrinter.c

raw symbols SCIP
1 /* Capstone Disassembly Engine */cxx . . $ `<file>/arch/BPF/BPFInstPrinter.c`/
2 /* BPF Backend by david942j <[email protected]>, 2019 */
3
4 #include <capstone/platform.h>cxx . . $ `<file>/include/capstone/platform.h`/
5
6 #include "BPFConstants.h"cxx . . $ `<file>/arch/BPF/BPFConstants.h`/
7 #include "BPFInstPrinter.h"cxx . . $ `<file>/arch/BPF/BPFInstPrinter.h`/
8 #include "BPFMapping.h"cxx . . $ `<file>/arch/BPF/BPFMapping.h`/
9
10 static cs_bpf_opcxx . . $ cs_bpf_op# *expand_bpf_operandscxx . . $ expand_bpf_operands(1e56f7813c2e030b).(cs_bpfcxx . . $ cs_bpf# *bpf)
11 {
12 /* assert(bpf->op_count < 3); */
13 return &bpf->operandscxx . . $ cs_bpf#operands.[bpf->op_countcxx . . $ cs_bpf#op_count.++];
14 }
15
16 static void push_op_regcxx . . $ push_op_reg(fcac6194ecb4f15c).(cs_bpfcxx . . $ cs_bpf# *bpf, bpf_op_typecxx . . $ bpf_op_type# val, uint8_tcxx . . $ uint8_t# ac_mode)
17 {
18 cs_bpf_opcxx . . $ cs_bpf_op# *op = expand_bpf_operandscxx . . $ expand_bpf_operands(1e56f7813c2e030b).(bpf);
19
20 op->typecxx . . $ cs_bpf_op#type. = BPF_OP_REGcxx . . $ BPF_OP_REG.;
21 op->regcxx . . $ cs_bpf_op#$anonymous_type_0#reg. = val;
22 op->accesscxx . . $ cs_bpf_op#access. = ac_mode;
23 }
24
25 static void push_op_immcxx . . $ push_op_imm(5566be0fda542b8e).(cs_bpfcxx . . $ cs_bpf# *bpf, uint64_tcxx . . $ uint64_t# val)
26 {
27 cs_bpf_opcxx . . $ cs_bpf_op# *op = expand_bpf_operandscxx . . $ expand_bpf_operands(1e56f7813c2e030b).(bpf);
28
29 op->typecxx . . $ cs_bpf_op#type. = BPF_OP_IMMcxx . . $ BPF_OP_IMM.;
30 op->immcxx . . $ cs_bpf_op#$anonymous_type_0#imm. = val;
31 }
32
33 static void push_op_offcxx . . $ push_op_off(3bd66864ee2f9c72).(cs_bpfcxx . . $ cs_bpf# *bpf, uint32_tcxx . . $ uint32_t# val)
34 {
35 cs_bpf_opcxx . . $ cs_bpf_op# *op = expand_bpf_operandscxx . . $ expand_bpf_operands(1e56f7813c2e030b).(bpf);
36
37 op->typecxx . . $ cs_bpf_op#type. = BPF_OP_OFFcxx . . $ BPF_OP_OFF.;
38 op->offcxx . . $ cs_bpf_op#$anonymous_type_0#off. = val;
39 }
40
41 static void push_op_memcxx . . $ push_op_mem(bafd4c614d7d709d).(cs_bpfcxx . . $ cs_bpf# *bpf, bpf_regcxx . . $ bpf_reg# reg, uint32_tcxx . . $ uint32_t# val)
42 {
43 cs_bpf_opcxx . . $ cs_bpf_op# *op = expand_bpf_operandscxx . . $ expand_bpf_operands(1e56f7813c2e030b).(bpf);
44
45 op->typecxx . . $ cs_bpf_op#type. = BPF_OP_MEMcxx . . $ BPF_OP_MEM.;
46 op->memcxx . . $ cs_bpf_op#$anonymous_type_0#mem..basecxx . . $ bpf_op_mem#base. = reg;
47 op->memcxx . . $ cs_bpf_op#$anonymous_type_0#mem..dispcxx . . $ bpf_op_mem#disp. = val;
48 }
49
50 static void push_op_mmemcxx . . $ push_op_mmem(3bd66864ee2f9c72).(cs_bpfcxx . . $ cs_bpf# *bpf, uint32_tcxx . . $ uint32_t# val)
51 {
52 cs_bpf_opcxx . . $ cs_bpf_op# *op = expand_bpf_operandscxx . . $ expand_bpf_operands(1e56f7813c2e030b).(bpf);
53
54 op->typecxx . . $ cs_bpf_op#type. = BPF_OP_MMEMcxx . . $ BPF_OP_MMEM.;
55 op->mmemcxx . . $ cs_bpf_op#$anonymous_type_0#mmem. = val;
56 }
57
58 static void push_op_mshcxx . . $ push_op_msh(3bd66864ee2f9c72).(cs_bpfcxx . . $ cs_bpf# *bpf, uint32_tcxx . . $ uint32_t# val)
59 {
60 cs_bpf_opcxx . . $ cs_bpf_op# *op = expand_bpf_operandscxx . . $ expand_bpf_operands(1e56f7813c2e030b).(bpf);
61
62 op->typecxx . . $ cs_bpf_op#type. = BPF_OP_MSHcxx . . $ BPF_OP_MSH.;
63 op->mshcxx . . $ cs_bpf_op#$anonymous_type_0#msh. = val;
64 }
65
66 static void push_op_extcxx . . $ push_op_ext(cda9cf6e6b24d4ea).(cs_bpfcxx . . $ cs_bpf# *bpf, bpf_ext_typecxx . . $ bpf_ext_type# val)
67 {
68 cs_bpf_opcxx . . $ cs_bpf_op# *op = expand_bpf_operandscxx . . $ expand_bpf_operands(1e56f7813c2e030b).(bpf);
69
70 op->typecxx . . $ cs_bpf_op#type. = BPF_OP_EXTcxx . . $ BPF_OP_EXT.;
71 op->extcxx . . $ cs_bpf_op#$anonymous_type_0#ext. = val;
72 }
73
74 static void convert_operandscxx . . $ convert_operands(1f26b700748237a8).(MCInstcxx . . $ MCInst# *MI, cs_bpfcxx . . $ cs_bpf# *bpf)
75 {
76 unsigned opcode = MCInst_getOpcodecxx . . $ MCInst_getOpcode(66549afbf0596d6c).(MI);
77 unsigned mc_op_count = MCInst_getNumOperandscxx . . $ MCInst_getNumOperands(66549afbf0596d6c).(MI);
78 MCOperandcxx . . $ MCOperand# *op;
79 MCOperandcxx . . $ MCOperand# *op2;
80 unsigned i;
81
82 bpf->op_countcxx . . $ cs_bpf#op_count. = 0;
83 if (BPF_CLASScxx . . $ `arch/BPF/BPFConstants.h:9:9`!(opcode) == BPF_CLASS_LDcxx . . $ `arch/BPF/BPFConstants.h:12:9`! || BPF_CLASScxx . . $ `arch/BPF/BPFConstants.h:9:9`!(opcode) == BPF_CLASS_LDXcxx . . $ `arch/BPF/BPFConstants.h:13:9`!) {
84 switch (BPF_MODEcxx . . $ `arch/BPF/BPFConstants.h:73:9`!(opcode)) {
85 case BPF_MODE_IMMcxx . . $ `arch/BPF/BPFConstants.h:75:9`!:
86 if (EBPF_MODEcxx . . $ `arch/BPF/BPFMapping.h:11:9`!(MI->csh)) {
87 push_op_regcxx . . $ push_op_reg(fcac6194ecb4f15c).(bpf, MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 0)), CS_AC_WRITEcxx . . $ CS_AC_WRITE.);
88 push_op_immcxx . . $ push_op_imm(5566be0fda542b8e).(bpf, MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 1)));
89 } else {
90 push_op_immcxx . . $ push_op_imm(5566be0fda542b8e).(bpf, MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 0)));
91 }
92 break;
93 case BPF_MODE_ABScxx . . $ `arch/BPF/BPFConstants.h:76:9`!:
94 op = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 0);
95 push_op_memcxx . . $ push_op_mem(bafd4c614d7d709d).(bpf, BPF_REG_INVALIDcxx . . $ BPF_REG_INVALID., (uint32_tcxx . . $ uint32_t#)MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(op));
96 break;
97 case BPF_MODE_INDcxx . . $ `arch/BPF/BPFConstants.h:77:9`!:
98 op = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 0);
99 op2 = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 1);
100 push_op_memcxx . . $ push_op_mem(bafd4c614d7d709d).(bpf, MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(op), (uint32_tcxx . . $ uint32_t#)MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(op2));
101 break;
102 case BPF_MODE_MEMcxx . . $ `arch/BPF/BPFConstants.h:78:9`!:
103 if (EBPF_MODEcxx . . $ `arch/BPF/BPFMapping.h:11:9`!(MI->csh)) {
104 /* ldx{w,h,b,dw} dst, [src+off] */
105 push_op_regcxx . . $ push_op_reg(fcac6194ecb4f15c).(bpf, MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 0)), CS_AC_WRITEcxx . . $ CS_AC_WRITE.);
106 op = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 1);
107 op2 = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 2);
108 push_op_memcxx . . $ push_op_mem(bafd4c614d7d709d).(bpf, MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(op), (uint32_tcxx . . $ uint32_t#)MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(op2));
109 }
110 else {
111 push_op_mmemcxx . . $ push_op_mmem(3bd66864ee2f9c72).(bpf, (uint32_tcxx . . $ uint32_t#)MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 0)));
112 }
113 break;
114 case BPF_MODE_LENcxx . . $ `arch/BPF/BPFConstants.h:79:9`!:
115 push_op_extcxx . . $ push_op_ext(cda9cf6e6b24d4ea).(bpf, BPF_EXT_LENcxx . . $ BPF_EXT_LEN.);
116 break;
117 case BPF_MODE_MSHcxx . . $ `arch/BPF/BPFConstants.h:80:9`!:
118 op = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 0);
119 push_op_mshcxx . . $ push_op_msh(3bd66864ee2f9c72).(bpf, (uint32_tcxx . . $ uint32_t#)MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(op));
120 break;
121 /* case BPF_MODE_XADD: // not exists */
122 }
123 return;
124 }
125 if (BPF_CLASScxx . . $ `arch/BPF/BPFConstants.h:9:9`!(opcode) == BPF_CLASS_STcxx . . $ `arch/BPF/BPFConstants.h:14:9`! || BPF_CLASScxx . . $ `arch/BPF/BPFConstants.h:9:9`!(opcode) == BPF_CLASS_STXcxx . . $ `arch/BPF/BPFConstants.h:15:9`!) {
126 if (!EBPF_MODEcxx . . $ `arch/BPF/BPFMapping.h:11:9`!(MI->csh)) {
127 // cBPF has only one case - st* M[k]
128 push_op_mmemcxx . . $ push_op_mmem(3bd66864ee2f9c72).(bpf, (uint32_tcxx . . $ uint32_t#)MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 0)));
129 return;
130 }
131 /* eBPF has two cases:
132 * - st [dst + off], src
133 * - xadd [dst + off], src
134 * they have same form of operands.
135 */
136 op = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 0);
137 op2 = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 1);
138 push_op_memcxx . . $ push_op_mem(bafd4c614d7d709d).(bpf, MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(op), (uint32_tcxx . . $ uint32_t#)MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(op2));
139 op = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 2);
140 if (MCOperand_isImmcxx . . $ MCOperand_isImm(8be14e8515538be0).(op))
141 push_op_immcxx . . $ push_op_imm(5566be0fda542b8e).(bpf, MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(op));
142 else if (MCOperand_isRegcxx . . $ MCOperand_isReg(8be14e8515538be0).(op))
143 push_op_regcxx . . $ push_op_reg(fcac6194ecb4f15c).(bpf, MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(op), CS_AC_READcxx . . $ CS_AC_READ.);
144 return;
145 }
146
147 if (BPF_CLASScxx . . $ `arch/BPF/BPFConstants.h:9:9`!(opcode) == BPF_CLASS_JMPcxx . . $ `arch/BPF/BPFConstants.h:17:9`!) {
148 for (i = 0; i < mc_op_count; i++) {
149 op = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, i);
150 if (MCOperand_isImmcxx . . $ MCOperand_isImm(8be14e8515538be0).(op)) {
151 /* decide the imm is BPF_OP_IMM or BPF_OP_OFF type here */
152 /*
153 * 1. ja +off
154 * 2. j {x,k}, +jt, +jf // cBPF
155 * 3. j dst_reg, {src_reg, k}, +off // eBPF
156 */
157 if (BPF_OPcxx . . $ `arch/BPF/BPFConstants.h:22:9`!(opcode) == BPF_JUMP_JAcxx . . $ `arch/BPF/BPFConstants.h:41:9`! ||
158 (!EBPF_MODEcxx . . $ `arch/BPF/BPFMapping.h:11:9`!(MI->csh) && i >= 1) ||
159 (EBPF_MODEcxx . . $ `arch/BPF/BPFMapping.h:11:9`!(MI->csh) && i == 2))
160 push_op_offcxx . . $ push_op_off(3bd66864ee2f9c72).(bpf, (uint32_tcxx . . $ uint32_t#)MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(op));
161 else
162 push_op_immcxx . . $ push_op_imm(5566be0fda542b8e).(bpf, MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(op));
163 }
164 else if (MCOperand_isRegcxx . . $ MCOperand_isReg(8be14e8515538be0).(op)) {
165 push_op_regcxx . . $ push_op_reg(fcac6194ecb4f15c).(bpf, MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(op), CS_AC_READcxx . . $ CS_AC_READ.);
166 }
167 }
168 return;
169 }
170
171 if (!EBPF_MODEcxx . . $ `arch/BPF/BPFMapping.h:11:9`!(MI->csh)) {
172 /* In cBPF mode, all registers in operands are accessed as read */
173 for (i = 0; i < mc_op_count; i++) {
174 op = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, i);
175 if (MCOperand_isImmcxx . . $ MCOperand_isImm(8be14e8515538be0).(op))
176 push_op_immcxx . . $ push_op_imm(5566be0fda542b8e).(bpf, MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(op));
177 else if (MCOperand_isRegcxx . . $ MCOperand_isReg(8be14e8515538be0).(op))
178 push_op_regcxx . . $ push_op_reg(fcac6194ecb4f15c).(bpf, MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(op), CS_AC_READcxx . . $ CS_AC_READ.);
179 }
180 return;
181 }
182
183 /* remain cases are: eBPF mode && ALU */
184 /* if (BPF_CLASS(opcode) == BPF_CLASS_ALU || BPF_CLASS(opcode) == BPF_CLASS_ALU64) */
185
186 /* We have three types:
187 * 1. {l,b}e dst // dst = byteswap(dst)
188 * 2. neg dst // dst = -dst
189 * 3. <op> dst, {src_reg, imm} // dst = dst <op> src
190 * so we can simply check the number of operands,
191 * exactly one operand means we are in case 1. and 2.,
192 * otherwise in case 3.
193 */
194 if (mc_op_count == 1) {
195 op = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 0);
196 push_op_regcxx . . $ push_op_reg(fcac6194ecb4f15c).(bpf, MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(op), CS_AC_READcxx . . $ CS_AC_READ. | CS_AC_WRITEcxx . . $ CS_AC_WRITE.);
197 }
198 else { // if (mc_op_count == 2)
199 op = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 0);
200 push_op_regcxx . . $ push_op_reg(fcac6194ecb4f15c).(bpf, MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(op), CS_AC_READcxx . . $ CS_AC_READ. | CS_AC_WRITEcxx . . $ CS_AC_WRITE.);
201
202 op = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, 1);
203 if (MCOperand_isImmcxx . . $ MCOperand_isImm(8be14e8515538be0).(op))
204 push_op_immcxx . . $ push_op_imm(5566be0fda542b8e).(bpf, MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(op));
205 else if (MCOperand_isRegcxx . . $ MCOperand_isReg(8be14e8515538be0).(op))
206 push_op_regcxx . . $ push_op_reg(fcac6194ecb4f15c).(bpf, MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(op), CS_AC_READcxx . . $ CS_AC_READ.);
207 }
208 }
209
210 static void print_operandcxx . . $ print_operand(43c8a253f1f760d8).(MCInstcxx . . $ MCInst# *MI, struct SStreamcxx . . $ SStream# *O, const cs_bpf_opcxx . . $ cs_bpf_op# *op)
211 {
212 switch (op->typecxx . . $ cs_bpf_op#type.) {
213 case BPF_OP_INVALIDcxx . . $ BPF_OP_INVALID.:
214 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "invalid");
215 break;
216 case BPF_OP_REGcxx . . $ BPF_OP_REG.:
217 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, BPF_reg_namecxx . . $ BPF_reg_name(efd1348d9ae5172e).((cshcxx . . $ csh#)MI->cshcxx . . $ MCInst#csh., op->regcxx . . $ cs_bpf_op#$anonymous_type_0#reg.));
218 break;
219 case BPF_OP_IMMcxx . . $ BPF_OP_IMM.:
220 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "0x%" PRIx64cxx . . $ `<external>/15933738808807975373/inttypes.h:126:10`!, op->immcxx . . $ cs_bpf_op#$anonymous_type_0#imm.);
221 break;
222 case BPF_OP_OFFcxx . . $ BPF_OP_OFF.:
223 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "+0x%x", op->offcxx . . $ cs_bpf_op#$anonymous_type_0#off.);
224 break;
225 case BPF_OP_MEMcxx . . $ BPF_OP_MEM.:
226 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "[");
227 if (op->memcxx . . $ cs_bpf_op#$anonymous_type_0#mem..basecxx . . $ bpf_op_mem#base. != BPF_REG_INVALIDcxx . . $ BPF_REG_INVALID.)
228 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, BPF_reg_namecxx . . $ BPF_reg_name(efd1348d9ae5172e).((cshcxx . . $ csh#)MI->cshcxx . . $ MCInst#csh., op->memcxx . . $ cs_bpf_op#$anonymous_type_0#mem..basecxx . . $ bpf_op_mem#base.));
229 if (op->memcxx . . $ cs_bpf_op#$anonymous_type_0#mem..dispcxx . . $ bpf_op_mem#disp. != 0) {
230 if (op->memcxx . . $ cs_bpf_op#$anonymous_type_0#mem..basecxx . . $ bpf_op_mem#base. != BPF_REG_INVALIDcxx . . $ BPF_REG_INVALID.)
231 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "+");
232 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "0x%x", op->memcxx . . $ cs_bpf_op#$anonymous_type_0#mem..dispcxx . . $ bpf_op_mem#disp.);
233 }
234 if (op->memcxx . . $ cs_bpf_op#$anonymous_type_0#mem..basecxx . . $ bpf_op_mem#base. == BPF_REG_INVALIDcxx . . $ BPF_REG_INVALID. && op->memcxx . . $ cs_bpf_op#$anonymous_type_0#mem..dispcxx . . $ bpf_op_mem#disp. == 0) // special case
235 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "0x0");
236 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "]");
237 break;
238 case BPF_OP_MMEMcxx . . $ BPF_OP_MMEM.:
239 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "m[0x%x]", op->mmemcxx . . $ cs_bpf_op#$anonymous_type_0#mmem.);
240 break;
241 case BPF_OP_MSHcxx . . $ BPF_OP_MSH.:
242 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "4*([0x%x]&0xf)", op->mshcxx . . $ cs_bpf_op#$anonymous_type_0#msh.);
243 break;
244 case BPF_OP_EXTcxx . . $ BPF_OP_EXT.:
245 switch (op->extcxx . . $ cs_bpf_op#$anonymous_type_0#ext.) {
246 case BPF_EXT_LENcxx . . $ BPF_EXT_LEN.:
247 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "#len");
248 break;
249 }
250 break;
251 }
252 }
253
254 /*
255 * 1. human readable mnemonic
256 * 2. set pubOpcode (BPF_INSN_*)
257 * 3. set detail->bpf.operands
258 * */
259 void BPF_printInstcxx . . $ BPF_printInst(6238f66e5ea10f57).(MCInstcxx . . $ MCInst# *MI, struct SStreamcxx . . $ SStream# *O, void *PrinterInfo)
260 {
261 int i;
262 cs_insncxx . . $ cs_insn# insn;
263 cs_bpfcxx . . $ cs_bpf# bpf;
264
265 insn.detailcxx . . $ cs_insn#detail. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
266 /* set pubOpcode as instruction id */
267 BPF_get_insn_idcxx . . $ BPF_get_insn_id(b32a94ba649bfb5a).((cs_structcxx . . $ cs_struct#*)MI->cshcxx . . $ MCInst#csh., &insn, MCInst_getOpcodecxx . . $ MCInst_getOpcode(66549afbf0596d6c).(MI));
268 MCInst_setOpcodePubcxx . . $ MCInst_setOpcodePub(1d3fdd902ae43da2).(MI, insn.idcxx . . $ cs_insn#id.);
269
270 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, BPF_insn_namecxx . . $ BPF_insn_name(efd1348d9ae5172e).((cshcxx . . $ csh#)MI->cshcxx . . $ MCInst#csh., insn.idcxx . . $ cs_insn#id.));
271 convert_operandscxx . . $ convert_operands(1f26b700748237a8).(MI, &bpf);
272 for (i = 0; i < bpf.op_countcxx . . $ cs_bpf#op_count.; i++) {
273 if (i == 0)
274 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "\t");
275 else
276 SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, ", ");
277 print_operandcxx . . $ print_operand(43c8a253f1f760d8).(MI, O, &bpf.operandscxx . . $ cs_bpf#operands.[i]);
278 }
279
280 #ifndef CAPSTONE_DIET
281 if (MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.) {
282 MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->bpfcxx . . $ cs_detail#$anonymous_type_0#bpf. = bpf;
283 }
284 #endif
285 }