Skip to content

Using PhASAR with Docker

fabianbs96 edited this page Nov 20, 2019 · 8 revisions

Abstract

Recently we have prepared PhASAR for being able to run in a docker container. This makes it a lot easier to use PhASAR, since it is no longer required for each user to build it manually. Additionally PhASAR is now platform independent - as far as docker is, which increases the usability.

For more information about docker see the documentation or tutorial.

In the following you can find guides on how to use PhASAR from a container and how to build it.

Fetch a prebuilt Docker image

A prebuilt docker image can be found at https://hub.docker.com/r/pdschbrt/phasar.

Pull the docker image using:

docker pull pdschbrt/phasar

We are currently setting up an automated pipeline such that a new docker image is build for each push made to PhASAR's repository.

Build a Docker Image

When you don't want to use a prebuilt docker image, you can also build it yourself.

First, open the terminal and navigate to the top level PhASAR directory. This folder should contain a Dockerfile file. If not, please check your current branch. To build the image, type

docker build -t phasar:latest .

This can take some time and will utilize as many cores of your machine as you have assigned to the docker engine. Note: This build-process requires an internet connection as it needs to install all PhASAR-dependencies.

Run PhASAR from a Container

Once you have installed docker and have a PhASAR-image available on your computer, running it is easy:

docker run phasar

Appending any command-line parameters will pass them directly to PhASAR. For example docker run phasar --help will display the help-screen of PhASAR.

Retrieving results from container

There are several analyses, which (can) write their analysis-results into a file. As without docker, you can specify the results-file with the -O parameter. But this file will now be created and written to only in the container. You can copy the results-file <results-file-in-container> to a file <results-file-on-host> on the host-system using

docker cp <container-id>:/usr/src/phasar/<results-file-in-container> <results-file-on-host>

where you have to fill in <container-id> with the name or id of the container in which you have run the analysis. You can lookup the container-id using docker ps -a.

Example

Consider the example file simple.ll. It contains the constant variables %2,%3 and %4 (alias the variables i, j and k from the .cpp file). We now run a linear constant propagation to check this property:

docker run phasar -m ./examples/llvm-hello_world/target/simple.ll -D IDE_LinearConstantAnalysis --output results.json
docker ps -a
docker cp 0b9d6e6a283a:/usr/src/phasar/results.json results.json

Then you can inspect the results.json file, which is now copied to the host system.

Note: The container-id 0b9d6e6a283a is specific for this run and will very likely differ on your machine or with different containers.

Clone this wiki locally