-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move RR_MAGIC_SAVE_DATA_FD support to MagicSaveDataMonitor
- Loading branch information
1 parent
5db2329
commit 5a6f587
Showing
10 changed files
with
113 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* -*- Mode: C++; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ | ||
|
||
#include "MagicSaveDataMonitor.h" | ||
|
||
#include <rr/rr.h> | ||
|
||
#include "log.h" | ||
#include "Session.h" | ||
#include "task.h" | ||
#include "util.h" | ||
|
||
static void dump_path_data(Task* t, TraceFrame::Time global_time, | ||
const char* tag, char* filename, | ||
size_t filename_size, const void* buf, | ||
size_t buf_len, remote_ptr<void> addr) { | ||
format_dump_filename(t, global_time, tag, filename, filename_size); | ||
dump_binary_data(filename, tag, (const uint32_t*)buf, buf_len / 4, addr); | ||
} | ||
|
||
static void notify_save_data_error(Task* t, remote_ptr<void> addr, | ||
const void* rec_buf, size_t rec_buf_len, | ||
const void* rep_buf, size_t rep_buf_len) { | ||
char rec_dump[PATH_MAX]; | ||
char rep_dump[PATH_MAX]; | ||
TraceFrame::Time global_time = t->current_trace_frame().time(); | ||
|
||
dump_path_data(t, global_time, "rec_save_data", rec_dump, sizeof(rec_dump), | ||
rec_buf, rec_buf_len, addr); | ||
dump_path_data(t, global_time, "rep_save_data", rep_dump, sizeof(rep_dump), | ||
rep_buf, rep_buf_len, addr); | ||
|
||
ASSERT(t, | ||
(rec_buf_len == rep_buf_len && !memcmp(rec_buf, rep_buf, rec_buf_len))) | ||
<< "Divergence in contents of 'tracee-save buffer'. Recording executed\n" | ||
"\n" | ||
" write(" << RR_MAGIC_SAVE_DATA_FD << ", " << addr << ", " | ||
<< rec_buf_len << ")\n" | ||
"\n" | ||
"and replay executed\n" | ||
"\n" | ||
" write(" << RR_MAGIC_SAVE_DATA_FD << ", " << addr | ||
<< ", " << rep_buf_len | ||
<< ")\n" | ||
"\n" | ||
"The contents of the tracee-save buffers have been dumped to disk.\n" | ||
"Compare them by using the following command\n" | ||
"\n" | ||
"$ diff -u " << rec_dump << " " << rep_dump | ||
<< " >save-data-diverge.diff\n"; | ||
} | ||
|
||
void MagicSaveDataMonitor::did_write(Task* t, | ||
const std::vector<Range>& ranges) { | ||
for (auto& r : ranges) { | ||
if (t->session().is_recording()) { | ||
t->record_remote(r.data.cast<uint8_t>(), r.length); | ||
} else if (t->session().is_replaying()) { | ||
auto bytes = t->read_mem(r.data.cast<uint8_t>(), r.length); | ||
auto rec = t->trace_reader().read_raw_data(); | ||
if (rec.data != bytes) { | ||
notify_save_data_error(t, rec.addr, rec.data.data(), rec.data.size(), | ||
bytes.data(), bytes.size()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* -*- Mode: C++; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ | ||
|
||
#ifndef RR_MAGIC_SAVE_DATA_MONITOR_H_ | ||
#define RR_MAGIC_SAVE_DATA_MONITOR_H_ | ||
|
||
#include "FileMonitor.h" | ||
|
||
/** | ||
* A FileMonitor to track writes to RR_MAGIC_SAVE_DATA_FD. | ||
* Currently does nothing other than prevent syscallbuf from buffering output | ||
* to those fds. | ||
*/ | ||
class MagicSaveDataMonitor : public FileMonitor { | ||
public: | ||
MagicSaveDataMonitor() {} | ||
|
||
/** | ||
* During recording, record the written data. | ||
* During replay, check that the written data matches what was recorded. | ||
*/ | ||
virtual void did_write(Task* t, const std::vector<Range>& ranges); | ||
}; | ||
|
||
#endif /* RR_MAGIC_SAVE_DATA_MONITOR_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters