capstone-engine / capstone

Capstone disassembly/disassembler framework for ARM, ARM64 (ARMv8), Alpha, BPF, Ethereum VM, HPPA, LoongArch, M68K, M680X, Mips, MOS65XX, PPC, RISC-V(rv32G/rv64G), SH, Sparc, SystemZ, TMS320C64X, TriCore, Webassembly, XCore and X86.
http://www.capstone-engine.org
7.57k stars 1.55k forks source link

Operands missing/incorrect in Diet mode #1883

Open clubby789 opened 2 years ago

clubby789 commented 2 years ago

The docs for Diet mode state

@op_str

Without operand string, we can still extract equivalent information out of @detail->operands, which contains all details about operands of instruction.

For example, instruction “ADD EAX, EBX” would have 2 operands of register type X86_OP_REG, with register IDs of X86_REG_EAX & X86_REG_EBX.

However, this does not seem to be universally true: https://github.com/capstone-engine/capstone/blob/fee83fcc1ad096c22d4f2066ccb58ad1a76a9886/arch/M68K/M68KInstPrinter.c#L262-L277 The extension data (which contains op_count and operands) is only copied into the cs_detail if CAPSTONE_DIET isn't enabled.

I believe this also occurs in other places, as, when enabling this for capstone-rs I get argument mismatches in these unit tests:

    test::test_arch_m68k_detail
    test::test_arch_ppc_detail
    test::test_arch_x86_detail
Rot127 commented 3 months ago

Is this still an issue for you? If yes, I opened an issue about fixing the DIET build in general: https://github.com/capstone-engine/capstone/issues/2404 If you have more requests, it would be nice to have them there.