diff --git a/src/experiments/l4-sys/CMakeLists.txt b/src/experiments/l4-sys/CMakeLists.txt index dca62f2a..e7dba56e 100644 --- a/src/experiments/l4-sys/CMakeLists.txt +++ b/src/experiments/l4-sys/CMakeLists.txt @@ -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 diff --git a/src/experiments/l4-sys/experiment.cc b/src/experiments/l4-sys/experiment.cc index 354d7ef0..7732c225 100644 --- a/src/experiments/l4-sys/experiment.cc +++ b/src/experiments/l4-sys/experiment.cc @@ -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 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(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(&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; diff --git a/src/experiments/l4-sys/experimentInfo.hpp b/src/experiments/l4-sys/experimentInfo.hpp index 829250a5..55e63579 100644 --- a/src/experiments/l4-sys/experimentInfo.hpp +++ b/src/experiments/l4-sys/experimentInfo.hpp @@ -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__