svf-tools 1.0.487 → 1.0.488

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.
@@ -69,70 +69,64 @@ std::string ExtAPI::get_name(const SVFFunction *F)
69
69
  return funName;
70
70
  }
71
71
 
72
+ // Get environment variables $SVF_DIR and "npm root" through popen() method
72
73
  std::string GetStdoutFromCommand(std::string command)
73
74
  {
74
75
  char buffer[128];
75
76
  std::string result = "";
76
-
77
77
  // Open pipe to file
78
78
  FILE *pipe = popen(command.c_str(), "r");
79
79
  if (!pipe)
80
80
  {
81
81
  return "popen failed!";
82
82
  }
83
-
84
83
  // read till end of process:
85
84
  while (!feof(pipe))
86
85
  {
87
-
88
86
  // use buffer to read and add to result
89
87
  if (fgets(buffer, 128, pipe) != NULL)
90
88
  result += buffer;
91
89
  }
92
-
93
90
  pclose(pipe);
94
91
  // remove "\n"
95
92
  result.erase(remove(result.begin(), result.end(), '\n'), result.end());
96
93
  return result;
97
94
  }
98
95
 
99
- // Get ExtAPI.json
96
+ // Get ExtAPI.json file
100
97
  FILE *getJsonFile(std::string path)
101
98
  {
102
99
  std::string jsonFilePath = GetStdoutFromCommand(path);
103
100
  if (path.compare("npm root") == 0)
104
101
  {
105
- std::string json_path = "";
106
102
  int os_flag = 1;
103
+ // SVF installed via npm needs to determine the type of operating system, otherwise the ExtAPI.json path may not be found
104
+ // Linux os
107
105
  #ifdef linux
108
106
  os_flag = 0;
109
- json_path = "/svf-lib/SVF-linux";
107
+ jsonFilePath.append("/svf-lib/SVF-linux");
110
108
  #endif
109
+ // Mac os
111
110
  if (os_flag == 1)
112
111
  {
113
- json_path = "/svf-lib/SVF-osx";
112
+ jsonFilePath.append("/svf-lib/SVF-osx");
114
113
  }
115
- jsonFilePath.append(json_path);
116
114
  }
117
115
  jsonFilePath.append(EXTAPI_JSON_PATH);
118
116
  FILE *file = nullptr;
119
117
  file = fopen(jsonFilePath.c_str(), "r");
120
- if (file != nullptr)
121
- {
122
- return file;
123
- }
124
- else
125
- {
126
- return nullptr;
127
- }
118
+ return file;
128
119
  }
129
120
 
130
121
  // Get specifications of external functions in ExtAPI.json file
131
122
  cJSON *ExtAPI::get_FunJson(const std::string funName)
132
123
  {
133
-
134
124
  if (!root)
135
125
  {
126
+ // Three ways to get ExtAPI.json path
127
+ // 1. default path(get ExtAPI.json path from Util/config.h)
128
+ // 2. from $SVF_DIR
129
+ // 3. from "npm root"(If SVF is installed via npm)
136
130
  std::string jsonFilePath = PROJECT_PATH;
137
131
  jsonFilePath.append(EXTAPI_JSON_PATH);
138
132
  // open file
@@ -146,7 +140,7 @@ cJSON *ExtAPI::get_FunJson(const std::string funName)
146
140
  file = getJsonFile("npm root");
147
141
  if (file == nullptr)
148
142
  {
149
- assert(false && "Open Json file fails!");
143
+ assert(false && "Open ExtAPI.json file fails!");
150
144
  return nullptr;
151
145
  }
152
146
  }
@@ -164,7 +158,7 @@ cJSON *ExtAPI::get_FunJson(const std::string funName)
164
158
  u32_t size = fread(jsonStr, sizeof(char), fileSize, file);
165
159
  if (size == 0)
166
160
  {
167
- assert("read Json file fails!");
161
+ assert(false && "Read ExtAPI.json file fails!");
168
162
  return nullptr;
169
163
  }
170
164
  fclose(file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.487",
3
+ "version": "1.0.488",
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": {