Debug basics
Step-by-Step Guide
- 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) orCmd+Shift+X
(Mac). - Search for CMake(by twxs) & CMake Tools(by microsoft) & C/C++ and click Install.
- Open the Command Palette:
- Open the Command Palette by typing
Ctrl+Shift+P
(Windows/Linux) orCmd+Shift+P
(Mac).
- Open the Command Palette by typing
- 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) orCmd+B
(Mac) and clickOpen Folder
- Choose
working directory (ex. 01-deque)
directory as a root.
- In the Command Palette, type
- Run Debug:
- Open debug target's source code
ex. deque_test.cpp
. - Open the Command Palette by typing
Ctrl+Shift+P
(Windows/Linux) orCmd+Shift+P
(Mac). - type
Cmake
, and chooseCmake: Debug
- If you want to change debug target, Open the Command Palette by typing
Ctrl+Shift+P
(Windows/Linux) orCmd+Shift+P
(Mac), and chooseCmake: Set Launch/Debug target
- You can choose different debug target within directories under CMake
- Open debug target's source code
- Debug Tips:
- You can use some hot-keys in vscode debugger.
hot-keys Description F5
Debugging F9
Set breakpoint F10
Jump to next line Shift + F5
Terminate debugging Ctrl + K + F
Auto indent - There's a quick info box you can use to handle the debugger more easily.
From left to right,- Continue
- Step over (Jump to next line)
- Step into (Jump into function)
- Step out (Execute all statement of function)
- Restart
- Stop
- You can use some hot-keys in vscode debugger.