Skip to content

Lab Exercise 1

Jiawei Wang edited this page May 27, 2024 · 46 revisions

Lab-Exercise-1 folder layout

$tree Lab-Exercise-1
├── GraphAlgorithm.cpp
├── GraphAlgorithm.h
├── test.cpp
├── CMakeLists.txt

1. Get the latest Lab-Exercise-1 code template

* Before coding, please type cd $HOME/Software-Security-Analysis and git pull in your terminal to make sure you always have the latest version of the code template before coding.

If git pull fails due to the conflict with your local changes, type git stash to store your current code in a temporal branch and type git pull again. If you want to retrieve your code back, type git stash pop.

2. Lab-Exercise-1 coding task

Function Description Marks
reachability DFS to traverse each program path from src to dst 50%
solveWorklist Constraint solving 50%
  • Run ctest -R lab1 -VV and pass the test without any assertion by test.cpp
  • Upload GraphAlgorithm.cpp to UNSW WebCMS for your submission when you are finished with this lab. Your implementation will be evaluated against our internal tests. You will get the full marks if your code can pass them all. Unfortunately, internal tests are private. Here, we only provided two test cases in test.cpp. You are encouraged to add more test cases by yourself to validate the correctness of your implementation.

*You will be working on GraphAlgorithm.cpp only and there is NO need to modify other files under the Lab-Exercise-1 folder

3. Configuration && debugging

To enable debugging and running, switch your executable by setting the program and args fields as described here or follow the below screenshot.

3.2 Debug your code

*If there is an assertion or unexpected output, you will need to debug and find bugs.

Step 1: Set the breakpoint where you want to stop your program and press the 'debug' button

Step 2: 'Step over' /'Step in' / 'Step out'

  • 'Step over' to the next step of your program
  • 'Step in' to the current line of your program
  • 'Step out' to mainstream of your program where you stepped in before

Step 3: During your debugging, you can also watch the value of a variable you are interested in.


More information about C++

Clone this wiki locally