-
Notifications
You must be signed in to change notification settings - Fork 116
Building Teaching Software Analysis Repo from scratch
These are instructions for building LLVM, SVF, and the assignments (Teaching-Software-Analysis) from scratch. This is useful if you like to work with your own editor or terminal or have trouble with Docker, the image, or VSCode (M1 Macs currently do).
These instructions are for UNIX-y systems like Linux or macOS. Windows Subsystem for Linux might do as well.
Install CMake through your package manager. Some possibilities (these commands may require use of sudo
):
- Debian and Ubuntu based systems
$ sudo apt-get update
$ sudo apt-get install -y cmake unzip
- macOS using Homebrew
$ brew install cmake
- macOS using MacPorts
$ port install cmake
If you run into an error about permissions, prefix the command with sudo
, e.g. sudo apt-get install cmake
.
Alternatively, install CMake according to the CMake website (make sure to update your PATH
to include cmake
).
We will do everything in this directory.
$ mkdir svf-teaching
$ cd svf-teaching
Grab the SVF sources.
$ git clone https://github.com/SVF-Tools/SVF.git
$ cd SVF
Build. This should take a few minutes (LLVM build may take over 10 mins).
$ ./build.sh
Save the full path to our SVF build in a variable (which will be used to build Teaching-Software-Analysis next).
$ . ./setup.sh
Finally, move up a level.
$ cd ..
Grab the Teaching-Software-Analysis sources.
$ git clone https://github.com/SVF-tools/Teaching-Software-Analysis
$ cd Teaching-Software-Analysis
Configure. We use the Debug
build type to make debugging your assignments easier.
$ cmake -DCMAKE_BUILD_TYPE=Debug .
Build.
$ make
Congratulations! All built.
If you take a peak in the bin
directory, you can see your assignments, the hello world program, and the svfir program. To run the hello world program for example, you can
$ ./bin/hello
With your favourite text editor, you can modify the sources in directories like Assignment-1
or HelloWorld
, run make
again from the Teaching-Software-Verification
directory, and then rerun your programs.
To debug assignments, simply run your assignment with a debugger (like LLDB or GDB), for example:
$ lldb ./bin/hello
Some resources on LLDB:
Install the CodeLLDB extension in VSCode. It looks like:
Still in the same Teaching-Software-Verification
directory we created in Section 5, replace the contents of:
-
.vscode/launch.json
with:
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "lldb",
"request": "launch",
// Please change to executable of your working assignment e.g. Assignment-1: assign-1
"program": "${workspaceFolder}/bin/assign-3",
"args": ["-stat=false"], // may input the test llvm bc file or other options may use
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"MIMode": "lldb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: cpp build active file"
}
]
}
-
.vscode/tasks.json
with:
{
"tasks": [
{
"label": "C/C++: cpp build active file",
"type": "shell",
"command": "make",
"options": {
"cwd": "${workspaceFolder}"
},
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
-
.vscode/c_cpp_properties.json
with:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/../SVF/**",
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "macos-clang-arm64",
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
]
}
],
"version": 4
}
-
.vscode/settings.json
with:
(i.e., make it empty.)
Now you can follow Section 2 from the Docker/VSCode instructions.
Note: if an assertion is triggered, as is usually the case with failed test cases, the debugger will take you to some scary assembly (actually where the code stopped execution in some system library). Don't fret, you can still move around the call stack to someplace more familiar.