rename error codes ERR_MEM_READ, ERR_MEM_WRITE, ERR_MEM_FETCH

This commit is contained in:
Nguyen Anh Quynh 2015-09-09 16:25:48 +08:00
parent d3d38d3f21
commit d7ef204398
7 changed files with 36 additions and 36 deletions

View file

@ -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

View file

@ -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)

View file

@ -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;

View file

@ -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

View file

@ -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()

View file

@ -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;

20
uc.c
View file

@ -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