Giter Site home page Giter Site logo

facebook / sparta Goto Github PK

View Code? Open in Web Editor NEW
608.0 26.0 49.0 824 KB

SPARTA is a library of software components specially designed for building high-performance static analyzers based on the theory of Abstract Interpretation.

License: MIT License

CMake 0.82% Shell 0.07% C++ 78.97% Rust 20.15%

sparta's Introduction

SPARTA

Support Ukraine Rust Build C++ crates.io

SPARTA is a library of software components specially designed for building high-performance static analyzers based on the theory of Abstract Interpretation.

Abstract Interpretation

Abstract Interpretation is a theory of semantic approximation that provides a foundational framework for the design of static program analyzers. Static analyzers built following the methodology of Abstract Interpretation are mathematically sound, i.e., the semantic information they compute is guaranteed to hold in all possible execution contexts considered. Moreover, these analyzers are able to infer complex properties of programs, the expressiveness of which can be finely tuned in order to control the analysis time. Static analyzers based on Abstract Interpretation are routinely used to perform the formal verification of flight software in the aerospace industry, for example.

Why SPARTA?

Building an industrial-grade static analysis tool based on Abstract Interpretation from scratch is a daunting task that requires the attention of experts in the field. The purpose of SPARTA is to drastically simplify the engineering of Abstract Interpretation by providing a set of software components that have a simple API, are highly performant and can be easily assembled to build a production-quality static analyzer. By encapsulating the complex implementation details of Abstract Interpretation, SPARTA lets the tool developer focus on the three fundamental axes in the design of an analysis:

  • Semantics: the program properties to analyze (range of numerical variables, aliasing relation, etc.)
  • Partitioning: the granularity of the properties analyzed (intraprocedural, interprocedural, context-sensitive, etc.)
  • Abstraction: the representation of the program properties (sign, interval, alias graph, etc.)

SPARTA is an acronym that stands for Semantics, PARTitioning and Abstraction.

Using SPARTA

A detailed documentation for SPARTA can be found in the code of the library itself. It includes code samples, typical use cases and references to the literature. Additionally, the unit tests are a good illustration of how to use the API. The unit test for the fixpoint iterator, in particular, implements a complete analysis (live variables) for a simple language.

SPARTA is the analytic engine that powers most optimization passes of the ReDex Android bytecode optimizer. The ReDex codebase contains multiple examples of analyses built with SPARTA that run at industrial scale. The interprocedural constant propagation illustrates how to assemble the building blocks provided by SPARTA in order to implement a sophisticated yet scalable analysis.

Dependencies

SPARTA requires Boost 1.71 or later.

macOS

You will need Xcode with the command line tools installed. To get the command line tools, please use:

xcode-select --install

Boost can be obtained via homebrew:

brew install boost

Ubuntu (64-bit)

On Ubuntu 16.04 or later, Boost can be installed through the package manager:

sudo apt-get install libboost-all-dev

For earlier versions of Ubuntu, we provide a script to install Boost:

sudo ./get_boost.sh

Setup

SPARTA is a header-only C++ library. You can just copy the contents of the include directory to any location in the include path of your compiler.

We also provide a quick setup using cmake that builds all the tests:

# Assume you are in the SPARTA directory
mkdir build-cmake
cd build-cmake
# .. is the root source directory of SPARTA
cmake ..
cmake --build .

To run the unit tests, please type:

make test

To copy the header files into /usr/local/include/sparta and set up a cmake library for SPARTA, you can use the following command:

sudo make install

CMake Setup

