svf-tools 1.0.983 → 1.0.984

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.983",
3
+ "version": "1.0.984",
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": {
@@ -358,7 +358,7 @@ protected:
358
358
 
359
359
  protected:
360
360
  // there data should be shared with subclasses
361
- Map<std::string, std::function<void(const CallSite &)>> func_map;
361
+ Map<std::string, std::function<void(const CallICFGNode*)>> func_map;
362
362
  Set<const CallICFGNode*> checkpoints;
363
363
  Set<std::string> checkpoint_names;
364
364
  Map<const ICFGNode*, AbstractState>
@@ -963,10 +963,9 @@ void AEStat::performStat()
963
963
  void AbstractInterpretation::initExtFunMap()
964
964
  {
965
965
  #define SSE_FUNC_PROCESS(LLVM_NAME ,FUNC_NAME) \
966
- auto sse_##FUNC_NAME = [this](const CallSite &cs) { \
966
+ auto sse_##FUNC_NAME = [this](const CallICFGNode *callNode) { \
967
967
  /* run real ext function */ \
968
- const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>( \
969
- svfir->getICFG()->getICFGNode(cs.getInstruction())); \
968
+ const CallSite& cs = SVFUtil::getSVFCallSite(callNode); \
970
969
  AbstractState& as = getAbsStateFromTrace(callNode); \
971
970
  u32_t rhs_id = svfir->getValueNode(cs.getArgument(0)); \
972
971
  if (!as.inVarToValTable(rhs_id)) return; \
@@ -997,12 +996,10 @@ void AbstractInterpretation::initExtFunMap()
997
996
  SSE_FUNC_PROCESS(cosh, cosh);
998
997
  SSE_FUNC_PROCESS(tanh, tanh);
999
998
 
1000
- auto sse_svf_assert = [this](const CallSite &cs)
999
+ auto sse_svf_assert = [this](const CallICFGNode* callNode)
1001
1000
  {
1002
- const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(
1003
- svfir->getICFG()->getICFGNode(cs.getInstruction()));
1004
1001
  checkpoints.erase(callNode);
1005
- u32_t arg0 = svfir->getValueNode(cs.getArgument(0));
1002
+ u32_t arg0 = svfir->getValueNode(SVFUtil::getSVFCallSite(callNode).getArgument(0));
1006
1003
  AbstractState&as = getAbsStateFromTrace(callNode);
1007
1004
  as[arg0].getInterval().meet_with(IntervalValue(1, 1));
1008
1005
  if (as[arg0].getInterval().equals(IntervalValue(1, 1)))
@@ -1011,18 +1008,17 @@ void AbstractInterpretation::initExtFunMap()
1011
1008
  }
1012
1009
  else
1013
1010
  {
1014
- SVFUtil::errs() <<"svf_assert Fail. " << cs.getInstruction()->toString() << "\n";
1011
+ SVFUtil::errs() <<"svf_assert Fail. " << callNode->toString() << "\n";
1015
1012
  assert(false);
1016
1013
  }
1017
1014
  return;
1018
1015
  };
1019
1016
  func_map["svf_assert"] = sse_svf_assert;
1020
1017
 
1021
- auto svf_print = [&](const CallSite &cs)
1018
+ auto svf_print = [&](const CallICFGNode* callNode)
1022
1019
  {
1020
+ const CallSite& cs = SVFUtil::getSVFCallSite(callNode);
1023
1021
  if (cs.arg_size() < 2) return;
1024
- const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(
1025
- svfir->getICFG()->getICFGNode(cs.getInstruction()));
1026
1022
  AbstractState&as = getAbsStateFromTrace(callNode);
1027
1023
  u32_t num_id = svfir->getValueNode(cs.getArgument(0));
1028
1024
  std::string text = strRead(as, cs.getArgument(1));
@@ -1034,11 +1030,10 @@ void AbstractInterpretation::initExtFunMap()
1034
1030
  func_map["svf_print"] = svf_print;
1035
1031
 
1036
1032
 
1037
- auto sse_scanf = [&](const CallSite &cs)
1033
+ auto sse_scanf = [&](const CallICFGNode* callNode)
1038
1034
  {
1039
- const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(
1040
- svfir->getICFG()->getICFGNode(cs.getInstruction()));
1041
1035
  AbstractState& as = getAbsStateFromTrace(callNode);
1036
+ const CallSite& cs = SVFUtil::getSVFCallSite(callNode);
1042
1037
  //scanf("%d", &data);
1043
1038
  if (cs.arg_size() < 2) return;
1044
1039
 
@@ -1058,12 +1053,11 @@ void AbstractInterpretation::initExtFunMap()
1058
1053
  }
1059
1054
  }
