mips_detail.c
Go to the documentation of this file.
1 /* Capstone testing regression */
2 /* By Do Minh Tuan <tuanit96@gmail.com>, 02-2019 */
3 
4 
5 #include "factory.h"
6 
7 char *get_detail_mips(csh *handle, cs_mode mode, cs_insn *ins)
8 {
9  int i;
10  cs_mips *mips;
11  char *result;
12 
13  result = (char *)malloc(sizeof(char));
14  result[0] = '\0';
15 
16  if (ins->detail == NULL)
17  return result;
18 
19  mips = &(ins->detail->mips);
20  if (mips->op_count)
21  add_str(&result, " ; op_count: %u", mips->op_count);
22 
23  for (i = 0; i < mips->op_count; i++) {
24  cs_mips_op *op = &(mips->operands[i]);
25  switch((int)op->type) {
26  default:
27  break;
28  case MIPS_OP_REG:
29  add_str(&result, " ; operands[%u].type: REG = %s", i, cs_reg_name(*handle, op->reg));
30  break;
31  case MIPS_OP_IMM:
32  add_str(&result, " ; operands[%u].type: IMM = 0x%" PRIx64 "", i, op->imm);
33  break;
34  case MIPS_OP_MEM:
35  add_str(&result, " ; operands[%u].type: MEM", i);
36  if (op->mem.base != MIPS_REG_INVALID)
37  add_str(&result, " ; operands[%u].mem.base: REG = %s", i, cs_reg_name(*handle, op->mem.base));
38  if (op->mem.disp != 0)
39  add_str(&result, " ; operands[%u].mem.disp: 0x%" PRIx64 "", i, op->mem.disp);
40 
41  break;
42  }
43 
44  }
45 
46  return result;
47 }
48 
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
MIPS_OP_REG
@ MIPS_OP_REG
= CS_OP_REG (Register operand).
Definition: mips.h:24
factory.h
MIPS_OP_MEM
@ MIPS_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: mips.h:26
mode
const char int mode
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:135
cs_mode
cs_mode
Mode type.
Definition: capstone.h:103
cs_reg_name
const CAPSTONE_EXPORT char *CAPSTONE_API cs_reg_name(csh ud, unsigned int reg)
Definition: cs.c:1176
add_str
void add_str(char **src, const char *format,...)
Definition: helper.c:89
MIPS_REG_INVALID
@ MIPS_REG_INVALID
Definition: mips.h:31
csh
size_t csh
Definition: capstone.h:71
cs_mips_op
Instruction operand.
Definition: mips.h:240
get_detail_mips
char * get_detail_mips(csh *handle, cs_mode mode, cs_insn *ins)
Definition: mips_detail.c:7
handle
static csh handle
Definition: test_arm_regression.c:16
MIPS_OP_IMM
@ MIPS_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: mips.h:25
mips
Definition: test_winkernel.cpp:63
op
static grpc_op * op
Definition: test/core/fling/client.cc:47
cs_mips
Instruction structure.
Definition: mips.h:250
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:40