├── .gitignore
├── ASPLOS20-README.md
├── LICENSE
├── README.md
├── build.xml
├── lib
├── commons-cli-1.3.1.jar
├── commons-io-2.13.0.jar
├── jgrapht
│ ├── antlr4-runtime-4.7.1.jar
│ ├── commons-lang3-3.8.1.jar
│ ├── commons-text-1.5.jar
│ ├── fastutil-8.2.2.jar
│ ├── guava-26.0-jre.jar
│ ├── jgrapht-bundle-1.3.0.jar
│ ├── jgrapht-core-1.3.0.jar
│ ├── jgrapht-demo-1.3.0.jar
│ ├── jgrapht-ext-1.3.0.jar
│ ├── jgrapht-guava-1.3.0.jar
│ ├── jgrapht-io-1.3.0.jar
│ ├── jgrapht-opt-1.3.0.jar
│ ├── jgraphx-3.4.1.3.jar
│ └── jheaps-0.9.jar
├── lz4-1.3-SNAPSHOT.jar
├── parserv.jar
└── rvparse.jar
├── notes
├── Generate_RoadRunner_traces.md
└── PrintSubsetTool.java.txt
├── rapid.png
└── src
├── Aerodrome.java
├── AerodromeBasic.java
├── ExcludeMethods.java
├── FHB.java
├── Goldilocks.java
├── HB.java
├── HBEpoch.java
├── LockSet.java
├── META-INF
└── MANIFEST.MF
├── MetaInfo.java
├── OSR.java
├── PrintCSV.java
├── PrintSTD.java
├── PrintSTDFilter.java
├── SHB.java
├── SHBEpoch.java
├── SyncPreserving.java
├── Velodrome.java
├── WCP.java
├── cmd
├── CmdOptions.java
└── GetOptions.java
├── engine
├── Engine.java
├── accesstimes
│ ├── AccessTimesEngine.java
│ ├── RefinedAccessTimesEngine.java
│ └── orderedvars
│ │ ├── OrderedVarsEngine.java
│ │ ├── OrderedVarsEvent.java
│ │ └── OrderedVarsState.java
├── atomicity
│ ├── AtomicityEngine.java
│ ├── AtomicityEvent.java
│ ├── State.java
│ └── conflictserializability
│ │ ├── aerodrome
│ │ ├── AerodromeEngine.java
│ │ ├── AerodromeEvent.java
│ │ └── AerodromeState.java
│ │ ├── aerodrome_basic
│ │ ├── AerodromeEngine.java
│ │ ├── AerodromeEvent.java
│ │ └── AerodromeState.java
│ │ └── velodome
│ │ ├── VelodromeEngine.java
│ │ ├── VelodromeEvent.java
│ │ └── VelodromeState.java
├── metainfo
│ └── MetaInfoEngine.java
├── print
│ ├── PrintEngine.java
│ └── PrintFilterEngine.java
└── racedetectionengine
│ ├── OSR
│ ├── AccessEventInfo.java
│ ├── AcqEventInfo.java
│ ├── EventInfo.java
│ ├── OSREngine.java
│ ├── OSREvent.java
│ ├── OSRState.java
│ ├── POBuild
│ │ ├── NumArrayMin.java
│ │ ├── POBuildReverse.java
│ │ ├── PartialOrder.java
│ │ ├── RangeMinima.java
│ │ └── RangeMinimaQuery.java
│ └── RelEventInfo.java
│ ├── RaceDetectionEngine.java
│ ├── RaceDetectionEvent.java
│ ├── State.java
│ ├── fhb
│ ├── FHBEngine.java
│ ├── FHBEvent.java
│ └── FHBState.java
│ ├── goldilocks
│ ├── GoldilocksEngine.java
│ ├── GoldilocksEvent.java
│ ├── GoldilocksOfflineEngine.java
│ └── GoldilocksState.java
│ ├── hb
│ ├── HBEngine.java
│ ├── HBEvent.java
│ └── HBState.java
│ ├── hb_epoch
│ ├── HBEpochEngine.java
│ ├── HBEpochEvent.java
│ └── HBEpochState.java
│ ├── lockset
│ ├── LockSetEngine.java
│ ├── LockSetEvent.java
│ ├── LockSetOfflineEngine.java
│ └── LockSetState.java
│ ├── shb
│ ├── SHBEngine.java
│ ├── SHBEvent.java
│ ├── SHBOfflineEngine.java
│ ├── SHBState.java
│ └── distance
│ │ ├── SHBEngine.java
│ │ ├── SHBEvent.java
│ │ ├── SHBOfflineEngine.java
│ │ └── SHBState.java
│ ├── shb_epoch
│ ├── SHBEpochEngine.java
│ ├── SHBEpochEvent.java
│ └── SHBEpochState.java
│ ├── syncpreserving
│ ├── SyncPreservingRaceEngine.java
│ ├── SyncPreservingRaceEvent.java
│ ├── SyncPreservingRaceOfflineEngine.java
│ ├── SyncPreservingRaceState.java
│ └── distance
│ │ ├── SyncPreservingRaceEngine.java
│ │ ├── SyncPreservingRaceEvent.java
│ │ ├── SyncPreservingRaceOfflineEngine.java
│ │ └── SyncPreservingRaceState.java
│ └── wcp
│ ├── WCPEngine.java
│ ├── WCPEvent.java
│ ├── WCPState.java
│ ├── WCPView.java
│ └── distance
│ ├── WCPAnnotationEngine.java
│ ├── WCPEngine.java
│ ├── WCPEvent.java
│ ├── WCPState.java
│ └── WCPView.java
├── event
├── Decoration.java
├── Event.java
├── EventType.java
├── Lock.java
├── Thread.java
└── Variable.java
├── notes
├── Generate_RoadRunner_traces.md
└── PrintSubsetTool.java.txt
├── parse
├── ParserType.java
├── csv
│ ├── Parse.java
│ └── ParseCSV.java
├── rr
│ ├── Parse.java
│ └── ParseRoadRunner.java
├── std
│ ├── Parse.java
│ └── ParseStandard.java
└── util
│ ├── CannotParseException.java
│ └── EventInfo.java
└── util
├── NeibhorsHardCodeWordTricks.java
├── Pair.java
├── PairComparators.java
├── PairHardCodeWordTricks.java
├── Quintet.java
├── Transaction.java
├── Triplet.java
├── TripletComparators.java
├── ll
├── EfficientLLView.java
├── EfficientLinkedList.java
└── EfficientNode.java
├── trace
├── Trace.java
└── TraceAndDataSets.java
├── treeclock
└── TreeClock.java
└── vectorclock
├── AdaptiveVC.java
├── ClockPair.java
├── Epoch.java
├── FullAdaptiveVC.java
├── SemiAdaptiveVC.java
├── VectorClock.java
└── VectorClockOpt.java
/.gitignore:
--------------------------------------------------------------------------------
1 | out/
2 | .idea/
3 | OSR-sync-github.iml
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Umang Mathur
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/lib/commons-cli-1.3.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/commons-cli-1.3.1.jar
--------------------------------------------------------------------------------
/lib/commons-io-2.13.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/commons-io-2.13.0.jar
--------------------------------------------------------------------------------
/lib/jgrapht/antlr4-runtime-4.7.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/antlr4-runtime-4.7.1.jar
--------------------------------------------------------------------------------
/lib/jgrapht/commons-lang3-3.8.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/commons-lang3-3.8.1.jar
--------------------------------------------------------------------------------
/lib/jgrapht/commons-text-1.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/commons-text-1.5.jar
--------------------------------------------------------------------------------
/lib/jgrapht/fastutil-8.2.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/fastutil-8.2.2.jar
--------------------------------------------------------------------------------
/lib/jgrapht/guava-26.0-jre.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/guava-26.0-jre.jar
--------------------------------------------------------------------------------
/lib/jgrapht/jgrapht-bundle-1.3.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/jgrapht-bundle-1.3.0.jar
--------------------------------------------------------------------------------
/lib/jgrapht/jgrapht-core-1.3.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/jgrapht-core-1.3.0.jar
--------------------------------------------------------------------------------
/lib/jgrapht/jgrapht-demo-1.3.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/jgrapht-demo-1.3.0.jar
--------------------------------------------------------------------------------
/lib/jgrapht/jgrapht-ext-1.3.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/jgrapht-ext-1.3.0.jar
--------------------------------------------------------------------------------
/lib/jgrapht/jgrapht-guava-1.3.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/jgrapht-guava-1.3.0.jar
--------------------------------------------------------------------------------
/lib/jgrapht/jgrapht-io-1.3.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/jgrapht-io-1.3.0.jar
--------------------------------------------------------------------------------
/lib/jgrapht/jgrapht-opt-1.3.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/jgrapht-opt-1.3.0.jar
--------------------------------------------------------------------------------
/lib/jgrapht/jgraphx-3.4.1.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/jgraphx-3.4.1.3.jar
--------------------------------------------------------------------------------
/lib/jgrapht/jheaps-0.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/jgrapht/jheaps-0.9.jar
--------------------------------------------------------------------------------
/lib/lz4-1.3-SNAPSHOT.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/lz4-1.3-SNAPSHOT.jar
--------------------------------------------------------------------------------
/lib/parserv.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/parserv.jar
--------------------------------------------------------------------------------
/lib/rvparse.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/lib/rvparse.jar
--------------------------------------------------------------------------------
/notes/Generate_RoadRunner_traces.md:
--------------------------------------------------------------------------------
1 | In order to support RoadRunner traces, I have added a custom printing tool (that only prints a small subset of events, unlike the pre-existing PrintTool [abbreviated `P`] ).
2 | This tool is called PrintSubsetTool and the supplied file `PrintSubsetTool.java` in this folder is the file that you have to put in the appropriate place.
3 |
4 | ## Instructions for generating RoadRunner files :
5 |
6 | 1. Download RoadRunner tool [here](https://github.com/stephenfreund/RoadRunner).
7 | Let us say that RoadRunner sits in ${RoadRunnerRoot} directory.
8 |
9 | 2. Move the file [`PrintSubsetTool.java`](PrintSubsetTool.java.txt) to the folder ${RoadRunner}/src/rr/simple .
10 | That's it! RoadRunner is so designed as to automatically take care of all the book-keeping when you write a new tool.
11 |
12 | 3. Compile Roadrunner as you normally would (see `INSTALL.txt`) in ${RoadRunnerRoot} .
13 | Most likely, a simple `ant` (in ${RoadRunnerRoot} ) will do the job.
14 |
15 | 4. Once RoadRunner is compiled, we can run our tool.
16 | Let us say we want to print the events of the class `/path/to/class` .
17 | Then, the command you should run is
18 | ```
19 | rrrun -noFP -noxml -quiet -noTidGC -tool=PS /path/to/class > /path/to/test.rr
20 | ```
21 | `/path/to/test.rr` is the log file that is generated.
22 | This file is quite readable and you can open it to see the events for yourself.
23 | This is how the file would look like:
24 | ```
25 | [main: RoadRunner Agent Loaded.]
26 | [main: Running in FAST Mode]
27 | [RR: Creating Fresh Meta Data]
28 | [main: ----- ----- ----- ----- Meep Meep. ----- ----- ----- -----]
29 | [main: ]
30 | @ main[tid = 0] started .
31 | @ Enter(0,test/Test.main([Ljava/lang/String;)V) from null
32 | @ Thread-0[tid = 1] started by main[tid = 0].
33 | @ Start(0,1)
34 | .
35 | .
36 | .
37 | ```
38 |
39 | The option `-noFP` disallows any fast-path optimization that RoadRunner would normally employ. In the absence of this flag, some of the access events are not printed.
40 | The options `-noxml` and `-quiet` reduce the clutter that RoadRunner normally produces.
41 | The option `-noTidGC` is (as of now) an unstable/experimental feature. In the absence of this flag, RoadRunner allows thread-id's of dead threads to be re-used. I did not explicitly handle such traces where you would reuse thread ids. Hence, this flag.
42 |
--------------------------------------------------------------------------------
/rapid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/focs-lab/rapid/109435809b567dab44431e44fb3f690ce0f58c5f/rapid.png
--------------------------------------------------------------------------------
/src/Aerodrome.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.atomicity.conflictserializability.aerodrome.AerodromeEngine;
4 |
5 | public class Aerodrome {
6 |
7 | public Aerodrome() {
8 |
9 | }
10 |
11 | public static void main(String[] args) {
12 | CmdOptions options = new GetOptions(args).parse();
13 | AerodromeEngine engine = new AerodromeEngine(options.parserType, options.path, options.verbosity);
14 | boolean time_reporting = true;
15 | long startTimeAnalysis = 0;
16 | if(time_reporting){
17 | startTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
18 | }
19 | engine.analyzeTrace(false);
20 | if(time_reporting){
21 | long stopTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
22 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
23 | System.out.println("Time for full analysis = " + timeAnalysis + " milliseconds");
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/AerodromeBasic.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.atomicity.conflictserializability.aerodrome_basic.AerodromeEngine;
4 |
5 | public class AerodromeBasic {
6 |
7 | public AerodromeBasic() {
8 |
9 | }
10 |
11 | public static void main(String[] args) {
12 | CmdOptions options = new GetOptions(args).parse();
13 |
14 | boolean time_reporting = true;
15 | long startTimeAnalysis = 0;
16 | if(time_reporting){
17 | startTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
18 | }
19 |
20 | AerodromeEngine engine = new AerodromeEngine(options.parserType, options.path, options.verbosity);
21 | engine.analyzeTrace(false);
22 |
23 | if(time_reporting){
24 | long stopTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
25 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
26 | System.out.println("Time for full analysis = " + timeAnalysis + " milliseconds");
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/ExcludeMethods.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import event.Event;
4 | import parse.rr.ParseRoadRunner;
5 |
6 | public class ExcludeMethods {
7 |
8 | public ExcludeMethods() {
9 |
10 | }
11 |
12 | public static void main(String[] args) {
13 | CmdOptions options = new GetOptions(args).parse();
14 | String traceFile = options.path;
15 | String excludeFile = options.excludeList;
16 | Event e = new Event();
17 | ParseRoadRunner parser;
18 | if(!(excludeFile == null)) {
19 | parser = new ParseRoadRunner(traceFile, excludeFile);
20 | }
21 | else {
22 | parser = new ParseRoadRunner(traceFile);
23 | }
24 | while(parser.checkAndGetNext(e)){
25 | System.out.println(e.toStandardFormat());
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/FHB.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.racedetectionengine.fhb.FHBEngine;
4 |
5 | public class FHB {
6 |
7 | public FHB() {
8 |
9 | }
10 |
11 | public static void main(String[] args) {
12 | CmdOptions options = new GetOptions(args).parse();
13 | FHBEngine engine = new FHBEngine(options.parserType, options.path);
14 | boolean time_reporting = true;
15 | long startTimeAnalysis = 0;
16 | if (time_reporting) {
17 | startTimeAnalysis = System.currentTimeMillis(); // System.nanoTime();
18 | }
19 | engine.analyzeTrace(options.multipleRace, options.verbosity);
20 |
21 | if (time_reporting) {
22 | long stopTimeAnalysis = System.currentTimeMillis(); // System.nanoTime();
23 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
24 | System.out.println("Time for analysis = " + timeAnalysis + " milliseconds");
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Goldilocks.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.racedetectionengine.goldilocks.GoldilocksEngine;
4 |
5 | public class Goldilocks {
6 |
7 | public Goldilocks() {
8 |
9 | }
10 |
11 | public static void main(String[] args) {
12 | CmdOptions options = new GetOptions(args).parse();
13 |
14 | boolean time_reporting = true;
15 | long startTimeAnalysis = 0;
16 | if(time_reporting){
17 | startTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
18 | }
19 |
20 | GoldilocksEngine engine = new GoldilocksEngine(options.parserType, options.path, options.verbosity);
21 | engine.analyzeTrace(options.multipleRace, options.verbosity);
22 |
23 | if(time_reporting){
24 | long stopTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
25 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
26 | System.out.println("Time for analysis = " + timeAnalysis + " milliseconds");
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/HB.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.racedetectionengine.hb.HBEngine;
4 |
5 | public class HB {
6 |
7 | public HB() {
8 |
9 | }
10 |
11 | public static void main(String[] args) {
12 | CmdOptions options = new GetOptions(args).parse();
13 | long startTimeAnalysis = System.currentTimeMillis();
14 | HBEngine engine = new HBEngine(options.parserType, options.path);
15 | engine.analyzeTrace(options.multipleRace, options.verbosity);
16 | long stopTimeAnalysis = System.currentTimeMillis();
17 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
18 | System.out.println("Time for analysis = " + timeAnalysis + " milliseconds");
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/HBEpoch.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.racedetectionengine.hb_epoch.HBEpochEngine;
4 |
5 | public class HBEpoch {
6 |
7 | public HBEpoch() {
8 |
9 | }
10 |
11 | public static void main(String[] args) {
12 | CmdOptions options = new GetOptions(args).parse();
13 |
14 | boolean time_reporting = true;
15 | long startTimeAnalysis = 0;
16 | if(time_reporting){
17 | startTimeAnalysis = System.currentTimeMillis();
18 | }
19 |
20 | HBEpochEngine engine = new HBEpochEngine(options.parserType, options.path);
21 | engine.analyzeTrace(options.multipleRace, options.verbosity);
22 |
23 | if(time_reporting){
24 | long stopTimeAnalysis = System.currentTimeMillis();
25 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
26 | System.out.println("Time for analysis = " + timeAnalysis + " milliseconds");
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/LockSet.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.racedetectionengine.lockset.LockSetEngine;
4 |
5 | public class LockSet {
6 |
7 | public LockSet() {
8 |
9 | }
10 |
11 | public static void main(String[] args) {
12 | CmdOptions options = new GetOptions(args).parse();
13 |
14 | boolean time_reporting = true;
15 | long startTimeAnalysis = 0;
16 | if(time_reporting){
17 | startTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
18 | }
19 |
20 | LockSetEngine engine = new LockSetEngine(options.parserType, options.path, options.verbosity);
21 | engine.analyzeTrace(options.multipleRace, options.verbosity);
22 |
23 | if(time_reporting){
24 | long stopTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
25 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
26 | System.out.println("Time for analysis = " + timeAnalysis + " milliseconds");
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Main-Class: OSR
3 |
4 |
--------------------------------------------------------------------------------
/src/MetaInfo.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.metainfo.MetaInfoEngine;
4 |
5 | public class MetaInfo {
6 |
7 | public MetaInfo() {
8 |
9 | }
10 |
11 | public static void main(String[] args) {
12 | CmdOptions options = new GetOptions(args).parse();
13 | MetaInfoEngine engine = new MetaInfoEngine(options.parserType, options.path);
14 | engine.analyzeTrace();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/OSR.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.racedetectionengine.OSR.OSREngine;
4 | import engine.racedetectionengine.OSR.POBuild.POBuildReverse;
5 | import engine.racedetectionengine.hb.HBEngine;
6 | import event.Event;
7 | import event.Lock;
8 | import event.Thread;
9 | import event.Variable;
10 | import parse.ParserType;
11 |
12 | import java.io.File;
13 | import java.io.IOException;
14 | import java.util.ArrayList;
15 | import java.util.List;
16 | import java.util.Map;
17 |
18 | public class OSR {
19 | public static void main(String[] args) throws IOException {
20 | CmdOptions options = new GetOptions(args).parse();
21 | long startTimeAnalysis = System.currentTimeMillis();
22 |
23 | OSREngine engine = new OSREngine(options.parserType, options.path);
24 | engine.analyzeTrace(options.multipleRace, options.verbosity);
25 |
26 | long stopTimeAnalysis = System.currentTimeMillis();
27 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
28 | double timeInSeconds = timeAnalysis * 1.0 / 1000;
29 | double timeInMin = timeAnalysis * 1.0 / 60000;
30 | ArrayList racyEvents = new ArrayList<>(engine.state.racyEvents);
31 | racyEvents.sort((a, b) -> Math.toIntExact(a - b));
32 | System.out.println("======================================================");
33 | System.out.println("Time for analysis = " + timeAnalysis + " milliseconds");
34 | System.out.println("Time for analysis in seconds = " + String.format("%.3f", timeInSeconds));
35 | System.out.println("Time for analysis in mins = " + String.format("%.1f", timeInMin));
36 | System.out.println("Number of racy events: " + engine.state.racyEvents.size());
37 | System.out.println("Racy events: " + racyEvents);
38 | System.out.println("Number of racy locations: " + engine.state.racyLocations.size());
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/PrintCSV.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.print.PrintEngine;
4 | import parse.ParserType;
5 |
6 | public class PrintCSV {
7 |
8 | public PrintCSV() {
9 |
10 | }
11 |
12 | public static void main(String[] args) {
13 | CmdOptions options = new GetOptions(args).parse();
14 | PrintEngine engine = new PrintEngine(options.parserType, options.path);
15 | engine.analyzeTrace(ParserType.CSV);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/PrintSTD.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.print.PrintEngine;
4 | import parse.ParserType;
5 |
6 | public class PrintSTD {
7 |
8 | public PrintSTD() {
9 |
10 | }
11 |
12 | public static void main(String[] args) {
13 | CmdOptions options = new GetOptions(args).parse();
14 | PrintEngine engine = new PrintEngine(options.parserType, options.path);
15 | engine.analyzeTrace(ParserType.STD);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/PrintSTDFilter.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.print.PrintFilterEngine;
4 | import parse.ParserType;
5 |
6 | public class PrintSTDFilter {
7 |
8 | public PrintSTDFilter() {
9 |
10 | }
11 |
12 | public static void main(String[] args) {
13 | CmdOptions options = new GetOptions(args).parse();
14 | PrintFilterEngine engine = new PrintFilterEngine(options.parserType, options.path);
15 | engine.analyzeTrace(ParserType.STD);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/SHB.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.racedetectionengine.shb.SHBEngine;
4 |
5 | public class SHB {
6 |
7 | public SHB() {
8 |
9 | }
10 |
11 | public static void main(String[] args) {
12 | CmdOptions options = new GetOptions(args).parse();
13 |
14 | boolean time_reporting = true;
15 | long startTimeAnalysis = 0;
16 | if (time_reporting) {
17 | startTimeAnalysis = System.currentTimeMillis();
18 | }
19 |
20 | SHBEngine engine = new SHBEngine(options.parserType, options.path);
21 | engine.analyzeTrace(options.multipleRace, options.verbosity);
22 |
23 | if (time_reporting) {
24 | long stopTimeAnalysis = System.currentTimeMillis();
25 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
26 | System.out.println("Time for analysis = " + timeAnalysis + " milliseconds");
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/SHBEpoch.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.racedetectionengine.shb_epoch.SHBEpochEngine;
4 |
5 | public class SHBEpoch {
6 |
7 | public SHBEpoch() {
8 |
9 | }
10 |
11 | public static void main(String[] args) {
12 | CmdOptions options = new GetOptions(args).parse();
13 |
14 | boolean time_reporting = true;
15 | long startTimeAnalysis = 0;
16 | if(time_reporting){
17 | startTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
18 | }
19 |
20 | SHBEpochEngine engine = new SHBEpochEngine(options.parserType, options.path);
21 | engine.analyzeTrace(options.multipleRace, options.verbosity);
22 |
23 | if(time_reporting){
24 | long stopTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
25 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
26 | System.out.println("Time for analysis = " + timeAnalysis + " milliseconds");
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/SyncPreserving.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.racedetectionengine.syncpreserving.SyncPreservingRaceOfflineEngine;
4 |
5 | public class SyncPreserving {
6 |
7 | public SyncPreserving() {
8 |
9 | }
10 |
11 | public static void main(String[] args) {
12 | CmdOptions options = new GetOptions(args).parse();
13 |
14 | boolean time_reporting = true;
15 | long startTimeAnalysis = 0;
16 | if (time_reporting) {
17 | startTimeAnalysis = System.currentTimeMillis(); // System.nanoTime();
18 | }
19 |
20 | SyncPreservingRaceOfflineEngine engine = new SyncPreservingRaceOfflineEngine(
21 | options.parserType, options.path);
22 | engine.analyzeTrace(options.multipleRace, options.verbosity);
23 |
24 | if (time_reporting) {
25 | long stopTimeAnalysis = System.currentTimeMillis(); // System.nanoTime();
26 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
27 | System.out.println("Time for analysis = " + timeAnalysis + " milliseconds");
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Velodrome.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.atomicity.conflictserializability.velodome.VelodromeEngine;
4 |
5 | public class Velodrome {
6 |
7 | public Velodrome() {
8 |
9 | }
10 |
11 | public static void main(String[] args) {
12 | CmdOptions options = new GetOptions(args).parse();
13 | VelodromeEngine engine = new VelodromeEngine(options.parserType, options.path, options.verbosity);
14 |
15 | boolean time_reporting = true;
16 | long startTimeAnalysis = 0;
17 | if(time_reporting){
18 | startTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
19 | }
20 |
21 | engine.analyzeTrace(false);
22 |
23 | System.out.println("Number of transactions remaining = " + engine.numTransactionsActive());
24 |
25 | if(time_reporting){
26 | long stopTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
27 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
28 | System.out.println("Time for full analysis = " + timeAnalysis + " milliseconds");
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/WCP.java:
--------------------------------------------------------------------------------
1 | import cmd.CmdOptions;
2 | import cmd.GetOptions;
3 | import engine.racedetectionengine.wcp.WCPEngine;
4 |
5 | public class WCP {
6 |
7 | public WCP() {
8 |
9 | }
10 |
11 | public static void main(String[] args) {
12 | CmdOptions options = new GetOptions(args).parse();
13 |
14 | boolean time_reporting = true;
15 | long startTimeAnalysis = 0;
16 | if (time_reporting) {
17 | startTimeAnalysis = System.currentTimeMillis(); // System.nanoTime();
18 | }
19 |
20 | WCPEngine engine = new WCPEngine(options.parserType, options.path);
21 | engine.analyzeTrace(options.multipleRace, options.verbosity);
22 |
23 | if (time_reporting) {
24 | long stopTimeAnalysis = System.currentTimeMillis(); // System.nanoTime();
25 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
26 | System.out.println(
27 | "Time for full analysis = " + timeAnalysis + " milliseconds");
28 | }
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/cmd/CmdOptions.java:
--------------------------------------------------------------------------------
1 | package cmd;
2 |
3 | import parse.ParserType;
4 |
5 | public class CmdOptions {
6 |
7 | public ParserType parserType;
8 | public boolean online;
9 | public boolean multipleRace;
10 | public String path;
11 | public int verbosity;
12 | public String excludeList;
13 |
14 | public CmdOptions() {
15 | this.parserType = ParserType.CSV;
16 | this.online = true;
17 | this.multipleRace = true;
18 | this.path = null;
19 | this.verbosity = 0;
20 | this.excludeList = null;
21 | }
22 |
23 | public String toString(){
24 | String str = "";
25 | str += "parserType " + " = " + this.parserType.toString() + "\n";
26 | str += "online " + " = " + this.online + "\n";
27 | str += "multipleRace " + " = " + this.multipleRace + "\n";
28 | str += "path " + " = " + this.path + "\n";
29 | str += "verbosity " + " = " + this.verbosity + "\n";
30 | str += "excludeList " + " = " + this.excludeList + "\n";
31 | return str;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/cmd/GetOptions.java:
--------------------------------------------------------------------------------
1 | package cmd;
2 |
3 | import java.util.logging.Level;
4 | import java.util.logging.Logger;
5 |
6 | import org.apache.commons.cli.DefaultParser;
7 | import org.apache.commons.cli.CommandLine;
8 | import org.apache.commons.cli.CommandLineParser;
9 | import org.apache.commons.cli.HelpFormatter;
10 | import org.apache.commons.cli.Options;
11 | import org.apache.commons.cli.ParseException;
12 |
13 | import parse.ParserType;
14 |
15 | public class GetOptions {
16 |
17 | private static final Logger log = Logger.getLogger(GetOptions.class.getName());
18 | private String[] args = null;
19 | private Options options = new Options();
20 |
21 | public GetOptions(String[] args) {
22 | this.args = args;
23 | options.addOption("h", "help", false, "generate this message");
24 | options.addOption("f", "format", true, "format of the trace. Possible choices include rv, csv, rr, std (Default : csv) ");
25 | options.addOption("s", "single", false, "force the algorithm to terminate after the first race is detected");
26 | options.addOption("p", "path", true, "the path to the trace file/folder (Required)");
27 | options.addOption("v", "verbosity", true, "for setting verbosity: Allowed levels = 0, 1, 2 (Default : 0)");
28 | options.addOption("m", "excluded-methods", true, "path to file that lists methods to be excluded");
29 | }
30 |
31 | public CmdOptions parse() {
32 | CommandLineParser parser = new DefaultParser();
33 | CommandLine cmd = null;
34 | CmdOptions cmdOpt = new CmdOptions();;
35 |
36 | try {
37 | cmd = parser.parse(options, args);
38 | if (cmd.hasOption("h"))
39 | help();
40 |
41 | if (cmd.hasOption("f")) {
42 | cmdOpt.parserType = ParserType.getType(cmd.getOptionValue("f")) ;
43 | }
44 |
45 | if (cmd.hasOption("s")) {
46 | cmdOpt.multipleRace = false;
47 | }
48 |
49 | if (cmd.hasOption("v")) {
50 | try{
51 | cmdOpt.verbosity = Integer.parseInt(cmd.getOptionValue("v"));
52 | if(cmdOpt.verbosity < 0 || cmdOpt.verbosity > 3){
53 | log.log(Level.INFO, "Invalid verbosity level : " + cmdOpt.verbosity);
54 | }
55 | }
56 | catch (NumberFormatException nfe){
57 | log.log(Level.INFO, "Invalid verbosity option : " + cmd.getOptionValue("v"));
58 | }
59 | }
60 |
61 | if (cmd.hasOption("p")) {
62 | cmdOpt.path = cmd.getOptionValue("p") ;
63 | }
64 | else {
65 | log.log(Level.INFO, "MIssing path to file/folder");
66 | help();
67 | }
68 |
69 | if (cmd.hasOption("m")) {
70 | cmdOpt.excludeList = cmd.getOptionValue("m") ;
71 | }
72 |
73 | } catch (ParseException e) {
74 | help();
75 | }
76 |
77 | return cmdOpt;
78 | }
79 |
80 | private void help() {
81 | HelpFormatter formater = new HelpFormatter();
82 | formater.printHelp("RAPID", options);
83 | System.exit(0);
84 | }
85 |
86 | public static void main(String[] args) {
87 | new GetOptions(args).parse();
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/engine/Engine.java:
--------------------------------------------------------------------------------
1 | package engine;
2 |
3 | import event.Event;
4 | import parse.ParserType;
5 | import parse.rr.ParseRoadRunner;
6 | import parse.rv.ParseRVPredict;
7 | import parse.std.ParseStandard;
8 | import util.trace.Trace;
9 |
10 | public abstract class Engine {
11 | protected ParserType parserType;
12 | protected Trace trace; // CSV
13 | protected ParseRVPredict rvParser;// RV
14 | protected ParseStandard stdParser; // STD
15 | protected ParseRoadRunner rrParser; // RR
16 | protected E handlerEvent;
17 |
18 | public Engine(ParserType pType) {
19 | this.parserType = pType;
20 | }
21 |
22 | protected void initializeReader(String trace_folder) {
23 | if (this.parserType.isRV()) {
24 | initializeReaderRV(trace_folder);
25 | } else if (this.parserType.isCSV()) {
26 | initializeReaderCSV(trace_folder);
27 | } else if (this.parserType.isSTD()) {
28 | initializeReaderSTD(trace_folder);
29 | } else if (this.parserType.isRR()) {
30 | initializeReaderRR(trace_folder);
31 | }
32 | }
33 |
34 | protected abstract void initializeReaderRV(String trace_folder);
35 |
36 | protected abstract void initializeReaderCSV(String trace_file);
37 |
38 | protected abstract void initializeReaderSTD(String trace_file);
39 |
40 | protected abstract void initializeReaderRR(String trace_file);
41 |
42 | protected void printCompletionStatus() {
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/engine/accesstimes/orderedvars/OrderedVarsEngine.java:
--------------------------------------------------------------------------------
1 | package engine.accesstimes.orderedvars;
2 |
3 | import java.util.HashMap;
4 | import java.util.HashSet;
5 |
6 | import engine.racedetectionengine.RaceDetectionEngine;
7 | import event.Thread;
8 | import parse.ParserType;
9 |
10 | public class OrderedVarsEngine extends RaceDetectionEngine{
11 |
12 | public OrderedVarsEngine(ParserType pType, String trace_folder, int verbosity) {
13 | super(pType);
14 | this.threadSet = new HashSet ();
15 | initializeReader(trace_folder);
16 | this.state = new OrderedVarsState(this.threadSet, verbosity);
17 | handlerEvent = new OrderedVarsEvent();
18 | this.enablePrintStatus = false;
19 | }
20 |
21 | @Override
22 | protected boolean skipEvent(OrderedVarsEvent handlerEvent) {
23 | return false;
24 | }
25 |
26 | @Override
27 | protected void postHandleEvent(OrderedVarsEvent handlerEvent) {
28 | }
29 |
30 | public HashSet getOrdredVars(){
31 | return this.state.orderedVariables;
32 | }
33 |
34 | public HashMap> getVariableToThreadSet(){
35 | return this.state.variableToThreadSet;
36 | }
37 |
38 | public HashMap> getLockToThreadSet(){
39 | return this.state.lockToThreadSet;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/engine/accesstimes/orderedvars/OrderedVarsState.java:
--------------------------------------------------------------------------------
1 | package engine.accesstimes.orderedvars;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.HashSet;
6 | import java.util.Iterator;
7 |
8 | import engine.racedetectionengine.State;
9 | import event.Thread;
10 | import event.Variable;
11 | import util.vectorclock.VectorClock;
12 |
13 | public class OrderedVarsState extends State {
14 |
15 | // ==== Internal data ====
16 | public HashMap threadToIndex;
17 | private HashMap variableToIndex;
18 | private int numThreads;
19 | private int numVariables;
20 |
21 | // ==== Data used for algorithm ====
22 |
23 | // Data for maintaining the partial order
24 | public ArrayList clockThread;
25 | public ArrayList lastWriteVariable;
26 | public HashMap thread_lastWriteAccessForVariable; // VarName -> threadId. thread_lastWriteAccessForVariable(x) = thread that performed the last write on x
27 | public HashSet readVars; // Set of vars x such that the last access on x was a read.
28 | public ArrayList lastVariable_read;
29 |
30 | public HashSet orderedVariables;
31 | public HashMap> lockToThreadSet;
32 | public HashMap> variableToThreadSet;
33 | public HashSet variablesWritten;
34 |
35 |
36 | // ==== parameter flags ====
37 | public boolean tickClockOnAccess;
38 | public int verbosity;
39 |
40 | public OrderedVarsState(HashSet tSet, int verbosity) {
41 | this.verbosity = verbosity;
42 | initInternalData(tSet);
43 | initData(tSet);
44 | }
45 |
46 | private void initInternalData(HashSet tSet) {
47 | this.threadToIndex = new HashMap();
48 | this.numThreads = 0;
49 | Iterator tIter = tSet.iterator();
50 | while (tIter.hasNext()) {
51 | int threadId = tIter.next().getId();
52 | this.threadToIndex.put(threadId, (Integer) this.numThreads);
53 | this.numThreads++;
54 | }
55 |
56 | this.variableToIndex = new HashMap();
57 | this.numVariables = 0;
58 | }
59 |
60 | private void initialize1DArrayOfVectorClocksWithBottom(
61 | ArrayList arr, int len) {
62 | for (int i = 0; i < len; i++) {
63 | arr.add(new VectorClock(this.numThreads));
64 | }
65 | }
66 |
67 | public void initData(HashSet tSet) {
68 |
69 | // initialize clockThread
70 | this.clockThread = new ArrayList();
71 | initialize1DArrayOfVectorClocksWithBottom(this.clockThread, this.numThreads);
72 | for (int i = 0; i < this.numThreads; i++) {
73 | VectorClock C_t = this.clockThread.get(i);
74 | C_t.setClockIndex(i, 1);
75 | }
76 |
77 | // initialize lastWriteVariable
78 | this.lastWriteVariable = new ArrayList();
79 |
80 | // initialize lastWriteVariable
81 | this.lastVariable_read = new ArrayList();
82 | this.thread_lastWriteAccessForVariable = new HashMap ();
83 | this.readVars = new HashSet ();
84 |
85 | // initialize orderedVariables
86 | this.orderedVariables = new HashSet ();
87 |
88 | this.lockToThreadSet = new HashMap>();
89 | this.variableToThreadSet = new HashMap>();
90 | this.variablesWritten = new HashSet ();
91 | }
92 |
93 | // Access methods
94 | private VectorClock getVectorClockFrom1DArray(ArrayList arr,
95 | int index) {
96 | if (index < 0 || index >= arr.size()) {
97 | throw new IllegalArgumentException("Illegal Out of Bound access");
98 | }
99 | return arr.get(index);
100 | }
101 |
102 | public int checkAndAddVariable(Variable v) {
103 | if (!variableToIndex.containsKey(v.getName())) {
104 | variableToIndex.put(v.getName(), this.numVariables);
105 | this.numVariables++;
106 | this.lastWriteVariable.add(new VectorClock(this.numThreads));
107 | this.lastVariable_read.add(new VectorClock(this.numThreads));
108 | this.orderedVariables.add(v.getName());
109 | }
110 | return variableToIndex.get(v.getName());
111 | }
112 |
113 | public void incClockThread(Thread t) {
114 | int tIndex = threadToIndex.get(t.getId());
115 | VectorClock C_t = getVectorClock(clockThread, t);
116 | int origVal = C_t.getClockIndex(tIndex);
117 | C_t.setClockIndex(tIndex, origVal + 1);
118 | }
119 |
120 | public VectorClock getVectorClock(ArrayList arr, Thread t) {
121 | int tIndex = threadToIndex.get(t.getId());
122 | return getVectorClockFrom1DArray(arr, tIndex);
123 | }
124 |
125 | public VectorClock getVectorClock(ArrayList arr, Variable v) {
126 | int vIndex = checkAndAddVariable(v);
127 | return getVectorClockFrom1DArray(arr, vIndex);
128 | }
129 |
130 | public void setClockIndex(VectorClock vc, int tId, int val) {
131 | int tIndex = threadToIndex.get(tId);
132 | vc.setClockIndex(tIndex, val);
133 | }
134 |
135 | public int getClockIndex(VectorClock vc, int tId) {
136 | int tIndex = threadToIndex.get(tId);
137 | return vc.getClockIndex(tIndex);
138 | }
139 |
140 | public boolean isThreadRelevant(Thread t) {
141 | return this.threadToIndex.containsKey(t.getId());
142 | }
143 |
144 | public void printMemory() {
145 | System.err.println("Number of threads = " + Integer.toString(this.numThreads));
146 | System.err
147 | .println("Number of variables = " + Integer.toString(this.numVariables));
148 | }
149 | }
--------------------------------------------------------------------------------
/src/engine/atomicity/AtomicityEngine.java:
--------------------------------------------------------------------------------
1 | package engine.atomicity;
2 |
3 | import java.util.HashSet;
4 |
5 | import engine.Engine;
6 | import event.Thread;
7 | import parse.ParserType;
8 | import parse.csv.ParseCSV;
9 | import parse.rr.ParseRoadRunner;
10 | import parse.rv.ParseRVPredict;
11 | import parse.std.ParseStandard;
12 | import util.trace.TraceAndDataSets;
13 |
14 | public abstract class AtomicityEngine> extends Engine {
15 |
16 | public St state;
17 | protected HashSet threadSet;
18 |
19 | protected long eventCount;
20 | protected Long violationCount;
21 | protected Long totalSkippedEvents;
22 |
23 | public AtomicityEngine(ParserType pType) {
24 | super(pType);
25 | }
26 |
27 | protected void initializeReaderRV(String trace_folder){
28 | rvParser = new ParseRVPredict(trace_folder, this.threadSet);
29 | }
30 |
31 | protected void initializeReaderCSV(String trace_file){
32 | TraceAndDataSets traceAndDataSets = ParseCSV.parse(true, trace_file);
33 | this.threadSet = traceAndDataSets.getThreadSet();
34 | this.trace = traceAndDataSets.getTrace();
35 | }
36 |
37 | protected void initializeReaderSTD(String trace_folder){
38 | stdParser = new ParseStandard(trace_folder, true);
39 | threadSet = stdParser.getThreadSet();
40 | }
41 |
42 | protected void initializeReaderRR(String trace_folder){
43 | rrParser = new ParseRoadRunner(trace_folder, true);
44 | threadSet = rrParser.getThreadSet();
45 | }
46 |
47 | protected boolean analyzeEvent(RDE handlerEvent, Long eventCount){
48 | boolean violationDetected = false;
49 | try{
50 | violationDetected = handlerEvent.Handle(state);
51 | }
52 | catch(OutOfMemoryError oome){
53 | oome.printStackTrace();
54 | System.err.println("Number of events = " + Long.toString(eventCount));
55 | state.printMemory();
56 | }
57 | if(state.verbosity==3 && handlerEvent.getType().isAccessType() ){
58 | System.out.println("|"+Long.toString(eventCount));
59 | }
60 |
61 | // if (violationDetected) {
62 | // System.out.println(handlerEvent.getLocId());
63 | // }
64 | return violationDetected;
65 | }
66 |
67 | public void analyzeTrace(boolean multipleRace){
68 | eventCount = (long) 0;
69 | violationCount = (long) 0;
70 | totalSkippedEvents = (long) 0;
71 | if(this.parserType.isRV()){
72 | analyzeTraceRV(multipleRace);
73 | }
74 | else if(this.parserType.isCSV()){
75 | analyzeTraceCSV(multipleRace);
76 | }
77 | else if(this.parserType.isSTD()){
78 | analyzeTraceSTD(multipleRace);
79 | }
80 | else if(this.parserType.isRR()){
81 | analyzeTraceRR(multipleRace);
82 | }
83 |
84 | System.out.println("Analysis complete");
85 | if(violationCount > 0) {
86 | System.out.println("Atomicity violation detected");
87 | }
88 | else {
89 | System.out.println("No atomicity violation detected");
90 | }
91 | System.out.println("Number of events analyzed = " + Long.toString(eventCount));
92 | }
93 |
94 | protected void analyzeTraceCSV(boolean multipleRace) {
95 | for(eventCount = 0; eventCount < trace.getSize(); eventCount ++){
96 | handlerEvent.copyFrom(trace.getEventAt((int)eventCount));
97 | if(skipEvent(handlerEvent)){
98 | totalSkippedEvents = totalSkippedEvents + 1;
99 | }
100 | else{
101 | boolean raceDetected = analyzeEvent(handlerEvent, eventCount);
102 | if(raceDetected){
103 | violationCount ++;
104 | if (!multipleRace){
105 | break;
106 | }
107 | }
108 | postHandleEvent(handlerEvent);
109 | }
110 | }
111 | }
112 |
113 | protected void analyzeTraceRV(boolean multipleRace) {
114 | if(rvParser.pathListNotNull()){
115 | while(rvParser.hasNext()){
116 | eventCount = eventCount + 1;
117 | rvParser.getNextEvent(handlerEvent);
118 |
119 | if(skipEvent(handlerEvent)){
120 | totalSkippedEvents = totalSkippedEvents + 1;
121 | }
122 | else{
123 | boolean raceDetected = analyzeEvent(handlerEvent, (long) eventCount);
124 | if(raceDetected){
125 | violationCount ++;
126 | if (!multipleRace){
127 | break;
128 | }
129 | }
130 | postHandleEvent(handlerEvent);
131 | }
132 | }
133 | }
134 | }
135 |
136 | protected void analyzeTraceSTD(boolean multipleRace) {
137 | while(stdParser.hasNext()){
138 | eventCount = eventCount + 1;
139 | stdParser.getNextEvent(handlerEvent);
140 |
141 | if(skipEvent(handlerEvent)){
142 | totalSkippedEvents = totalSkippedEvents + 1;
143 | }
144 | else{
145 | boolean violationDetected = analyzeEvent(handlerEvent, (long) eventCount);
146 | if(violationDetected){
147 | violationCount ++;
148 | if (!multipleRace){
149 | break;
150 | }
151 | }
152 | postHandleEvent(handlerEvent);
153 | }
154 | }
155 | }
156 |
157 | protected void analyzeTraceRR(boolean multipleRace) {
158 | while(rrParser.checkAndGetNext(handlerEvent)){
159 | eventCount = eventCount + 1;
160 |
161 | if(skipEvent(handlerEvent)){
162 | totalSkippedEvents = totalSkippedEvents + 1;
163 | }
164 | else{
165 | boolean violationDetected = analyzeEvent(handlerEvent, (long) eventCount);
166 | if(violationDetected){
167 | violationCount ++;
168 | if (!multipleRace){
169 | break;
170 | }
171 | }
172 | postHandleEvent(handlerEvent);
173 | }
174 | }
175 | }
176 |
177 | protected abstract boolean skipEvent(RDE handlerEvent);
178 |
179 | protected abstract void postHandleEvent(RDE handlerEvent);
180 |
181 | }
182 |
--------------------------------------------------------------------------------
/src/engine/atomicity/AtomicityEvent.java:
--------------------------------------------------------------------------------
1 | package engine.atomicity;
2 |
3 | import event.Event;
4 |
5 | public abstract class AtomicityEvent extends Event {
6 | public AtomicityEvent(){
7 | super();
8 | }
9 |
10 | public void copyFrom(Event fromEvent){
11 | super.copyFrom(fromEvent);
12 | }
13 |
14 | public void printRaceInfo(S state){
15 | if(this.getType().isLockType()) this.printRaceInfoLockType(state);
16 | if(this.getType().isAccessType()) this.printRaceInfoAccessType(state);
17 | if(this.getType().isExtremeType()) this.printRaceInfoExtremeType(state);
18 | if(this.getType().isTransactionType()) this.printRaceInfoTransactionType(state);
19 | }
20 |
21 | public boolean Handle(S state) {
22 | return this.HandleSub(state);
23 | }
24 |
25 | public boolean HandleSub(S state){
26 | boolean violationDetected = false;
27 |
28 | if(this.getType().isAcquire()) violationDetected = this.HandleSubAcquire(state);
29 | if(this.getType().isRelease()) violationDetected = this.HandleSubRelease(state);
30 | if(this.getType().isRead()) violationDetected = this.HandleSubRead(state);
31 | if(this.getType().isWrite()) violationDetected = this.HandleSubWrite(state);
32 | if(this.getType().isFork()) violationDetected = this.HandleSubFork(state);
33 | if(this.getType().isJoin()) violationDetected = this.HandleSubJoin(state);
34 | if(this.getType().isBegin()) violationDetected = this.HandleSubBegin(state);
35 | if(this.getType().isEnd()) violationDetected = this.HandleSubEnd(state);
36 |
37 | return violationDetected;
38 | }
39 |
40 | public abstract void printRaceInfoLockType(S state);
41 | public abstract void printRaceInfoAccessType(S state);
42 | public abstract void printRaceInfoExtremeType(S state);
43 | public abstract void printRaceInfoTransactionType(S state);
44 |
45 | public abstract boolean HandleSubAcquire(S state);
46 | public abstract boolean HandleSubRelease(S state);
47 | public abstract boolean HandleSubRead(S state);
48 | public abstract boolean HandleSubWrite(S state);
49 | public abstract boolean HandleSubFork(S state);
50 | public abstract boolean HandleSubJoin(S state);
51 | public abstract boolean HandleSubBegin(S state);
52 | public abstract boolean HandleSubEnd(S state);
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/engine/atomicity/State.java:
--------------------------------------------------------------------------------
1 | package engine.atomicity;
2 |
3 | public abstract class State {
4 |
5 | //parameter flags
6 | public boolean forceOrder;
7 | public boolean tickClockOnAccess;
8 | public int verbosity;
9 |
10 | public abstract void printMemory();
11 | }
12 |
--------------------------------------------------------------------------------
/src/engine/atomicity/conflictserializability/aerodrome/AerodromeEngine.java:
--------------------------------------------------------------------------------
1 | package engine.atomicity.conflictserializability.aerodrome;
2 |
3 | import java.util.HashSet;
4 |
5 | import engine.atomicity.AtomicityEngine;
6 | import event.Thread;
7 | import parse.ParserType;
8 |
9 | public class AerodromeEngine extends AtomicityEngine{
10 |
11 | public AerodromeEngine(ParserType pType, String trace_folder, int verbosity) {
12 | super(pType);
13 | this.threadSet = new HashSet ();
14 | initializeReader(trace_folder);
15 | this.state = new AerodromeState(this.threadSet, verbosity);
16 | handlerEvent = new AerodromeEvent();
17 | }
18 |
19 | @Override
20 | protected boolean skipEvent(AerodromeEvent handlerEvent) {
21 | return false;
22 | }
23 |
24 | @Override
25 | protected void postHandleEvent(AerodromeEvent handlerEvent) {
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/engine/atomicity/conflictserializability/aerodrome_basic/AerodromeEngine.java:
--------------------------------------------------------------------------------
1 | package engine.atomicity.conflictserializability.aerodrome_basic;
2 |
3 | import java.util.HashSet;
4 |
5 | import engine.atomicity.AtomicityEngine;
6 | import event.Thread;
7 | import parse.ParserType;
8 |
9 | public class AerodromeEngine extends AtomicityEngine{
10 |
11 | public AerodromeEngine(ParserType pType, String trace_folder, int verbosity) {
12 | super(pType);
13 | this.threadSet = new HashSet ();
14 | initializeReader(trace_folder);
15 | this.state = new AerodromeState(this.threadSet, verbosity);
16 | handlerEvent = new AerodromeEvent();
17 | }
18 |
19 | @Override
20 | protected boolean skipEvent(AerodromeEvent handlerEvent) {
21 | return false;
22 | }
23 |
24 | @Override
25 | protected void postHandleEvent(AerodromeEvent handlerEvent) {
26 | // if(handlerEvent.getType().isAccessType()){
27 | // if(state.verbosity == 1 || state.verbosity == 2){
28 | // System.out.println();
29 | // }
30 | // }
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/engine/atomicity/conflictserializability/velodome/VelodromeEngine.java:
--------------------------------------------------------------------------------
1 | package engine.atomicity.conflictserializability.velodome;
2 |
3 | import java.util.HashSet;
4 |
5 | import engine.atomicity.AtomicityEngine;
6 | import event.Thread;
7 | import parse.ParserType;
8 |
9 | public class VelodromeEngine extends AtomicityEngine{
10 |
11 | public VelodromeEngine(ParserType pType, String trace_folder, int verbosity) {
12 | super(pType);
13 | this.threadSet = new HashSet ();
14 | initializeReader(trace_folder);
15 | this.state = new VelodromeState(this.threadSet, verbosity);
16 | handlerEvent = new VelodromeEvent();
17 | }
18 |
19 | @Override
20 | protected boolean skipEvent(VelodromeEvent handlerEvent) {
21 | return false;
22 | }
23 |
24 | @Override
25 | protected void postHandleEvent(VelodromeEvent handlerEvent) {
26 | }
27 |
28 | public int numTransactionsActive() {
29 | return this.state.numTransactionsActive();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/engine/print/PrintEngine.java:
--------------------------------------------------------------------------------
1 | package engine.print;
2 | import java.util.HashMap;
3 |
4 | import engine.Engine;
5 | import event.Event;
6 | import event.EventType;
7 | import event.Thread;
8 | import parse.ParserType;
9 | import parse.csv.ParseCSV;
10 | import parse.rr.ParseRoadRunner;
11 | import parse.rv.ParseRVPredict;
12 | import parse.std.ParseStandard;
13 | import util.trace.TraceAndDataSets;
14 |
15 | public class PrintEngine extends Engine {
16 |
17 | int totThreads;
18 | int currentThreadIdx;
19 | HashMap tIndexMap;
20 | static HashMap type2String;
21 |
22 | private static void initType2String(){
23 | type2String = new HashMap ();
24 | type2String.put(EventType.ACQUIRE, "acq");
25 | type2String.put(EventType.RELEASE, "rel");
26 | type2String.put(EventType.READ, "r");
27 | type2String.put(EventType.WRITE, "w");
28 | type2String.put(EventType.FORK, "fork");
29 | type2String.put(EventType.JOIN, "join");
30 | }
31 |
32 | public PrintEngine(ParserType pType, String trace_folder) {
33 | super(pType);
34 | initializeReader(trace_folder);
35 | initType2String();
36 | handlerEvent = new Event();
37 | tIndexMap = new HashMap ();
38 | currentThreadIdx = 0;
39 | }
40 |
41 | public void analyzeTrace(ParserType outputType) {
42 | if(this.parserType.isRV()){
43 | analyzeTraceRV(outputType);
44 | }
45 | else if(this.parserType.isCSV()){
46 | analyzeTraceCSV(outputType);
47 | }
48 | else if(this.parserType.isSTD()){
49 | analyzeTraceSTD(outputType);
50 | }
51 | else if(this.parserType.isRR()){
52 | analyzeTraceRR(outputType);
53 | }
54 | }
55 |
56 | private void analyzeTraceRV(ParserType outputType) {
57 | if(rvParser.pathListNotNull()){
58 | while(rvParser.hasNext()){
59 | rvParser.getNextEvent(handlerEvent);
60 | if(! skipEvent(handlerEvent)){
61 | processEvent(outputType);
62 | }
63 | }
64 | }
65 | }
66 |
67 | private void analyzeTraceSTD(ParserType outputType) {
68 | while(stdParser.hasNext()){
69 | stdParser.getNextEvent(handlerEvent);
70 | if(! skipEvent(handlerEvent)){
71 | processEvent(outputType);
72 | }
73 | }
74 | }
75 |
76 | private void analyzeTraceCSV(ParserType outputType) {
77 | for(int eCount = 0; eCount < trace.getSize(); eCount ++){
78 | handlerEvent = trace.getEventAt(eCount);
79 | if(! skipEvent(handlerEvent)){
80 | processEvent(outputType);
81 | }
82 | }
83 | }
84 |
85 | private void analyzeTraceRR(ParserType outputType) {
86 | while(rrParser.checkAndGetNext(handlerEvent)){
87 | if(! skipEvent(handlerEvent)){
88 | processEvent(outputType);
89 | }
90 | }
91 | }
92 |
93 | private boolean skipEvent(Event handlerEvent){
94 | boolean skip = false;
95 | return skip;
96 | }
97 |
98 | private String toCSV(Event e, int tIdx, int totThreads){
99 | String csvStr = "";
100 | String decor_name = "";
101 | if(e.getType().isAccessType()){
102 | decor_name = e.getVariable().getName();
103 | }
104 | else if(e.getType().isLockType()){
105 | decor_name = e.getLock().getName();
106 | }
107 | else if(e.getType().isExtremeType()){
108 | Integer target_index = this.tIndexMap.get(e.getTarget());
109 | if(target_index == null){
110 | decor_name = "-unknown-thread-";
111 | }
112 | else{
113 | decor_name = "T" + target_index;
114 | }
115 | }
116 | for(int i = 0; i {
17 |
18 | int totThreads;
19 | int currentThreadIdx;
20 | HashMap tIndexMap;
21 | static HashMap type2String;
22 |
23 | private static void initType2String(){
24 | type2String = new HashMap ();
25 | type2String.put(EventType.ACQUIRE, "acq");
26 | type2String.put(EventType.RELEASE, "rel");
27 | type2String.put(EventType.READ, "r");
28 | type2String.put(EventType.WRITE, "w");
29 | type2String.put(EventType.FORK, "fork");
30 | type2String.put(EventType.JOIN, "join");
31 | }
32 |
33 | public PrintFilterEngine(ParserType pType, String trace_folder) {
34 | super(pType);
35 | initializeReader(trace_folder);
36 | initType2String();
37 | handlerEvent = new Event();
38 | tIndexMap = new HashMap ();
39 | currentThreadIdx = 0;
40 |
41 | boolean time_reporting = true;
42 | long startTimeAnalysis = 0;
43 | if(time_reporting){
44 | startTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
45 | }
46 | AccessTimesEngine accessTimesEngine = new AccessTimesEngine(pType, trace_folder);
47 | accessTimesEngine.computeLastAccessTimes();
48 | if(time_reporting){
49 | long stopTimeAnalysis = System.currentTimeMillis(); //System.nanoTime();
50 | long timeAnalysis = stopTimeAnalysis - startTimeAnalysis;
51 | System.out.println("Time for Phase-1 = " + timeAnalysis + " milliseconds");
52 | }
53 | }
54 |
55 | public void analyzeTrace(ParserType outputType) {
56 | if(this.parserType.isRV()){
57 | analyzeTraceRV(outputType);
58 | }
59 | else if(this.parserType.isCSV()){
60 | analyzeTraceCSV(outputType);
61 | }
62 | else if(this.parserType.isSTD()){
63 | analyzeTraceSTD(outputType);
64 | }
65 | else if(this.parserType.isRR()){
66 | analyzeTraceRR(outputType);
67 | }
68 | }
69 |
70 | private void analyzeTraceRV(ParserType outputType) {
71 | if(rvParser.pathListNotNull()){
72 | while(rvParser.hasNext()){
73 | rvParser.getNextEvent(handlerEvent);
74 | if(! skipEvent(handlerEvent)){
75 | processEvent(outputType);
76 | }
77 | }
78 | }
79 | }
80 |
81 | private void analyzeTraceSTD(ParserType outputType) {
82 | while(stdParser.hasNext()){
83 | stdParser.getNextEvent(handlerEvent);
84 | if(! skipEvent(handlerEvent)){
85 | processEvent(outputType);
86 | }
87 | }
88 | }
89 |
90 | private void analyzeTraceCSV(ParserType outputType) {
91 | for(int eCount = 0; eCount < trace.getSize(); eCount ++){
92 | handlerEvent = trace.getEventAt(eCount);
93 | if(! skipEvent(handlerEvent)){
94 | processEvent(outputType);
95 | }
96 | }
97 | }
98 |
99 | private void analyzeTraceRR(ParserType outputType) {
100 | while(rrParser.checkAndGetNext(handlerEvent)){
101 | if(! skipEvent(handlerEvent)){
102 | processEvent(outputType);
103 | }
104 | }
105 | }
106 |
107 | private boolean skipEvent(Event handlerEvent){
108 | boolean skip = false;
109 | return skip;
110 | }
111 |
112 | private String toCSV(Event e, int tIdx, int totThreads){
113 | String csvStr = "";
114 | String decor_name = "";
115 | if(e.getType().isAccessType()){
116 | decor_name = e.getVariable().getName();
117 | }
118 | else if(e.getType().isLockType()){
119 | decor_name = e.getLock().getName();
120 | }
121 | else if(e.getType().isExtremeType()){
122 | Integer target_index = this.tIndexMap.get(e.getTarget());
123 | if(target_index == null){
124 | decor_name = "-unknown-thread-";
125 | }
126 | else{
127 | decor_name = "T" + target_index;
128 | }
129 | }
130 | for(int i = 0; i = mid+1) {
185 | return sumRange(root.right, start, end);
186 | } else {
187 | int l = sumRange(root.left, start, mid);
188 | int r = sumRange(root.right, mid+1, end);
189 |
190 | return l < r ? l : r ;
191 | }
192 | }
193 | }
194 | }
--------------------------------------------------------------------------------
/src/engine/racedetectionengine/OSR/POBuild/PartialOrder.java:
--------------------------------------------------------------------------------
1 | package engine.racedetectionengine.OSR.POBuild;
2 |
3 | import util.Triplet;
4 | import util.vectorclock.VectorClock;
5 |
6 | import java.util.*;
7 |
8 | // This class exposes the method for abstract graph building
9 |
10 | public class PartialOrder {
11 | public int width; // number of threads
12 | public List