Open F1o0T opened 9 months ago
Yes, RISC-V is one of the difficult architectures to add. Because it wasn't refactored yet to use Auto-Sync. This won't be the only crash you will encounter I think. There are still some unhandled cases.
This one it is apparently the simple-type of an operand, which has no enum string (for whatever reason).
The simple types of operands are added to the operand mapping tables (here ARM as example, check the CS_DATA_TYPE_...
values). printInsnOpMapEntry
emits such an entry in the mapping tables, this is why it crashes there.
If you want to continue to develop on RISC-V, you can add an if clause and skip it for RISC-V. Just emit CS_DATA_TYPE_LAST
instead of the enum name.
Be aware though, that this is really not an easy task. RISC-V seemed rather complex the last time I casually looked at it. So plan in more time.
Let me know when you've made a decision. So we can add you to https://github.com/capstone-engine/capstone/issues/2015 as RISC-V dev.
For the crashes, you can install the llvm-symbolizer to resolve the addresses to symbol names. No need for gdb
.
See the most recent work on this in https://github.com/capstone-engine/capstone/pull/2498
Hello,
I was successfully able to use the ASUpdater.py script to generate the inc files for Arm. However, when I try the same with RISCV, I am getting the following issue.
python3.11 ./Updater/ASUpdater.py -a RISCV
I have executed the used llvm-tblgen command independently
/home/projects/capstone-playground/capstone/suite/auto-sync/llvm-capstone/build/bin/llvm-tblgen --printerLang=CCS --gen-asm-matcher -I /home/projects/capstone-playground/capstone/suite/auto-sync/llvm-capstone/llvm/include -I /home/projects/capstone-playground/capstone/suite/auto-sync/llvm-capstone/llvm/lib/Target/RISCV /home/projects/capstone-playground/capstone/suite/auto-sync/llvm-capstone/llvm/lib/Target/RISCV/RISCV.td
I got the following error:
Here is the generated crash backtrace from gdb.
gdb -q --args /home/projects/capstone-playground/capstone/suite/auto-sync/llvm-capstone/build/bin/llvm-tblgen --printerLang=CCS --gen-asm-matcher -I /home/projects/capstone-playground/capstone/suite/auto-sync/llvm-capstone/llvm/include -I /home/projects/capstone-playground/capstone/suite/auto-sync/llvm-capstone/llvm/lib/Target/RISCV /home/projects/capstone-playground/capstone/suite/auto-sync/llvm-capstone/llvm/lib/Target/RISCV/RISCV.td
I have added a
printf("InsnNum: %d\n", InsnNum);
inside the following for loop in the functionasmMatcherEmitMatchTable
:the last printed InsnNum is
254
before the crash occures insideprintInsnOpMapEntry
Any idea what could have gone wrong? Thanks in advance!