-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic non-determinism checking for SC/TSO/PSO.
Will detect and report if a branch condition evaluates differently during a replay of a computation.
- Loading branch information
1 parent
af151f9
commit ac12d1a
Showing
18 changed files
with
371 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
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,49 @@ | ||
/* Copyright (C) 2017 Carl Leonardsson | ||
* | ||
* This file is part of Nidhugg. | ||
* | ||
* Nidhugg is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Nidhugg is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "DetCheckTraceBuilder.h" | ||
|
||
DetCheckTraceBuilder::DetCheckTraceBuilder(const Configuration &conf) : TraceBuilder(conf){ | ||
reset_cond_branch_log(); | ||
} | ||
|
||
void DetCheckTraceBuilder::reset_cond_branch_log(){ | ||
cond_branch_log_index = 0; | ||
} | ||
|
||
bool DetCheckTraceBuilder::cond_branch(bool cnd){ | ||
if(is_replaying()){ | ||
assert(cond_branch_log_index < cond_branch_log.size()); | ||
bool logged = cond_branch_log[cond_branch_log_index]; | ||
++cond_branch_log_index; | ||
if(logged != cnd){ | ||
nondeterminism_error("Branch condition value changed in replay."); | ||
return false; | ||
} | ||
}else{ | ||
if(cond_branch_log_index < cond_branch_log.size()){ | ||
cond_branch_log[cond_branch_log_index] = cnd; | ||
}else{ | ||
assert(cond_branch_log_index == cond_branch_log.size()); | ||
cond_branch_log.push_back(cnd); | ||
} | ||
++cond_branch_log_index; | ||
} | ||
return true; | ||
} |
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,65 @@ | ||
/* Copyright (C) 2017 Carl Leonardsson | ||
* | ||
* This file is part of Nidhugg. | ||
* | ||
* Nidhugg is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Nidhugg is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <config.h> | ||
|
||
#ifndef __DET_CHECK_TRACE_BUILDER_H__ | ||
#define __DET_CHECK_TRACE_BUILDER_H__ | ||
|
||
#include "TraceBuilder.h" | ||
|
||
/* A DetCheckTraceBuilder is an abstract TraceBuilder which adds some | ||
* functionality for detecting and reporting thread-wise | ||
* nondeterminism in the target program during computation replays. | ||
*/ | ||
class DetCheckTraceBuilder : public TraceBuilder { | ||
public: | ||
DetCheckTraceBuilder(const Configuration &conf = Configuration::default_conf); | ||
virtual ~DetCheckTraceBuilder(){}; | ||
/* Execute a conditional branch instruction, branching on the value | ||
* cnd. | ||
* | ||
* If thread-wise non-determinism is detected, an error is | ||
* registered and false is returned. Otherwise true is returned. | ||
*/ | ||
virtual bool cond_branch(bool cnd); | ||
/* Returns true if the currently scheduled event is a replay of a | ||
* previous computation. | ||
*/ | ||
virtual bool is_replaying() const = 0; | ||
protected: | ||
/* Call before starting a new computation to restart the branch | ||
* logging. | ||
*/ | ||
virtual void reset_cond_branch_log(); | ||
|
||
/* cond_branch_log and cond_branch_log_index are used to log the | ||
* conditional branches of a computation. cond_branch_log contains | ||
* the branch condition values in order of execution. The first | ||
* cond_branch_log_index entries in cond_branch_log correspond to | ||
* branches that have been executed in the current | ||
* computation. Later entries are carried over from previous | ||
* (longer) computations. The carried-over entries are used to check | ||
* that the branching is deterministic during computation replay. | ||
*/ | ||
std::vector<bool> cond_branch_log; | ||
unsigned cond_branch_log_index; // See above | ||
}; | ||
|
||
#endif |
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
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
Oops, something went wrong.