Preparing CiAO experiments
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1984 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -24,15 +24,16 @@ using namespace fail;
|
||||
|
||||
// Check if configuration dependencies are satisfied:
|
||||
#if !defined(CONFIG_EVENT_BREAKPOINTS) || !defined(CONFIG_SR_RESTORE) || \
|
||||
!defined(CONFIG_SR_SAVE) || !defined(CONFIG_EVENT_TRAP)
|
||||
!defined(CONFIG_SR_SAVE)
|
||||
#error This experiment needs: breakpoints, traps, save, and restore. Enable these in the configuration.
|
||||
#endif
|
||||
|
||||
bool VEZSExperiment::run()
|
||||
{
|
||||
Logger log("VEZS-Example", false);
|
||||
ElfReader elf("./system");
|
||||
log << elf.getAddressByName("main") << endl;
|
||||
ElfReader elf("./x86_bare_test");
|
||||
log << "STARTING EXPERIMENT" << endl;
|
||||
log << "main() address: " << elf.getAddressByName("main") << endl;
|
||||
|
||||
BPSingleListener bp;
|
||||
#if 0
|
||||
@ -41,34 +42,47 @@ bool VEZSExperiment::run()
|
||||
if(simulator.addListenerAndResume(&bp) == &bp){
|
||||
log << "test function entry reached, saving state" << endl;
|
||||
}
|
||||
log << "EIP = " << hex << bp.getTriggerInstructionPointer() << " or " << simulator.getRegisterManager().getInstructionPointer() << endl;
|
||||
log << "EIP = " << hex << bp.getTriggerInstructionPointer() << endl;
|
||||
//simulator.terminate();
|
||||
simulator.save("vezs.state");
|
||||
simulator.terminate();
|
||||
#endif
|
||||
#if 1
|
||||
|
||||
int bit_offset = 2;
|
||||
for (int instr_offset = 0; instr_offset < OOSTUBS_NUMINSTR; ++instr_offset) {
|
||||
//int bit_offset = 2;
|
||||
//for (int instr_offset = 0; instr_offset < OOSTUBS_NUMINSTR; ++instr_offset) {
|
||||
|
||||
// STEP 3: The actual experiment.
|
||||
log << "restoring state" << endl;
|
||||
simulator.restore("vezs.state");
|
||||
|
||||
log << "EIP = " << hex << simulator.getRegisterManager().getInstructionPointer() << endl;
|
||||
log << " current EIP = " << simulator.getCPU(0).getInstructionPointer() << endl;
|
||||
log << " Task0 start: " << elf.getAddressByName("_ZN5Alpha17functionTaskTask0Ev") << endl;
|
||||
BPSingleListener bpt0;
|
||||
BPSingleListener bpt1;
|
||||
bpt0.setWatchInstructionPointer(elf.getAddressByName("_ZN5Alpha17functionTaskTask0Ev"));
|
||||
bpt1.setWatchInstructionPointer(elf.getAddressByName("_ZN4Beta17functionTaskTask1Ev"));
|
||||
|
||||
bp.setWatchInstructionPointer(ANY_ADDR);
|
||||
for (int count = 0; count < instr_offset; ++count) {
|
||||
simulator.addListenerAndResume(&bp);
|
||||
simulator.addListener(&bpt1);
|
||||
simulator.addListenerAndResume(&bpt0);
|
||||
log << "EIP = " << simulator.getCPU(0).getInstructionPointer() <<" "<<elf.getNameByAddress(simulator.getCPU(0).getInstructionPointer()) << endl;
|
||||
simulator.resume();
|
||||
log << "EIP = " << simulator.getCPU(0).getInstructionPointer() <<" "<<elf.getNameByAddress(simulator.getCPU(0).getInstructionPointer()) << endl;
|
||||
|
||||
simulator.clearListeners();
|
||||
bpt1.setWatchInstructionPointer(elf.getAddressByName("_ZN2os3krn9SchedImpl18superDispatch_implEPS1_hh"));
|
||||
for(int i = 0; i < 10; i++){
|
||||
simulator.addListenerAndResume(&bpt1);
|
||||
log << "EIP = " << simulator.getCPU(0).getInstructionPointer() <<" "<<elf.getNameByAddress(simulator.getCPU(0).getInstructionPointer()) << endl;
|
||||
}
|
||||
|
||||
|
||||
int32_t data = simulator.getRegisterManager().getRegister(RID_CAX)->getData();
|
||||
#endif
|
||||
#if 0
|
||||
int32_t data = simulator.getCPU(0).getRegister(RID_CAX)->getData();
|
||||
// The INJECTION:
|
||||
int32_t newdata = data ^ (1<<bit_offset);
|
||||
simulator.getRegisterManager().getRegister(RID_CAX)->setData(newdata);
|
||||
simulator.getCPU(0).getRegister(RID_CAX)->setData(newdata);
|
||||
|
||||
int32_t injection_ip = simulator.getRegisterManager().getInstructionPointer();
|
||||
int32_t injection_ip = simulator.getCPU(0).getInstructionPointer();
|
||||
log << "inject @ ip " << injection_ip
|
||||
<< " (offset " << dec << instr_offset << ")"
|
||||
<< " bit " << bit_offset << ": 0x"
|
||||
@ -105,7 +119,7 @@ bool VEZSExperiment::run()
|
||||
BaseListener* ev = simulator.resume();
|
||||
|
||||
// record latest IP regardless of result
|
||||
injection_ip = simulator.getRegisterManager().getInstructionPointer();
|
||||
injection_ip = simulator.getCPU(0).getInstructionPointer();
|
||||
|
||||
|
||||
if (ev == &ev_end) {
|
||||
@ -126,6 +140,6 @@ bool VEZSExperiment::run()
|
||||
}
|
||||
|
||||
#endif
|
||||
// Explicitly terminate, or the simulator will continue to run.
|
||||
simulator.terminate();
|
||||
// Explicitly terminate, or the simulator will continue to run.
|
||||
simulator.terminate();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user