Rizin
unix-like reverse engineering framework and cli tools
TestXcore Class Reference

Static Public Member Functions

static void print_ins_detail (Capstone.CsInsn ins)
 
static void main (String argv[])
 

Static Public Attributes

static Capstone cs
 

Static Package Functions

static byte[] hexString2Byte (String s)
 

Static Package Attributes

static final String XCORE_CODE = "fe0ffe171317c6feec1797f8ec4f1ffdec3707f2455bf9fa02061b1009fdeca7"
 

Static Private Member Functions

static String hex (int i)
 
static String hex (long i)
 

Detailed Description

Definition at line 9 of file TestXcore.java.

Member Function Documentation

◆ hex() [1/2]

static String TestXcore.hex ( int  i)
inlinestaticprivate

Definition at line 25 of file TestXcore.java.

25  {
26  return Integer.toString(i, 16);
27  }
lzma_index ** i
Definition: index.h:629

References i.

◆ hex() [2/2]

static String TestXcore.hex ( long  i)
inlinestaticprivate

Definition at line 29 of file TestXcore.java.

29  {
30  return Long.toString(i, 16);
31  }

References i.

◆ hexString2Byte()

static byte [] TestXcore.hexString2Byte ( String  s)
inlinestaticpackage

Definition at line 10 of file TestXcore.java.

10  {
11  // from http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
12  int len = s.length();
13  byte[] data = new byte[len / 2];
14  for (int i = 0; i < len; i += 2) {
15  data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
16  + Character.digit(s.charAt(i+1), 16));
17  }
18  return data;
19  }
size_t len
Definition: 6502dis.c:15
static RzSocket * s
Definition: rtr.c:28

References i, len, and s.

Referenced by main().

◆ main()

static void TestXcore.main ( String  argv[])
inlinestatic

Definition at line 61 of file TestXcore.java.

61  {
62 
63  final TestBasic.platform[] all_tests = {
64  new TestBasic.platform(Capstone.CS_ARCH_XCORE, Capstone.CS_MODE_BIG_ENDIAN, hexString2Byte(XCORE_CODE), "XCore"),
65  };
66 
67  for (int i=0; i<all_tests.length; i++) {
69  System.out.println(new String(new char[16]).replace("\0", "*"));
70  System.out.println("Platform: " + test.comment);
71  System.out.println("Code: " + TestBasic.stringToHex(test.code));
72  System.out.println("Disasm:");
73 
74  cs = new Capstone(test.arch, test.mode);
75  cs.setDetail(Capstone.CS_OPT_ON);
76  Capstone.CsInsn[] all_ins = cs.disasm(test.code, 0x1000);
77 
78  for (int j = 0; j < all_ins.length; j++) {
79  print_ins_detail(all_ins[j]);
80  System.out.println();
81  }
82  System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
83 
84  // Close when done
85  cs.close();
86  }
87  }
static String stringToHex(byte[] code)
Definition: TestBasic.java:30
static void print_ins_detail(Capstone.CsInsn ins)
Definition: TestXcore.java:33
static final String XCORE_CODE
Definition: TestXcore.java:21
static byte[] hexString2Byte(String s)
Definition: TestXcore.java:10
static Capstone cs
Definition: TestXcore.java:23
tuple all_tests
Definition: test_arm.py:18
-lz4-versions
int replace(char *string, const char *token, const char *fmt,...)
Definition: tms320_dasm.c:325

References test_arm.all_tests, cs, hexString2Byte(), i, print_ins_detail(), replace(), TestBasic.stringToHex(), and XCORE_CODE.

◆ print_ins_detail()

static void TestXcore.print_ins_detail ( Capstone.CsInsn  ins)
inlinestatic

Definition at line 33 of file TestXcore.java.

33  {
34  System.out.printf("0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr);
35 
36  Xcore.OpInfo operands = (Xcore.OpInfo) ins.operands;
37 
38  if (operands.op.length != 0) {
39  System.out.printf("\top_count: %d\n", operands.op.length);
40  for (int c=0; c<operands.op.length; c++) {
42  if (i.type == XCORE_OP_REG)
43  System.out.printf("\t\toperands[%d].type: REG = %s\n", c, ins.regName(i.value.reg));
44  if (i.type == XCORE_OP_IMM)
45  System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
46  if (i.type == XCORE_OP_MEM) {
47  System.out.printf("\t\toperands[%d].type: MEM\n", c);
48  if (i.value.mem.base != XCORE_REG_INVALID)
49  System.out.printf("\t\t\toperands[%d].mem.base: REG = %s\n", c, ins.regName(i.value.mem.base));
50  if (i.value.mem.index != XCORE_REG_INVALID)
51  System.out.printf("\t\t\toperands[%d].mem.index: REG = %s\n", c, ins.regName(i.value.mem.index));
52  if (i.value.mem.disp != 0)
53  System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, i.value.mem.disp);
54  if (i.value.mem.direct != 1)
55  System.out.printf("\t\t\toperands[%d].mem.direct: -1\n", c);
56  }
57  }
58  }
59  }
@ XCORE_REG_INVALID
Definition: xcore.h:27
@ XCORE_OP_REG
= CS_OP_REG (Register operand).
Definition: xcore.h:20
@ XCORE_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: xcore.h:21
@ XCORE_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: xcore.h:22
#define c(i)
Definition: sha256.c:43
if(dbg->bits==RZ_SYS_BITS_64)
Definition: windows-arm64.h:4

References c, i, if(), XCORE_OP_IMM, XCORE_OP_MEM, XCORE_OP_REG, and XCORE_REG_INVALID.

Referenced by main().

Member Data Documentation

◆ cs

Capstone TestXcore.cs
static

Definition at line 23 of file TestXcore.java.

Referenced by main().

◆ XCORE_CODE

final String TestXcore.XCORE_CODE = "fe0ffe171317c6feec1797f8ec4f1ffdec3707f2455bf9fa02061b1009fdeca7"
staticpackage

Definition at line 21 of file TestXcore.java.

Referenced by main().


The documentation for this class was generated from the following file: