Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config option to disable incremental analysis #51

Merged
merged 1 commit into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private static void addAnalysis() {
magpieServer.addAnalysis(analysis, language);

// add HTTP server for showing CFGs, only if the option is specified in the configuration
if (gobpieConfiguration.getshowCfg() != null && gobpieConfiguration.getshowCfg()) {
if (gobpieConfiguration.getShowCfg()) {
String httpServerAddress = new GobPieHTTPServer(goblintService).start();
magpieServer.addHttpServer(httpServerAddress);
magpieServer.addCommand("showcfg", new ShowCFGCommand(httpServerAddress));
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/analysis/GoblintAnalysis.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package analysis;

import api.GoblintService;
import api.messages.GoblintAnalysisResult;
import api.messages.GoblintFunctionsResult;
import api.messages.GoblintMessagesResult;
import api.messages.Params;
import api.messages.*;
import com.ibm.wala.classLoader.Module;
import goblintserver.GoblintServer;
import gobpie.GobPieConfiguration;
Expand Down Expand Up @@ -189,7 +186,7 @@ private void preAnalyse() {
* @throws GobPieException in case the analysis was aborted or returned a VerifyError.
*/
private CompletableFuture<Collection<AnalysisResult>> reanalyse() {
return goblintService.analyze(new Params())
return goblintService.analyze(new AnalyzeParams(!gobpieConfiguration.useIncrementalAnalysis()))
.thenCompose(this::getComposedAnalysisResults);
}

Expand All @@ -215,7 +212,7 @@ private CompletableFuture<Collection<AnalysisResult>> getComposedAnalysisResults
didAnalysisNotSucceed(analysisResult);
// Get warning messages
CompletableFuture<List<GoblintMessagesResult>> messagesCompletableFuture = goblintService.messages();
if (gobpieConfiguration.getshowCfg() == null || !gobpieConfiguration.getshowCfg()) {
if (!gobpieConfiguration.getShowCfg()) {
return messagesCompletableFuture.thenApply(this::convertMessagesFromJson);
}
// Get list of functions
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/api/GoblintService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface GoblintService {
// request: {"jsonrpc":"2.0","id":0,"method":"analyze","params":{}}
// response: {"id":0,"jsonrpc":"2.0","result":{"status":["Success"]}}
@JsonRequest
CompletableFuture<GoblintAnalysisResult> analyze(Params params);
CompletableFuture<GoblintAnalysisResult> analyze(AnalyzeParams params);

// request: {"jsonrpc":"2.0","id":0,"method":"messages"}
// response: {"id":0,"jsonrpc":"2.0","result":[{"tags":[{"Category":["Race"]}], ... }]}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/api/messages/AnalyzeParams.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package api.messages;

public class AnalyzeParams {

boolean reset;

public AnalyzeParams(boolean reset) {
this.reset = reset;
}

}
11 changes: 8 additions & 3 deletions src/main/java/gobpie/GobPieConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
* @author Karoliine Holter
* @since 0.0.2
*/

@SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"})
public class GobPieConfiguration {

private String goblintConf;
private String[] preAnalyzeCommand;
private Boolean showCfg;
private boolean showCfg = false;
private boolean incrementalAnalysis = true;

public String getGoblintConf() {
return this.goblintConf;
Expand All @@ -24,8 +25,12 @@ public String[] getPreAnalyzeCommand() {
return this.preAnalyzeCommand;
}

public Boolean getshowCfg() {
public boolean getShowCfg() {
return this.showCfg;
}

public boolean useIncrementalAnalysis() {
return incrementalAnalysis;
}

}