svf-tools 1.0.1273 → 1.0.1275
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/svf/lib/Util/ExtAPI.cpp +45 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1275",
|
|
4
4
|
"description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
package/svf/lib/Util/ExtAPI.cpp
CHANGED
|
@@ -71,50 +71,68 @@ bool ExtAPI::setExtBcPath(const std::string& path)
|
|
|
71
71
|
return false;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
// Get
|
|
74
|
+
// Get stdout from a shell command.
|
|
75
|
+
// Return empty string if the command fails.
|
|
75
76
|
static std::string GetStdoutFromCommand(const std::string& command)
|
|
76
77
|
{
|
|
77
78
|
char buffer[128];
|
|
78
|
-
std::string result
|
|
79
|
-
|
|
79
|
+
std::string result;
|
|
80
|
+
|
|
80
81
|
FILE* pipe = popen(command.c_str(), "r");
|
|
81
82
|
if (!pipe)
|
|
83
|
+
return "";
|
|
84
|
+
|
|
85
|
+
while (fgets(buffer, sizeof(buffer), pipe) != nullptr)
|
|
82
86
|
{
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
// read till end of process:
|
|
86
|
-
while (!feof(pipe))
|
|
87
|
-
{
|
|
88
|
-
// use buffer to read and add to result
|
|
89
|
-
if (fgets(buffer, 128, pipe) != NULL)
|
|
90
|
-
result += buffer;
|
|
87
|
+
result += buffer;
|
|
91
88
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
|
|
90
|
+
int status = pclose(pipe);
|
|
91
|
+
if (status != 0)
|
|
92
|
+
return "";
|
|
93
|
+
|
|
94
|
+
// remove trailing newlines
|
|
95
|
+
result.erase(std::remove(result.begin(), result.end(), '\n'), result.end());
|
|
96
|
+
result.erase(std::remove(result.begin(), result.end(), '\r'), result.end());
|
|
97
|
+
|
|
95
98
|
return result;
|
|
96
99
|
}
|
|
97
100
|
|
|
98
|
-
// Get extapi.bc file path
|
|
101
|
+
// Get extapi.bc file path from SVF_DIR or npm installation
|
|
99
102
|
static std::string getFilePath(const std::string& path)
|
|
100
103
|
{
|
|
101
|
-
std::string bcFilePath
|
|
102
|
-
|
|
104
|
+
std::string bcFilePath;
|
|
105
|
+
|
|
106
|
+
if (path == "SVF_DIR")
|
|
103
107
|
{
|
|
104
|
-
char
|
|
105
|
-
if (svfdir)
|
|
106
|
-
|
|
108
|
+
const char* svfdir = getenv("SVF_DIR");
|
|
109
|
+
if (!svfdir)
|
|
110
|
+
return "";
|
|
111
|
+
|
|
112
|
+
bcFilePath = svfdir;
|
|
113
|
+
|
|
107
114
|
if (!bcFilePath.empty() && bcFilePath.back() != '/')
|
|
108
115
|
bcFilePath.push_back('/');
|
|
109
|
-
|
|
116
|
+
|
|
117
|
+
bcFilePath.append(SVF_BUILD_TYPE "-build/lib/extapi.bc");
|
|
110
118
|
}
|
|
111
|
-
else if (path
|
|
119
|
+
else if (path == "npm root")
|
|
112
120
|
{
|
|
113
|
-
|
|
114
|
-
|
|
121
|
+
// Check npm exists before calling `npm root`.
|
|
122
|
+
// If npm is missing, this command returns empty.
|
|
123
|
+
bcFilePath = GetStdoutFromCommand(
|
|
124
|
+
"command -v npm >/dev/null 2>&1 && npm root"
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
if (bcFilePath.empty())
|
|
128
|
+
return "";
|
|
129
|
+
|
|
130
|
+
if (bcFilePath.back() != '/')
|
|
115
131
|
bcFilePath.push_back('/');
|
|
132
|
+
|
|
116
133
|
bcFilePath.append("SVF/lib/extapi.bc");
|
|
117
134
|
}
|
|
135
|
+
|
|
118
136
|
return bcFilePath;
|
|
119
137
|
}
|
|
120
138
|
|
|
@@ -180,13 +198,14 @@ std::string ExtAPI::getExtBcPath()
|
|
|
180
198
|
}
|
|
181
199
|
|
|
182
200
|
// 5. Use npm root + standard relative path (for npm installations)
|
|
183
|
-
|
|
201
|
+
std::string npmPath = getFilePath("npm root");
|
|
202
|
+
if (setExtBcPath(npmPath))
|
|
184
203
|
{
|
|
185
204
|
return extBcPath;
|
|
186
205
|
}
|
|
187
206
|
else
|
|
188
207
|
{
|
|
189
|
-
candidatePaths.push_back(
|
|
208
|
+
candidatePaths.push_back(npmPath.empty() ? "npm root unavailable" : npmPath);
|
|
190
209
|
}
|
|
191
210
|
|
|
192
211
|
// 6. Use the directory of the loaded libSVFCore.so/.dylib + extapi.bc
|