Adds a new emulation instrumentation interface with simpler convenience routines for identifying the original application instruction fetch and operands.
Uses the new interface in memtrace_simple. Separate commits will update memval_simple, memtrace_x86, and drmemtrace.
Adds an x86 test that runs the memtrace_simple sample on the allasm_repstr app and ensures we see 2-byte "rep movs" instructions instead of the 1-byte "movs" that the existing sample client records due to not being emulation-aware. Adds a -log_to_stderr flag to the sample to make the test simpler and not have to deal with log files.
Adding new events is separated into #4947 which we may attempt in the future. Removing rep string non-fetched instructions is #4948.
Testing:
memtrace_simple before:
$ bin64/drrun -c api/bin/libmemtrace_simple.so -- suite/tests/bin/allasm_repstr && cat ls -1td api/bin/*.log|head -1
Format: : , <(r)ead/(w)rite/opcode>
0x401018: 1, movs
0x40200e: 1, r
0x402000: 1, w
0x401018: 1, movs
0x40200f: 1, r
0x402001: 1, w
0x401018: 1, movs
0x402010: 1, r
0x402002: 1, w
0x401018: 1, movs
0x402011: 1, r
0x402003: 1, w
0x401018: 1, movs
0x402012: 1, r
0x402004: 1, w
After:
Format: : , <(r)ead/(w)rite/opcode>
0x401018: 2, rep movs
0x40200e: 1, r
0x402000: 1, w
0x401018: 2, rep movs
0x40200f: 1, r
0x402001: 1, w
0x401018: 2, rep movs
0x402010: 1, r
0x402002: 1, w
0x401018: 2, rep movs
0x402011: 1, r
0x402003: 1, w
0x401018: 2, rep movs
0x402012: 1, r
0x402004: 1, w
memtrace_simple on a gather expansion: $ ninja && bin64/drrun -c api/bin/libmemtrace_simple.so -log_to_stderr -- suite/tests/bin/allasm_scattergather Format: : , <(r)ead/(w)rite/opcode> 0x40105c: 11, mov 0x402022: 4, w 0x401067: 11, mov 0x402026: 4, w 0x401072: 11, mov 0x40202a: 4, w 0x40108a: 7, mov 0x402026: 4, r 0x40108a: 7, mov 0x40202e: 4, r 0x40108a: 7, mov 0x40202a: 4, r => Format: : , <(r)ead/(w)rite/opcode> 0x40105c: 11, mov 0x402022: 4, w 0x401067: 11, mov 0x402026: 4, w 0x401072: 11, mov 0x40202a: 4, w 0x40108a: 10, vpgatherdd 0x402026: 4, r 0x40202e: 4, r 0x40202a: 4, r
Issue: #4865 (closed)