Skip to content

Commit 02e5465

Browse files
committed
merge development into master
2 parents 248095e + b847156 commit 02e5465

88 files changed

Lines changed: 653 additions & 253 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@ If you are using PhASAR without the wish or expertise to contribute to its code
3333
Thanks for contributing to the PhASAR project.
3434

3535
`std::cout << "Thank you!\n";`
36+
37+
## Additional Notes for Student Assistants
38+
When implementing a new feature please name you feature branch according to the following naming scheme:
39+
40+
* `f-CamelCase`

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ COPY . /usr/src/phasar
1212

1313
RUN ./bootstrap_docker.sh
1414

15-
ENTRYPOINT [ "./build/phasar" ]
15+
ENTRYPOINT [ "./build/phasar-llvm/phasar-llvm" ]

include/phasar/Controller/AnalysisConfigurations.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ ANALYSIS_CONFIGURATIONS("IFDSUninitializedVariables", "ifds-uninit", IFDSUniniti
1515
ANALYSIS_CONFIGURATIONS("IFDSConstAnalysis", "ifds-const", IFDSConstAnalysis)
1616
ANALYSIS_CONFIGURATIONS("IFDSTaintAnalysis", "ifds-taint", IFDSTaintAnalysis)
1717
ANALYSIS_CONFIGURATIONS("IDETaintAnalysis", "ide-taint", IDETaintAnalysis)
18-
ANALYSIS_CONFIGURATIONS("IDETypeStateAnalysis", "ide-ts", IDETypeStateAnalysis)
18+
ANALYSIS_CONFIGURATIONS("IDECSTDIOTypeStateAnalysis", "ide-stdio-ts", IDECSTDIOTypeStateAnalysis)
19+
ANALYSIS_CONFIGURATIONS("IDEOpenSSLTypeStateAnalysis", "ide-openssl-ts", IDEOpenSSLTypeStateAnalysis)
1920
ANALYSIS_CONFIGURATIONS("IFDSTypeAnalysis", "ifds-ts", IFDSTypeAnalysis)
2021
ANALYSIS_CONFIGURATIONS("IFDSSolverTest", "ifds-solvertest", IFDSSolverTest)
2122
ANALYSIS_CONFIGURATIONS("IFDSLinearConstantAnalysis", "ifds-lca", IFDSLinearConstantAnalysis)

include/phasar/Controller/AnalysisController.h

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,33 @@
1515
#include <string>
1616
#include <vector>
1717

18+
#include <boost/filesystem.hpp>
19+
1820
#include <phasar/DB/ProjectIRDB.h>
1921
#include <phasar/PhasarLLVM/AnalysisStrategy/Strategies.h>
2022
#include <phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h>
2123
#include <phasar/PhasarLLVM/Pointer/LLVMPointsToInfo.h>
2224
#include <phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h>
2325
#include <phasar/PhasarLLVM/Utils/DataFlowAnalysisType.h>
26+
#include <phasar/Utils/EnumFlags.h>
2427

2528
namespace psr {
2629

30+
enum class AnalysisControllerEmitterOptions : uint32_t {
31+
None = 0,
32+
EmitIR = (1 << 0),
33+
EmitRawResults = (1 << 1),
34+
EmitTextReport = (1 << 2),
35+
EmitGraphicalReport = (1 << 3),
36+
EmitESGAsDot = (1 << 4),
37+
EmitTHAsText = (1 << 5),
38+
EmitTHAsDot = (1 << 6),
39+
EmitCGAsText = (1 << 7),
40+
EmitCGAsDot = (1 << 8),
41+
EmitPTAAsText = (1 << 9),
42+
EmitPTAAsDOT = (1 << 10)
43+
};
44+
2745
class AnalysisController {
2846
private:
2947
ProjectIRDB &IRDB;
@@ -34,21 +52,67 @@ class AnalysisController {
3452
std::vector<std::string> AnalysisConfigs;
3553
std::set<std::string> EntryPoints;
3654
[[maybe_unused]] AnalysisStrategy Strategy;
55+
AnalysisControllerEmitterOptions EmitterOptions =
56+
AnalysisControllerEmitterOptions::None;
57+
std::string ProjectID;
58+
std::string OutDirectory;
59+
boost::filesystem::path ResultDirectory;
3760

3861
void executeDemandDriven();
62+
3963
void executeIncremental();
64+
4065
void executeModuleWise();
66+
4167
void executeVariational();
68+
4269
void executeWholeProgram();
4370

71+
void emitRequestedHelperAnalysisResults();
72+
73+
template <typename T> void emitRequestedDataFlowResults(T &WPA) {
74+
if (EmitterOptions & AnalysisControllerEmitterOptions::EmitTextReport) {
75+
if (!ResultDirectory.empty()) {
76+
std::ofstream OFS(ResultDirectory.string() + "/psr-report.txt");
77+
WPA.emitTextReport(OFS);
78+
} else {
79+
WPA.emitTextReport();
80+
}
81+
}
82+
if (EmitterOptions &
83+
AnalysisControllerEmitterOptions::EmitGraphicalReport) {
84+
if (!ResultDirectory.empty()) {
85+
std::ofstream OFS(ResultDirectory.string() + "/psr-report.html");
86+
WPA.emitGraphicalReport(OFS);
87+
} else {
88+
WPA.emitGraphicalReport();
89+
}
90+
}
91+
if (EmitterOptions & AnalysisControllerEmitterOptions::EmitRawResults) {
92+
if (!ResultDirectory.empty()) {
93+
std::ofstream OFS(ResultDirectory.string() + "/psr-raw-results.txt");
94+
WPA.dumpResults(OFS);
95+
} else {
96+
WPA.dumpResults();
97+
}
98+
}
99+
}
100+
44101
public:
45102
AnalysisController(ProjectIRDB &IRDB,
46103
std::vector<DataFlowAnalysisType> DataFlowAnalyses,
47104
std::vector<std::string> AnalysisConfigs,
105+
PointerAnalysisType PTATy, CallGraphAnalysisType CGTy,
48106
std::set<std::string> EntryPoints,
49-
AnalysisStrategy Strategy);
107+
AnalysisStrategy Strategy,
108+
AnalysisControllerEmitterOptions EmitterOptions,
109+
std::string ProjectID = "default-phasar-project",
110+
std::string OutDirectory = "");
111+
50112
~AnalysisController() = default;
113+
51114
AnalysisController(const AnalysisController &) = delete;
115+
52116
AnalysisController(AnalysisController &&) = delete;
53117

54118
void executeAs(AnalysisStrategy Strategy);

include/phasar/DB/ProjectIRDB.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#ifndef PHASAR_DB_PROJECTIRDB_H_
1111
#define PHASAR_DB_PROJECTIRDB_H_
1212

13-
#include <initializer_list>
13+
#include <iostream>
1414
#include <map>
1515
#include <memory>
1616
#include <set>
@@ -146,7 +146,8 @@ class ProjectIRDB {
146146

147147
void print() const;
148148

149-
void emitPreprocessedIR(std::ostream &os, bool shortendIR) const;
149+
void emitPreprocessedIR(std::ostream &os = std::cout,
150+
bool shortendIR = true) const;
150151

151152
/**
152153
* Allows the (de-)serialization of Instructions, Arguments, GlobalValues and

include/phasar/PhasarLLVM/AnalysisStrategy/WholeProgramAnalysis.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,27 @@ class WholeProgramAnalysis {
128128

129129
void operator()() { solve(); }
130130

131-
void dumpResults(std::ostream &OS = std::cout) {}
131+
void dumpResults(std::ostream &OS = std::cout) {
132+
DataFlowSolver.dumpResults(OS);
133+
}
132134

133-
void emitTextualReport(std::ostream &OS) {}
135+
void emitTextReport(std::ostream &OS = std::cout) {
136+
DataFlowSolver.emitTextReport(OS);
137+
}
134138

135-
void emitGraphicalReport() {}
139+
void emitGraphicalReport(std::ostream &OS = std::cout) {
140+
DataFlowSolver.emitGraphicalReport(OS);
141+
}
136142

137143
void releaseAllHelperAnalyses() {
138144
releasePointerInformation();
139145
releaseCallGraph();
140146
releaseTypeHierarchy();
141147
}
142148

143-
TypeHierarchyTy *releasePointerInformation() { return PointerInfo.release(); }
149+
PointerAnalysisTy *releasePointerInformation() {
150+
return PointerInfo.release();
151+
}
144152

145153
CallGraphAnalysisTy *releaseCallGraph() { return CallGraph.release(); }
146154

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/EdgeFunctions/AllBottom.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <string>
2424

2525
#include <phasar/PhasarLLVM/DataFlowSolver/IfdsIde/EdgeFunction.h>
26-
#include <phasar/Utils/Macros.h>
2726

2827
namespace psr {
2928

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/FlowEdgeFunctionCache.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class FlowEdgeFunctionCache {
141141
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
142142
<< "(N) Call Stmt : " << problem.NtoString(callStmt));
143143
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
144-
<< "(M) Dest Mthd : " << problem.MtoString(destMthd));
144+
<< "(M) Dest Mthd : " << problem.FtoString(destMthd));
145145
auto key = std::tie(callStmt, destMthd);
146146
if (CallFlowFunctionCache.count(key)) {
147147
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
@@ -172,7 +172,7 @@ class FlowEdgeFunctionCache {
172172
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
173173
<< "(N) Call Site : " << problem.NtoString(callSite));
174174
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
175-
<< "(M) Callee : " << problem.MtoString(calleeMthd));
175+
<< "(M) Callee : " << problem.FtoString(calleeMthd));
176176
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
177177
<< "(N) Exit Stmt : " << problem.NtoString(exitStmt));
178178
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
@@ -213,7 +213,7 @@ class FlowEdgeFunctionCache {
213213
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG) << "(M) Callee's : ");
214214
for (auto callee : callees) {
215215
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
216-
<< " " << problem.MtoString(callee));
216+
<< " " << problem.FtoString(callee));
217217
}
218218
auto key = std::tie(callSite, retSite, callees);
219219
if (CallToRetFlowFunctionCache.count(key)) {
@@ -248,7 +248,7 @@ class FlowEdgeFunctionCache {
248248
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
249249
<< "(N) Call Stmt : " << problem.NtoString(callStmt));
250250
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
251-
<< "(M) Dest Mthd : " << problem.MtoString(destMthd));
251+
<< "(M) Dest Mthd : " << problem.FtoString(destMthd));
252252
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG) << ' ');
253253
auto ff = problem.getSummaryFlowFunction(callStmt, destMthd);
254254
return ff;
@@ -297,7 +297,7 @@ class FlowEdgeFunctionCache {
297297
<< "(D) Src Node : " << problem.DtoString(srcNode));
298298
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
299299
<< "(M) Dest Mthd : "
300-
<< problem.MtoString(destinationMethod));
300+
<< problem.FtoString(destinationMethod));
301301
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
302302
<< "(D) Dest Node : " << problem.DtoString(destNode));
303303
auto key = std::tie(callStmt, srcNode, destinationMethod, destNode);
@@ -329,7 +329,7 @@ class FlowEdgeFunctionCache {
329329
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
330330
<< "(N) Call Site : " << problem.NtoString(callSite));
331331
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
332-
<< "(M) Callee : " << problem.MtoString(calleeMethod));
332+
<< "(M) Callee : " << problem.FtoString(calleeMethod));
333333
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
334334
<< "(N) Exit Stmt : " << problem.NtoString(exitStmt));
335335
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
@@ -375,7 +375,7 @@ class FlowEdgeFunctionCache {
375375
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG) << "(M) Callee's : ");
376376
for (auto callee : callees) {
377377
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
378-
<< " " << problem.MtoString(callee));
378+
<< " " << problem.FtoString(callee));
379379
}
380380
auto key = std::tie(callSite, callNode, retSite, retSiteNode);
381381
if (CallToRetEdgeFunctionCache.count(key)) {

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/IDETabulationProblem.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef PHASAR_PHASARLLVM_IFDSIDE_IDETABULATIONPROBLEM_H_
1818
#define PHASAR_PHASARLLVM_IFDSIDE_IDETABULATIONPROBLEM_H_
1919

20+
#include <iostream>
2021
#include <memory>
2122
#include <set>
2223
#include <string>
@@ -51,13 +52,22 @@ class IDETabulationProblem : public IFDSTabulationProblem<N, D, M, T, V, I>,
5152
virtual std::shared_ptr<EdgeFunction<L>> allTopFunction() = 0;
5253
#pragma clang diagnostic push
5354
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
54-
virtual void emitTextReport(std::ostream &os,
55-
const SolverResults<N, D, L> &SR) {
56-
os << "No text report available!\n";
55+
virtual void emitTextReport(const SolverResults<N, D, L> &SR,
56+
std::ostream &OS = std::cout) {
57+
OS << "No text report available!\n";
58+
}
59+
#pragma clang diagnostic pop
60+
61+
#pragma clang diagnostic push
62+
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
63+
virtual void emitGraphicalReport(const SolverResults<N, D, L> &SR,
64+
std::ostream &OS = std::cout) {
65+
OS << "No graphical report available!\n";
5766
}
5867
#pragma clang diagnostic pop
5968
private:
6069
using IFDSTabulationProblem<N, D, M, T, V, I>::emitTextReport;
70+
using IFDSTabulationProblem<N, D, M, T, V, I>::emitGraphicalReport;
6171
};
6272

6373
} // namespace psr

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/IFDSIDESolverConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct IFDSIDESolverConfig {
3636
bool followReturnsPastSeeds = false;
3737
bool autoAddZero = true;
3838
bool computeValues = true;
39-
bool recordEdges = false;
39+
bool recordEdges = true;
4040
bool emitESG =
4141
(PhasarConfig::VariablesMap().count("emit-esg-as-dot"))
4242
? PhasarConfig::VariablesMap()["emit-esg-as-dot"].as<bool>()

0 commit comments

Comments
 (0)