import-trace: dynamic instruction off-by-one

Richard noticed that instr2 values are off by one when done with the
MemoryImporter vs. with his own importer.  The core problem is that
the dynamic instruction counter in the Importer base class
(Importer::copy_to_database, instruction_count_t instr) gets increased
*after* reporting an IP event to the importer implementation; this has
the side-effect that memory access events have a +1 dynamic
instruction count offset with regard to the IP event of the
instruction they belong to.

Bottom line: IP events and all memory events belonging to that
instruction should have the same dynamic instruction number.
Christian argued for the numbers starting with 0, which, as a side
effect, relativizes the repercussions of the change introduced in the
previous commit, as the new "first" event gets the sequence number 0
now.

 -  All experiments and importers only dealing with memory accesses
    (MemoryImporter) are affected by this change:  The dynamic
    instruction count now starts with 0 instead of 1.  Together with
    the previous commit, the only change is one additional dynamic
    instruction at position 0.  Note that existing trace files do not
    have this additional instruction, which shifts all trace positions
    by 1.

 -  All importers that process *only* IP events (InstructionImporter,
    RandomJumpImporter, RegisterImporter) won't see any difference.
    Commit 036e340, though, introduced a +1 offset.

 -  Experiments that use these instruction counts for navigating to
    the target instruction must be checked to properly deal with the
    dynamic instruction #0 (no forwarding necessary).  All dynamic
    instruction offsetting should now work uniformly for both memory
    accesses and all other fault models.  To be sure everything works
    in order, sanity-check the current absolute instruction pointer
    right before fault injection.

Change-Id: I3f509f1b47836fa78fd029a7bb7c36c878912d97
This commit is contained in:
Horst Schirmeier
2013-09-18 15:35:38 +02:00
parent 3dc752cd09
commit 22b9646b80

View File

@ -66,6 +66,8 @@ bool Importer::copy_to_database(fail::ProtoIStream &ps) {
// instruction counter within trace
instruction_count_t instr = 0;
// instruction counter new memory access events belong to
instruction_count_t instr_memaccess = 0;
// the currently processed event
Trace_Event ev;
@ -92,6 +94,7 @@ bool Importer::copy_to_database(fail::ProtoIStream &ps) {
LOG << "error: instruction_count_t overflow, aborting at instr=" << instr << std::endl;
return false;
}
/* Another instruction was executed, handle it in the
subclass */
if (!handle_ip_event(curtime, instr, ev)) {
@ -99,10 +102,12 @@ bool Importer::copy_to_database(fail::ProtoIStream &ps) {
return false;
}
// all subsequent mem access events belong to this dynamic instr
instr_memaccess = instr;
instr++;
} else {
if (!handle_mem_event(curtime, instr, ev)) {
LOG << "error: handle_mem_event() failed at instr=" << instr << std::endl;
if (!handle_mem_event(curtime, instr_memaccess, ev)) {
LOG << "error: handle_mem_event() failed at instr=" << instr_memaccess << std::endl;
return false;
}
}