From d7ef2043985a1b5d039111925efaf311a13c75fe Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Wed, 9 Sep 2015 16:25:48 +0800 Subject: [PATCH] rename error codes ERR_MEM_READ, ERR_MEM_WRITE, ERR_MEM_FETCH --- bindings/go/unicorn/unicorn_const.go | 6 +++--- bindings/go/unicorn/x86_test.go | 8 ++++---- bindings/java/unicorn/UnicornConst.java | 6 +++--- bindings/python/unicorn/unicorn_const.py | 6 +++--- include/unicorn/unicorn.h | 6 +++--- qemu/softmmu_template.h | 20 ++++++++++---------- uc.c | 20 ++++++++++---------- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/bindings/go/unicorn/unicorn_const.go b/bindings/go/unicorn/unicorn_const.go index 192f3c0..5cd094d 100644 --- a/bindings/go/unicorn/unicorn_const.go +++ b/bindings/go/unicorn/unicorn_const.go @@ -39,9 +39,9 @@ const ( ERR_HANDLE = 3 ERR_MODE = 4 ERR_VERSION = 5 - ERR_MEM_READ = 6 - ERR_MEM_WRITE = 7 - ERR_MEM_FETCH = 8 + ERR_READ_INVALID = 6 + ERR_WRITE_INVALID = 7 + ERR_FETCH_INVALID = 8 ERR_CODE_INVALID = 9 ERR_HOOK = 10 ERR_INSN_INVALID = 11 diff --git a/bindings/go/unicorn/x86_test.go b/bindings/go/unicorn/x86_test.go index 302a105..fe72f2e 100644 --- a/bindings/go/unicorn/x86_test.go +++ b/bindings/go/unicorn/x86_test.go @@ -49,8 +49,8 @@ func TestX86InvalidRead(t *testing.T) { t.Fatal(err) } err = mu.Start(ADDRESS, ADDRESS+uint64(len(code))) - if err.(UcError) != ERR_MEM_READ { - t.Fatal("Expected ERR_MEM_READ") + if err.(UcError) != ERR_READ_INVALID { + t.Fatal("Expected ERR_READ_INVALID") } ecx, _ := mu.RegRead(X86_REG_ECX) edx, _ := mu.RegRead(X86_REG_EDX) @@ -66,8 +66,8 @@ func TestX86InvalidWrite(t *testing.T) { t.Fatal(err) } err = mu.Start(ADDRESS, ADDRESS+uint64(len(code))) - if err.(UcError) != ERR_MEM_WRITE { - t.Fatal("Expected ERR_MEM_WRITE") + if err.(UcError) != ERR_WRITE_INVALID { + t.Fatal("Expected ERR_WRITE_INVALID") } ecx, _ := mu.RegRead(X86_REG_ECX) edx, _ := mu.RegRead(X86_REG_EDX) diff --git a/bindings/java/unicorn/UnicornConst.java b/bindings/java/unicorn/UnicornConst.java index 9212212..9b9743c 100644 --- a/bindings/java/unicorn/UnicornConst.java +++ b/bindings/java/unicorn/UnicornConst.java @@ -41,9 +41,9 @@ public interface UnicornConst { public static final int UC_ERR_HANDLE = 3; public static final int UC_ERR_MODE = 4; public static final int UC_ERR_VERSION = 5; - public static final int UC_ERR_MEM_READ = 6; - public static final int UC_ERR_MEM_WRITE = 7; - public static final int UC_ERR_MEM_FETCH = 8; + public static final int UC_ERR_READ_INVALID = 6; + public static final int UC_ERR_WRITE_INVALID = 7; + public static final int UC_ERR_FETCH_INVALID = 8; public static final int UC_ERR_CODE_INVALID = 9; public static final int UC_ERR_HOOK = 10; public static final int UC_ERR_INSN_INVALID = 11; diff --git a/bindings/python/unicorn/unicorn_const.py b/bindings/python/unicorn/unicorn_const.py index e676a56..d87eb1b 100644 --- a/bindings/python/unicorn/unicorn_const.py +++ b/bindings/python/unicorn/unicorn_const.py @@ -37,9 +37,9 @@ UC_ERR_ARCH = 2 UC_ERR_HANDLE = 3 UC_ERR_MODE = 4 UC_ERR_VERSION = 5 -UC_ERR_MEM_READ = 6 -UC_ERR_MEM_WRITE = 7 -UC_ERR_MEM_FETCH = 8 +UC_ERR_READ_INVALID = 6 +UC_ERR_WRITE_INVALID = 7 +UC_ERR_FETCH_INVALID = 8 UC_ERR_CODE_INVALID = 9 UC_ERR_HOOK = 10 UC_ERR_INSN_INVALID = 11 diff --git a/include/unicorn/unicorn.h b/include/unicorn/unicorn.h index 1b75b82..7ca0d0d 100644 --- a/include/unicorn/unicorn.h +++ b/include/unicorn/unicorn.h @@ -111,9 +111,9 @@ typedef enum uc_err { UC_ERR_HANDLE, // Invalid handle UC_ERR_MODE, // Invalid/unsupported mode: uc_open() UC_ERR_VERSION, // Unsupported version (bindings) - UC_ERR_MEM_READ, // Quit emulation due to invalid memory READ: uc_emu_start() - UC_ERR_MEM_WRITE, // Quit emulation due to invalid memory WRITE: uc_emu_start() - UC_ERR_MEM_FETCH, // Quit emulation due to invalid memory FETCH: uc_emu_start() + UC_ERR_READ_INVALID, // Quit emulation due to invalid memory READ: uc_emu_start() + UC_ERR_WRITE_INVALID, // Quit emulation due to invalid memory WRITE: uc_emu_start() + UC_ERR_FETCH_INVALID, // Quit emulation due to invalid memory FETCH: uc_emu_start() UC_ERR_CODE_INVALID, // Quit emulation due to invalid code address: uc_emu_start() UC_ERR_HOOK, // Invalid hook type: uc_hook_add() UC_ERR_INSN_INVALID, // Quit emulation due to invalid instruction: uc_emu_start() diff --git a/qemu/softmmu_template.h b/qemu/softmmu_template.h index 0e741eb..9e8afd4 100644 --- a/qemu/softmmu_template.h +++ b/qemu/softmmu_template.h @@ -186,10 +186,10 @@ WORD_TYPE helper_le_ld_name(CPUArchState *env, target_ulong addr, int mmu_idx, if (mr == NULL) { #if defined(SOFTMMU_CODE_ACCESS) mem_access = UC_MEM_FETCH; - error_code = UC_ERR_MEM_FETCH; + error_code = UC_ERR_FETCH_INVALID; #else mem_access = UC_MEM_READ; - error_code = UC_ERR_MEM_READ; + error_code = UC_ERR_READ_INVALID; #endif if (uc->hook_mem_idx != 0 && ((uc_cb_eventmem_t)uc->hook_callbacks[uc->hook_mem_idx].callback)( uc, mem_access, addr, DATA_SIZE, 0, @@ -283,7 +283,7 @@ WORD_TYPE helper_le_ld_name(CPUArchState *env, target_ulong addr, int mmu_idx, ioaddr = env->iotlb[mmu_idx][index]; if (ioaddr == 0) { env->invalid_addr = addr; - env->invalid_error = UC_ERR_MEM_READ; + env->invalid_error = UC_ERR_READ_INVALID; // printf("Invalid memory read at " TARGET_FMT_lx "\n", addr); cpu_exit(env->uc->current_cpu); return 0; @@ -376,10 +376,10 @@ WORD_TYPE helper_be_ld_name(CPUArchState *env, target_ulong addr, int mmu_idx, if (mr == NULL) { #if defined(SOFTMMU_CODE_ACCESS) mem_access = UC_MEM_FETCH; - error_code = UC_ERR_MEM_FETCH; + error_code = UC_ERR_FETCH_INVALID; #else mem_access = UC_MEM_READ; - error_code = UC_ERR_MEM_READ; + error_code = UC_ERR_READ_INVALID; #endif if (uc->hook_mem_idx != 0 && ((uc_cb_eventmem_t)uc->hook_callbacks[uc->hook_mem_idx].callback)( uc, mem_access, addr, DATA_SIZE, 0, @@ -473,7 +473,7 @@ WORD_TYPE helper_be_ld_name(CPUArchState *env, target_ulong addr, int mmu_idx, if (ioaddr == 0) { env->invalid_addr = addr; - env->invalid_error = UC_ERR_MEM_READ; + env->invalid_error = UC_ERR_READ_INVALID; // printf("Invalid memory read at " TARGET_FMT_lx "\n", addr); cpu_exit(env->uc->current_cpu); return 0; @@ -614,7 +614,7 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, uc->hook_callbacks[uc->hook_mem_idx].user_data)) { // save error & quit env->invalid_addr = addr; - env->invalid_error = UC_ERR_MEM_WRITE; + env->invalid_error = UC_ERR_WRITE_INVALID; // printf("***** Invalid memory write at " TARGET_FMT_lx "\n", addr); cpu_exit(uc->current_cpu); return; @@ -670,7 +670,7 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, ioaddr = env->iotlb[mmu_idx][index]; if (ioaddr == 0) { env->invalid_addr = addr; - env->invalid_error = UC_ERR_MEM_WRITE; + env->invalid_error = UC_ERR_WRITE_INVALID; // printf("***** Invalid memory write at " TARGET_FMT_lx "\n", addr); cpu_exit(env->uc->current_cpu); return; @@ -760,7 +760,7 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, uc->hook_callbacks[uc->hook_mem_idx].user_data)) { // save error & quit env->invalid_addr = addr; - env->invalid_error = UC_ERR_MEM_WRITE; + env->invalid_error = UC_ERR_WRITE_INVALID; // printf("***** Invalid memory write at " TARGET_FMT_lx "\n", addr); cpu_exit(uc->current_cpu); return; @@ -816,7 +816,7 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, ioaddr = env->iotlb[mmu_idx][index]; if (ioaddr == 0) { env->invalid_addr = addr; - env->invalid_error = UC_ERR_MEM_WRITE; + env->invalid_error = UC_ERR_WRITE_INVALID; // printf("***** Invalid memory write at " TARGET_FMT_lx "\n", addr); cpu_exit(env->uc->current_cpu); return; diff --git a/uc.c b/uc.c index 725136d..8282e82 100644 --- a/uc.c +++ b/uc.c @@ -69,12 +69,12 @@ const char *uc_strerror(uc_err code) return "Invalid mode (UC_ERR_MODE)"; case UC_ERR_VERSION: return "Different API version between core & binding (UC_ERR_VERSION)"; - case UC_ERR_MEM_READ: - return "Invalid memory read (UC_ERR_MEM_READ)"; - case UC_ERR_MEM_WRITE: - return "Invalid memory write (UC_ERR_MEM_WRITE)"; - case UC_ERR_MEM_FETCH: - return "Invalid memory fetch (UC_ERR_MEM_FETCH)"; + case UC_ERR_READ_INVALID: + return "Invalid memory read (UC_ERR_READ_INVALID)"; + case UC_ERR_WRITE_INVALID: + return "Invalid memory write (UC_ERR_WRITE_INVALID)"; + case UC_ERR_FETCH_INVALID: + return "Invalid memory fetch (UC_ERR_FETCH_INVALID)"; case UC_ERR_CODE_INVALID: return "Invalid code address (UC_ERR_CODE_INVALID)"; case UC_ERR_HOOK: @@ -343,7 +343,7 @@ uc_err uc_mem_read(uc_engine *uc, uint64_t address, void *_bytes, size_t size) uint8_t *bytes = _bytes; if (!check_mem_area(uc, address, size)) - return UC_ERR_MEM_READ; + return UC_ERR_READ_INVALID; size_t count = 0, len; @@ -364,7 +364,7 @@ uc_err uc_mem_read(uc_engine *uc, uint64_t address, void *_bytes, size_t size) if (count == size) return UC_ERR_OK; else - return UC_ERR_MEM_READ; + return UC_ERR_READ_INVALID; } UNICORN_EXPORT @@ -373,7 +373,7 @@ uc_err uc_mem_write(uc_engine *uc, uint64_t address, const void *_bytes, size_t const uint8_t *bytes = _bytes; if (!check_mem_area(uc, address, size)) - return UC_ERR_MEM_WRITE; + return UC_ERR_WRITE_INVALID; size_t count = 0, len; @@ -404,7 +404,7 @@ uc_err uc_mem_write(uc_engine *uc, uint64_t address, const void *_bytes, size_t if (count == size) return UC_ERR_OK; else - return UC_ERR_MEM_WRITE; + return UC_ERR_WRITE_INVALID; } #define TIMEOUT_STEP 2 // microseconds