1060
1055
  };
1061
- auto sse_fscanf = [&](const CallSite &cs)
1056
+ auto sse_fscanf = [&](const CallICFGNode* callNode)
1062
1057
  {
1063
1058
  //fscanf(stdin, "%d", &data);
1059
+ const CallSite& cs = SVFUtil::getSVFCallSite(callNode);
1064
1060
  if (cs.arg_size() < 3) return;
1065
- const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(
1066
- svfir->getICFG()->getICFGNode(cs.getInstruction()));
1067
1061
  AbstractState& as = getAbsStateFromTrace(callNode);
1068
1062
  u32_t dst_id = svfir->getValueNode(cs.getArgument(2));
1069
1063
  if (!as.inVarToAddrsTable(dst_id))
@@ -1090,11 +1084,10 @@ void AbstractInterpretation::initExtFunMap()
1090
1084
  func_map["__isoc99_sscanf"] = sse_scanf;
1091
1085
  func_map["vscanf"] = sse_scanf;
1092
1086
 
1093
- auto sse_fread = [&](const CallSite &cs)
1087
+ auto sse_fread = [&](const CallICFGNode *callNode)
1094
1088
  {
1089
+ const CallSite& cs = SVFUtil::getSVFCallSite(callNode);
1095
1090
  if (cs.arg_size() < 3) return;
1096
- const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(
1097
- svfir->getICFG()->getICFGNode(cs.getInstruction()));
1098
1091
  AbstractState&as = getAbsStateFromTrace(callNode);
1099
1092
  u32_t block_count_id = svfir->getValueNode(cs.getArgument(2));
1100
1093
  u32_t block_size_id = svfir->getValueNode(cs.getArgument(1));
@@ -1104,16 +1097,15 @@ void AbstractInterpretation::initExtFunMap()
1104
1097
  };
1105
1098
  func_map["fread"] = sse_fread;
1106
1099
 
1107
- auto sse_sprintf = [&](const CallSite &cs)
1100
+ auto sse_sprintf = [&](const CallICFGNode *callNode)
1108
1101
  {
1109
1102
  // printf is difficult to predict since it has no byte size arguments
1110
1103
  };
1111
1104
 
1112
- auto sse_snprintf = [&](const CallSite &cs)
1105
+ auto sse_snprintf = [&](const CallICFGNode *callNode)
1113
1106
  {
1107
+ const CallSite& cs = SVFUtil::getSVFCallSite(callNode);
1114
1108
  if (cs.arg_size() < 2) return;
1115
- const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(
1116
- svfir->getICFG()->getICFGNode(cs.getInstruction()));
1117
1109
  AbstractState&as = getAbsStateFromTrace(callNode);
1118
1110
  u32_t size_id = svfir->getValueNode(cs.getArgument(1));
1119
1111
  u32_t dst_id = svfir->getValueNode(cs.getArgument(0));
@@ -1149,13 +1141,12 @@ void AbstractInterpretation::initExtFunMap()
1149
1141
  func_map["_snwprintf"] = sse_snprintf;
1150
1142
 
1151
1143
 
1152
- auto sse_itoa = [&](const CallSite &cs)
1144
+ auto sse_itoa = [&](const CallICFGNode* callNode)
1153
1145
  {
1154
1146
  // itoa(num, ch, 10);
1155
1147
  // num: int, ch: char*, 10 is decimal
1148
+ const CallSite& cs = SVFUtil::getSVFCallSite(callNode);
1156
1149
  if (cs.arg_size() < 3) return;
1157
- const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(
1158
- svfir->getICFG()->getICFGNode(cs.getInstruction()));
1159
1150
  AbstractState&as = getAbsStateFromTrace(callNode);
1160
1151
  u32_t num_id = svfir->getValueNode(cs.getArgument(0));
1161
1152
 
@@ -1165,13 +1156,12 @@ void AbstractInterpretation::initExtFunMap()
1165
1156
  func_map["itoa"] = sse_itoa;
1166
1157
 
1167
1158
 
1168
- auto sse_strlen = [&](const CallSite &cs)
1159
+ auto sse_strlen = [&](const CallICFGNode *callNode)
1169
1160
  {
1170
1161
  // check the arg size
1162
+ const CallSite& cs = SVFUtil::getSVFCallSite(callNode);
1171
1163
  if (cs.arg_size() < 1) return;
1172
1164
  const SVFValue* strValue = cs.getArgument(0);
1173
- const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(
1174
- svfir->getICFG()->getICFGNode(cs.getInstruction()));
1175
1165
  AbstractState& as = getAbsStateFromTrace(callNode);
1176
1166
  NodeID value_id = svfir->getValueNode(strValue);
1177
1167
  u32_t lhsId = svfir->getValueNode(cs.getInstruction());
@@ -1227,12 +1217,11 @@ void AbstractInterpretation::initExtFunMap()
1227
1217
  func_map["strlen"] = sse_strlen;
1228
1218
  func_map["wcslen"] = sse_strlen;
1229
1219
 
1230
- auto sse_recv = [&](const CallSite &cs)
1220
+ auto sse_recv = [&](const CallICFGNode *callNode)
1231
1221
  {
1232
1222
  // recv(sockfd, buf, len, flags);
1223
+ const CallSite& cs = SVFUtil::getSVFCallSite(callNode);
1233
1224
  if (cs.arg_size() < 4) return;
1234
- const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(
1235
- svfir->getICFG()->getICFGNode(cs.getInstruction()));
1236
1225
  AbstractState&as = getAbsStateFromTrace(callNode);
1237
1226
  u32_t len_id = svfir->getValueNode(cs.getArgument(2));
1238
1227
  IntervalValue len = as[len_id].getInterval() - IntervalValue(1);
@@ -1241,10 +1230,9 @@ void AbstractInterpretation::initExtFunMap()
1241
1230
  };
1242
1231
  func_map["recv"] = sse_recv;
1243
1232
  func_map["__recv"] = sse_recv;
1244
- auto safe_bufaccess = [&](const CallSite &cs)
1233
+ auto safe_bufaccess = [&](const CallICFGNode *callNode)
1245
1234
  {
1246
- const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(
1247
- svfir->getICFG()->getICFGNode(cs.getInstruction()));
1235
+ const CallSite& cs = SVFUtil::getSVFCallSite(callNode);
1248
1236
  checkpoints.erase(callNode);
1249
1237
  //void SAFE_BUFACCESS(void* data, int size);
1250
1238
  if (cs.arg_size() < 2) return;
@@ -1280,10 +1268,9 @@ void AbstractInterpretation::initExtFunMap()
1280
1268
  };
1281
1269
  func_map["SAFE_BUFACCESS"] = safe_bufaccess;
1282
1270
 
1283
- auto unsafe_bufaccess = [&](const CallSite &cs)
1271
+ auto unsafe_bufaccess = [&](const CallICFGNode *callNode)
1284
1272
  {
1285
- const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(
1286
- svfir->getICFG()->getICFGNode(cs.getInstruction()));
1273
+ const CallSite& cs = SVFUtil::getSVFCallSite(callNode);
1287
1274
  checkpoints.erase(callNode);
1288
1275
  //void UNSAFE_BUFACCESS(void* data, int size);
1289
1276
  if (cs.arg_size() < 2) return;
@@ -1377,7 +1364,7 @@ void AbstractInterpretation::handleExtAPI(const CallICFGNode *call)
1377
1364
  {
1378
1365
  if (func_map.find(fun->getName()) != func_map.end())
1379
1366
  {
1380
- func_map[fun->getName()](cs);
1367
+ func_map[fun->getName()](call);
1381
1368
  }
1382
1369
  else
1383
1370
  {