From b9e76ddb6ba47798a8eafa1e4abd4bd8978ed02d Mon Sep 17 00:00:00 2001 From: billow Date: Fri, 23 Jun 2023 17:47:34 +0800 Subject: [PATCH 1/4] Fix capstone_test.c --- suite/cstest/src/capstone_test.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/suite/cstest/src/capstone_test.c b/suite/cstest/src/capstone_test.c index 984355585f..aca1236828 100644 --- a/suite/cstest/src/capstone_test.c +++ b/suite/cstest/src/capstone_test.c @@ -194,7 +194,6 @@ void test_single_issue(csh *handle, cs_mode mode, char *line, int detail) { char **list_part, **list_byte, **list_part_issue_result; int size_part, size_byte, size_part_issue_result; - char *tmptmp; int i, count, j; unsigned char *code; cs_insn *insn; @@ -255,9 +254,7 @@ void test_single_issue(csh *handle, cs_mode mode, char *line, int detail) for (i = 0; i < size_part_issue_result; ++i) { trim_str(list_part_issue_result[i]); - memset(tmptmp, 0, MAXMEM); - - tmptmp = (char *)malloc(sizeof(char)); + char *tmptmp = (char *)malloc(sizeof(char)); tmptmp[0] = '\0'; add_str(&tmptmp, "%s", list_part_issue_result[i]); add_str(&tmptmp, " ;"); @@ -270,9 +267,9 @@ void test_single_issue(csh *handle, cs_mode mode, char *line, int detail) free(cs_result); // free_strs(list_part_cs_result, size_part_cs_result); free_strs(list_part_issue_result, size_part_issue_result); - free(tmptmp); _fail(__FILE__, __LINE__); } + free(tmptmp); } cs_free(insn, count); From 49adaac59905336f609de9094f396c2b43a7b96d Mon Sep 17 00:00:00 2001 From: billow Date: Fri, 23 Jun 2023 20:47:11 +0800 Subject: [PATCH 2/4] Fix const_generator.py and tricore_const.py --- bindings/const_generator.py | 3 ++- bindings/python/capstone/__init__.py | 2 ++ bindings/python/capstone/tricore_const.py | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bindings/const_generator.py b/bindings/const_generator.py index 938583f6fa..ec4985c89b 100644 --- a/bindings/const_generator.py +++ b/bindings/const_generator.py @@ -31,7 +31,8 @@ 'comment_close': '', }, 'python': { - 'header': "# For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [%s_const.py]\n", + 'header': "from .__init__ import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OPT_MEM\n" + "# For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [%s_const.py]\n", 'footer': "", 'line_format': '%s = %s\n', 'out_file': './python/capstone/%s_const.py', diff --git a/bindings/python/capstone/__init__.py b/bindings/python/capstone/__init__.py index b3ffc1bfe1..0f8072e195 100755 --- a/bindings/python/capstone/__init__.py +++ b/bindings/python/capstone/__init__.py @@ -110,6 +110,8 @@ 'CS_OPT_ON', 'CS_OPT_OFF', + 'CS_OPT_MEM', + 'CS_ERR_OK', 'CS_ERR_MEM', 'CS_ERR_ARCH', diff --git a/bindings/python/capstone/tricore_const.py b/bindings/python/capstone/tricore_const.py index 25aa370f59..5f01bad601 100644 --- a/bindings/python/capstone/tricore_const.py +++ b/bindings/python/capstone/tricore_const.py @@ -1,3 +1,4 @@ +from .__init__ import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OPT_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [tricore_const.py] TRICORE_OP_INVALID = CS_OP_INVALID TRICORE_OP_REG = CS_OP_REG From b39fac744fc6bdaf2a2339f03a89b2368fd073d8 Mon Sep 17 00:00:00 2001 From: billow Date: Fri, 23 Jun 2023 23:46:19 +0800 Subject: [PATCH 3/4] Fix tricore.h --- include/capstone/tricore.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/capstone/tricore.h b/include/capstone/tricore.h index cc64e899ca..4c9ee00391 100644 --- a/include/capstone/tricore.h +++ b/include/capstone/tricore.h @@ -23,7 +23,7 @@ typedef enum tricore_op_type { TRICORE_OP_INVALID = CS_OP_INVALID, ///< CS_OP_INVALID (Uninitialized). TRICORE_OP_REG = CS_OP_REG, ///< CS_OP_REG (Register operand). TRICORE_OP_IMM = CS_OP_IMM, ///< CS_OP_IMM (Immediate operand). - TRICORE_OP_MEM = CS_OPT_MEM, ///< CS_OP_MEM (Memory operand). + TRICORE_OP_MEM = CS_OP_MEM, ///< CS_OP_MEM (Memory operand). } tricore_op_type; /// Instruction's operand referring to memory From 14ea1ae1d8c8b9077df986c60a6af3d6e4cdd0ba Mon Sep 17 00:00:00 2001 From: billow Date: Fri, 23 Jun 2023 23:46:47 +0800 Subject: [PATCH 4/4] Update all *_const.py --- bindings/const_generator.py | 2 +- bindings/python/capstone/arm64_const.py | 1 + bindings/python/capstone/arm_const.py | 1 + bindings/python/capstone/bpf_const.py | 1 + bindings/python/capstone/evm_const.py | 1 + bindings/python/capstone/m680x_const.py | 1 + bindings/python/capstone/m68k_const.py | 1 + bindings/python/capstone/mips_const.py | 1 + bindings/python/capstone/mos65xx_const.py | 1 + bindings/python/capstone/ppc_const.py | 1 + bindings/python/capstone/riscv_const.py | 1 + bindings/python/capstone/sparc_const.py | 1 + bindings/python/capstone/sysz_const.py | 1 + bindings/python/capstone/tms320c64x_const.py | 1 + bindings/python/capstone/tricore_const.py | 4 ++-- bindings/python/capstone/wasm_const.py | 1 + bindings/python/capstone/x86_const.py | 1 + bindings/python/capstone/xcore_const.py | 1 + 18 files changed, 19 insertions(+), 3 deletions(-) diff --git a/bindings/const_generator.py b/bindings/const_generator.py index ec4985c89b..74c5f1e66c 100644 --- a/bindings/const_generator.py +++ b/bindings/const_generator.py @@ -31,7 +31,7 @@ 'comment_close': '', }, 'python': { - 'header': "from .__init__ import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OPT_MEM\n" + 'header': "from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM\n" "# For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [%s_const.py]\n", 'footer': "", 'line_format': '%s = %s\n', diff --git a/bindings/python/capstone/arm64_const.py b/bindings/python/capstone/arm64_const.py index 1417f8a916..f2210ffdd0 100644 --- a/bindings/python/capstone/arm64_const.py +++ b/bindings/python/capstone/arm64_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [arm64_const.py] ARM64_SFT_INVALID = 0 diff --git a/bindings/python/capstone/arm_const.py b/bindings/python/capstone/arm_const.py index 4395f80e29..22c4f6df93 100644 --- a/bindings/python/capstone/arm_const.py +++ b/bindings/python/capstone/arm_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [arm_const.py] ARM_SFT_INVALID = 0 diff --git a/bindings/python/capstone/bpf_const.py b/bindings/python/capstone/bpf_const.py index 2dfe9ba288..6b89081e21 100644 --- a/bindings/python/capstone/bpf_const.py +++ b/bindings/python/capstone/bpf_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [bpf_const.py] BPF_OP_INVALID = 0 diff --git a/bindings/python/capstone/evm_const.py b/bindings/python/capstone/evm_const.py index 6bd0e5af35..5013b0f657 100644 --- a/bindings/python/capstone/evm_const.py +++ b/bindings/python/capstone/evm_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [evm_const.py] EVM_INS_STOP = 0 diff --git a/bindings/python/capstone/m680x_const.py b/bindings/python/capstone/m680x_const.py index 2ed71ab5d4..6c68b241c2 100644 --- a/bindings/python/capstone/m680x_const.py +++ b/bindings/python/capstone/m680x_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [m680x_const.py] M680X_OPERAND_COUNT = 9 diff --git a/bindings/python/capstone/m68k_const.py b/bindings/python/capstone/m68k_const.py index 39f54184c8..90755e3d29 100644 --- a/bindings/python/capstone/m68k_const.py +++ b/bindings/python/capstone/m68k_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [m68k_const.py] M68K_OPERAND_COUNT = 4 diff --git a/bindings/python/capstone/mips_const.py b/bindings/python/capstone/mips_const.py index af2f2094ba..b6c5886bb2 100644 --- a/bindings/python/capstone/mips_const.py +++ b/bindings/python/capstone/mips_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [mips_const.py] MIPS_OP_INVALID = 0 diff --git a/bindings/python/capstone/mos65xx_const.py b/bindings/python/capstone/mos65xx_const.py index 44c807a387..7c3b803d47 100644 --- a/bindings/python/capstone/mos65xx_const.py +++ b/bindings/python/capstone/mos65xx_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [mos65xx_const.py] MOS65XX_REG_INVALID = 0 diff --git a/bindings/python/capstone/ppc_const.py b/bindings/python/capstone/ppc_const.py index 3fc144edda..a8cd49d581 100644 --- a/bindings/python/capstone/ppc_const.py +++ b/bindings/python/capstone/ppc_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [ppc_const.py] PPC_BC_INVALID = 0 diff --git a/bindings/python/capstone/riscv_const.py b/bindings/python/capstone/riscv_const.py index 562946486c..2b3c50dfd1 100644 --- a/bindings/python/capstone/riscv_const.py +++ b/bindings/python/capstone/riscv_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [riscv_const.py] # Operand type for instruction's operands diff --git a/bindings/python/capstone/sparc_const.py b/bindings/python/capstone/sparc_const.py index 6187691f89..b12eabb6eb 100644 --- a/bindings/python/capstone/sparc_const.py +++ b/bindings/python/capstone/sparc_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [sparc_const.py] SPARC_CC_INVALID = 0 diff --git a/bindings/python/capstone/sysz_const.py b/bindings/python/capstone/sysz_const.py index e2e9cdd4bf..d79baf8f03 100644 --- a/bindings/python/capstone/sysz_const.py +++ b/bindings/python/capstone/sysz_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [sysz_const.py] SYSZ_CC_INVALID = 0 diff --git a/bindings/python/capstone/tms320c64x_const.py b/bindings/python/capstone/tms320c64x_const.py index 7f8daaeb62..50c7d24670 100644 --- a/bindings/python/capstone/tms320c64x_const.py +++ b/bindings/python/capstone/tms320c64x_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [tms320c64x_const.py] TMS320C64X_OP_INVALID = 0 diff --git a/bindings/python/capstone/tricore_const.py b/bindings/python/capstone/tricore_const.py index 5f01bad601..258a2cdad1 100644 --- a/bindings/python/capstone/tricore_const.py +++ b/bindings/python/capstone/tricore_const.py @@ -1,9 +1,9 @@ -from .__init__ import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OPT_MEM +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [tricore_const.py] TRICORE_OP_INVALID = CS_OP_INVALID TRICORE_OP_REG = CS_OP_REG TRICORE_OP_IMM = CS_OP_IMM -TRICORE_OP_MEM = CS_OPT_MEM +TRICORE_OP_MEM = CS_OP_MEM TRICORE_OP_COUNT = 8 TRICORE_REG_INVALID = 0 diff --git a/bindings/python/capstone/wasm_const.py b/bindings/python/capstone/wasm_const.py index eaa078d43c..5ad810a6de 100644 --- a/bindings/python/capstone/wasm_const.py +++ b/bindings/python/capstone/wasm_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [wasm_const.py] WASM_OP_INVALID = 0 diff --git a/bindings/python/capstone/x86_const.py b/bindings/python/capstone/x86_const.py index a1d3396357..9b43b535b1 100644 --- a/bindings/python/capstone/x86_const.py +++ b/bindings/python/capstone/x86_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [x86_const.py] X86_REG_INVALID = 0 diff --git a/bindings/python/capstone/xcore_const.py b/bindings/python/capstone/xcore_const.py index f1b74855d3..5cc8ebe016 100644 --- a/bindings/python/capstone/xcore_const.py +++ b/bindings/python/capstone/xcore_const.py @@ -1,3 +1,4 @@ +from . import CS_OP_INVALID, CS_OP_REG, CS_OP_IMM, CS_OP_MEM # For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [xcore_const.py] XCORE_OP_INVALID = 0