svf-lib 1.0.1928 → 1.0.1929

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.
Binary file
Binary file
@@ -62,7 +62,9 @@ public:
62
62
 
63
63
  public:
64
64
  /// default constructor
65
- AbstractState() {}
65
+ AbstractState()
66
+ {
67
+ }
66
68
 
67
69
  AbstractState(VarToAbsValMap&_varToValMap, LocToAbsValMap&_locToValMap) : _varToAbsVal(_varToValMap),
68
70
  _locToAbsVal(_locToValMap) {}
@@ -182,6 +184,20 @@ public:
182
184
  return _varToAbsVal.at(varId);
183
185
  }
184
186
 
187
+ /// get memory addresses of variable
188
+ AbstractValue &getAddrs(u32_t id)
189
+ {
190
+ if (_varToAbsVal.find(id)!= _varToAbsVal.end())
191
+ {
192
+ return _varToAbsVal[id];
193
+ }
194
+ else
195
+ {
196
+ _varToAbsVal[id] = AddressValue();
197
+ return _varToAbsVal[id];
198
+ }
199
+ }
200
+
185
201
  /// whether the variable is in varToAddrs table
186
202
  inline bool inVarToAddrsTable(u32_t id) const
187
203
  {
@@ -436,314 +452,7 @@ protected:
436
452
 
437
453
  };
438
454
 
