added additional two instrumentalization callbacks called when Bochs

started, but before reading .bochsrc and before Bochs exits.
This commit is contained in:
Alexander Krisak 2008-10-01 11:36:04 +00:00
parent c009e87a81
commit dcf7330e69
8 changed files with 304 additions and 248 deletions

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: instrument.cc,v 1.24 2008-06-23 02:56:31 sshwarts Exp $ // $Id: instrument.cc,v 1.25 2008-10-01 11:36:04 akrisak Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -63,6 +63,9 @@ static struct instruction_t {
static logfunctions *instrument_log = new logfunctions (); static logfunctions *instrument_log = new logfunctions ();
#define LOG_THIS instrument_log-> #define LOG_THIS instrument_log->
void bx_instr_init_env(void) {}
void bx_instr_exit_env(void) {}
void bx_instr_init(unsigned cpu) void bx_instr_init(unsigned cpu)
{ {
assert(cpu < BX_SMP_PROCESSORS); assert(cpu < BX_SMP_PROCESSORS);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: instrument.h,v 1.29 2008-09-06 17:49:31 sshwarts Exp $ // $Id: instrument.h,v 1.30 2008-10-01 11:36:04 akrisak Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -56,6 +56,9 @@
class bxInstruction_c; class bxInstruction_c;
void bx_instr_init_env(void);
void bx_instr_exit_env(void);
// called from the CPU core // called from the CPU core
void bx_instr_init(unsigned cpu); void bx_instr_init(unsigned cpu);
@ -75,6 +78,10 @@ void bx_instr_hwinterrupt(unsigned cpu, unsigned vector, Bit16u cs, bx_address e
void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, unsigned len, unsigned rw); void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, unsigned len, unsigned rw);
/* initialization/deinitialization of instrumentalization*/
# define BX_INSTR_INIT_ENV() bx_instr_init_env()
# define BX_INSTR_EXIT_ENV() bx_instr_exit_env()
/* simulation init, shutdown, reset */ /* simulation init, shutdown, reset */
# define BX_INSTR_INIT(cpu_id) bx_instr_init(cpu_id) # define BX_INSTR_INIT(cpu_id) bx_instr_init(cpu_id)
# define BX_INSTR_EXIT(cpu_id) # define BX_INSTR_EXIT(cpu_id)
@ -137,6 +144,10 @@ void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, uns
#else #else
/* initialization/deinitialization of instrumentalization*/
# define BX_INSTR_INIT_ENV()
# define BX_INSTR_EXIT_ENV()
/* simulation init, shutdown, reset */ /* simulation init, shutdown, reset */
# define BX_INSTR_INIT(cpu_id) # define BX_INSTR_INIT(cpu_id)
# define BX_INSTR_EXIT(cpu_id) # define BX_INSTR_EXIT(cpu_id)

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: instrument.cc,v 1.19 2008-06-23 02:56:31 sshwarts Exp $ // $Id: instrument.cc,v 1.20 2008-10-01 11:36:04 akrisak Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -33,6 +33,10 @@ bxInstrumentation *icpu = NULL;
static disassembler bx_disassembler; static disassembler bx_disassembler;
void bx_instr_init_env(void) {}
void bx_instr_exit_env(void) {}
void bx_instr_init(unsigned cpu) void bx_instr_init(unsigned cpu)
{ {
assert(cpu < BX_SMP_PROCESSORS); assert(cpu < BX_SMP_PROCESSORS);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: instrument.h,v 1.27 2008-09-06 17:49:31 sshwarts Exp $ // $Id: instrument.h,v 1.28 2008-10-01 11:36:04 akrisak Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -123,6 +123,10 @@ void bx_instr_init(unsigned cpu);
extern bxInstrumentation *icpu; extern bxInstrumentation *icpu;
/* initialization/deinitialization of instrumentalization*/
# define BX_INSTR_INIT_ENV() bx_instr_init_env()
# define BX_INSTR_EXIT_ENV() bx_instr_exit_env()
/* simulation init, shutdown, reset */ /* simulation init, shutdown, reset */
# define BX_INSTR_INIT(cpu_id) bx_instr_init(cpu_id); # define BX_INSTR_INIT(cpu_id) bx_instr_init(cpu_id);
# define BX_INSTR_EXIT(cpu_id) # define BX_INSTR_EXIT(cpu_id)
@ -185,6 +189,10 @@ extern bxInstrumentation *icpu;
#else #else
/* initialization/deinitialization of instrumentalization*/
# define BX_INSTR_INIT_ENV()
# define BX_INSTR_EXIT_ENV()
/* simulation init, shutdown, reset */ /* simulation init, shutdown, reset */
# define BX_INSTR_INIT(cpu_id) # define BX_INSTR_INIT(cpu_id)
# define BX_INSTR_EXIT(cpu_id) # define BX_INSTR_EXIT(cpu_id)

View File

@ -1,241 +1,253 @@
README-instrumentation README-instrumentation
To use instrumentation features in bochs, you must compile in support for it. To use instrumentation features in bochs, you must compile in support for it.
You should build a custom instrumentation library in a separate directory in You should build a custom instrumentation library in a separate directory in
the "instrument/" directory. To tell configure which instrumentation library the "instrument/" directory. To tell configure which instrumentation library
you want to use, use the "--enable-instrumentation" option. The default you want to use, use the "--enable-instrumentation" option. The default
library consists of a set of stubs, and the following are equivalent: library consists of a set of stubs, and the following are equivalent:
./configure [...] --enable-instrumentation ./configure [...] --enable-instrumentation
./configure [...] --enable-instrumentation="instrument/stubs" ./configure [...] --enable-instrumentation="instrument/stubs"
You could make a separate directory with your custom library, for example You could make a separate directory with your custom library, for example
"instrument/myinstrument", copy the contents of the "instrument/stubs" "instrument/myinstrument", copy the contents of the "instrument/stubs"
directory to it, then customize it. Use: directory to it, then customize it. Use:
./configure [...] --enable-instrumentation="instrument/myinstrument" ./configure [...] --enable-instrumentation="instrument/myinstrument"
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
BOCHS instrumentation callbacks BOCHS instrumentation callbacks
void bx_instr_init(unsigned cpu); void bx_instr_init_env();
The callback is called when Bochs is initialized, before of reading .bochsrc.
The callback is called each time, when Bochs initializes the CPU object. It It can be used for registration of parameters in siminterface. Then
can be used for initialization of user's data, dynamic memory allocation and when bx_instr_init() is called it can access configuration parameters defined
etc.
by bx_instr_init_env(), so instrumentalization module can use additional
void bx_instr_exit(unsigned cpu); options in .bochsrc.
The callback is called each time, when Bochs destructs the CPU object. It can
be used for destruction of user's data, allocated by bx_instr_init callback.
void bx_instr_exit_env();
The callback is called each time, when Bochs is exits.
void bx_instr_reset(unsigned cpu); void bx_instr_init(unsigned cpu);
The callback is called each time, when Bochs resets the CPU object. It would The callback is called each time, when Bochs initializes the CPU object. It
be executed once at the start of simulation and each time that user presses can be used for initialization of user's data, dynamic memory allocation and
RESET BUTTON on the simulator's control panel. etc.
void bx_instr_exit(unsigned cpu);
void bx_instr_hlt(unsigned cpu);
The callback is called each time, when Bochs destructs the CPU object. It can
The callback is called each time, when Bochs' emulated CPU enters HALT or be used for destruction of user's data, allocated by bx_instr_init callback.
SHUTDOWN state.
void bx_instr_reset(unsigned cpu);
void bx_instr_mwait(unsigned cpu, bx_phy_address addr, unsigned len, Bit32u flags);
The callback is called each time, when Bochs resets the CPU object. It would
The callback is called each time, when Bochs' emulated CPU enters to the MWAIT be executed once at the start of simulation and each time that user presses
state. The callback receives monitored memory range and MWAIT flags as a RESET BUTTON on the simulator's control panel.
parameters.
void bx_instr_hlt(unsigned cpu);
void bx_instr_new_instruction(unsigned cpu);
The callback is called each time, when Bochs' emulated CPU enters HALT or
The callback is called each time, when Bochs completes (commits) already SHUTDOWN state.
finished instruction and starts a new one.
void bx_instr_mwait(unsigned cpu, bx_phy_address addr, unsigned len, Bit32u flags);
void bx_instr_cnear_branch_taken(unsigned cpu, bx_address new_eip);
The callback is called each time, when Bochs' emulated CPU enters to the MWAIT
The callback is called each time, when currently executed instruction is a state. The callback receives monitored memory range and MWAIT flags as a
conditional near branch and it is taken. parameters.
void bx_instr_cnear_branch_not_taken(unsigned cpu); void bx_instr_new_instruction(unsigned cpu);
The callback is called each time, when currently executed instruction is a The callback is called each time, when Bochs completes (commits) already
conditional near branch and it is not taken. finished instruction and starts a new one.
void bx_instr_ucnear_branch(unsigned cpu, unsigned what, bx_address new_eip); void bx_instr_cnear_branch_taken(unsigned cpu, bx_address new_eip);
The callback is called each time, when currently executed instruction is an The callback is called each time, when currently executed instruction is a
unconditional near branch (always taken). conditional near branch and it is taken.
void bx_instr_far_branch(unsigned cpu, unsigned what, Bit16u new_cs, bx_address new_eip); void bx_instr_cnear_branch_not_taken(unsigned cpu);
The callback is called each time, when currently executed instruction is an The callback is called each time, when currently executed instruction is a
unconditional far branch (always taken). conditional near branch and it is not taken.
void bx_instr_opcode(unsigned cpu, const Bit8u *opcode, unsigned len, bx_bool is32, bx_bool is64); void bx_instr_ucnear_branch(unsigned cpu, unsigned what, bx_address new_eip);
The callback is called each time, when Bochs starts to decode a new The callback is called each time, when currently executed instruction is an
instruction. Through this callback function Bochs could provide an opcode of unconditional near branch (always taken).
the instruction, opcode length and an execution mode (16/32/64).
Currently the callback is not supported when trace-cache optimization feature void bx_instr_far_branch(unsigned cpu, unsigned what, Bit16u new_cs, bx_address new_eip);
is enabled.
The callback is called each time, when currently executed instruction is an
unconditional far branch (always taken).
void bx_instr_interrupt(unsigned cpu, unsigned vector);
The callback is called each time, when Bochs simulator executes an interrupt void bx_instr_opcode(unsigned cpu, const Bit8u *opcode, unsigned len, bx_bool is32, bx_bool is64);
(software interrupt, hardware interrupt or an exception).
The callback is called each time, when Bochs starts to decode a new
instruction. Through this callback function Bochs could provide an opcode of
void bx_instr_exception(unsigned cpu, unsigned vector); the instruction, opcode length and an execution mode (16/32/64).
The callback is called each time, when Bochs simulator executes an exception. Currently the callback is not supported when trace-cache optimization feature
is enabled.
void bx_instr_hwinterrupt(unsigned cpu, unsigned vector, Bit16u cs, bx_address eip);
void bx_instr_interrupt(unsigned cpu, unsigned vector);
The callback is called each time, when Bochs simulator executes a hardware
interrupt. The callback is called each time, when Bochs simulator executes an interrupt
(software interrupt, hardware interrupt or an exception).
void bx_instr_clflush(unsigned cpu, bx_address laddr, bx_phy_address paddr);
void bx_instr_exception(unsigned cpu, unsigned vector);
The callback is called each time the CLFLUSH instruction is executed.
The callback is called each time, when Bochs simulator executes an exception.
void bx_instr_tlb_cntrl(unsigned cpu, unsigned what, bx_phy_address new_cr3);
void bx_instr_cache_cntrl(unsigned cpu, unsigned what); void bx_instr_hwinterrupt(unsigned cpu, unsigned vector, Bit16u cs, bx_address eip);
The callback is called each time, when Bochs simulator executes a cache/tlb The callback is called each time, when Bochs simulator executes a hardware
control instruction. interrupt.
Possible instruction types, passed through bx_instr_tlb_cntrl:
void bx_instr_clflush(unsigned cpu, bx_address laddr, bx_phy_address paddr);
#define BX_INSTR_MOV_CR3 10
#define BX_INSTR_INVLPG 11 The callback is called each time the CLFLUSH instruction is executed.
#define BX_INSTR_TASKSWITCH 12
Possible instruction types, passed through bx_instr_cache_cntrl: void bx_instr_tlb_cntrl(unsigned cpu, unsigned what, bx_phy_address new_cr3);
void bx_instr_cache_cntrl(unsigned cpu, unsigned what);
#define BX_INSTR_INVD 20
#define BX_INSTR_WBINVD 21 The callback is called each time, when Bochs simulator executes a cache/tlb
control instruction.
void bx_instr_prefetch_hint(unsigned cpu, unsigned what, unsigned seg, bx_address offset); Possible instruction types, passed through bx_instr_tlb_cntrl:
The callback is called each time, when Bochs simulator executes a PREFETCH #define BX_INSTR_MOV_CR3 10
instruction. #define BX_INSTR_INVLPG 11
#define BX_INSTR_TASKSWITCH 12
Possible PREFETCH types:
Possible instruction types, passed through bx_instr_cache_cntrl:
#define BX_INSTR_PREFETCH_NTA 00
#define BX_INSTR_PREFETCH_T0 01 #define BX_INSTR_INVD 20
#define BX_INSTR_PREFETCH_T1 02 #define BX_INSTR_WBINVD 21
#define BX_INSTR_PREFETCH_T2 03
The seg/offset arguments indicate the address of the requested prefetch. void bx_instr_prefetch_hint(unsigned cpu, unsigned what, unsigned seg, bx_address offset);
The callback is called each time, when Bochs simulator executes a PREFETCH
void bx_instr_wrmsr(unsigned cpu, unsigned msr, Bit64u value); instruction.
This callback is called each time when WRMSR instruction is executed. Possible PREFETCH types:
MSR number and written value passed as parameters to the callback function.
#define BX_INSTR_PREFETCH_NTA 00
#define BX_INSTR_PREFETCH_T0 01
void bx_instr_repeat_iteration(unsigned cpu, bxInstruction_c *i); #define BX_INSTR_PREFETCH_T1 02
#define BX_INSTR_PREFETCH_T2 03
The callback is called each time, when Bochs simulator starts a new repeat
iteration. The seg/offset arguments indicate the address of the requested prefetch.
void bx_instr_before_execution(unsigned cpu, bxInstruction_c *i); void bx_instr_wrmsr(unsigned cpu, unsigned msr, Bit64u value);
The callback is called each time, when Bochs simulator starts a new This callback is called each time when WRMSR instruction is executed.
instruction execution. In case of repeat instruction the callback will MSR number and written value passed as parameters to the callback function.
be called only once before the first iteration will be started.
void bx_instr_repeat_iteration(unsigned cpu, bxInstruction_c *i);
void bx_instr_after_execution(unsigned cpu, bxInstruction_c *i);
The callback is called each time, when Bochs simulator starts a new repeat
The callback is called each time, when Bochs simulator finishes any iteration.
instruction execution. In case of repeat instruction the callback will
be called only once after all repeat iterations.
void bx_instr_before_execution(unsigned cpu, bxInstruction_c *i);
void bx_instr_lin_access(unsigned cpu, bx_address lin, bx_address phy, unsigned len, unsigned rw); The callback is called each time, when Bochs simulator starts a new
instruction execution. In case of repeat instruction the callback will
The callback is called each time, when Bochs simulator executes a linear be called only once before the first iteration will be started.
memory access. Note that no page split accesses will be generated because
Bochs splits page split accesses to two different memory accesses during its
execution flow. The callback also will not be generated in case of direct void bx_instr_after_execution(unsigned cpu, bxInstruction_c *i);
physical memory access like in SMM, VMM or SVM modes.
The callback is called each time, when Bochs simulator finishes any
Possible access types are: BX_READ, BX_WRITE and BX_RW. instruction execution. In case of repeat instruction the callback will
be called only once after all repeat iterations.
Currently the callback is not supported when repeat-speedups optimization is
enabled.
void bx_instr_lin_access(unsigned cpu, bx_address lin, bx_address phy, unsigned len, unsigned rw);
void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, unsigned len, unsigned rw); The callback is called each time, when Bochs simulator executes a linear
memory access. Note that no page split accesses will be generated because
The callback is called each time, when Bochs simulator executes segment based Bochs splits page split accesses to two different memory accesses during its
linear memory access. In contrast to previous callback it will be called even execution flow. The callback also will not be generated in case of direct
if memory access fails because of any reason (for example segment protection physical memory access like in SMM, VMM or SVM modes.
failure or page fault).
Possible access types are: BX_READ, BX_WRITE and BX_RW.
The callback will not be called for system memory accesses like sys desriptor
tables reads/writes or new stack pushes during far call or exception. Currently the callback is not supported when repeat-speedups optimization is
enabled.
void bx_instr_phy_read(unsigned cpu, bx_address addr, unsigned len);
void bx_instr_phy_write(unsigned cpu, bx_address addr, unsigned len); void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, unsigned len, unsigned rw);
These callback functions are the feedback from external memory system. The callback is called each time, when Bochs simulator executes segment based
linear memory access. In contrast to previous callback it will be called even
if memory access fails because of any reason (for example segment protection
void bx_instr_inp(Bit16u addr, unsigned len); failure or page fault).
void bx_instr_outp(Bit16u addr, unsigned len);
void bx_instr_inp2(Bit16u addr, unsigned len, unsigned val); The callback will not be called for system memory accesses like sys desriptor
void bx_instr_outp2(Bit16u addr, unsigned len, unsigned val); tables reads/writes or new stack pushes during far call or exception.
These callback functions are a feedback from various system devices.
void bx_instr_phy_read(unsigned cpu, bx_address addr, unsigned len);
----------------------------------------------------------------------------- void bx_instr_phy_write(unsigned cpu, bx_address addr, unsigned len);
Known problems:
These callback functions are the feedback from external memory system.
1. BX_INSTR_LIN_ACCESS doesn't work when repeat-speedups feature is enabled.
2. BX_INSTR_MEM_DATA doesn't work when repeat-speedups feature is enabled. void bx_instr_inp(Bit16u addr, unsigned len);
void bx_instr_outp(Bit16u addr, unsigned len);
3. BX_INSTR_OPCODE doesn't work with trace cache optimization enabled void bx_instr_inp2(Bit16u addr, unsigned len, unsigned val);
void bx_instr_outp2(Bit16u addr, unsigned len, unsigned val);
Feature requests:
These callback functions are a feedback from various system devices.
1. BX_INSTR_CNEAR_BRANCH_NOT_TAKEN callback should have an additional
'not taken' new_EIP parameter. -----------------------------------------------------------------------------
Known problems:
2. BX_INSTR_SMI, BX_INSTR_NMI, BX_INSTR_SIPI and other external events
callbacks 1. BX_INSTR_LIN_ACCESS doesn't work when repeat-speedups feature is enabled.
3. 2. BX_INSTR_MEM_DATA doesn't work when repeat-speedups feature is enabled.
While using Bochs as a reference model for simulations, the simulator needs 3. BX_INSTR_OPCODE doesn't work with trace cache optimization enabled
information about what loads/stores are taking place with each instruction.
Presumably, that is what the BX_INSTR_MEM_DATA() instrumentation macros Feature requests:
cover (which is the place where our simulator hooks up).
1. BX_INSTR_CNEAR_BRANCH_NOT_TAKEN callback should have an additional
The RETnear_xxx() functions call access_linear() directly, rather than call 'not taken' new_EIP parameter.
read_virtual_xxx() functions. This is a problem for code making use of the
BX_INSTR_MEM_DATA() hook because it does not get called for these 2. BX_INSTR_SMI, BX_INSTR_NMI, BX_INSTR_SIPI and other external events
instructions. Should this be changed along with some other instructions callbacks
that exhibit this?
Brian Slechta 3.
While using Bochs as a reference model for simulations, the simulator needs
information about what loads/stores are taking place with each instruction.
Presumably, that is what the BX_INSTR_MEM_DATA() instrumentation macros
cover (which is the place where our simulator hooks up).
The RETnear_xxx() functions call access_linear() directly, rather than call
read_virtual_xxx() functions. This is a problem for code making use of the
BX_INSTR_MEM_DATA() hook because it does not get called for these
instructions. Should this be changed along with some other instructions
that exhibit this?
Brian Slechta

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: instrument.cc,v 1.27 2008-09-06 17:49:32 sshwarts Exp $ // $Id: instrument.cc,v 1.28 2008-10-01 11:36:04 akrisak Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -29,6 +29,9 @@
#if BX_INSTRUMENTATION #if BX_INSTRUMENTATION
void bx_instr_init_env(void) {}
void bx_instr_exit_env(void) {}
void bx_instr_init(unsigned cpu) {} void bx_instr_init(unsigned cpu) {}
void bx_instr_exit(unsigned cpu) {} void bx_instr_exit(unsigned cpu) {}
void bx_instr_reset(unsigned cpu) {} void bx_instr_reset(unsigned cpu) {}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: instrument.h,v 1.35 2008-09-06 17:49:32 sshwarts Exp $ // $Id: instrument.h,v 1.36 2008-10-01 11:36:04 akrisak Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -56,6 +56,9 @@
class bxInstruction_c; class bxInstruction_c;
void bx_instr_init_env(void);
void bx_instr_exit_env(void);
// called from the CPU core // called from the CPU core
void bx_instr_init(unsigned cpu); void bx_instr_init(unsigned cpu);
@ -102,6 +105,10 @@ void bx_instr_phy_read(unsigned cpu, bx_address addr, unsigned len);
void bx_instr_wrmsr(unsigned cpu, unsigned addr, Bit64u value); void bx_instr_wrmsr(unsigned cpu, unsigned addr, Bit64u value);
/* initialization/deinitialization of instrumentalization*/
# define BX_INSTR_INIT_ENV() bx_instr_init_env()
# define BX_INSTR_EXIT_ENV() bx_instr_exit_env()
/* simulation init, shutdown, reset */ /* simulation init, shutdown, reset */
# define BX_INSTR_INIT(cpu_id) bx_instr_init(cpu_id) # define BX_INSTR_INIT(cpu_id) bx_instr_init(cpu_id)
# define BX_INSTR_EXIT(cpu_id) bx_instr_exit(cpu_id) # define BX_INSTR_EXIT(cpu_id) bx_instr_exit(cpu_id)
@ -167,6 +174,10 @@ void bx_instr_wrmsr(unsigned cpu, unsigned addr, Bit64u value);
#else #else
/* initialization/deinitialization of instrumentalization*/
# define BX_INSTR_INIT_ENV()
# define BX_INSTR_EXIT_ENV()
/* simulation init, shutdown, reset */ /* simulation init, shutdown, reset */
# define BX_INSTR_INIT(cpu_id) # define BX_INSTR_INIT(cpu_id)
# define BX_INSTR_EXIT(cpu_id) # define BX_INSTR_EXIT(cpu_id)

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: main.cc,v 1.382 2008-05-30 20:35:05 sshwarts Exp $ // $Id: main.cc,v 1.383 2008-10-01 11:36:04 akrisak Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -263,8 +263,11 @@ int bxmain (void) {
static jmp_buf context; static jmp_buf context;
if (setjmp (context) == 0) { if (setjmp (context) == 0) {
SIM->set_quit_context (&context); SIM->set_quit_context (&context);
BX_INSTR_INIT_ENV();
if (bx_init_main(bx_startup_flags.argc, bx_startup_flags.argv) < 0) if (bx_init_main(bx_startup_flags.argc, bx_startup_flags.argv) < 0)
{ BX_INSTR_EXIT_ENV();
return 0; return 0;
}
// read a param to decide which config interface to start. // read a param to decide which config interface to start.
// If one exists, start it. If not, just begin. // If one exists, start it. If not, just begin.
bx_param_enum_c *ci_param = SIM->get_param_enum(BXPN_SEL_CONFIG_INTERFACE); bx_param_enum_c *ci_param = SIM->get_param_enum(BXPN_SEL_CONFIG_INTERFACE);
@ -303,6 +306,7 @@ int bxmain (void) {
fgets(buf, sizeof(buf), stdin); fgets(buf, sizeof(buf), stdin);
} }
#endif #endif
BX_INSTR_EXIT_ENV();
return SIM->get_exit_code(); return SIM->get_exit_code();
} }