diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 276af3d..0000000
--- a/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-BUILD/
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..73f69e0
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/llvm.iml b/.idea/llvm.iml
new file mode 100644
index 0000000..b7d6dff
--- /dev/null
+++ b/.idea/llvm.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..f6634f1
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..5ed16fa
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..4849c1a
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
deleted file mode 100644
index 29b3339..0000000
--- a/README.md
+++ /dev/null
@@ -1,29 +0,0 @@
-## 0. Install npm, zlib, unzip, cmake, gcc, nodejs (skip this step if you machine has these libs)
-
-```
-sudo apt-get install zlib1g-dev unzip cmake gcc g++ libtinfo5 nodejs
-```
-
-## 1. Install SVF and its dependence (LLVM pre-built binary) via npm
-```
-npm i --silent svf-lib --prefix ${HOME}
-```
-
-## 2. Clone repository
-```
-git clone https://github.com/SVF-tools/SVF-example.git
-```
-
-## 3. Setup SVF environment and build your project
-```
-source ./env.sh
-```
-cmake the project (`cmake -DCMAKE_BUILD_TYPE=Debug .` for debug build)
-```
-cmake . && make
-```
-## 4. Analyze a bc file using svf-ex executable
-```
-clang -S -c -g -fno-discard-value-names -emit-llvm example.c -o example.ll
-./bin/svf-ex example.ll
-```
diff --git a/__pycache__/main.cpython-38.pyc b/__pycache__/main.cpython-38.pyc
new file mode 100644
index 0000000..d04fd50
Binary files /dev/null and b/__pycache__/main.cpython-38.pyc differ
diff --git a/app.py b/app.py
new file mode 100644
index 0000000..49d7505
--- /dev/null
+++ b/app.py
@@ -0,0 +1,102 @@
+# -*- coding: utf-8 -*-
+import sys, os, subprocess
+from PyQt5.QtWidgets import (QWidget, QLabel, QApplication)
+from main import *
+
+
+
+class MyUI(QWidget, Ui_visual):
+ def __init__(self, parent=None):
+ super(MyUI, self).__init__(parent)
+ self.setupUi(self)
+ self.check.clicked.connect(self.doCheck)
+ self.trans.clicked.connect(self.doTrans)
+ self.git.clicked.connect(self.doGit)
+ self.close.clicked.connect(self.doClose)
+ self.clear.clicked.connect(self.doClear)
+
+ def doCheck(self):
+ # tools install
+ statement = 'echo " " |sudo -S apt-get install zlib1g-dev unzip cmake gcc g++ nodejs libtinfo5 python3 npm'
+ result = self.subprocess_popen(statement)
+ if result == None:
+ self.textEdit.setText('configure failed. command: "apt-get install zlib1g-dev unzip cmake gcc g++ nodejs libtinfo5 python3 npm"')
+ return
+ else:
+ for res in result:
+ self.textEdit.append(res)
+
+ # npm install
+ statement = 'npm i --silent svf-lib --prefix ${HOME}'
+ self.textEdit.setText('npm installing...')
+ result = self.subprocess_popen(statement)
+ if result == None:
+ self.textEdit.setText('configure failed. command: "npm i --silent svf-lib --prefix ${HOME}"')
+ return
+ else:
+ for res in result:
+ self.textEdit.append(res)
+
+ # cmake make
+ statement = 'cd SVF-Python-example && cmake . && make && clang -S -c -g -fno-discard-value-names -emit-llvm example.c -o example.ll'
+ self.textEdit.setText('cmake make...')
+ result = self.subprocess_popen(statement)
+ if result == None:
+ self.textEdit.setText('configure failed. command: "cmake . && make"')
+ return
+ else:
+ for res in result:
+ self.textEdit.append(res)
+
+
+ def doTrans(self):
+ tt = os.popen('cd /home/tp/PycharmProjects/llvm/svf-example-py-master1206 && python3 ./src/svf-ex.py ./example.ll')
+ self.textEdit.setText(tt.read())
+
+ def doGit(self):
+ path = 'SVF-Python-example'
+ if os.path.exists(path):
+ os.remove(path)
+ self.textEdit.setText('cloning...')
+ result = self.subprocess_popen('git clone https://github.com/SVF-tools/SVF-Python-example')
+ if result == None:
+ self.textEdit.setText('git clone failed.')
+ else:
+ for res in result:
+ self.textEdit.append(res)
+
+ def doClose(self):
+ app = QApplication.instance()
+ app.quit()
+
+ def doClear(self):
+ self.textEdit.clear()
+
+ def os_system(self, statement):
+ result = os.system(statement)
+ if result != 0:
+ return None
+ else:
+ return result
+
+ def subprocess_popen(self, statement):
+ p = subprocess.Popen(statement, shell=True, stdout=subprocess.PIPE)
+ while p.poll() is None:
+ if p.wait() != 0:
+ print("命令执行失败")
+ return None
+ else:
+ re = p.stdout.readlines()
+ result = []
+ for i in range(len(re)):
+ res = re[i].decode('utf-8').strip('\r\n')
+ result.append(res)
+ return result
+
+
+
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+ myUI = MyUI()
+ myUI.show()
+ sys.exit(app.exec_())
\ No newline at end of file
diff --git a/example.ll b/example.ll
deleted file mode 100644
index ebedec3..0000000
--- a/example.ll
+++ /dev/null
@@ -1,47 +0,0 @@
-; ModuleID = 'swap.ll'
-source_filename = "swap.c"
-target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-apple-macosx10.15.0"
-
-; Function Attrs: noinline nounwind optnone ssp uwtable
-define void @swap(i8** %p, i8** %q) #0 {
-entry:
- %p.addr = alloca i8**, align 8
- %q.addr = alloca i8**, align 8
- %t = alloca i8*, align 8
- store i8** %p, i8*** %p.addr, align 8
- store i8** %q, i8*** %q.addr, align 8
- %0 = load i8**, i8*** %p.addr, align 8
- %1 = load i8*, i8** %0, align 8
- store i8* %1, i8** %t, align 8
- %2 = load i8**, i8*** %q.addr, align 8
- %3 = load i8*, i8** %2, align 8
- %4 = load i8**, i8*** %p.addr, align 8
- store i8* %3, i8** %4, align 8
- %5 = load i8*, i8** %t, align 8
- %6 = load i8**, i8*** %q.addr, align 8
- store i8* %5, i8** %6, align 8
- ret void
-}
-
-; Function Attrs: noinline nounwind optnone ssp uwtable
-define i32 @main() #0 {
-entry:
- %a1 = alloca i8, align 1
- %b1 = alloca i8, align 1
- %a = alloca i8*, align 8
- %b = alloca i8*, align 8
- store i8* %a1, i8** %a, align 8
- store i8* %b1, i8** %b, align 8
- call void @swap(i8** %a, i8** %b)
- ret i32 0
-}
-
-attributes #0 = { noinline nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
-
-!llvm.module.flags = !{!0, !1}
-!llvm.ident = !{!2}
-
-!0 = !{i32 1, !"wchar_size", i32 4}
-!1 = !{i32 7, !"PIC Level", i32 2}
-!2 = !{!"clang version 10.0.0 "}
diff --git a/main.py b/main.py
new file mode 100644
index 0000000..836715b
--- /dev/null
+++ b/main.py
@@ -0,0 +1,76 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'main.ui'
+#
+# Created by: PyQt5 UI code generator 5.15.4
+#
+# WARNING: Any manual changes made to this file will be lost when pyuic5 is
+# run again. Do not edit this file unless you know what you are doing.
+
+
+from PyQt5 import QtCore, QtGui, QtWidgets
+
+
+class Ui_visual(object):
+ def setupUi(self, visual):
+ visual.setObjectName("visual")
+ visual.resize(791, 412)
+ self.label = QtWidgets.QLabel(visual)
+ self.label.setGeometry(QtCore.QRect(40, 20, 91, 41))
+ self.label.setObjectName("label")
+ self.textEdit = QtWidgets.QTextEdit(visual)
+ self.textEdit.setGeometry(QtCore.QRect(40, 60, 711, 241))
+ self.textEdit.setObjectName("textEdit")
+ self.layoutWidget = QtWidgets.QWidget(visual)
+ self.layoutWidget.setGeometry(QtCore.QRect(60, 330, 671, 30))
+ self.layoutWidget.setObjectName("layoutWidget")
+ self.horizontalLayout = QtWidgets.QHBoxLayout(self.layoutWidget)
+ self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
+ self.horizontalLayout.setObjectName("horizontalLayout")
+ self.check = QtWidgets.QPushButton(self.layoutWidget)
+ self.check.setObjectName("check")
+ self.horizontalLayout.addWidget(self.check)
+ spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.horizontalLayout.addItem(spacerItem)
+ self.trans = QtWidgets.QPushButton(self.layoutWidget)
+ self.trans.setObjectName("trans")
+ self.horizontalLayout.addWidget(self.trans)
+ spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.horizontalLayout.addItem(spacerItem1)
+ self.git = QtWidgets.QPushButton(self.layoutWidget)
+ self.git.setObjectName("git")
+ self.horizontalLayout.addWidget(self.git)
+ spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.horizontalLayout.addItem(spacerItem2)
+ self.close = QtWidgets.QPushButton(self.layoutWidget)
+ self.close.setObjectName("close")
+ self.horizontalLayout.addWidget(self.close)
+ spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
+ self.horizontalLayout.addItem(spacerItem3)
+ self.clear = QtWidgets.QPushButton(self.layoutWidget)
+ self.clear.setObjectName("clear")
+ self.horizontalLayout.addWidget(self.clear)
+ self.label_2 = QtWidgets.QLabel(visual)
+ self.label_2.setGeometry(QtCore.QRect(250, 380, 361, 16))
+ self.label_2.setObjectName("label_2")
+ self.label_3 = QtWidgets.QLabel(visual)
+ self.label_3.setGeometry(QtCore.QRect(320, 10, 121, 31))
+ font = QtGui.QFont()
+ font.setPointSize(13)
+ self.label_3.setFont(font)
+ self.label_3.setObjectName("label_3")
+
+ self.retranslateUi(visual)
+ QtCore.QMetaObject.connectSlotsByName(visual)
+
+ def retranslateUi(self, visual):
+ _translate = QtCore.QCoreApplication.translate
+ visual.setWindowTitle(_translate("visual", "可视化"))
+ self.label.setText(_translate("visual", "控制台提示:"))
+ self.check.setText(_translate("visual", "配置环境"))
+ self.trans.setText(_translate("visual", "转换代码"))
+ self.git.setText(_translate("visual", "克隆Git"))
+ self.close.setText(_translate("visual", "关闭"))
+ self.clear.setText(_translate("visual", "清空屏幕"))
+ self.label_2.setText(_translate("visual", "注意:请先克隆项目,再配置环境,最后转换代码"))
+ self.label_3.setText(_translate("visual", "可视化配置工具"))
diff --git a/main.ui b/main.ui
new file mode 100644
index 0000000..7c5619b
--- /dev/null
+++ b/main.ui
@@ -0,0 +1,172 @@
+
+
+ visual
+
+
+
+ 0
+ 0
+ 791
+ 412
+
+
+
+ 可视化
+
+
+
+
+ 40
+ 20
+ 91
+ 41
+
+
+
+ 控制台提示:
+
+
+
+
+
+ 40
+ 60
+ 711
+ 241
+
+
+
+
+
+
+ 60
+ 330
+ 671
+ 30
+
+
+
+ -
+
+
+ 配置环境
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ 转换代码
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ 克隆GIT
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ 关闭
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ 清空屏幕
+
+
+
+
+
+
+
+
+ 250
+ 380
+ 361
+ 16
+
+
+
+ 注意:请先克隆项目,再配置环境,最后转换代码
+
+
+
+
+
+ 320
+ 10
+ 121
+ 31
+
+
+
+
+ 10
+
+
+
+ 可视化配置工具
+
+
+
+
+
+
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..7a3216a
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,75 @@
+apturl==0.5.2
+bcrypt==3.1.7
+blinker==1.4
+Brlapi==0.7.0
+certifi==2019.11.28
+chardet==3.0.4
+Click==7.0
+colorama==0.4.3
+command-not-found==0.3
+cryptography==2.8
+cupshelpers==1.0
+dbus-python==1.2.16
+defer==1.0.6
+distro==1.4.0
+distro-info===0.23ubuntu1
+duplicity==0.8.12.0
+entrypoints==0.3
+fasteners==0.14.1
+future==0.18.2
+httplib2==0.14.0
+idna==2.8
+keyring==18.0.1
+language-selector==0.1
+launchpadlib==1.10.13
+lazr.restfulclient==0.14.2
+lazr.uri==1.0.3
+lockfile==0.12.2
+louis==3.12.0
+macaroonbakery==1.3.1
+Mako==1.1.0
+MarkupSafe==1.1.0
+monotonic==1.5
+netifaces==0.10.4
+oauthlib==3.1.0
+olefile==0.46
+paramiko==2.6.0
+pexpect==4.6.0
+Pillow==7.0.0
+protobuf==3.6.1
+pycairo==1.16.2
+pycups==1.9.73
+PyGObject==3.36.0
+PyJWT==1.7.1
+pymacaroons==0.13.0
+PyNaCl==1.3.0
+PyQt5==5.15.4
+pyqt5-plugins==5.15.4.2.2
+PyQt5-Qt5==5.15.2
+PyQt5-sip==12.11.0
+pyqt5-tools==5.15.4.3.2
+pyRFC3339==1.1
+python-apt==2.0.0+ubuntu0.20.4.8
+python-dateutil==2.7.3
+python-debian===0.1.36ubuntu1
+python-dotenv==0.21.0
+pytz==2019.3
+pyxdg==0.26
+PyYAML==5.3.1
+qt5-applications==5.15.2.2.2
+qt5-tools==5.15.2.1.2
+reportlab==3.5.34
+requests==2.22.0
+requests-unixsocket==0.2.0
+SecretStorage==2.3.1
+simplejson==3.16.0
+six==1.14.0
+systemd-python==234
+ubuntu-advantage-tools==27.10
+ubuntu-drivers-common==0.0.0
+ufw==0.36
+unattended-upgrades==0.1
+urllib3==1.25.8
+usb-creator==0.3.7
+wadllib==1.3.3
+xkit==0.0.0
diff --git a/src/svf-ex.cpp b/src/svf-ex.cpp
deleted file mode 100644
index 77afdab..0000000
--- a/src/svf-ex.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-//===- svf-ex.cpp -- A driver example of SVF-------------------------------------//
-//
-// SVF: Static Value-Flow Analysis
-//
-// Copyright (C) <2013->
-//
-
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-//
-//===-----------------------------------------------------------------------===//
-
-/*
- // A driver program of SVF including usages of SVF APIs
- //
- // Author: Yulei Sui,
- */
-
-#include "SVF-LLVM/LLVMUtil.h"
-#include "Graphs/SVFG.h"
-#include "WPA/Andersen.h"
-#include "SVF-LLVM/SVFIRBuilder.h"
-#include "Util/Options.h"
-
-using namespace llvm;
-using namespace std;
-using namespace SVF;
-
-static llvm::cl::opt InputFilename(cl::Positional,
- llvm::cl::desc(""), llvm::cl::init("-"));
-
-/*!
- * An example to query alias results of two LLVM values
- */
-SVF::AliasResult aliasQuery(PointerAnalysis* pta, Value* v1, Value* v2)
-{
- SVFValue* val1 = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(v1);
- SVFValue* val2 = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(v2);
-
- return pta->alias(val1,val2);
-}
-
-/*!
- * An example to print points-to set of an LLVM value
- */
-std::string printPts(PointerAnalysis* pta, Value* val)
-{
-
- std::string str;
- raw_string_ostream rawstr(str);
- SVFValue* svfval = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(val);
-
- NodeID pNodeId = pta->getPAG()->getValueNode(svfval);
- const PointsTo& pts = pta->getPts(pNodeId);
- for (PointsTo::iterator ii = pts.begin(), ie = pts.end();
- ii != ie; ii++)
- {
- rawstr << " " << *ii << " ";
- PAGNode* targetObj = pta->getPAG()->getGNode(*ii);
- if(targetObj->hasValue())
- {
- rawstr << "(" << targetObj->getValue()->toString() << ")\t ";
- }
- }
-
- return rawstr.str();
-
-}
-
-
-/*!
- * An example to query/collect all successor nodes from a ICFGNode (iNode) along control-flow graph (ICFG)
- */
-void traverseOnICFG(ICFG* icfg, const Instruction* inst)
-{
- SVFInstruction* svfinst = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(inst);
-
- ICFGNode* iNode = icfg->getICFGNode(svfinst);
- FIFOWorkList worklist;
- Set visited;
- worklist.push(iNode);
-
- /// Traverse along VFG
- while (!worklist.empty())
- {
- const ICFGNode* iNode = worklist.pop();
- for (ICFGNode::const_iterator it = iNode->OutEdgeBegin(), eit =
- iNode->OutEdgeEnd(); it != eit; ++it)
- {
- ICFGEdge* edge = *it;
- ICFGNode* succNode = edge->getDstNode();
- if (visited.find(succNode) == visited.end())
- {
- visited.insert(succNode);
- worklist.push(succNode);
- }
- }
- }
-}
-
-/*!
- * An example to query/collect all the uses of a definition of a value along value-flow graph (VFG)
- */
-void traverseOnVFG(const SVFG* vfg, Value* val)
-{
- SVFIR* pag = SVFIR::getPAG();
- SVFValue* svfval = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(val);
-
- PAGNode* pNode = pag->getGNode(pag->getValueNode(svfval));
- const VFGNode* vNode = vfg->getDefSVFGNode(pNode);
- FIFOWorkList worklist;
- Set visited;
- worklist.push(vNode);
-
- /// Traverse along VFG
- while (!worklist.empty())
- {
- const VFGNode* vNode = worklist.pop();
- for (VFGNode::const_iterator it = vNode->OutEdgeBegin(), eit =
- vNode->OutEdgeEnd(); it != eit; ++it)
- {
- VFGEdge* edge = *it;
- VFGNode* succNode = edge->getDstNode();
- if (visited.find(succNode) == visited.end())
- {
- visited.insert(succNode);
- worklist.push(succNode);
- }
- }
- }
-
- /// Collect all LLVM Values
- for(Set::const_iterator it = visited.begin(), eit = visited.end(); it!=eit; ++it)
- {
- const VFGNode* node = *it;
- /// can only query VFGNode involving top-level pointers (starting with % or @ in LLVM IR)
- /// PAGNode* pNode = vfg->getLHSTopLevPtr(node);
- /// Value* val = pNode->getValue();
- }
-}
-
-int main(int argc, char ** argv)
-{
-
- int arg_num = 0;
- char **arg_value = new char*[argc];
- std::vector moduleNameVec;
- LLVMUtil::processArguments(argc, argv, arg_num, arg_value, moduleNameVec);
- cl::ParseCommandLineOptions(arg_num, arg_value,
- "Whole Program Points-to Analysis\n");
-
- if (Options::WriteAnder == "ir_annotator")
- {
- LLVMModuleSet::getLLVMModuleSet()->preProcessBCs(moduleNameVec);
- }
-
- SVFModule* svfModule = LLVMModuleSet::getLLVMModuleSet()->buildSVFModule(moduleNameVec);
-
- /// Build Program Assignment Graph (SVFIR)
- SVFIRBuilder builder(svfModule);
- SVFIR* pag = builder.build();
-
- /// Create Andersen's pointer analysis
- Andersen* ander = AndersenWaveDiff::createAndersenWaveDiff(pag);
-
- /// Query aliases
- /// aliasQuery(ander,value1,value2);
-
- /// Print points-to information
- /// printPts(ander, value1);
-
- /// Call Graph
- PTACallGraph* callgraph = ander->getPTACallGraph();
-
- /// ICFG
- ICFG* icfg = pag->getICFG();
-
- /// Value-Flow Graph (VFG)
- VFG* vfg = new VFG(callgraph);
-
- /// Sparse value-flow graph (SVFG)
- SVFGBuilder svfBuilder;
- SVFG* svfg = svfBuilder.buildFullSVFG(ander);
-
- /// Collect uses of an LLVM Value
- /// traverseOnVFG(svfg, value);
-
- /// Collect all successor nodes on ICFG
- /// traverseOnICFG(icfg, value);
-
- // clean up memory
- delete vfg;
- delete svfg;
- AndersenWaveDiff::releaseAndersenWaveDiff();
- SVFIR::releaseSVFIR();
-
- LLVMModuleSet::getLLVMModuleSet()->dumpModulesToFile(".svf.bc");
- SVF::LLVMModuleSet::releaseLLVMModuleSet();
-
- llvm::llvm_shutdown();
- return 0;
-}
-
diff --git a/.github/workflows/svf-example-build.yml b/svf-example-py/.github/workflows/svf-example-build.yml
similarity index 89%
rename from .github/workflows/svf-example-build.yml
rename to svf-example-py/.github/workflows/svf-example-build.yml
index 1869294..d976539 100644
--- a/.github/workflows/svf-example-build.yml
+++ b/svf-example-py/.github/workflows/svf-example-build.yml
@@ -31,7 +31,7 @@ jobs:
sudo apt-get update
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
- sudo apt-get install cmake gcc g++ nodejs doxygen graphviz
+ sudo apt-get install cmake gcc g++ nodejs doxygen graphviz python3
# install llvm and svf
- name: env-setup
@@ -44,3 +44,6 @@ jobs:
source $GITHUB_WORKSPACE/env.sh
cmake .
make
+ clang -S -c -g -fno-discard-value-names -emit-llvm example.c -o example.ll
+ python3 ./src/svf-ex.py example.ll
+
diff --git a/svf-example-py/.gitignore b/svf-example-py/.gitignore
new file mode 100644
index 0000000..7fdb61d
--- /dev/null
+++ b/svf-example-py/.gitignore
@@ -0,0 +1,12 @@
+BUILD/
+.vscode/
+CMakeCache.txt
+cmake_install.cmake
+Makefile
+__pycache__/
+CMakeFiles/
+example.svf.bc
+py/cpp/libsvfModule.so
+example.ll
+src/svfModule/libsvfModule.so
+src/svfLLVMUtil/libsvfLLVMUtil.so
diff --git a/CMakeLists.txt b/svf-example-py/CMakeLists.txt
similarity index 90%
rename from CMakeLists.txt
rename to svf-example-py/CMakeLists.txt
index a6c9f26..2b853a7 100644
--- a/CMakeLists.txt
+++ b/svf-example-py/CMakeLists.txt
@@ -43,19 +43,17 @@ endif()
if(CMAKE_BUILD_TYPE MATCHES "Debug")
MESSAGE (STATUS "building SVF in debug mode")
if (EXISTS "${SVF_DIR}/Debug-build")
- set(SVF_BIN "${SVF_DIR}/Debug-build")
+ set(SVF_LIB "${SVF_DIR}/Debug-build/lib/libSvf.a")
else()
- set(SVF_BIN "${SVF_DIR}/Release-build")
+ set(SVF_LIB "${SVF_DIR}/Release-build/lib/libSvf.a")
endif()
else()
MESSAGE (STATUS "building SVF in release mode")
- set(SVF_BIN "${SVF_DIR}/Release-build")
+ set(SVF_LIB "${SVF_DIR}/Release-build/lib/libSvf.a")
+
endif()
set(SVF_HEADER "${SVF_DIR}/include")
-set(SVF_LIB "${SVF_BIN}/lib/libSvf.a")
-set(SVF_BIN_HEADER "${SVF_BIN}/include")
-include_directories(${SVF_HEADER}
- ${SVF_BIN_HEADER})
+include_directories(${SVF_HEADER})
#set z3 env
if (DEFINED Z3_DIR)
@@ -92,4 +90,5 @@ else()
LINK_DIRECTORIES(${Z3_DIR}/bin)
endif()
-add_subdirectory(src)
+add_subdirectory(src/svfModule)
+add_subdirectory(src/svfLLVMUtil)
diff --git a/svf-example-py/README.md b/svf-example-py/README.md
new file mode 100644
index 0000000..bf4609c
--- /dev/null
+++ b/svf-example-py/README.md
@@ -0,0 +1,25 @@
+## 0. Install npm, zlib, unzip, cmake, gcc, nodejs (if you machine does not have these libs)
+```
+sudo apt-get install zlib1g-dev unzip cmake gcc g++ nodejs libtinfo5 python3
+```
+
+## 1. Install SVF and its dependence (LLVM pre-built binary) via npm
+```
+npm i --silent svf-lib --prefix ${HOME}
+```
+
+## 2. Clone repository
+```
+git clone https://github.com/SVF-tools/SVF-example.git
+```
+
+## 3. Setup SVF environment and create python lib
+```
+source ./env.sh
+cmake . && make
+```
+## 4. Analyze a bc file using svf-ex.py
+```
+clang -S -c -g -fno-discard-value-names -emit-llvm example.c -o example.ll
+python3 ./src/svf-ex.py example.ll
+```
diff --git a/env.sh b/svf-example-py/env.sh
old mode 100755
new mode 100644
similarity index 100%
rename from env.sh
rename to svf-example-py/env.sh
diff --git a/example.c b/svf-example-py/example.c
similarity index 100%
rename from example.c
rename to svf-example-py/example.c
diff --git a/svf-example-py/src/svf-ex.py b/svf-example-py/src/svf-ex.py
new file mode 100644
index 0000000..e4b5064
--- /dev/null
+++ b/svf-example-py/src/svf-ex.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import re
+import sys
+# import os
+# sys.path.append(os.getcwd() + '/py')
+
+from svfLLVMUtil import LLVMUtil
+from svfModule import SVFG, cl
+from svfModule import LLVMModuleSet
+from svfModule import SVFIRBuilder
+from svfModule import AndersenWaveDiff
+from svfModule import SVFIR, VFG, SVFGBuilder
+
+def main(argv):
+ moduleNameVec = []
+
+ LLVMUtil.processArguments(argv, moduleNameVec)
+ # cl.ParseCommandLineOptions()
+
+ svfModule = LLVMModuleSet.buildSVFModule(moduleNameVec)
+
+ svfModule.buildSymbolTableInfo()
+
+ pag = SVFIRBuilder.build()
+
+ ander = AndersenWaveDiff.createAndersenWaveDiff(pag)
+ callgraph = ander.getPTACallGraph()
+ pag.getICFG()
+
+ VFG.newInstances(callgraph)
+
+ SVFGBuilder.buildFullSVFG(ander)
+
+ VFG.delete()
+ SVFG.delete()
+ AndersenWaveDiff.releaseAndersenWaveDiff()
+ SVFIR.releaseSVFIR()
+ LLVMModuleSet.dumpModulesToFile('.svf.bc')
+ LLVMModuleSet.releaseLLVMModuleSet()
+
+
+
+if __name__ == "__main__":
+ # execute only if run as a script
+ argv = sys.argv
+ main(argv)
diff --git a/svf-example-py/src/svfLLVMUtil.py b/svf-example-py/src/svfLLVMUtil.py
new file mode 100644
index 0000000..853acc5
--- /dev/null
+++ b/svf-example-py/src/svfLLVMUtil.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import ctypes
+
+import os
+import sys
+
+if(sys.platform == 'linux'):
+ libsvfLLVMUtil = ctypes.cdll.LoadLibrary(os.getcwd() + '/src/svfLLVMUtil/libsvfLLVMUtil.so')
+elif(sys.platform == 'darwin'):
+ libsvfLLVMUtil = ctypes.cdll.LoadLibrary(os.getcwd() + '/src/svfLLVMUtil/libsvfLLVMUtil.dylib')
+
+
+class LLVMUtil(object):
+ global libsvfLLVMUtil
+ LLVMUtil = libsvfLLVMUtil
+ def processArguments(self, argv, moduleNameVec):
+ select = (ctypes.c_char_p * len(argv))()
+ for key, item in enumerate(argv):
+ select[key] = item.encode('utf-8')
+ self.LLVMUtil.processArguments(ctypes.c_int(len(argv)), select)
+ num = self.LLVMUtil.getModuleNameVecLen()
+ # print('num = ' + str(num))
+ i = 0
+ while i < num:
+ result = ctypes.create_string_buffer(100)
+ self.LLVMUtil.getModuleNameVecItem(ctypes.c_int(i), result)
+ # str_p = self.LLVMUtil.getModuleNameVecItem(ctypes.c_int(i))
+ # print('s: ' + result.value.decode('utf-8'))
+ moduleNameVec.append(result.value.decode('utf-8'))
+ i = i + 1
+ # print(moduleNameVec)
+
+
+LLVMUtil = LLVMUtil()
\ No newline at end of file
diff --git a/svf-example-py/src/svfLLVMUtil/CMakeLists.txt b/svf-example-py/src/svfLLVMUtil/CMakeLists.txt
new file mode 100644
index 0000000..bba55ca
--- /dev/null
+++ b/svf-example-py/src/svfLLVMUtil/CMakeLists.txt
@@ -0,0 +1,11 @@
+project(svfLLVMUtil)
+llvm_map_components_to_libnames(llvm_libs bitwriter core ipo irreader instcombine instrumentation target linker analysis scalaropts support )
+file (GLOB SOURCES
+ llvm_util.cpp
+)
+ADD_LIBRARY(svfLLVMUtil SHARED ${SOURCES})
+
+target_link_libraries(svfLLVMUtil ${SVF_LIB} ${llvm_libs})
+target_link_libraries(svfLLVMUtil ${Z3_LIBRARIES})
+set_target_properties(svfLLVMUtil PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
\ No newline at end of file
diff --git a/svf-example-py/src/svfLLVMUtil/llvm_util.cpp b/svf-example-py/src/svfLLVMUtil/llvm_util.cpp
new file mode 100644
index 0000000..f0f66b3
--- /dev/null
+++ b/svf-example-py/src/svfLLVMUtil/llvm_util.cpp
@@ -0,0 +1,36 @@
+#include "SVF-FE/LLVMUtil.h"
+
+using namespace SVF;
+
+extern "C" {
+ char **arg_value = NULL;
+ int arg_num = 0;
+ std::vector moduleNameVec;
+ int moduleNameVecLen = 0;
+ void processArguments(int argc, char **argv);
+ int getModuleNameVecLen();
+ const char* getModuleNameVecItem(int index, char* result);
+}
+
+
+void processArguments(int argc, char **_argv){
+ // TODD: delete free
+ arg_value = new char*[argc];
+ LLVMUtil::processArguments(argc, _argv, arg_num, arg_value, moduleNameVec);
+
+}
+
+int getModuleNameVecLen(){
+ return moduleNameVec.size();
+}
+
+const char* getModuleNameVecItem(int index, char* result){
+ // printf("moduleNameVec.size():%ld, index: %d\n", moduleNameVec.size(), index);
+ if(index < moduleNameVec.size()){
+ // printf("moduleNameVec[index]:%s\n", moduleNameVec[index].c_str());
+ snprintf(result, strlen(moduleNameVec[index].c_str()) + 1, "%s", moduleNameVec[index].c_str());
+ }
+ return result;
+}
+
+
diff --git a/svf-example-py/src/svfModule.py b/svf-example-py/src/svfModule.py
new file mode 100644
index 0000000..0a9a0a2
--- /dev/null
+++ b/svf-example-py/src/svfModule.py
@@ -0,0 +1,129 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import ctypes
+
+import os
+import sys
+
+# print('sys.platform:' + sys.platform)
+
+if(sys.platform == 'linux'):
+ libSvfModule = ctypes.cdll.LoadLibrary(os.getcwd() + '/src/svfModule/libsvfModule.so')
+elif(sys.platform == 'darwin'):
+ libSvfModule = ctypes.cdll.LoadLibrary(os.getcwd() + '/src/svfModule/libsvfModule.dylib')
+
+class SVFUtil(object):
+ global libSvfModule
+ svfUtil = libSvfModule
+ def processArguments(self, argv):
+ select = (ctypes.c_char_p * len(argv))()
+ for key, item in enumerate(argv):
+ select[key] = item.encode('utf-8')
+ self.svfUtil.processArguments(len(argv), select)
+
+class LLVMModuleSet(object) :
+ global libSvfModule
+ llv = libSvfModule
+ def buildSVFModule(self, moduleNameVec):
+ for i in moduleNameVec:
+ self.llv.setModuleNameVec(ctypes.c_char_p(i.encode('utf-8')))
+ self.llv.buildSVFModule()
+ return SVFModule
+ def dumpModulesToFile(self, s):
+ self.llv.dumpModulesToFile(ctypes.c_char_p(s.encode('utf-8')));
+ def releaseLLVMModuleSet(self):
+ self.llv.releaseLLVMModuleSet();
+
+class cl(object):
+ global libSvfModule
+ _cl = libSvfModule
+ def ParseCommandLineOptions(self):
+ self._cl.ParseCommandLineOptions()
+
+
+class SVFModule(object):
+ global libSvfModule
+ svfModule = libSvfModule
+ def buildSymbolTableInfo(self):
+ self.svfModule.buildSymbolTableInfo()
+
+class SVFIRBuilder(object):
+ global libSvfModule
+ svfIRBuilder = libSvfModule
+ def build(self):
+ self.svfIRBuilder.build()
+ return SVFIR
+
+class SVFIR(object):
+ global libSvfModule
+ svfIR = libSvfModule
+ def getICFG(self):
+ self.svfIR.getICFG()
+ def releaseSVFIR(self):
+ self.svfIR.getICFG()
+
+class AndersenWaveDiff(object):
+ global libSvfModule
+ andersenWaveDiff = libSvfModule
+ def createAndersenWaveDiff(self, pag):
+ self.andersenWaveDiff.createAndersenWaveDiff()
+ return Andersen
+ def releaseAndersenWaveDiff(self):
+ self.andersenWaveDiff.releaseAndersenWaveDiff()
+
+class Andersen(object):
+ global libSvfModule
+ andersen = libSvfModule
+ def getPTACallGraph(self):
+ self.andersen.getPTACallGraph()
+ return PTACallGraph
+
+
+class PTACallGraph(object):
+ pass
+
+
+class ICFG(object):
+ pass
+
+class VFG(object):
+ global libSvfModule
+ vfg = libSvfModule
+ def newInstances(self, callgraph):
+ self.vfg.newInstances()
+
+ def delete(self):
+ self.vfg.deleteSvfg()
+
+class SVFGBuilder(object):
+ global libSvfModule
+ svfgBuilder = libSvfModule
+ def buildFullSVFG(self, ander):
+ self.svfgBuilder.buildFullSVFG()
+
+class SVFG(object):
+ global libSvfModule
+ svfg = libSvfModule
+ def delete(self):
+ self.svfg.deleteSvfg()
+
+class llvm(object):
+ global libSvfModule
+ llvm = libSvfModule
+ def llvm_shutdown(self):
+ self.llvm.llvm_shutdown()
+
+SVFUtil = SVFUtil()
+LLVMModuleSet = LLVMModuleSet()
+SVFModule = SVFModule()
+cl = cl()
+SVFIRBuilder = SVFIRBuilder()
+AndersenWaveDiff = AndersenWaveDiff()
+Andersen = Andersen()
+SVFIR = SVFIR()
+ICFG = ICFG()
+VFG = VFG()
+SVFGBuilder = SVFGBuilder()
+llvm = llvm()
+SVFG = SVFG()
\ No newline at end of file
diff --git a/src/CMakeLists.txt b/svf-example-py/src/svfModule/CMakeLists.txt
similarity index 52%
rename from src/CMakeLists.txt
rename to svf-example-py/src/svfModule/CMakeLists.txt
index d28cbf6..367bacb 100644
--- a/src/CMakeLists.txt
+++ b/svf-example-py/src/svfModule/CMakeLists.txt
@@ -1,10 +1,11 @@
+project(svfModule)
llvm_map_components_to_libnames(llvm_libs bitwriter core ipo irreader instcombine instrumentation target linker analysis scalaropts support )
file (GLOB SOURCES
*.cpp
)
-add_executable(svf-ex ${SOURCES})
+ADD_LIBRARY(svfModule SHARED ${SOURCES})
-target_link_libraries(svf-ex ${SVF_LIB} ${llvm_libs})
-target_link_libraries(svf-ex ${Z3_LIBRARIES})
-set_target_properties( svf-ex PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
+target_link_libraries(svfModule ${SVF_LIB} ${llvm_libs})
+target_link_libraries(svfModule ${Z3_LIBRARIES})
+set_target_properties(svfModule PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
\ No newline at end of file
diff --git a/svf-example-py/src/svfModule/svfModule.cpp b/svf-example-py/src/svfModule/svfModule.cpp
new file mode 100644
index 0000000..1edc737
--- /dev/null
+++ b/svf-example-py/src/svfModule/svfModule.cpp
@@ -0,0 +1,118 @@
+#include "SVF-FE/LLVMUtil.h"
+#include "Graphs/SVFG.h"
+#include "WPA/Andersen.h"
+#include "SVF-FE/SVFIRBuilder.h"
+#include "Util/Options.h"
+
+using namespace llvm;
+using namespace std;
+using namespace SVF;
+
+extern "C" {
+ char **arg_value = NULL;
+ int arg_num = 0;
+ std::vector moduleNameVec;
+ SVFModule* svfModule;
+ SVFIRBuilder *builder;
+ SVFIR* pag;
+ Andersen* ander;
+ PTACallGraph* callgraph;
+ ICFG* icfg;
+ VFG* vfg;
+ SVFGBuilder* svfBuilder;
+ SVFG* svfg;
+
+ void ParseCommandLineOptions();
+ void buildSVFModule();
+ void setModuleNameVec(char* name);
+ void buildSymbolTableInfo();
+ void build();
+ void createAndersenWaveDiff();
+ void getPTACallGraph();
+ void getICFG();
+ void newInstances();
+ void buildFullSVFG();
+ void deleteSvfg();
+ void deleteVfg();
+ void releaseAndersenWaveDiff();
+ void releaseSVFIR();
+ void dumpModulesToFile(const char *s);
+ void releaseLLVMModuleSet();
+ void llvm_shutdown();
+}
+
+void ParseCommandLineOptions(){
+ printf("arg_num: %d\n", arg_num);
+ for(int i = 0; i < arg_num; i++){
+ printf("arg_value[%d]:%s\n", i, arg_value[i]);
+ }
+ cl::ParseCommandLineOptions(arg_num, arg_value, "Whole Program Points-to Analysis\n");
+}
+
+void buildSVFModule(){
+ svfModule = LLVMModuleSet::getLLVMModuleSet()->buildSVFModule(moduleNameVec);
+}
+
+void setModuleNameVec(char* name){
+ if(name != nullptr){
+ std::string s(name);
+ // printf("name:%s\n", name);
+ moduleNameVec.push_back(s);
+ }
+}
+
+void buildSymbolTableInfo(){
+ svfModule->buildSymbolTableInfo();
+}
+
+void build(){
+ SVFIRBuilder _builder;
+ pag = _builder.build(svfModule);
+}
+
+void createAndersenWaveDiff(){
+ ander = AndersenWaveDiff::createAndersenWaveDiff(pag);
+}
+
+void getPTACallGraph(){
+ callgraph = ander->getPTACallGraph();
+}
+
+void getICFG(){
+ icfg = pag->getICFG();
+}
+
+void newInstances(){
+ vfg = new VFG(callgraph);
+}
+
+void buildFullSVFG(){
+ SVFGBuilder _svfBuilder;
+ _svfBuilder.buildFullSVFG(ander);
+}
+
+void deleteVfg(){
+ delete vfg;
+}
+void deleteSvfg(){
+ delete svfg;
+}
+
+void releaseAndersenWaveDiff(){
+ AndersenWaveDiff::releaseAndersenWaveDiff();
+}
+
+void releaseSVFIR(){
+ SVFIR::releaseSVFIR();
+}
+
+void dumpModulesToFile(const char *s){
+ LLVMModuleSet::getLLVMModuleSet()->dumpModulesToFile(s);
+}
+void releaseLLVMModuleSet(){
+ SVF::LLVMModuleSet::releaseLLVMModuleSet();
+}
+
+void llvm_shutdown(){
+ llvm::llvm_shutdown();
+}
diff --git a/venv/bin/Activate.ps1 b/venv/bin/Activate.ps1
new file mode 100644
index 0000000..a3bc6fb
--- /dev/null
+++ b/venv/bin/Activate.ps1
@@ -0,0 +1,241 @@
+<#
+.Synopsis
+Activate a Python virtual environment for the current PowerShell session.
+
+.Description
+Pushes the python executable for a virtual environment to the front of the
+$Env:PATH environment variable and sets the prompt to signify that you are
+in a Python virtual environment. Makes use of the command line switches as
+well as the `pyvenv.cfg` file values present in the virtual environment.
+
+.Parameter VenvDir
+Path to the directory that contains the virtual environment to activate. The
+default value for this is the parent of the directory that the Activate.ps1
+script is located within.
+
+.Parameter Prompt
+The prompt prefix to display when this virtual environment is activated. By
+default, this prompt is the name of the virtual environment folder (VenvDir)
+surrounded by parentheses and followed by a single space (ie. '(.venv) ').
+
+.Example
+Activate.ps1
+Activates the Python virtual environment that contains the Activate.ps1 script.
+
+.Example
+Activate.ps1 -Verbose
+Activates the Python virtual environment that contains the Activate.ps1 script,
+and shows extra information about the activation as it executes.
+
+.Example
+Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
+Activates the Python virtual environment located in the specified location.
+
+.Example
+Activate.ps1 -Prompt "MyPython"
+Activates the Python virtual environment that contains the Activate.ps1 script,
+and prefixes the current prompt with the specified string (surrounded in
+parentheses) while the virtual environment is active.
+
+.Notes
+On Windows, it may be required to enable this Activate.ps1 script by setting the
+execution policy for the user. You can do this by issuing the following PowerShell
+command:
+
+PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
+
+For more information on Execution Policies:
+https://go.microsoft.com/fwlink/?LinkID=135170
+
+#>
+Param(
+ [Parameter(Mandatory = $false)]
+ [String]
+ $VenvDir,
+ [Parameter(Mandatory = $false)]
+ [String]
+ $Prompt
+)
+
+<# Function declarations --------------------------------------------------- #>
+
+<#
+.Synopsis
+Remove all shell session elements added by the Activate script, including the
+addition of the virtual environment's Python executable from the beginning of
+the PATH variable.
+
+.Parameter NonDestructive
+If present, do not remove this function from the global namespace for the
+session.
+
+#>
+function global:deactivate ([switch]$NonDestructive) {
+ # Revert to original values
+
+ # The prior prompt:
+ if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
+ Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
+ Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
+ }
+
+ # The prior PYTHONHOME:
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
+ Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
+ Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
+ }
+
+ # The prior PATH:
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
+ Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
+ Remove-Item -Path Env:_OLD_VIRTUAL_PATH
+ }
+
+ # Just remove the VIRTUAL_ENV altogether:
+ if (Test-Path -Path Env:VIRTUAL_ENV) {
+ Remove-Item -Path env:VIRTUAL_ENV
+ }
+
+ # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
+ if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
+ Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
+ }
+
+ # Leave deactivate function in the global namespace if requested:
+ if (-not $NonDestructive) {
+ Remove-Item -Path function:deactivate
+ }
+}
+
+<#
+.Description
+Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
+given folder, and returns them in a map.
+
+For each line in the pyvenv.cfg file, if that line can be parsed into exactly
+two strings separated by `=` (with any amount of whitespace surrounding the =)
+then it is considered a `key = value` line. The left hand string is the key,
+the right hand is the value.
+
+If the value starts with a `'` or a `"` then the first and last character is
+stripped from the value before being captured.
+
+.Parameter ConfigDir
+Path to the directory that contains the `pyvenv.cfg` file.
+#>
+function Get-PyVenvConfig(
+ [String]
+ $ConfigDir
+) {
+ Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
+
+ # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
+ $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
+
+ # An empty map will be returned if no config file is found.
+ $pyvenvConfig = @{ }
+
+ if ($pyvenvConfigPath) {
+
+ Write-Verbose "File exists, parse `key = value` lines"
+ $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
+
+ $pyvenvConfigContent | ForEach-Object {
+ $keyval = $PSItem -split "\s*=\s*", 2
+ if ($keyval[0] -and $keyval[1]) {
+ $val = $keyval[1]
+
+ # Remove extraneous quotations around a string value.
+ if ("'""".Contains($val.Substring(0, 1))) {
+ $val = $val.Substring(1, $val.Length - 2)
+ }
+
+ $pyvenvConfig[$keyval[0]] = $val
+ Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
+ }
+ }
+ }
+ return $pyvenvConfig
+}
+
+
+<# Begin Activate script --------------------------------------------------- #>
+
+# Determine the containing directory of this script
+$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
+$VenvExecDir = Get-Item -Path $VenvExecPath
+
+Write-Verbose "Activation script is located in path: '$VenvExecPath'"
+Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
+Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
+
+# Set values required in priority: CmdLine, ConfigFile, Default
+# First, get the location of the virtual environment, it might not be
+# VenvExecDir if specified on the command line.
+if ($VenvDir) {
+ Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
+}
+else {
+ Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
+ $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
+ Write-Verbose "VenvDir=$VenvDir"
+}
+
+# Next, read the `pyvenv.cfg` file to determine any required value such
+# as `prompt`.
+$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
+
+# Next, set the prompt from the command line, or the config file, or
+# just use the name of the virtual environment folder.
+if ($Prompt) {
+ Write-Verbose "Prompt specified as argument, using '$Prompt'"
+}
+else {
+ Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
+ if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
+ Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
+ $Prompt = $pyvenvCfg['prompt'];
+ }
+ else {
+ Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virutal environment)"
+ Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
+ $Prompt = Split-Path -Path $venvDir -Leaf
+ }
+}
+
+Write-Verbose "Prompt = '$Prompt'"
+Write-Verbose "VenvDir='$VenvDir'"
+
+# Deactivate any currently active virtual environment, but leave the
+# deactivate function in place.
+deactivate -nondestructive
+
+# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
+# that there is an activated venv.
+$env:VIRTUAL_ENV = $VenvDir
+
+if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
+
+ Write-Verbose "Setting prompt to '$Prompt'"
+
+ # Set the prompt to include the env name
+ # Make sure _OLD_VIRTUAL_PROMPT is global
+ function global:_OLD_VIRTUAL_PROMPT { "" }
+ Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
+ New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
+
+ function global:prompt {
+ Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
+ _OLD_VIRTUAL_PROMPT
+ }
+}
+
+# Clear PYTHONHOME
+if (Test-Path -Path Env:PYTHONHOME) {
+ Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
+ Remove-Item -Path Env:PYTHONHOME
+}
+
+# Add the venv to the PATH
+Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
+$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
diff --git a/venv/bin/activate b/venv/bin/activate
new file mode 100644
index 0000000..5a7041e
--- /dev/null
+++ b/venv/bin/activate
@@ -0,0 +1,76 @@
+# This file must be used with "source bin/activate" *from bash*
+# you cannot run it directly
+
+deactivate () {
+ # reset old environment variables
+ if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
+ PATH="${_OLD_VIRTUAL_PATH:-}"
+ export PATH
+ unset _OLD_VIRTUAL_PATH
+ fi
+ if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
+ PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
+ export PYTHONHOME
+ unset _OLD_VIRTUAL_PYTHONHOME
+ fi
+
+ # This should detect bash and zsh, which have a hash command that must
+ # be called to get it to forget past commands. Without forgetting
+ # past commands the $PATH changes we made may not be respected
+ if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
+ hash -r
+ fi
+
+ if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
+ PS1="${_OLD_VIRTUAL_PS1:-}"
+ export PS1
+ unset _OLD_VIRTUAL_PS1
+ fi
+
+ unset VIRTUAL_ENV
+ if [ ! "${1:-}" = "nondestructive" ] ; then
+ # Self destruct!
+ unset -f deactivate
+ fi
+}
+
+# unset irrelevant variables
+deactivate nondestructive
+
+VIRTUAL_ENV="/home/tp/PycharmProjects/llvm/venv"
+export VIRTUAL_ENV
+
+_OLD_VIRTUAL_PATH="$PATH"
+PATH="$VIRTUAL_ENV/bin:$PATH"
+export PATH
+
+# unset PYTHONHOME if set
+# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
+# could use `if (set -u; : $PYTHONHOME) ;` in bash
+if [ -n "${PYTHONHOME:-}" ] ; then
+ _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
+ unset PYTHONHOME
+fi
+
+if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
+ _OLD_VIRTUAL_PS1="${PS1:-}"
+ if [ "x(venv) " != x ] ; then
+ PS1="(venv) ${PS1:-}"
+ else
+ if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
+ # special case for Aspen magic directories
+ # see https://aspen.io/
+ PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
+ else
+ PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
+ fi
+ fi
+ export PS1
+fi
+
+# This should detect bash and zsh, which have a hash command that must
+# be called to get it to forget past commands. Without forgetting
+# past commands the $PATH changes we made may not be respected
+if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
+ hash -r
+fi
diff --git a/venv/bin/activate.csh b/venv/bin/activate.csh
new file mode 100644
index 0000000..d497801
--- /dev/null
+++ b/venv/bin/activate.csh
@@ -0,0 +1,37 @@
+# This file must be used with "source bin/activate.csh" *from csh*.
+# You cannot run it directly.
+# Created by Davide Di Blasi .
+# Ported to Python 3.3 venv by Andrew Svetlov
+
+alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate'
+
+# Unset irrelevant variables.
+deactivate nondestructive
+
+setenv VIRTUAL_ENV "/home/tp/PycharmProjects/llvm/venv"
+
+set _OLD_VIRTUAL_PATH="$PATH"
+setenv PATH "$VIRTUAL_ENV/bin:$PATH"
+
+
+set _OLD_VIRTUAL_PROMPT="$prompt"
+
+if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
+ if ("venv" != "") then
+ set env_name = "venv"
+ else
+ if (`basename "VIRTUAL_ENV"` == "__") then
+ # special case for Aspen magic directories
+ # see https://aspen.io/
+ set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
+ else
+ set env_name = `basename "$VIRTUAL_ENV"`
+ endif
+ endif
+ set prompt = "[$env_name] $prompt"
+ unset env_name
+endif
+
+alias pydoc python -m pydoc
+
+rehash
diff --git a/venv/bin/activate.fish b/venv/bin/activate.fish
new file mode 100644
index 0000000..361d6f6
--- /dev/null
+++ b/venv/bin/activate.fish
@@ -0,0 +1,75 @@
+# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org)
+# you cannot run it directly
+
+function deactivate -d "Exit virtualenv and return to normal shell environment"
+ # reset old environment variables
+ if test -n "$_OLD_VIRTUAL_PATH"
+ set -gx PATH $_OLD_VIRTUAL_PATH
+ set -e _OLD_VIRTUAL_PATH
+ end
+ if test -n "$_OLD_VIRTUAL_PYTHONHOME"
+ set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
+ set -e _OLD_VIRTUAL_PYTHONHOME
+ end
+
+ if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
+ functions -e fish_prompt
+ set -e _OLD_FISH_PROMPT_OVERRIDE
+ functions -c _old_fish_prompt fish_prompt
+ functions -e _old_fish_prompt
+ end
+
+ set -e VIRTUAL_ENV
+ if test "$argv[1]" != "nondestructive"
+ # Self destruct!
+ functions -e deactivate
+ end
+end
+
+# unset irrelevant variables
+deactivate nondestructive
+
+set -gx VIRTUAL_ENV "/home/tp/PycharmProjects/llvm/venv"
+
+set -gx _OLD_VIRTUAL_PATH $PATH
+set -gx PATH "$VIRTUAL_ENV/bin" $PATH
+
+# unset PYTHONHOME if set
+if set -q PYTHONHOME
+ set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
+ set -e PYTHONHOME
+end
+
+if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
+ # fish uses a function instead of an env var to generate the prompt.
+
+ # save the current fish_prompt function as the function _old_fish_prompt
+ functions -c fish_prompt _old_fish_prompt
+
+ # with the original prompt function renamed, we can override with our own.
+ function fish_prompt
+ # Save the return status of the last command
+ set -l old_status $status
+
+ # Prompt override?
+ if test -n "(venv) "
+ printf "%s%s" "(venv) " (set_color normal)
+ else
+ # ...Otherwise, prepend env
+ set -l _checkbase (basename "$VIRTUAL_ENV")
+ if test $_checkbase = "__"
+ # special case for Aspen magic directories
+ # see https://aspen.io/
+ printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal)
+ else
+ printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal)
+ end
+ end
+
+ # Restore the return status of the previous command.
+ echo "exit $old_status" | .
+ _old_fish_prompt
+ end
+
+ set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
+end
diff --git a/venv/bin/python b/venv/bin/python
new file mode 100644
index 0000000..4e58b60
--- /dev/null
+++ b/venv/bin/python
@@ -0,0 +1 @@
+python3.8
\ No newline at end of file
diff --git a/venv/bin/python3 b/venv/bin/python3
new file mode 100644
index 0000000..4e58b60
--- /dev/null
+++ b/venv/bin/python3
@@ -0,0 +1 @@
+python3.8
\ No newline at end of file
diff --git a/venv/bin/python3.8 b/venv/bin/python3.8
new file mode 100644
index 0000000..02a1389
--- /dev/null
+++ b/venv/bin/python3.8
@@ -0,0 +1 @@
+/usr/bin/python3.8
\ No newline at end of file
diff --git a/venv/lib64 b/venv/lib64
new file mode 100644
index 0000000..7951405
--- /dev/null
+++ b/venv/lib64
@@ -0,0 +1 @@
+lib
\ No newline at end of file
diff --git a/venv/pyvenv.cfg b/venv/pyvenv.cfg
new file mode 100644
index 0000000..853404e
--- /dev/null
+++ b/venv/pyvenv.cfg
@@ -0,0 +1,3 @@
+home = /usr/bin
+include-system-site-packages = false
+version = 3.8.10