Adjust instruction tracing

write a trace file that can be input to the *-trace FAIL tools

Change-Id: Iaa13fab5bcba86f3d940831d9ea583a458998191
This commit is contained in:
Björn Döbel
2013-08-28 10:16:13 +02:00
parent 6ddc7d911b
commit 2a06b97480
3 changed files with 20 additions and 4 deletions

View File

@ -37,7 +37,7 @@ add_library(fail-${EXPERIMENT_NAME} ${PROTO_SRCS} ${PROTO_HDRS} ${MY_CAMPAIGN_SR
find_package(LibUdis86 REQUIRED)
include_directories(${LIBUDIS86_INCLUDE_DIRS})
link_directories(${LIBUDIS86_LINK_DIRS})
add_dependencies(fail-${EXPERIMENT_NAME} fail-comm)
add_dependencies(fail-${EXPERIMENT_NAME} fail-comm fail-tracing)
target_link_libraries(fail-${EXPERIMENT_NAME} ${LIBUDIS86_LIBRARIES} ${PROTOBUF_LIBRARY})
## This is the example's campaign server distributing experiment parameters

View File

@ -19,6 +19,8 @@
#include "sal/Memory.hpp"
#include "sal/Listener.hpp"
#include "config/FailConfig.hpp"
#include "util/ProtoStream.hpp"
#include "TracePlugin.pb.h"
#include "l4sys.pb.h"
@ -235,6 +237,9 @@ void L4SysExperiment::collectInstructionTrace(fail::BPSingleListener& bp)
map<address_t, unsigned> times_called_map;
bool injecting = false;
std::ofstream out("trace.pb");
ProtoOStream *os = new ProtoOStream(&out);
while (bp.getTriggerInstructionPointer() != L4SYS_FUNC_EXIT) {
simulator.addListenerAndResume(&bp);
count++;
@ -260,13 +265,24 @@ void L4SysExperiment::collectInstructionTrace(fail::BPSingleListener& bp)
reinterpret_cast<char const*>(calculateInstructionAddress()))
) {
accepted++;
// 1) The 'old' way of logging instructions -> DEPRECATE soon
TraceInstr new_instr;
log << "writing IP " << hex << curr_addr << " counter "
<< dec << times_called << endl;
<< dec << times_called << "(" << hex << BX_CPU(0)->cr3 << ")"
<< endl;
new_instr.trigger_addr = curr_addr;
new_instr.bp_counter = times_called;
instr_list_file.write(reinterpret_cast<char*>(&new_instr), sizeof(TraceInstr));
// 2) The 'new' way -> generate Events that can be processed by
// the generic *-trace tools
// XXX: need to log CR3 if we want multiple binaries here
Trace_Event e;
e.set_ip(curr_addr);
os->writeMessage(&e);
}
}
log << "saving instructions triggered during normal execution" << endl;

View File

@ -24,7 +24,7 @@
#define L4SYS_FILTER_INSTRUCTIONS 1
// kernel: 2377547, userland: 79405472
#define L4SYS_NUMINSTR 15099
#define L4SYS_NUMINSTR 2223
#define L4SYS_TOTINSTR 60214
#define L4SYS_BOCHS_IPS 5000000
@ -38,6 +38,6 @@
// flags
// 0 - preparation complete
// >0 - next step to execute
#define PREPARATION_STEP 2
#define PREPARATION_STEP 0
#endif // __L4SYS_EXPERIMENT_INFO_HPP__