Replay logging almost done. Only thing missing is stdout.

This commit is contained in:
2022-03-11 19:01:02 -05:00
parent 3c2f93759b
commit cfd299006f
4 changed files with 83 additions and 57 deletions

View File

@@ -49,6 +49,11 @@ public:
//
bool create_engine(const char *kind);
// Report to the logger that the engine is about to exit cleanly,
// without any error.
//
void clean_exit();
// These don't need to be logged.
//
const eng::vector<int> &drv_get_listen_ports() const { return e_->drv_get_listen_ports(); }
@@ -75,25 +80,27 @@ public:
class ReplayPlayer {
public:
enum Error {
ERR_NONE,
ERR_OPEN_LOGFILE,
ERR_LOGFILE_EOF,
ERR_LOGFILE_CORRUPT,
ERR_NONDERMINISTIC,
ERR_CREATE_ENGINE,
enum Status {
ST_REPLAYING,
ST_CLEAN_EXIT,
ST_ERR_OPENING_LOGFILE,
ST_LOGFILE_ENDS_ABRUPTLY,
ST_LOGFILE_CORRUPT,
ST_NONDERMINISTIC,
ST_COULDNT_CREATE_ENGINE,
};
private:
std::ifstream f_;
UniqueDrivenEngine e_;
std::unique_ptr<char[]> buf_;
Error error_;
Status status_;
std::string logfn_;
std::string engine_;
void set_error(Error e);
void set_status(Status e);
void create_engine();
void clean_exit();
void drv_clear_new_outgoing();
void drv_sent_outgoing();
void drv_recv_incoming();
@@ -114,16 +121,16 @@ public:
// Execute a single step from the replay log.
//
// Returns an error code, which is usually ERR_NONE.
// If it's anything else, display an error and stop.
// Returns a status code, which is usually ST_REPLAYING.
// If it's anything else, display the status and stop.
//
Error step();
Status step();
// Print an error message.
// Print a status message.
//
// Print a message associated with the most recent error.
// Print a message associated with the most recent status report.
//
void print_error(std::ostream &s);
void print_status(std::ostream &s);
};
} // namespace drv