If you are using CMake for your project, you can also use SPARTA in the following ways:

  • A system-wide installation of SPARTA will contain a CMake configuration file that exports the library as sparta::sparta. This enables the use of find_package to locate SPARTA. For example:

    find_package(Boost REQUIRED COMPONENTS thread) # required by SPARTA
    find_package(sparta REQUIRED)
    add_library(MyAnalysisLibrary)
    target_link_libraries(MyAnalysisLibrary PUBLIC sparta::sparta)
  • If you have cloned and "built" SPARTA locally, you can use a find_package call (such as the one above) and run CMake with the -Dsparta_DIR=<your_sparta_build_dir> to load the library:

    # Assuming you are at the top-level of your project that uses SPARTA
    mkdir build && cd build
    cmake .. -Dsparta_DIR=path/to/your/sparta/build
  • SPARTA can be added as a subdirectory in your project:

    # assuming you have cloned SPARTA into a folder named sparta
    add_subdirectory(sparta)
    add_library(MyAnalysisLibrary)
    target_link_libraries(MyAnalysisLibrary PUBLIC sparta::sparta)

Issues

Issues on GitHub are assigned priorities which reflect their urgency and how soon they are likely to be addressed.

  • P0: Unbreak now! A serious issue which should have someone working on it right now.
  • P1: High Priority. An important issue that someone should be actively working on.
  • P2: Mid Priority. An important issue which is in the queue to be processed soon.
  • P3: Low Priority. An important issue which may get dealt with at a later date.
  • P4: Wishlist. An issue with merit but low priority which is up for grabs but likely to be pruned if not addressed after a reasonable period.

License

SPARTA is MIT-licensed, see the LICENSE file in the root directory of this source tree.

sparta's People

Contributors

agampe avatar arnaudvenet avatar arthaud avatar diliop avatar dmitryvinn avatar int3 avatar nhusung avatar ntillmann avatar rshest avatar rybalkinsd avatar skkeem avatar ssj933 avatar stepancheg avatar technius avatar thezhangwei avatar xazax-hun avatar yuhshin-oss avatar yuxuanchen1997 avatar zertosh avatar zpao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sparta's Issues

Purely virtual function and CRTP

Hello together,

first of all: Thank you for releasing SPARTA on Github. As someone highly interested in static analysis and abstract interpretation I'm really excited about this. So again: Thank you.

I've got a question regarding your use of CRTP in the definition of AbstractDomain and AbstractValue. Nevertheless these classes are designed to use CRTP, they contain purely virtual functions.

Regarding libraries using CRTP you often see a function like this

Derived& derived() { return *static_cast<Derived*>(this); }

and a const version of that. A purely virtual function virtual void foo() = 0; can then be replaced by

inline void foo() { return derived().foo(); }

A method call to foo will then be completely statically dispatched. This would maybe decrease the binary size (since vtables are smaller) and could increase the performance (due to static dispatching). We use this approach at the high performance linear algebra library Eigen and I guess it works quite well.

I see the following downsides:

  1. Code gets more complicated and looks less clean
  2. No inbuilt compile-time check if a subclass implements a method (a call to a former purely virtual function will seg. fault at runtime). However, since SPARTA already depends on Boost, we could use Boost TTI to add checks in the (still virtual) destructor.
  3. No inbuilt override (and I have no idea how to mimic one)

I guess performance is crucial if you want a static analysis tool to be widely adopted and therefore want to advertise the changes suggested above.

If you are interested in a pull request addressing the ideas above, I would prepare something.

Cheers,
David

SPARTA build cmake failure

Hi,
I followed installation steps and got the following error (Ubuntu 18.04):

$ mkdir build-cmake
$ cd build-cmake
$ cmake ..
$ cmake --build . 
make: *** No targets specified and no makefile found.  Stop.

and indeed there is no Makefile inside SPARTA/build-cmake.
What am I doing wrong ? Thanks !

Documentation to Use SPARTA

Hi Team,

Thank you for releasing SPARTA. I am trying to explore different functionalities and APIs of SPARTA.However I am not able to find any document which explains the usage of SPARTA. Please let me know if there is any detailed document and examples to use SPARTA for different applications.
@int3 @facebook-github-bot , Any help is highly appreciated.
Thank you.
Ashis

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.