439
- class SparseAbstractState : public AbstractState
440
- {
441
- friend class SVFIR2AbsState;
442
- friend class RelationSolver;
443
-
444
- public:
445
- static SparseAbstractState globalES;
446
-
447
- public:
448
- /// default constructor
449
- SparseAbstractState() : AbstractState() {}
450
-
451
- SparseAbstractState(VarToAbsValMap&_varToValMap, LocToAbsValMap&_locToValMap) : AbstractState(_varToValMap, _locToValMap) {}
452
-
453
- /// copy constructor
454
- SparseAbstractState(const SparseAbstractState&rhs) : AbstractState(rhs)
455
- {
456
-
457
- }
458
-
459
- virtual ~SparseAbstractState() = default;
460
-
461
- SparseAbstractState&operator=(const SparseAbstractState&rhs)
462
- {
463
- AbstractState::operator=(rhs);
464
- return *this;
465
- }
466
-
467
- virtual void printExprValues(std::ostream &oss) const;
468
-
469
- /// move constructor
470
- SparseAbstractState(SparseAbstractState&&rhs) : AbstractState(std::move(rhs))
471
- {
472
-
473
- }
474
-
475
- /// operator= move constructor
476
- SparseAbstractState&operator=(SparseAbstractState&&rhs)
477
- {
478
- AbstractState::operator=(std::move(rhs));
479
- return *this;
480
- }
481
-
482
- public:
483
-
484
- /// get memory addresses of variable
485
- AbstractValue &getAddrs(u32_t id)
486
- {
487
- if (_varToAbsVal.find(id)!= _varToAbsVal.end())
488
- {
489
- return _varToAbsVal[id];
490
- }
491
- else if (globalES._varToAbsVal.find(id)!= globalES._varToAbsVal.end())
492
- {
493
- return globalES._varToAbsVal[id];
494
- }
495
- else
496
- {
497
- globalES._varToAbsVal[id] = AddressValue();
498
- return globalES._varToAbsVal[id];
499
- }
500
- }
501
-
502
- /// get abstract value of variable
503
- inline AbstractValue &operator[](u32_t varId)
504
- {
505
- auto localIt = _varToAbsVal.find(varId);
506
- if(localIt != _varToAbsVal.end())
507
- return localIt->second;
508
- else
509
- {
510
- return globalES._varToAbsVal[varId];
511
- }
512
- }
513
-
514
- /// whether the variable is in varToAddrs table
515
- inline bool inVarToAddrsTable(u32_t id) const
516
- {
517
- if (_varToAbsVal.find(id)!= _varToAbsVal.end())
518
- {
519
- if (_varToAbsVal.at(id).isAddr())
520
- {
521
- return true;
522
- }
523
- else
524
- {
525
- return false;
526
- }
527
- }
528
- else if (globalES._varToAbsVal.find(id)!= globalES._varToAbsVal.end())
529
- {
530
- if (globalES._varToAbsVal[id].isAddr())
531
- {
532
- return true;
533
- }
534
- else
535
- {
536
- return false;
537
- }
538
- }
539
- else
540
- {
541
- return false;
542
- }
543
- }
544
-
545
- /// whether the variable is in varToVal table
546
- inline bool inVarToValTable(u32_t id) const
547
- {
548
- if (_varToAbsVal.find(id)!= _varToAbsVal.end())
549
- {
550
- if (_varToAbsVal.at(id).isInterval())
551
- {
552
- return true;
553
- }
554
- else
555
- {
556
- return false;
557
- }
558
- }
559
- else if (globalES._varToAbsVal.find(id)!= globalES._varToAbsVal.end())
560
- {
561
- if (globalES._varToAbsVal[id].isInterval())
562
- {
563
- return true;
564
- }
565
- else
566
- {
567
- return false;
568
- }
569
- }
570
- else
571
- {
572
- return false;
573
- }
574
- }
575
-
576
- /// whether the memory address stores memory addresses
577
- inline bool inLocToAddrsTable(u32_t id) const
578
- {
579
- if (_locToAbsVal.find(id)!= _locToAbsVal.end())
580
- {
581
- if (_locToAbsVal.at(id).isAddr())
582
- {
583
- return true;
584
- }
585
- else
586
- {
587
- return false;
588
- }
589
- }
590
- else if (globalES._locToAbsVal.find(id)!= globalES._locToAbsVal.end())
591
- {
592
- if (globalES._locToAbsVal[id].isAddr())
593
- {
594
- return true;
595
- }
596
- else
597
- {
598
- return false;
599
- }
600
- }
601
- else
602
- {
603
- return false;
604
- }
605
- }
606
-
607
- /// whether the memory address stores abstract value
608
- inline bool inLocToValTable(u32_t id) const
609
- {
610
- if (_locToAbsVal.find(id)!= _locToAbsVal.end())
611
- {
612
- if (_locToAbsVal.at(id).isInterval())
613
- {
614
- return true;
615
- }
616
- else
617
- {
618
- return false;
619
- }
620
- }
621
- else if (globalES._locToAbsVal.find(id)!= globalES._locToAbsVal.end())
622
- {
623
- if (globalES._locToAbsVal[id].isInterval())
624
- {
625
- return true;
626
- }
627
- else
628
- {
629
- return false;
630
- }
631
- }
632
- else
633
- {
634
- return false;
635
- }
636
- }
637
-
638
- inline bool inLocalLocToValTable(u32_t id) const
639
- {
640
- if (_locToAbsVal.find(id)!= _locToAbsVal.end())
641
- {
642
- return _locToAbsVal.at(id).isInterval();
643
- }
644
- else
645
- return false;
646
- }
647
-
648
- inline bool inLocalLocToAddrsTable(u32_t id) const
649
- {
650
- if (_locToAbsVal.find(id)!= _locToAbsVal.end())
651
- {
652
- return _locToAbsVal.at(id).isAddr();
653
- }
654
- else
655
- return false;
656
- }
657
-
658
- public:
659
-
660
- inline void cpyItvToLocal(u32_t varId)
661
- {
662
- auto localIt = _varToAbsVal.find(varId);
663
- // local already have varId
664
- if (localIt != _varToAbsVal.end()) return;
665
- auto globIt = globalES._varToAbsVal.find(varId);
666
- if (globIt != globalES._varToAbsVal.end())
667
- {
668
- _varToAbsVal[varId] = globIt->second;
669
- }
670
- }
671
-
672
- /// domain widen with other, and return the widened domain
673
- SparseAbstractState widening(const SparseAbstractState&other);
674
-
675
- /// domain narrow with other, and return the narrowed domain
676
- SparseAbstractState narrowing(const SparseAbstractState&other);
677
-
678
- /// domain widen with other, important! other widen this.
679
- void widenWith(const SparseAbstractState&other);
680
-
681
- /// domain join with other, important! other widen this.
682
- void joinWith(const SparseAbstractState&other);
683
-
684
- /// domain narrow with other, important! other widen this.
685
- void narrowWith(const SparseAbstractState&other);
686
-
687
- /// domain meet with other, important! other widen this.
688
- void meetWith(const SparseAbstractState&other);
689
-
690
- u32_t hash() const;
691
-
692
- public:
693
-
694
- inline AbstractValue &load(u32_t addr)
695
- {
696
- assert(isVirtualMemAddress(addr) && "not virtual address?");
697
- u32_t objId = getInternalID(addr);
698
- auto it = _locToAbsVal.find(objId);
699
- if(it != _locToAbsVal.end())
700
- return it->second;
701
- else
702
- {
703
- auto globIt = globalES._locToAbsVal.find(objId);
704
- if(globIt != globalES._locToAbsVal.end())
705
- return globIt->second;
706
- else
707
- {
708
- return globalES._locToAbsVal[objId];
709
- }
710
-
711
- }
712
- }
713
-
714
- bool equals(const SparseAbstractState&other) const;
715
-
716
- bool operator==(const SparseAbstractState&rhs) const
717
- {
718
- return eqVarToValMap(_varToAbsVal, rhs._varToAbsVal) &&
719
- eqVarToValMap(_locToAbsVal, rhs._locToAbsVal);
720
- }
721
-
722
- bool operator!=(const SparseAbstractState&rhs) const
723
- {
724
- return !(*this == rhs);
725
- }
726
-
727
- bool operator<(const SparseAbstractState&rhs) const
728
- {
729
- return !(*this >= rhs);
730
- }
731
-
732
-
733
- bool operator>=(const SparseAbstractState&rhs) const
734
- {
735
- return geqVarToValMap(_varToAbsVal, rhs.getVarToVal()) && geqVarToValMap(_locToAbsVal, rhs._locToAbsVal);
736
- }
737
- };
738
455
  }
