From 642bdcfb0a856551aceda0c47594af9353cf60ed Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Thu, 7 Jul 2011 22:17:23 +0000 Subject: [PATCH] minimize instrumentation callback interface. removed bx_instr_new_instruction callback, the callback ALWAYS can be replaced with another one - bx_instr_before_execution TODO: fix instrumentation examples (example0 and example1) --- bochs/instrument/example0/instrument.cc | 2 +- bochs/instrument/example0/instrument.h | 7 +++---- bochs/instrument/example1/instrument.cc | 2 +- bochs/instrument/example1/instrument.h | 8 +++----- bochs/instrument/instrumentation.txt | 6 ------ bochs/instrument/stubs/instrument.cc | 1 - bochs/instrument/stubs/instrument.h | 4 ---- 7 files changed, 8 insertions(+), 22 deletions(-) diff --git a/bochs/instrument/example0/instrument.cc b/bochs/instrument/example0/instrument.cc index 756a41087..4bbadf5cb 100644 --- a/bochs/instrument/example0/instrument.cc +++ b/bochs/instrument/example0/instrument.cc @@ -79,7 +79,7 @@ void bx_instr_reset(unsigned cpu, unsigned type) instruction[cpu].is_branch = 0; } -void bx_instr_new_instruction(unsigned cpu) +void bx_instr_before_execution(unsigned cpu, bxInstruction_c *unused) { if (!active) return; diff --git a/bochs/instrument/example0/instrument.h b/bochs/instrument/example0/instrument.h index dd48c1dde..d2d8af416 100644 --- a/bochs/instrument/example0/instrument.h +++ b/bochs/instrument/example0/instrument.h @@ -63,7 +63,6 @@ void bx_instr_exit_env(void); void bx_instr_initialize(unsigned cpu); void bx_instr_reset(unsigned cpu, unsigned type); -void bx_instr_new_instruction(unsigned cpu); void bx_instr_cnear_branch_taken(unsigned cpu, bx_address new_eip); void bx_instr_cnear_branch_not_taken(unsigned cpu); @@ -72,6 +71,8 @@ void bx_instr_far_branch(unsigned cpu, unsigned what, Bit16u new_cs, bx_address void bx_instr_opcode(unsigned cpu, const Bit8u *opcode, unsigned len, bx_bool is32, bx_bool is64); +void bx_instr_before_execution(unsigned cpu, bxInstruction_c *i); + void bx_instr_interrupt(unsigned cpu, unsigned vector); void bx_instr_exception(unsigned cpu, unsigned vector, unsigned error_code); void bx_instr_hwinterrupt(unsigned cpu, unsigned vector, Bit16u cs, bx_address eip); @@ -88,7 +89,6 @@ void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, uns #define BX_INSTR_RESET(cpu_id, type) bx_instr_reset(cpu_id, type) #define BX_INSTR_HLT(cpu_id) #define BX_INSTR_MWAIT(cpu_id, addr, len, flags) -#define BX_INSTR_NEW_INSTRUCTION(cpu_id) bx_instr_new_instruction(cpu_id) /* called from command line debugger */ #define BX_INSTR_DEBUG_PROMPT() @@ -118,7 +118,7 @@ void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, uns #define BX_INSTR_PREFETCH_HINT(cpu_id, what, seg, offset) /* execution */ -#define BX_INSTR_BEFORE_EXECUTION(cpu_id, i) +#define BX_INSTR_BEFORE_EXECUTION(cpu_id, i) bx_instr_before_execution(cpu_id, i) #define BX_INSTR_AFTER_EXECUTION(cpu_id, i) #define BX_INSTR_REPEAT_ITERATION(cpu_id, i) @@ -153,7 +153,6 @@ void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, uns #define BX_INSTR_RESET(cpu_id, type) #define BX_INSTR_HLT(cpu_id) #define BX_INSTR_MWAIT(cpu_id, addr, len, flags) -#define BX_INSTR_NEW_INSTRUCTION(cpu_id) /* called from command line debugger */ #define BX_INSTR_DEBUG_PROMPT() diff --git a/bochs/instrument/example1/instrument.cc b/bochs/instrument/example1/instrument.cc index 17dee2ec2..c4e0f4ac3 100644 --- a/bochs/instrument/example1/instrument.cc +++ b/bochs/instrument/example1/instrument.cc @@ -52,7 +52,7 @@ void bxInstrumentation::bx_instr_reset(unsigned type) active = 1; } -void bxInstrumentation::bx_instr_new_instruction() +void bxInstrumentation::bx_instr_before_execution(bxInstruction_c *unused) { if (!active) return; diff --git a/bochs/instrument/example1/instrument.h b/bochs/instrument/example1/instrument.h index c0eba23a1..9acb00f45 100644 --- a/bochs/instrument/example1/instrument.h +++ b/bochs/instrument/example1/instrument.h @@ -104,7 +104,6 @@ public: bx_bool is_active() const { return active; } void bx_instr_reset(unsigned type); - void bx_instr_new_instruction(); void bx_instr_cnear_branch_taken(bx_address new_eip); void bx_instr_cnear_branch_not_taken(); @@ -113,6 +112,8 @@ public: void bx_instr_opcode(const Bit8u *opcode, unsigned len, bx_bool is32, bx_bool is64); + void bx_instr_before_execution(bxInstruction_c *i); + void bx_instr_interrupt(unsigned vector); void bx_instr_exception(unsigned vector, unsigned error_code); void bx_instr_hwinterrupt(unsigned vector, Bit16u cs, bx_address eip); @@ -138,8 +139,6 @@ extern bxInstrumentation *icpu; #define BX_INSTR_HLT(cpu_id) #define BX_INSTR_MWAIT(cpu_id, addr, len, flags) -#define BX_INSTR_NEW_INSTRUCTION(cpu_id) icpu[cpu_id].bx_instr_new_instruction() - /* called from command line debugger */ #define BX_INSTR_DEBUG_PROMPT() #define BX_INSTR_DEBUG_CMD(cmd) @@ -168,7 +167,7 @@ extern bxInstrumentation *icpu; #define BX_INSTR_PREFETCH_HINT(cpu_id, what, seg, offset) /* execution */ -#define BX_INSTR_BEFORE_EXECUTION(cpu_id, i) +#define BX_INSTR_BEFORE_EXECUTION(cpu_id, i) icpu[cpu_id].bx_instr_before_execution(i) #define BX_INSTR_AFTER_EXECUTION(cpu_id, i) #define BX_INSTR_REPEAT_ITERATION(cpu_id, i) @@ -202,7 +201,6 @@ extern bxInstrumentation *icpu; #define BX_INSTR_RESET(cpu_id, type) #define BX_INSTR_HLT(cpu_id) #define BX_INSTR_MWAIT(cpu_id, addr, len, flags) -#define BX_INSTR_NEW_INSTRUCTION(cpu_id) /* called from command line debugger */ #define BX_INSTR_DEBUG_PROMPT() diff --git a/bochs/instrument/instrumentation.txt b/bochs/instrument/instrumentation.txt index af620388a..71be344fc 100644 --- a/bochs/instrument/instrumentation.txt +++ b/bochs/instrument/instrumentation.txt @@ -66,12 +66,6 @@ state. The callback receives monitored memory range and MWAIT flags as a parameters. - void bx_instr_new_instruction(unsigned cpu); - -The callback is called each time, when Bochs completes (commits) already -finished instruction and starts a new one. - - void bx_instr_cnear_branch_taken(unsigned cpu, bx_address new_eip); The callback is called each time, when currently executed instruction is a diff --git a/bochs/instrument/stubs/instrument.cc b/bochs/instrument/stubs/instrument.cc index 852b8dad1..266dc7c36 100644 --- a/bochs/instrument/stubs/instrument.cc +++ b/bochs/instrument/stubs/instrument.cc @@ -32,7 +32,6 @@ void bx_instr_exit(unsigned cpu) {} void bx_instr_reset(unsigned cpu, unsigned type) {} void bx_instr_hlt(unsigned cpu) {} void bx_instr_mwait(unsigned cpu, bx_phy_address addr, unsigned len, Bit32u flags) {} -void bx_instr_new_instruction(unsigned cpu) {} void bx_instr_debug_promt() {} void bx_instr_debug_cmd(const char *cmd) {} diff --git a/bochs/instrument/stubs/instrument.h b/bochs/instrument/stubs/instrument.h index 1106d7e63..d9342e16f 100644 --- a/bochs/instrument/stubs/instrument.h +++ b/bochs/instrument/stubs/instrument.h @@ -66,7 +66,6 @@ void bx_instr_exit(unsigned cpu); void bx_instr_reset(unsigned cpu, unsigned type); void bx_instr_hlt(unsigned cpu); void bx_instr_mwait(unsigned cpu, bx_phy_address addr, unsigned len, Bit32u flags); -void bx_instr_new_instruction(unsigned cpu); void bx_instr_debug_promt(); void bx_instr_debug_cmd(const char *cmd); @@ -116,8 +115,6 @@ void bx_instr_wrmsr(unsigned cpu, unsigned addr, Bit64u value); #define BX_INSTR_MWAIT(cpu_id, addr, len, flags) \ bx_instr_mwait(cpu_id, addr, len, flags) -#define BX_INSTR_NEW_INSTRUCTION(cpu_id) bx_instr_new_instruction(cpu_id) - /* called from command line debugger */ #define BX_INSTR_DEBUG_PROMPT() bx_instr_debug_promt() #define BX_INSTR_DEBUG_CMD(cmd) bx_instr_debug_cmd(cmd) @@ -181,7 +178,6 @@ void bx_instr_wrmsr(unsigned cpu, unsigned addr, Bit64u value); #define BX_INSTR_RESET(cpu_id, type) #define BX_INSTR_HLT(cpu_id) #define BX_INSTR_MWAIT(cpu_id, addr, len, flags) -#define BX_INSTR_NEW_INSTRUCTION(cpu_id) /* called from command line debugger */ #define BX_INSTR_DEBUG_PROMPT()