mirror of
https://github.com/capstone-engine/capstone.git
synced 2024-12-01 01:10:29 +00:00
Fix partially inconsistent output from java binding
This commit is contained in:
parent
72a196e565
commit
7b08804440
@ -1,6 +1,6 @@
|
||||
TMPDIR = /tmp/capstone_test
|
||||
|
||||
DIFF = diff -u -b
|
||||
DIFF = diff -u -w
|
||||
|
||||
TEST = $(TMPDIR)/test
|
||||
TEST_ARM = $(TMPDIR)/test_arm
|
||||
|
@ -48,7 +48,7 @@ public class Test {
|
||||
Capstone.CS_ARCH_X86,
|
||||
Capstone.CS_MODE_32,
|
||||
new byte[] { (byte)0x8d, 0x4c, 0x32, 0x08, 0x01, (byte)0xd8, (byte)0x81, (byte)0xc6, 0x34, 0x12, 0x00, 0x00 },
|
||||
"X86 32bit (Intel syntax)"
|
||||
"X86 32 (Intel syntax)"
|
||||
),
|
||||
new platform(
|
||||
Capstone.CS_ARCH_X86,
|
||||
@ -102,18 +102,20 @@ public class Test {
|
||||
};
|
||||
|
||||
for (int j = 0; j < platforms.length; j++) {
|
||||
System.out.println("************");
|
||||
System.out.println("****************");
|
||||
System.out.println(String.format("Platform: %s", platforms[j].comment));
|
||||
System.out.println(String.format("Code: %s", stringToHex(platforms[j].code)));
|
||||
System.out.println("Disasm:");
|
||||
|
||||
Capstone cs = new Capstone(platforms[j].arch, platforms[j].mode);
|
||||
|
||||
Capstone.cs_insn[] all_insn = cs.disasm(platforms[j].code, 0x1000);
|
||||
|
||||
for (int i = 0; i < all_insn.length; i++) {
|
||||
System.out.println(String.format("0x%x\t%s\t%s", all_insn[i].address,
|
||||
System.out.println(String.format("0x%x: \t%s\t%s", all_insn[i].address,
|
||||
all_insn[i].mnemonic, all_insn[i].operands));
|
||||
|
||||
/*
|
||||
if (all_insn[i].regs_read[0] != 0) {
|
||||
System.out.print("\tRegister read: ");
|
||||
for(int k = 0; k < all_insn[i].regs_read.length; k++) {
|
||||
@ -142,8 +144,9 @@ public class Test {
|
||||
System.out.print(String.format("%d ", all_insn[i].groups[k]));
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
System.out.printf("0x%x:\n\n", all_insn[all_insn.length-1].address + all_insn[all_insn.length-1].size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,17 +52,17 @@ public class TestArm {
|
||||
|
||||
if (op_info.op != null) {
|
||||
System.out.printf("\top_count: %d\n", op_info.op.length);
|
||||
for (int c=1; c<op_info.op.length+1; c++) {
|
||||
Arm.Operand i = (Arm.Operand) op_info.op[c-1];
|
||||
for (int c=0; c<op_info.op.length; c++) {
|
||||
Arm.Operand i = (Arm.Operand) op_info.op[c];
|
||||
String imm = hex(i.value.imm);
|
||||
if (i.type == Arm.ARM_OP_REG)
|
||||
System.out.printf("\t\toperands[%d].type: REG = %s\n", c, cs.reg_name(i.value.reg));
|
||||
if (i.type == Arm.ARM_OP_IMM)
|
||||
System.out.printf("\t\toperands[%d].type: IMM = %s\n", c, imm);
|
||||
System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
|
||||
if (i.type == Arm.ARM_OP_PIMM)
|
||||
System.out.printf("\t\toperands[%d].type: P-IMM = %s\n", c, imm);
|
||||
System.out.printf("\t\toperands[%d].type: P-IMM = %d\n", c, i.value.imm);
|
||||
if (i.type == Arm.ARM_OP_CIMM)
|
||||
System.out.printf("\t\toperands[%d].type: C-IMM = %s\n", c, imm);
|
||||
System.out.printf("\t\toperands[%d].type: C-IMM = %d\n", c, i.value.imm);
|
||||
if (i.type == Arm.ARM_OP_FP)
|
||||
System.out.printf("\t\toperands[%d].type: FP = %f\n", c, i.value.fp);
|
||||
if (i.type == Arm.ARM_OP_MEM) {
|
||||
@ -74,9 +74,9 @@ public class TestArm {
|
||||
if (index != null)
|
||||
System.out.printf("\t\t\toperands[%d].mem.index: REG = %s\n", c, index);
|
||||
if (i.value.mem.scale != 1)
|
||||
System.out.printf("\t\t\toperands[%d].mem.scale: %s\n", c, hex(i.value.mem.scale));
|
||||
System.out.printf("\t\t\toperands[%d].mem.scale: %d\n", c, (i.value.mem.scale));
|
||||
if (i.value.mem.disp != 0)
|
||||
System.out.printf("\t\t\toperands[%d].mem.disp: %s\n", c, hex(i.value.mem.disp));
|
||||
System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, (i.value.mem.disp));
|
||||
}
|
||||
if (i.shift.type != Arm.ARM_SFT_INVALID && i.shift.value > 0)
|
||||
System.out.printf("\t\t\tShift: type = %d, value = %d\n", i.shift.type, i.shift.value);
|
||||
@ -106,6 +106,7 @@ public class TestArm {
|
||||
print_ins_detail(all_ins[j]);
|
||||
System.out.println();
|
||||
}
|
||||
System.out.printf("0x%x:\n\n", (all_ins[all_ins.length-1].address + all_ins[all_ins.length-1].size));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,15 +49,15 @@ public class TestArm64 {
|
||||
|
||||
if (op_info.op != null) {
|
||||
System.out.printf("\top_count: %d\n", op_info.op.length);
|
||||
for (int c=1; c<op_info.op.length+1; c++) {
|
||||
Arm64.Operand i = (Arm64.Operand) op_info.op[c-1];
|
||||
for (int c=0; c<op_info.op.length; c++) {
|
||||
Arm64.Operand i = (Arm64.Operand) op_info.op[c];
|
||||
String imm = hex(i.value.imm);
|
||||
if (i.type == Arm64.ARM64_OP_REG)
|
||||
System.out.printf("\t\toperands[%d].type: REG = %s\n", c, cs.reg_name(i.value.reg));
|
||||
if (i.type == Arm64.ARM64_OP_IMM)
|
||||
System.out.printf("\t\toperands[%d].type: IMM = %s\n", c, imm);
|
||||
System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
|
||||
if (i.type == Arm64.ARM64_OP_CIMM)
|
||||
System.out.printf("\t\toperands[%d].type: C-IMM = %s\n", c, imm);
|
||||
System.out.printf("\t\toperands[%d].type: C-IMM = %d\n", c, i.value.imm);
|
||||
if (i.type == Arm64.ARM64_OP_FP)
|
||||
System.out.printf("\t\toperands[%d].type: FP = %f\n", c, i.value.fp);
|
||||
if (i.type == Arm64.ARM64_OP_MEM) {
|
||||
@ -69,7 +69,7 @@ public class TestArm64 {
|
||||
if (index != null)
|
||||
System.out.printf("\t\t\toperands[%d].mem.index: REG = %s\n", c, index);
|
||||
if (i.value.mem.disp != 0)
|
||||
System.out.printf("\t\t\toperands[%d].mem.disp: %s\n", c, hex(i.value.mem.disp));
|
||||
System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, i.value.mem.disp);
|
||||
}
|
||||
if (i.shift.type != Arm64.ARM64_SFT_INVALID && i.shift.value > 0)
|
||||
System.out.printf("\t\t\tShift: type = %d, value = %d\n", i.shift.type, i.shift.value);
|
||||
|
@ -38,13 +38,13 @@ public class TestMips {
|
||||
|
||||
if (op_info.op != null) {
|
||||
System.out.printf("\top_count: %d\n", op_info.op.length);
|
||||
for (int c=1; c<op_info.op.length+1; c++) {
|
||||
Mips.Operand i = (Mips.Operand) op_info.op[c-1];
|
||||
for (int c=0; c<op_info.op.length; c++) {
|
||||
Mips.Operand i = (Mips.Operand) op_info.op[c];
|
||||
String imm = hex(i.value.imm);
|
||||
if (i.type == Mips.MIPS_OP_REG)
|
||||
System.out.printf("\t\toperands[%d].type: REG = %s\n", c, cs.reg_name(i.value.reg));
|
||||
if (i.type == Mips.MIPS_OP_IMM)
|
||||
System.out.printf("\t\toperands[%d].type: IMM = %s\n", c, imm);
|
||||
System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
|
||||
if (i.type == Mips.MIPS_OP_MEM) {
|
||||
System.out.printf("\t\toperands[%d].type: MEM\n",c);
|
||||
String base = cs.reg_name(i.value.mem.base);
|
||||
|
@ -18,9 +18,9 @@ public class TestX86 {
|
||||
return data;
|
||||
}
|
||||
|
||||
static final String X86_CODE16 = "8d4c320801d881c6341200000523010000368b84912301000041a113486d3a";
|
||||
static final String X86_CODE32 = "8d4c320801d881c6341200000523010000368b84912301000041a113486d3a8d0534120000";
|
||||
static final String X86_CODE64 = "55488b05b8130000";
|
||||
static final String X86_CODE16 = "8d4c320801d881c6341200000523010000368b849123010000418d8439896700008d8789670000b4c6";
|
||||
static final String X86_CODE32 = "8d4c320801d881c6341200000523010000368b849123010000418d8439896700008d8789670000b4c6";
|
||||
|
||||
public static Capstone cs;
|
||||
|
||||
@ -60,7 +60,7 @@ public class TestX86 {
|
||||
System.out.printf("\tmodrm: 0x%x\n", op_info.modrm);
|
||||
|
||||
// print displacement value
|
||||
System.out.printf("\tdisp: 0x%s\n", hex(op_info.disp));
|
||||
System.out.printf("\tdisp: 0x%x\n", op_info.disp);
|
||||
|
||||
// SIB is not available in 16-bit mode
|
||||
if ( (cs.mode & Capstone.CS_MODE_16) == 0)
|
||||
@ -72,19 +72,19 @@ public class TestX86 {
|
||||
System.out.printf("\timm_count: %d\n", count);
|
||||
for (int i=0; i<count; i++) {
|
||||
int index = ins.op_index(X86.X86_OP_IMM, i + 1);
|
||||
System.out.printf("\t\timms[%d] = 0x%x\n", i+1, (op_info.op[index].value.imm));
|
||||
System.out.printf("\t\timms[%d]: 0x%x\n", i+1, (op_info.op[index].value.imm));
|
||||
}
|
||||
}
|
||||
|
||||
if (op_info.op != null) {
|
||||
System.out.printf("\top_count: %d\n", op_info.op.length);
|
||||
for (int c=1; c<op_info.op.length+1; c++) {
|
||||
X86.Operand i = (X86.Operand) op_info.op[c-1];
|
||||
for (int c=0; c<op_info.op.length; c++) {
|
||||
X86.Operand i = (X86.Operand) op_info.op[c];
|
||||
String imm = hex(i.value.imm);
|
||||
if (i.type == X86.X86_OP_REG)
|
||||
System.out.printf("\t\toperands[%d].type: REG = %s\n", c, cs.reg_name(i.value.reg));
|
||||
if (i.type == X86.X86_OP_IMM)
|
||||
System.out.printf("\t\toperands[%d].type: IMM = %s\n", c, imm);
|
||||
System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm);
|
||||
if (i.type == X86.X86_OP_FP)
|
||||
System.out.printf("\t\toperands[%d].type: FP = %f\n", c, i.value.fp);
|
||||
if (i.type == X86.X86_OP_MEM) {
|
||||
@ -96,9 +96,9 @@ public class TestX86 {
|
||||
if (index != null)
|
||||
System.out.printf("\t\t\toperands[%d].mem.index: REG = %s\n", c, index);
|
||||
if (i.value.mem.scale != 1)
|
||||
System.out.printf("\t\t\toperands[%d].mem.scale: 0x%s\n", c, hex(i.value.mem.scale));
|
||||
System.out.printf("\t\t\toperands[%d].mem.scale: %d\n", c, i.value.mem.scale);
|
||||
if (i.value.mem.disp != 0)
|
||||
System.out.printf("\t\t\toperands[%d].mem.disp: 0x%s\n", c, hex(i.value.mem.disp));
|
||||
System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, i.value.mem.disp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user