Skip to main content

Debug basics

Step-by-Step Guide

  1. Install the CMake & CMake Tools Extension:
    • Open VS Code.
    • Go to the Extensions view by clicking on the square icon in the sidebar or typing Ctrl+Shift+X (Windows/Linux) or Cmd+Shift+X (Mac).
    • Search for CMake(by twxs) & CMake Tools(by microsoft) & C/C++ and click Install.
      alt text
  2. Open the Command Palette:
    • Open the Command Palette by typing Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac). alt text
  3. Connect to Host and set working space as root directory:
    • In the Command Palette, type Remote-SSH: Connect to Host... and select it.
    • Enter the user@host. compsec@kayle.snu.ac.kr:[port].
    • Replace [port] with your port number.
    • Type Ctrl+B(Windows/Linux) or Cmd+B(Mac) and click Open Folder
    • Choose working directory (ex. 01-deque) directory as a root. alt text
  4. Run Debug:
    • Open debug target's source code ex. deque_test.cpp.
    • Open the Command Palette by typing Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac).
    • type Cmake, and choose Cmake: Debug alt text
    • If you want to change debug target, Open the Command Palette by typing Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac), and choose Cmake: Set Launch/Debug target alt text
    • You can choose different debug target within directories under CMake alt text
  5. Debug Tips:
    • You can use some hot-keys in vscode debugger.
      hot-keysDescription
      F5Debugging
      F9Set breakpoint
      F10Jump to next line
      Shift + F5Terminate debugging
      Ctrl + K + FAuto indent
    • There's a quick info box you can use to handle the debugger more easily.
      alt text
      From left to right,
      1. Continue
      2. Step over (Jump to next line)
      3. Step into (Jump into function)
      4. Step out (Execute all statement of function)
      5. Restart
      6. Stop