当前位置: 首页 > 软件库 > 开发工具 > 编译器 >

phasar

A LLVM-based static analysis framework.
授权协议 View license
开发语言 C/C++
所属分类 开发工具、 编译器
软件类型 开源软件
地区 不详
投 递 者 公冶鸣
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

PhASAR a LLVM-based Static Analysis Framework

C++ StandardGitHub license

Version 0521

Secure Software Engineering Group

Required version of the C++ standard

PhASAR requires C++-17.

Currently supported version of LLVM

PhASAR is currently set up to support LLVM-12.0.

What is PhASAR?

PhASAR is a LLVM-based static analysis framework written in C++. It allows usersto specify arbitrary data-flow problems which are then solved in afully-automated manner on the specified LLVM IR target code. Computing points-toinformation, call-graph(s), etc. is done by the framework, thus you can focus onwhat matters.

How do I get started with PhASAR?

We have some documentation on PhASAR in our wiki. You probably would like to readthis README first and then have a look on the material provided on https://phasar.org/as well. Please also have a look on PhASAR's project directory and notice the project directoryexamples/ as well as the custom tool tools/myphasartool.cpp.

Building PhASAR

If you cannot work with one of the pre-built versions of PhASAR and would like tocompile PhASAR yourself, then please check the wiki for installing theprerequisites and compilation. It is recommended to compile PhASAR yourself inorder to get the full C++ experience and to have full control over the buildmode.

Please help us to improve PhASAR

You are using PhASAR and would like to help us in the future? Then pleasesupport us by filling out this web form.

By giving us feedback you help to decide in what direction PhASAR should stride inthe future and give us clues about our user base. Thank you very much!

Installation

PhASAR can be installed using the installer scripts as explained in the following.

Installing PhASAR on an Ubuntu system

In the following, we would like to give an complete example of how to installPhASAR using an Ubuntu or Unix-like system.

Therefore, we provide an installation script. To install PhASAR, just navigate to the top-leveldirectory of PhASAR and use the following command:

$ sudo ./bootstrap.sh

Done!

Installing PhASAR a MacOS system

Mac OS 10.13.1 or higher only!To install the framework on a Mac we will rely on Homebrew. (https://brew.sh/)

Please follow the instructions down below.

$ brew install boost
$ brew install python3
# Install llvm version 10
$ brew install llvm
# Setting the paths
# Use LLVM's Clang rather than Apple's Clang compiler
$ export CC=/usr/local/opt/llvm/bin/clang
$ export CXX=/usr/local/opt/llvm/bin/clang++
# Set PATH env variable to /usr/local/opt/llvm/bin
# Go to PhASAR directory run the following commands
$ git submodule init
$ git submodule update
$ mkdir build
$ cd build/
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make -j $(nproc) # or use a different number of cores to compile it
$ sudo make install # if you wish a system-wise installation

Compiling PhASAR (if not already done using the installation scripts)

Set the system's variables for the C and C++ compiler to clang:

$ export CC=/usr/local/bin/clang
$ export CXX=/usr/local/bin/clang++

You may need to adjust the paths according to your system. When you cloned PhASAR from Github you need to initialize PhASAR's submodules before building it:

$ git submodule init
$ git submodule update

If you downloaded PhASAR as a compressed release (e.g. .zip or .tar.gz) you can use the init-submodules-release.sh script that manually clones the required submodules:

$ utils/init-submodules-release.sh

Navigate into the PhASAR directory. The following commands will do the job and compile the PhASAR framework:

$ mkdir build
$ cd build/
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make -j $(nproc) # or use a different number of cores to compile it
$ sudo make install # if you wish to install PhASAR system wide

When you have used the bootstrap.sh script to install PhASAR, the above steps are already done.Use them as a reference if you wish to modify PhASAR and recompile it.

After compilation using cmake the following two binaries can be found in the build/ directory:

  • phasar-llvm - the actual PhASAR command-line tool
  • myphasartool - an example tool that shows how tools can be build on top of PhASAR

Use the command:

$ ./phasar-llvm --help

in order to display the manual and help message.

$ sudo make install

Please be careful and check if errors occur during the compilation.

When using CMake to compile PhASAR the following optional parameters can be used:

Parameter : Type Effect
BUILD_SHARED_LIBS : BOOL Build shared libraries (default is ON)
CMAKE_BUILD_TYPE : STRING Build PhASAR in 'Debug' or 'Release' mode
(default is 'Debug')
CMAKE_INSTALL_PREFIX : PATH Path where PhASAR will be installed if
“make install” is invoked or the “install”
target is built (default is /usr/local/phasar)
PHASAR_BUILD_DOC : BOOL Build PhASAR documentation (default is OFF)
PHASAR_BUILD_UNITTESTS : BOOL Build PhASAR unit tests (default is ON)
PHASAR_BUILD_IR : BOOL Build PhASAR IR (required for running the unit tests) (default is ON)
PHASAR_BUILD_OPENSSL_TS_UNITTESTS : BOOL Build PhASAR unit tests that require OpenSSL (default is OFF)
PHASAR_ENABLE_PAMM : STRING Enable the performance measurement mechanism
('Off', 'Core' or 'Full', default is Off)
PHASAR_ENABLE_PIC : BOOL Build Position-Independed Code (default is ON)
PHASAR_ENABLE_WARNINGS : BOOL Enable compiler warnings (default is ON)

You can use these parameters either directly or modify the installer-script bootstrap.sh

A remark on compile time

C++'s long compile times are always a pain. As shown in the above, when using cmake the compilation can easily be run in parallel, resulting in shorter compilation times. Make use of it!

Running a test solver

To test if everything works as expected please run the following command:

$ phasar-llvm --module test/build_systems_tests/installation_tests/module.ll -D ifds-solvertest

If you obtain output other than a segmentation fault or an exception terminating the program abnormally everything works as expected.

How to use PhASAR?

Please consult our PhASAR wiki pages.

Installing PhASAR's Git pre-commit hook

You are very much welcome to contribute to the PhASAR project.Please make sure that you install our pre-commit hook that ensures your commit adheres to the most important coding rules of the PhASAR project.For more details please consult Coding Conventions and Contributing to PhASAR.

To install the pre-commit hook, please run the following commands in PhASAR's root directory:

$ pip install pre-commit
$ pre-commit install

Thanks. And have fun with the project.

  • 一、简介 简介:PhASAR是一个基于LLVM的静态分析框架,用户可以进行数据流分析,框架会帮助进行指向分析、调用图构建。 安装:ubuntu下运行如下脚本。 # 安装 $ git clone https://github.com/secure-software-engineering/phasar.git $ sudo ./bootstrap.sh # 测试:若能获取正常输出,则表示安装正确。

  • 一、数据流分析 1.1 介绍 原理:数据流分析的原理可参考这些文章 Useful Literature。 说明:phasar提供了很多复杂机制,以便于用户自定义数据流分析。用户针对自己的需求,选择最合适的接口,用户只需要提供一个新类,即可实现该接口缺少的功能,该功能可作为分析的问题描述。将具体问题描述交给求解器求解,以下将列出多种数据流求解器。 (1)选择控制流图 首先需选择一种控制流图,以基于此

相关阅读

相关文章

相关问答

相关文档