Skip to content

Commit

Permalink
Added support for RoadRunner and STD formats
Browse files Browse the repository at this point in the history
  • Loading branch information
umangm committed Jun 23, 2019
1 parent e3ff915 commit 190323a
Show file tree
Hide file tree
Showing 23 changed files with 1,992 additions and 55 deletions.
97 changes: 49 additions & 48 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,55 @@
Any modifications will be overwritten.
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?eclipse.ant.import?>
as the first entry and export the buildfile again. --><project basedir="." default="build" name="ziptrack">
<property environment="env"/>
<property name="ECLIPSE_HOME" value="../../../../eclipse/java-neon/Eclipse.app/Contents/Eclipse/"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.8"/>
<property name="source" value="1.8"/>
<path id="ziptrack.classpath">
<pathelement location="bin"/>
<pathelement location="lib/commons-cli-1.3.1.jar"/>
<pathelement location="lib/lz4-1.3-SNAPSHOT.jar"/>
<pathelement location="lib/print.jar"/>
</path>
<target name="init">
<mkdir dir="bin"/>
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.launch"/>
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="bin"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="build-subprojects,build-project" name="build"/>
<target name="build-subprojects"/>
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
<src path="src"/>
<classpath refid="ziptrack.classpath"/>
</javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
<copy todir="${ant.library.dir}">
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</copy>
<unzip dest="${ant.library.dir}">
<patternset includes="jdtCompilerAdapter.jar"/>
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</unzip>
</target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
</target>
as the first entry and export the buildfile again. -->
<project basedir="." default="build" name="ziptrack">
<property environment="env" />
<property name="ECLIPSE_HOME" value="../../../../eclipse/java-neon/Eclipse.app/Contents/Eclipse/" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.8" />
<property name="source" value="1.8" />
<path id="ziptrack.classpath">
<pathelement location="bin" />
<pathelement location="lib/commons-cli-1.3.1.jar" />
<pathelement location="lib/lz4-1.3-SNAPSHOT.jar" />
<pathelement location="lib/printrv.jar" />
</path>
<target name="init">
<mkdir dir="bin" />
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.launch" />
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="bin" />
</target>
<target depends="clean" name="cleanall" />
<target depends="build-subprojects,build-project" name="build" />
<target name="build-subprojects" />
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}" />
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
<src path="src" />
<classpath refid="ziptrack.classpath" />
</javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects" />
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
<copy todir="${ant.library.dir}">
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar" />
</copy>
<unzip dest="${ant.library.dir}">
<patternset includes="jdtCompilerAdapter.jar" />
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar" />
</unzip>
</target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter" />
<antcall target="build" />
</target>
<target name="jar" depends="init,build">
<jar basedir="bin" destfile="ziptrack.jar">
<manifest>
Expand Down
Binary file removed lib/print.jar
Binary file not shown.
Binary file added lib/printrv.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/PrintTrace.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public PrintTrace() {
// Prints RVPredict traces in human-readable format.
public static void main(String[] args) {
CmdOptions options = new GetOptions(args).parse();
ZipTrackPrintEngine engine = new ZipTrackPrintEngine(options.path, true);
ZipTrackPrintEngine engine = new ZipTrackPrintEngine(options.parserType, options.path, options.map_file, true);
engine.analyzeTrace();
}
}
24 changes: 24 additions & 0 deletions src/print/cmd/CmdOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package print.cmd;

import print.parse.ParserType;

public class CmdOptions {
public String path;
public ParserType parserType;
public String map_file;

public CmdOptions() {
this.path = null;
this.map_file = null;
this.parserType = ParserType.RR;
}

public String toString(){
String str = "";
str += "path " + " = " + this.path + "\n";
str += "path to map file" + " = " + this.map_file + "\n";
str += "parserType " + " = " + this.parserType.toString() + "\n";
return str;
}

}
79 changes: 79 additions & 0 deletions src/print/cmd/GetOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package print.cmd;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;

import print.parse.ParserType;

public class GetOptions {

private static final Logger log = Logger.getLogger(GetOptions.class.getName());
private String[] args = null;
private Options options = new Options();

public GetOptions(String[] args) {
this.args = args;
options.addOption("h", "help", false, "generate this message");
options.addOption("f", "format", true, "format of the trace. Possible choices include rv, rr, std (Default : rr) ");
options.addOption("p", "path", true, "the path to the trace file/folder (Required)");
options.addOption("m", "map", true, "file path to dump the map file [mapping event ids to their descriptions] (Required)");

}

public CmdOptions parse() {
CommandLineParser parser = new DefaultParser();
CommandLine cmd = null;
CmdOptions cmdOpt = new CmdOptions();;

try {
cmd = parser.parse(options, args);
if (cmd.hasOption("h"))
help();

if (cmd.hasOption("f")) {
cmdOpt.parserType = ParserType.getType(cmd.getOptionValue("f")) ;
if (cmdOpt.parserType.isRV()) {
System.err.println("**Warning** - Provided file format is RV. RVPredict support is getting obsolete day-by-day. \nConsider using some other logger.\n");
}
}

if (cmd.hasOption("p")) {
cmdOpt.path = cmd.getOptionValue("p") ;
}
else {
log.log(Level.INFO, "MIssing path to trace file/folder");
help();
}

if (cmd.hasOption("m")) {
cmdOpt.map_file = cmd.getOptionValue("m") ;
}
else {
log.log(Level.INFO, "MIssing path to map file");
help();
}

} catch (ParseException e) {
help();
}

return cmdOpt;
}

private void help() {
HelpFormatter formater = new HelpFormatter();
formater.printHelp("Ziptrack-Print", options);
System.exit(0);
}

public static void main(String[] args) {
new GetOptions(args).parse();
}
}
43 changes: 43 additions & 0 deletions src/print/engine/Engine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package print.engine;

import print.parse.rr.ParseRoadRunner;
import print.parse.rv.parserv.ParseRVPredict;
import print.parse.std.ParseStandard;
import print.parse.ParserType;
import print.event.Event;

public abstract class Engine<E extends Event> {
protected ParserType parserType;
protected ParseRVPredict rvParser;//RV
protected ParseStandard stdParser; //STD
protected ParseRoadRunner rrParser; //RR
protected E handlerEvent;

public Engine(ParserType pType){
this.parserType = pType;
}

protected void initializeReader(String trace_folder) {
if(this.parserType.isRV()){
initializeReaderRV(trace_folder);
}
else if(this.parserType.isSTD()){
initializeReaderSTD(trace_folder);
}
else if(this.parserType.isRR()){
initializeReaderRR(trace_folder);
}
}

protected void initializeReaderRV(String trace_folder){
rvParser = new ParseRVPredict(trace_folder, null);
}

protected void initializeReaderSTD(String trace_file) {
stdParser = new ParseStandard(trace_file);
}

protected void initializeReaderRR(String trace_file) {
rrParser = new ParseRoadRunner(trace_file);
}
}
Loading

0 comments on commit 190323a

Please sign in to comment.