-
Notifications
You must be signed in to change notification settings - Fork 28
Assignment 1 Python
Use Alt + F12
to open a terminal in VSCode and then type the below command line.
Your implementation | ctest command line |
---|---|
Your reachability analysis | ctest -R "ass1-icfg-py/" |
Your points-to analysis | ctest -R "ass1-pta-py/" |
Your taint analysis | ctest -R "ass1-taint-py/" |
The entire Assignment-1 | ctest -R "ass1-.*-py/" |
Use the command wpa -ander -dump-icfg test1.ll
to generate the ICFG graph for your .ll
file. You can then view it as described above.
You can use the following commands to view the expected results for constraint graphs and points-to sets.
NOT
the results of your implementation — they represent the correct answers.
You should use them to compare with your own program’s output and debug accordingly.
- Use
wpa -ander -print-pts test1.ll
to print the final points-to set of each node to validateMAYALIAS
andNOALIAS
. - Use
wpa -ander -print-constraint-graph test1.ll
to print edges and nodes of the constraint graph. - Use
wpa -ander -dump-constraint-graph test1.ll
to export the graph to a dot file for visualization.
Retrieve or manipulate a variable's points-to set using the SVF APIs shown here.
Constraint Edge | Corresponding Color in Dot graphs (PAG and ConstraintGraph) |
---|---|
ADDR | Green |
COPY | Black or (dashed arrow for interprocedural COPY edges) |
LOAD | Red |
STORE | Blue |
GEP | Purple |
This guide walks you through converting a C++(C) source file to an interactive SVG representation of its Interprocedural Control Flow Graph (ICFG) using SVF tools.
Press Alt + F12
to open a terminal first.
clang++ -S -emit-llvm source.cpp(c) -o output.ll
-
-S
: Generate assembly (LLVM IR). -
-emit-llvm
: Emit LLVM IR instead of machine code. -
-o output.ll
: Output filename for the IR.
wpa -ander -dump-icfg output.ll
-
wpa
: Whole Program Analysis tool from SVF. -
-ander
: Enables Andersen’s pointer analysis. -
-dump-icfg
: Dumps the Interprocedural Control Flow Graph (ICFG) into a DOT file.
mv svfir_initial.dot output.dot
- Rename the auto-generated dot file to something meaningful.
dot -Tsvg output.dot -o output.svg
-
dot
: Graphviz command-line tool. -
-Tsvg
: Output format as SVG. -
-o output.svg
: Specifies the output file name.
google-chrome output.svg
However, if you're working inside a container, this command won’t work because GUI applications like Chrome can't run inside most containers.
Instead, copy the absolute path
to the .svg file, then paste it into the address bar
of Chrome on your host machine to view it
If you're successful, you'll see something similar to the output below.
✅ Alternatively, you can open it directly in VSCode with the Graphviz Preview extension.
clang++ -S -emit-llvm test1.cpp -o test1.ll
wpa -ander -dump-icfg test1.ll
mv svfir_initial.dot test1.dot
dot -Tsvg test1.dot -o test1.svg
google-chrome test1.svg
- Upload
Assignment1.py
to UNSWWebCMS
for your submission.
Your implementation will be evaluated against our 10 internal tests. You will get the full marks if your code can pass them all. Our internal tests are private. Here, we only provided a handful test cases under Assignment-1/Tests/testcases
. You are encouraged to add more test cases by yourself to validate the correctness of your implementation.
- You will be working on Assignment1.py
only and there is NO need to modify other files under the Assignment-1 folder
To debug in PyCharm
with parameters
, first set the parameters in Run > Edit Configurations, like below
After you set parameters, then set a breakpoint in your code, and finally right-click the script and select Debug to start debugging.