Skip to content

Commit b847156

Browse files
committed
added more detailed output flags
1 parent ac4afcc commit b847156

36 files changed

Lines changed: 315 additions & 115 deletions

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: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
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>
@@ -52,6 +54,9 @@ class AnalysisController {
5254
[[maybe_unused]] AnalysisStrategy Strategy;
5355
AnalysisControllerEmitterOptions EmitterOptions =
5456
AnalysisControllerEmitterOptions::None;
57+
std::string ProjectID;
58+
std::string OutDirectory;
59+
boost::filesystem::path ResultDirectory;
5560

5661
void executeDemandDriven();
5762

@@ -63,16 +68,33 @@ class AnalysisController {
6368

6469
void executeWholeProgram();
6570

66-
template <typename T> void emitRequestedResults(T &WPA) {
71+
void emitRequestedHelperAnalysisResults();
72+
73+
template <typename T> void emitRequestedDataFlowResults(T &WPA) {
6774
if (EmitterOptions & AnalysisControllerEmitterOptions::EmitTextReport) {
68-
WPA.emitTextReport();
75+
if (!ResultDirectory.empty()) {
76+
std::ofstream OFS(ResultDirectory.string() + "/psr-report.txt");
77+
WPA.emitTextReport(OFS);
78+
} else {
79+
WPA.emitTextReport();
80+
}
6981
}
7082
if (EmitterOptions &
7183
AnalysisControllerEmitterOptions::EmitGraphicalReport) {
72-
WPA.emitGraphicalReport();
84+
if (!ResultDirectory.empty()) {
85+
std::ofstream OFS(ResultDirectory.string() + "/psr-report.html");
86+
WPA.emitGraphicalReport(OFS);
87+
} else {
88+
WPA.emitGraphicalReport();
89+
}
7390
}
7491
if (EmitterOptions & AnalysisControllerEmitterOptions::EmitRawResults) {
75-
WPA.dumpResults();
92+
if (!ResultDirectory.empty()) {
93+
std::ofstream OFS(ResultDirectory.string() + "/psr-raw-results.txt");
94+
WPA.dumpResults(OFS);
95+
} else {
96+
WPA.dumpResults();
97+
}
7698
}
7799
}
78100

@@ -83,7 +105,9 @@ class AnalysisController {
83105
PointerAnalysisType PTATy, CallGraphAnalysisType CGTy,
84106
std::set<std::string> EntryPoints,
85107
AnalysisStrategy Strategy,
86-
AnalysisControllerEmitterOptions EmitterOptions);
108+
AnalysisControllerEmitterOptions EmitterOptions,
109+
std::string ProjectID = "default-phasar-project",
110+
std::string OutDirectory = "");
87111

88112
~AnalysisController() = default;
89113

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/Problems/TypeStateDescriptions/OpenSSLEVPKeyDerivationTypeStateDescription.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,38 @@ class OpenSSLEVPKeyDerivationTypeStateDescription
6161

6262
static const std::map<std::string, std::set<int>>
6363
OpenSSLEVPKeyDerivationFuncs;
64+
6465
// delta matrix to implement the state machine's delta function
6566
static const OpenSSLEVPKeyDerivationState delta[6][7];
67+
6668
OpenSSLEVPKeyDerivationToken funcNameToToken(const std::string &F) const;
6769

6870
public:
6971
bool isFactoryFunction(const std::string &F) const override;
72+
7073
bool isConsumingFunction(const std::string &F) const override;
74+
7175
bool isAPIFunction(const std::string &F) const override;
76+
7277
TypeStateDescription::State
7378
getNextState(std::string Tok, TypeStateDescription::State S) const override;
79+
7480
std::string getTypeNameOfInterest() const override;
81+
7582
std::set<int> getConsumerParamIdx(const std::string &F) const override;
83+
7684
std::set<int> getFactoryParamIdx(const std::string &F) const override;
85+
7786
std::string stateToString(TypeStateDescription::State S) const override;
87+
7888
TypeStateDescription::State bottom() const override;
89+
7990
TypeStateDescription::State top() const override;
91+
8092
TypeStateDescription::State uninit() const override;
93+
8194
TypeStateDescription::State start() const override;
95+
8296
TypeStateDescription::State error() const override;
8397
};
8498

include/phasar/PhasarLLVM/Utils/DOTGraph.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919

2020
#include <iosfwd>
2121
#include <map>
22-
#include <phasar/Utils/Macros.h>
2322
#include <set>
2423
#include <string>
2524

25+
#include <phasar/Utils/Utilities.h>
26+
2627
namespace psr {
2728

2829
class DOTConfig {

include/phasar/PhasarLLVM/Utils/DataFlowAnalysisType.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ DATA_FLOW_ANALYSIS_TYPES("IFDSUninitializedVariables", "ifds-uninit", IFDSUninit
1515
DATA_FLOW_ANALYSIS_TYPES("IFDSConstAnalysis", "ifds-const", IFDSConstAnalysis)
1616
DATA_FLOW_ANALYSIS_TYPES("IFDSTaintAnalysis", "ifds-taint", IFDSTaintAnalysis)
1717
DATA_FLOW_ANALYSIS_TYPES("IDETaintAnalysis", "ide-taint", IDETaintAnalysis)
18-
DATA_FLOW_ANALYSIS_TYPES("IDETypeStateAnalysis", "ide-ts", IDETypeStateAnalysis)
19-
DATA_FLOW_ANALYSIS_TYPES("IFDSTypeAnalysis", "ifds-ts", IFDSTypeAnalysis)
18+
DATA_FLOW_ANALYSIS_TYPES("IFDSTypeAnalysis", "ifds-type", IFDSTypeAnalysis)
19+
DATA_FLOW_ANALYSIS_TYPES("IDEOpenSSLTypeStateAnalysis", "ide-openssl-ts", IDEOpenSSLTypeStateAnalysis)
2020
DATA_FLOW_ANALYSIS_TYPES("IFDSSolverTest", "ifds-solvertest", IFDSSolverTest)
2121
DATA_FLOW_ANALYSIS_TYPES("IFDSLinearConstantAnalysis", "ifds-lca", IFDSLinearConstantAnalysis)
2222
DATA_FLOW_ANALYSIS_TYPES("IFDSFieldSensTaintAnalysis", "ifds-fstaint", IFDSFieldSensTaintAnalysis)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/******************************************************************************
2+
* Copyright (c) 2020 Philipp Schubert.
3+
* All rights reserved. This program and the accompanying materials are made
4+
* available under the terms of LICENSE.txt.
5+
*
6+
* Contributors:
7+
* Philipp Schubert and others
8+
*****************************************************************************/
9+
10+
#ifndef IO_FORMAT_TYPES
11+
#define IO_FORMAT_TYPES(NAME, CMDFLAG, TYPE)
12+
#endif
13+
14+
IO_FORMAT_TYPES("JSON", "json", JSON)
15+
IO_FORMAT_TYPES("SARIF", "sarif", SARIF)
16+
IO_FORMAT_TYPES("None", "none", None)
17+
18+
#undef IO_FORMAT_TYPES
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/******************************************************************************
2+
* Copyright (c) 2020 Philipp Schubert.
3+
* All rights reserved. This program and the accompanying materials are made
4+
* available under the terms of LICENSE.txt.
5+
*
6+
* Contributors:
7+
* Philipp Schubert and others
8+
*****************************************************************************/
9+
10+
#ifndef PHASAR_PHASARLLVM_UTILS_IOFORMAT_H_
11+
#define PHASAR_PHASARLLVM_UTILS_IOFORMAT_H_
12+
13+
#include <iosfwd>
14+
#include <string>
15+
16+
namespace psr {
17+
18+
enum class IOFormat {
19+
#define IO_FORMAT_TYPES(NAME, CMDFLAG, TYPE) TYPE,
20+
#include <phasar/PhasarLLVM/Utils/IOFormat.def>
21+
};
22+
23+
std::string to_string(const IOFormat &D);
24+
25+
IOFormat to_IOFormat(const std::string &S);
26+
27+
std::ostream &operator<<(std::ostream &os, const IOFormat &D);
28+
29+
} // namespace psr
30+
31+
#endif

include/phasar/Utils/LLVMShorthands.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
#ifndef PHASAR_UTILS_LLVMSHORTHANDS_H_
1818
#define PHASAR_UTILS_LLVMSHORTHANDS_H_
1919

20-
#include <phasar/Utils/Macros.h>
2120
#include <string>
2221
#include <vector>
2322

23+
#include <phasar/Utils/Utilities.h>
24+
2425
namespace llvm {
2526
class Value;
2627
class FunctionType;
Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,21 @@
77
* Philipp Schubert and others
88
*****************************************************************************/
99

10-
#ifndef PHASAR_UTILS_MACROS_H_
11-
#define PHASAR_UTILS_MACROS_H_
10+
#ifndef PHASAR_UTILS_UTILITIES_H_
11+
#define PHASAR_UTILS_UTILITIES_H_
1212

1313
#include <iosfwd>
1414
#include <set>
1515
#include <string>
1616
#include <vector>
17-
// Should include <iostream> due to the Macros using std::cerr
1817

1918
namespace llvm {
2019
class Type;
2120
} // namespace llvm
2221

2322
namespace psr {
2423

25-
#define MYDEBUG
26-
27-
#define HEREANDNOW \
28-
std::cerr << "file: " << __FILE__ << " line: " << __LINE__ \
29-
<< " function: " << __func__ << std::endl;
30-
31-
#define DIE_HARD exit(-1);
32-
33-
#define UNRECOVERABLE_CXX_ERROR_COND(BOOL, STRING) \
34-
if (!BOOL) { \
35-
HEREANDNOW; \
36-
std::cerr << STRING << std::endl; \
37-
exit(-1); \
38-
}
39-
40-
#define UNRECOVERABLE_CXX_ERROR_UNCOND(STRING) \
41-
HEREANDNOW; \
42-
std::cerr << STRING << std::endl; \
43-
exit(-1);
24+
std::string createTimeStamp();
4425

4526
std::string cxx_demangle(const std::string &mangled_name);
4627

0 commit comments

Comments
 (0)