739
456
 
740
- template<>
741
- struct std::hash<SVF::SparseAbstractState>
742
- {
743
- size_t operator()(const SVF::SparseAbstractState&exeState) const
744
- {
745
- return exeState.hash();
746
- }
747
- };
748
457
 
749
458
  #endif //Z3_EXAMPLE_INTERVAL_DOMAIN_H
@@ -143,10 +143,10 @@ protected:
143
143
  /**
144
144
  * Check if execution state exist by merging states of predecessor nodes
145
145
  *
146
- * @param node The ICFGNode to analyse
146
+ * @param block The ICFGNode to analyse
147
147
  * @return if this node has preceding execution state
148
148
  */
149
- bool hasInEdgesES(const ICFGNode* node);
149
+ bool propogateAbsStateToCurNode(const ICFGNode* block);
150
150
 
151
151
  /**
152
152
  * Check if execution state exist at the branch edge
@@ -154,7 +154,7 @@ protected:
154
154
  * @param intraEdge the edge from CmpStmt to the next node
155
155
  * @return if this edge is feasible
156
156
  */
157
- bool hasBranchES(const IntraCFGEdge* intraEdge, SparseAbstractState& es);
157
+ bool hasBranchES(const IntraCFGEdge* intraEdge, AbstractState& es);
158
158
 
159
159
  /**
160
160
  * handle instructions in ICFGNode
@@ -220,7 +220,7 @@ protected:
220
220
  * @return if this ICFGNode has preceding execution state
221
221
  */
222
222
  bool hasCmpBranchES(const CmpStmt* cmpStmt, s64_t succ,
223
- SparseAbstractState& es);
223
+ AbstractState& es);
224
224
 
225
225
  /**
226
226
  * Check if this SwitchInst and succ are satisfiable to the execution state.
@@ -230,7 +230,7 @@ protected:
230
230
  * @return if this ICFGNode has preceding execution state
231
231
  */
232
232
  bool hasSwitchBranchES(const SVFVar* var, s64_t succ,
233
- SparseAbstractState& es);
233
+ AbstractState& es);
234
234
 
235
235
 
