DynamoRIO / dynamorio

Dynamic Instrumentation Tool Platform
Other
2.63k stars 557 forks source link

Add drmemtrace replay-as-traced support to record_scheduler_t #6712

Closed derekbruening closed 6 months ago

derekbruening commented 6 months ago

Trying to use record_filter running as-traced on a smallish app based on the threadsig sample fails:

Encoding size 9 != instr size 3 for PC 0x7ffa29f26ba9
[scheduler] next_record[6]: from 2 @1710797586236606: type=10 size=2 addr=0x7ffa2b0582fc
[scheduler] next_record[6]: from 2 @1710797586236631: type=47 size=6 addr=0x12c840f
[scheduler] next_record[6]: waiting because timestamp 13355270234506704 is ahead of output 0
[scheduler] next_record[6]: replay segment in=2 (@909) type=0 start=876 end=909
next_record[7]: from 2 @1710797586238158: next_record[3]: from 4 @1710797586238082: [scheduler] [record_filter] next_record[6]: advancing to input 3 instr #0
next_record[6]: replay segment in=3 (@0) type=0 start=0 end=-1
next_record[6]: from 3 @1710797586237492: type=25 size=0 addr=0x6
next_record[0]: from 1 @1710797586238563: next_record[6]: from 3 @1710797586238516: type=28 size=2 addr=0x2f728c2a350003
next_record[6]: from 3 @1710797586238712: type=28 size=9 addr=0xe40
[scheduler] next_record[6]: from 3 @1710797586238981: type=22 size=4 addr=0x41194
[scheduler] next_record[6]: from 3 @1710797586239016: type=24 size=4 addr=0x4115c
[scheduler] next_record[6]: from 3 @1710797586239212: type=28 size=10 addr=0x40
[scheduler] [scheduler] next_record[6]: from 3 @1710797586239336: type=28 size=20 addr=0x989680
[record_filter] [scheduler] next_record[6]: from 3 @1710797586239495: type=28 size=18 addr=0x1000
[scheduler] next_record[6]: from 3 @1710797586239827: [record_filter] type=28 size=2 addr=0x2f728c2a3505d0
[scheduler] next_record[3]: from 4 @1710797586239853: next_record[6]: from 3 @1710797586239920: type=28 size=3 addr=0x7
[scheduler] next_record[6]: from 3 @1710797586240088: type=47 size=3 addr=0xc08548
[scheduler] next_record[6]: from 3 @1710797586240206: type=10 size=3 addr=0x7ffa29f26ba9

It's the segment endpoint: have to stop before the encoding. This would also affect skips, incl for ROI. Better to change record_file_reader to ++ the instr count at the encoding instead of the instr?

derekbruening commented 6 months ago

This is a little more complicated: we have to account for TRACE_MARKER_TYPE_BRANCH_TARGET as well which appears between the encoding and the instruction records.