Skip to content

Commit

Permalink
improved the reporting and added it to the runner
Browse files Browse the repository at this point in the history
  • Loading branch information
martinschaef committed Nov 9, 2015
1 parent cbaf0c5 commit 7095d89
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 15 deletions.
4 changes: 4 additions & 0 deletions runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def analyze_project(args, javac_commands):

if 'sourcepath' in switches:
bixie_command.extend(['-src', switches['sourcepath']])
else:
if 'java_files' in command:
src_string = (os.pathsep).join(command['java_files'])
bixie_command.extend(['-src', src_string])

if args.output_directory:
out_filename = os.path.join(args.output_directory, "report-%d.log" % i)
Expand Down
22 changes: 18 additions & 4 deletions src/main/java/bixie/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

package bixie;

import java.io.File;
import java.util.HashSet;
import java.util.Set;

import org.kohsuke.args4j.Option;

/**
Expand Down Expand Up @@ -65,10 +69,20 @@ public String getHtmlDir() {
/**
* Location of the source files for reporting.
*/
@Option(name = "-src", usage = "location of the source code directory")
private String srcDir=null;
public String getSrcDir() {
return srcDir;
@Option(name = "-src", usage = "List of all source files")
private String srcFilesString=null;
private Set<String> sourceFiles = null;
public Set<String> getSrcFilesString() {
if (srcFilesString!=null && sourceFiles==null) {
String[] files = srcFilesString.split(File.pathSeparator);
sourceFiles = new HashSet<String>();
if (files!=null) {
for (String s : files) {
sourceFiles.add(s);
}
}
}
return sourceFiles;
}


Expand Down
1 change: 1 addition & 0 deletions src/main/java/bixie/translation/GlobalsCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public static GlobalsCache v() {

public static void resetInstance() {
if (instance != null) {
TranslationHelpers.reset();
GlobalsCache.instance.procedureMap.clear();
GlobalsCache.instance.fieldMap.clear();
GlobalsCache.instance.unitLabelMap.clear();
Expand Down
44 changes: 33 additions & 11 deletions src/main/java/bixie/translation/soot/TranslationHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
package bixie.translation.soot;

import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import bixie.Options;
import bixie.boogie.ProgramFactory;
Expand Down Expand Up @@ -175,23 +177,43 @@ private static String getFileName(SootClass sc) {
}
File srcFile = new File(filename);

if (!srcFile.exists() && Options.v().getSrcDir()!=null) {
StringBuilder sb = new StringBuilder();
sb.append(Options.v().getSrcDir());
sb.append(File.separator);
sb.append(sc.getPackageName().replace(".", File.separator));
sb.append(File.separator);
sb.append(filename);
srcFile = new File(sb.toString());
if (!srcFile.exists()) {
Log.error("Source file not found: "+srcFile.getAbsolutePath() + ".\nCheck your settings.");
if (!srcFile.exists() && Options.v().getSrcFilesString()!=null) {
final String expectedName = sc.getPackageName().replace(".", File.separator) + File.separator + filename;
srcFile = findSourceFile(expectedName);
if (srcFile==null || !srcFile.exists()) {
Log.error("Source file not found: "+srcFile + ".\nCheck your settings.");
} else {
filename = srcFile.getAbsolutePath();
}
filename = srcFile.getAbsolutePath();
}

return filename;
}

public static void reset() {
sourceFiles.clear();
}

private static Map<String, File> sourceFiles = new HashMap<String,File>();

private static File findSourceFile(String expectedName) {
if (!sourceFiles.containsKey(expectedName)) {
File f = null;
for (String s: Options.v().getSrcFilesString()) {
if (s.contains(expectedName)) {
f = new File(s);
if (!f.exists()) {
throw new RuntimeException("Bug");
}
break;
}
}
sourceFiles.put(expectedName, f);
}
return sourceFiles.get(expectedName);
}


public static Statement createClonedAttribAssert() {
ProgramFactory pf = GlobalsCache.v().getPf();
Attribute[] res = new Attribute[] { pf
Expand Down

0 comments on commit 7095d89

Please sign in to comment.