Intel has provided sgx-gdb
for conveniently debugging SGX applications. However, it can only be interacted via terminal, which may be a little bit hard for beginners. This article introduces how to debug SGX applications in VS Code.
Prerequisites
- An SGX-compatible Linux system
- Visual Studio Code
- Fully SGX environment (with debug symbol installed, if not please follow this instruction)
- VS Code Extension:
Native Debug
installed
Steps
- Open the SGX project folder with your VS Code, and click the following icon in the left sidebar (or press Ctrl+Shift+D) to open RUN AND DEBUG window.
- Add a new configuration, and then an
launch.json
file will be opened. - Copy the following lines to the file:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(sgx) Debug",
"type": "gdb",
"request": "launch",
"target": "app",
"cwd": "${workspaceRoot}/",
"valuesFormatting": "parseText",
"gdbpath": "sgx-gdb"
}
]
}
This configuration assumes that your executable file is named as app
and at the root directory of your project. If not, please modify the cwd
(current working directory) and target
(executable binary) values.
- Add any breakpoint in your code and try it!