ppc_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 static const char* get_bc_name(int bc)
8 {
9  switch(bc) {
10  default:
11  case PPC_BC_INVALID:
12  return ("invalid");
13  case PPC_BC_LT:
14  return ("lt");
15  case PPC_BC_LE:
16  return ("le");
17  case PPC_BC_EQ:
18  return ("eq");
19  case PPC_BC_GE:
20  return ("ge");
21  case PPC_BC_GT:
22  return ("gt");
23  case PPC_BC_NE:
24  return ("ne");
25  case PPC_BC_UN:
26  return ("un");
27  case PPC_BC_NU:
28  return ("nu");
29  case PPC_BC_SO:
30  return ("so");
31  case PPC_BC_NS:
32  return ("ns");
33  }
34 }
35 
36 char *get_detail_ppc(csh *handle, cs_mode mode, cs_insn *ins)
37 {
38  cs_ppc *ppc;
39  int i;
40  char *result;
41 
42  result = (char *)malloc(sizeof(char));
43  result[0] = '\0';
44 
45  if (ins->detail == NULL)
46  return result;
47 
48  ppc = &(ins->detail->ppc);
49  if (ppc->op_count)
50  add_str(&result, " ; op_count: %u", ppc->op_count);
51 
52  for (i = 0; i < ppc->op_count; i++) {
53  cs_ppc_op *op = &(ppc->operands[i]);
54  switch((int)op->type) {
55  default:
56  break;
57  case PPC_OP_REG:
58  add_str(&result, " ; operands[%u].type: REG = %s", i, cs_reg_name(*handle, op->reg));
59  break;
60  case PPC_OP_IMM:
61  add_str(&result, " ; operands[%u].type: IMM = 0x%"PRIx64"", i, op->imm);
62  break;
63  case PPC_OP_MEM:
64  add_str(&result, " ; operands[%u].type: MEM", i);
65  if (op->mem.base != PPC_REG_INVALID)
66  add_str(&result, " ; operands[%u].mem.base: REG = %s", i, cs_reg_name(*handle, op->mem.base));
67  if (op->mem.disp != 0)
68  add_str(&result, " ; operands[%u].mem.disp: 0x%x", i, op->mem.disp);
69 
70  break;
71  case PPC_OP_CRX:
72  add_str(&result, " ; operands[%u].type: CRX", i);
73  add_str(&result, " ; operands[%u].crx.scale: %d", i, op->crx.scale);
74  add_str(&result, " ; operands[%u].crx.reg: %s", i, cs_reg_name(*handle, op->crx.reg));
75  add_str(&result, " ; operands[%u].crx.cond: %s", i, get_bc_name(op->crx.cond));
76  break;
77  }
78  }
79 
80  if (ppc->bc != 0)
81  add_str(&result, " ; Branch code: %u", ppc->bc);
82 
83  if (ppc->bh != 0)
84  add_str(&result, " ; Branch hint: %u", ppc->bh);
85 
86  if (ppc->update_cr0)
87  add_str(&result, " ; Update-CR0: True");
88 
89  return result;
90 }
91 
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
PPC_BC_EQ
@ PPC_BC_EQ
Definition: ppc.h:22
PPC_REG_INVALID
@ PPC_REG_INVALID
Definition: ppc.h:52
factory.h
cs_ppc_op
Instruction operand.
Definition: ppc.h:283
ppc
Definition: test_winkernel.cpp:71
PPC_OP_MEM
@ PPC_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: ppc.h:46
mode
const char int mode
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:135
PPC_BC_NU
@ PPC_BC_NU
Definition: ppc.h:27
PPC_BC_LT
@ PPC_BC_LT
Definition: ppc.h:20
cs_mode
cs_mode
Mode type.
Definition: capstone.h:103
PPC_BC_GE
@ PPC_BC_GE
Definition: ppc.h:23
PPC_BC_GT
@ PPC_BC_GT
Definition: ppc.h:24
cs_ppc
Instruction structure.
Definition: ppc.h:294
cs_reg_name
const CAPSTONE_EXPORT char *CAPSTONE_API cs_reg_name(csh ud, unsigned int reg)
Definition: cs.c:1176
PPC_BC_UN
@ PPC_BC_UN
Definition: ppc.h:26
PPC_BC_INVALID
@ PPC_BC_INVALID
Definition: ppc.h:19
add_str
void add_str(char **src, const char *format,...)
Definition: helper.c:89
PPC_BC_NS
@ PPC_BC_NS
not summary overflow
Definition: ppc.h:31
PPC_BC_NE
@ PPC_BC_NE
Definition: ppc.h:25
PPC_BC_SO
@ PPC_BC_SO
summary overflow
Definition: ppc.h:30
csh
size_t csh
Definition: capstone.h:71
get_detail_ppc
char * get_detail_ppc(csh *handle, cs_mode mode, cs_insn *ins)
Definition: ppc_detail.c:36
PPC_OP_REG
@ PPC_OP_REG
= CS_OP_REG (Register operand).
Definition: ppc.h:44
PPC_BC_LE
@ PPC_BC_LE
Definition: ppc.h:21
handle
static csh handle
Definition: test_arm_regression.c:16
PPC_OP_IMM
@ PPC_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: ppc.h:45
op
static grpc_op * op
Definition: test/core/fling/client.cc:47
get_bc_name
static const char * get_bc_name(int bc)
Definition: ppc_detail.c:7
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
PPC_OP_CRX
@ PPC_OP_CRX
Condition Register field.
Definition: ppc.h:47


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:45