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.61k stars 1.56k forks source link

Got abnormal behavior when set CS_OPT_DETAIL_REAL without CS_OPT_ON #2302

Closed yakamoz423 closed 2 months ago

yakamoz423 commented 7 months ago

Work environment

Questions Answers
OS/arch/bits Windows x86
Architecture armv8
Source of Capstone git clone & cmake mingw
Version/git commit next, 0d12bcacd75da8ba02f6294505e7bedd55002a66

Expected behavior

According to cs_v6_release_guide, I just set cs_option(handle, CS_OPT_DETAIL, CS_OPT_DETAIL_REAL);, and I found the details is part invalid.

Changing code to cs_option(handle, CS_OPT_DETAIL, (CS_OPT_ON | CS_OPT_DETAIL_REAL));, it works.

I think it's better to make CS_OPT_DETAIL_REAL implicitly turn on the detials? or maybe the doc need to update, and don't generate groups and condition info and condition when detail turned off.

Actual behavior

console print ERROR: Too many groups defined in instruction mapping. and groups info pile up while no other details. This image is not captured from cstool.

Steps to reproduce the behavior

Command:

cstool -r armbe e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201e3c00201 0x233
Rot127 commented 2 months ago

This gets fixed with https://github.com/capstone-engine/capstone/pull/2469

Unfortunately, implicitly enabling details for only CS_OPT_DETAIL_REAL doesn't work. Because we could not disable them afterwards. because CS_OPT_OFF = 0, CS_OPT_DETAIL_REAL | CS_OPT_OFF == CS_OPT_DETAIL_REAL.

Refactoring options is one of the many things on the list though.