236
236
  /**
@@ -374,9 +374,9 @@ private:
374
374
 
375
375
  // helper functions in handleCycle
376
376
  bool widenFixpointPass(const ICFGNode* cycle_head,
377
- SparseAbstractState& pre_es);
377
+ AbstractState& pre_es);
378
378
  bool narrowFixpointPass(const ICFGNode* cycle_head,
379
- SparseAbstractState& pre_es);
379
+ AbstractState& pre_es);
380
380
 
381
381
  protected:
382
382
  // there data should be shared with subclasses
@@ -385,8 +385,8 @@ protected:
385
385
  Set<std::string> _checkpoint_names;
386
386
 
387
387
  private:
388
- Map<const ICFGNode*, SparseAbstractState> _preAbstractTrace;
389
- Map<const ICFGNode*, SparseAbstractState> _postAbstractTrace;
388
+ Map<const ICFGNode*, AbstractState> _preAbstractTrace;
389
+ Map<const ICFGNode*, AbstractState> _postAbstractTrace;
390
390
  std::string _moduleName;
391
391
  };
392
392
  }
@@ -46,12 +46,12 @@ public:
46
46
  public:
47
47
  SVFIR2AbsState(SVFIR *ir) : _svfir(ir) {}
48
48
 
49
- void setEs(const SparseAbstractState&es)
49
+ void setEs(const AbstractState&es)
50
50
  {
51
51
  _es = es;
52
52
  }
53
53
 
54
- SparseAbstractState& getEs()
54
+ AbstractState& getEs()
55
55
  {
56
56
  return _es;
57
57
  }
@@ -66,9 +66,9 @@ public:
66
66
  return _relEs;
67
67
  }
68
68
 
69
- void widenAddrs(SparseAbstractState&lhs, const SparseAbstractState&rhs);
69
+ void widenAddrs(AbstractState&lhs, const AbstractState&rhs);
70
70
 
71
- void narrowAddrs(SparseAbstractState&lhs, const SparseAbstractState&rhs);
71
+ void narrowAddrs(AbstractState&lhs, const AbstractState&rhs);
72
72
 
73
73
  /// Return the field address given a pointer points to a struct object and an offset
74
74
  AbstractValue getGepObjAddress(u32_t pointer, APOffset offset);
@@ -101,7 +101,7 @@ public:
101
101
  return Z3Expr::getContext();
102
102
  }
103
103
 
104
- void applySummary(SparseAbstractState&es);
104
+ void applySummary(AbstractState&es);
105
105
 
106
106
 
107
107
  /// Init ObjVar
@@ -144,29 +144,27 @@ public:
144
144
  return _es.inLocToAddrsTable(id);
145
145
  }
146
146
 
147
- void moveToGlobal();
147
+ void handleAddr(const AddrStmt *addr);
148
148
 
149
- void translateAddr(const AddrStmt *addr);
149
+ void handleBinary(const BinaryOPStmt *binary);
150
150
 
151
- void translateBinary(const BinaryOPStmt *binary);
151
+ void handleCmp(const CmpStmt *cmp);
152
152
 
153
- void translateCmp(const CmpStmt *cmp);
153
+ void handleLoad(const LoadStmt *load);
154
154
 
155
- void translateLoad(const LoadStmt *load);
155
+ void handleStore(const StoreStmt *store);
156
156
 
157
- void translateStore(const StoreStmt *store);
157
+ void handleCopy(const CopyStmt *copy);
158
158
 
159
- void translateCopy(const CopyStmt *copy);
159
+ void handleCall(const CallPE *callPE);
160
160
 
161
- void translateCall(const CallPE *callPE);
161
+ void handleRet(const RetPE *retPE);
162
162
 
163
- void translateRet(const RetPE *retPE);
163
+ void handleGep(const GepStmt *gep);
164
164
 
165
- void translateGep(const GepStmt *gep);
165
+ void handleSelect(const SelectStmt *select);
166
166
 
167
- void translateSelect(const SelectStmt *select);
168
-
169
- void translatePhi(const PhiStmt *phi);
167
+ void handlePhi(const PhiStmt *phi);
170
168
 
171
169
  /// Return the internal index if idx is an address otherwise return the value of idx
172
170
  static inline u32_t getInternalID(u32_t idx)
@@ -188,30 +186,30 @@ public:
188
186
 
189
187
  protected:
190
188
 
191
- void translateBinaryRel(const BinaryOPStmt *binary);
189
+ void handleBinaryRel(const BinaryOPStmt *binary);
192
190
 
193
- void translateCmpRel(const CmpStmt *cmp);
191
+ void handleCmpRel(const CmpStmt *cmp);
194
192
 
195
- void translateLoadRel(const LoadStmt *load);
193
+ void handleLoadRel(const LoadStmt *load);
196
194
 
197
- void translateStoreRel(const StoreStmt *store);
195
+ void handleStoreRel(const StoreStmt *store);
198
196
 
199
- void translateCopyRel(const CopyStmt *copy);
197
+ void handleCopyRel(const CopyStmt *copy);
200
198
 
201
- void translateCallRel(const CallPE *callPE);
199
+ void handleCallRel(const CallPE *callPE);
202
200
 
203
- void translateRetRel(const RetPE *retPE);
201
+ void handleRetRel(const RetPE *retPE);
204
202
 
205
- void translateSelectRel(const SelectStmt *select);
203
+ void handleSelectRel(const SelectStmt *select);
206
204
 
207
- void translatePhiRel(const PhiStmt *phi, const ICFGNode *srcNode, const std::vector<const ICFGEdge *> &path);
205
+ void handlePhiRel(const PhiStmt *phi, const ICFGNode *srcNode, const std::vector<const ICFGEdge *> &path);
208
206
 
209
207
  private:
210
208
  SVFIR *_svfir;
211
- SparseAbstractState _es;
209
+ AbstractState _es;
212
210
  RelExeState _relEs;
213
211
 
214
- Map<NodeID, SparseAbstractState*> _br_cond;
212
+ Map<NodeID, AbstractState*> _br_cond;
215
213
  AbstractValue getZExtValue(const SVFVar* var, const SVFType*);
216
214
  };
217
215
  }
@@ -3,7 +3,7 @@
3
3
  ####### Any changes to this file will be overwritten by the next CMake run ####
4
4
  ####### The input file was .config.cmake.in ########
5
5
 
6
- get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
6
+ get_filename_component(PACKAGE_${CMAKE_FIND_PACKAGE_NAME}_COUNTER_1 "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
7
7
 
8
8
  macro(set_and_check _var _file)
9
9
  set(${_var} "${_file}")
@@ -24,23 +24,23 @@ endmacro()
24
24
 
25
25
  ####################################################################################
26
26
 
27
- set_and_check(SVF_INSTALL_ROOT "${PACKAGE_PREFIX_DIR}")
28
- set_and_check(SVF_INSTALL_BIN_DIR "${PACKAGE_PREFIX_DIR}/bin")
29
- set_and_check(SVF_INSTALL_LIB_DIR "${PACKAGE_PREFIX_DIR}/lib")
27
+ set_and_check(SVF_INSTALL_ROOT "${PACKAGE_${CMAKE_FIND_PACKAGE_NAME}_COUNTER_1}")
28
+ set_and_check(SVF_INSTALL_BIN_DIR "${PACKAGE_${CMAKE_FIND_PACKAGE_NAME}_COUNTER_1}/bin")
29
+ set_and_check(SVF_INSTALL_LIB_DIR "${PACKAGE_${CMAKE_FIND_PACKAGE_NAME}_COUNTER_1}/lib")
30
30
 
31
- set(SVF_INCLUDE_PATH "${PACKAGE_PREFIX_DIR}/../svf/include")
32
- set(SVF_LLVM_INCLUDE_PATH "${PACKAGE_PREFIX_DIR}/../svf-llvm/include")
31
+ set(SVF_INCLUDE_PATH "${PACKAGE_${CMAKE_FIND_PACKAGE_NAME}_COUNTER_1}/../svf/include")
32
+ set(SVF_LLVM_INCLUDE_PATH "${PACKAGE_${CMAKE_FIND_PACKAGE_NAME}_COUNTER_1}/../svf-llvm/include")
33
33
 
34
34
  if(EXISTS ${SVF_INCLUDE_PATH} AND EXISTS ${SVF_LLVM_INCLUDE_PATH})
35
- set(SVF_INSTALL_INCLUDE_DIR "${SVF_INCLUDE_PATH};${SVF_LLVM_INCLUDE_PATH};${PACKAGE_PREFIX_DIR}/include")
35
+ set(SVF_INSTALL_INCLUDE_DIR "${SVF_INCLUDE_PATH};${SVF_LLVM_INCLUDE_PATH};${PACKAGE_${CMAKE_FIND_PACKAGE_NAME}_COUNTER_1}/include")
36
36
  else()
37
- set_and_check(SVF_INSTALL_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")
37
+ set_and_check(SVF_INSTALL_INCLUDE_DIR "${PACKAGE_${CMAKE_FIND_PACKAGE_NAME}_COUNTER_1}/include")
38
38
  endif()
39
39
 
40
40
  message(STATUS "SVF_INSTALL_INCLUDE_DIR is set to: ${SVF_INSTALL_INCLUDE_DIR}")
41
41
 
42
- set_and_check(SVF_INSTALL_EXTAPI_DIR "${PACKAGE_PREFIX_DIR}/lib")
43
- set_and_check(SVF_INSTALL_EXTAPI_FILE "${PACKAGE_PREFIX_DIR}/lib/extapi.bc")
42
+ set_and_check(SVF_INSTALL_EXTAPI_DIR "${PACKAGE_${CMAKE_FIND_PACKAGE_NAME}_COUNTER_1}/lib")
43
+ set_and_check(SVF_INSTALL_EXTAPI_FILE "${PACKAGE_${CMAKE_FIND_PACKAGE_NAME}_COUNTER_1}/lib/extapi.bc")
44
44
 
45
45
  set(SVF_SANITIZE "")
46
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1928",
3
+ "version": "1.0.1929",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {