Skip to content

Commit 25ff4a7

Browse files
committed
add debug description to README
Signed-off-by: Jun Kimura <junkxdev@gmail.com>
1 parent 052e658 commit 25ff4a7

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

samples/hello-rust/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,51 @@ Remove all build artifacts:
6767
make clean
6868
```
6969

70+
### Debug with sgx-gdb
71+
72+
The Intel SGX SDK provides `sgx-gdb`, a GDB extension for debugging SGX enclaves.
73+
74+
#### Build for Debugging
75+
76+
**Important**: To use the debugger, you must build with debug symbols:
77+
78+
```bash
79+
make clean
80+
make DEBUG=1 all
81+
```
82+
83+
This builds both the enclave and application with debug information (`-g` flag).
84+
85+
#### Basic Debugging
86+
87+
To debug the application and enclave:
88+
89+
```bash
90+
cd bin
91+
SGX_DEBUG=1 sgx-gdb ./app
92+
```
93+
94+
#### Memory Usage Analysis
95+
96+
You can use the SGX Enclave Memory Measurement Tool (EMMT) to analyze enclave memory usage:
97+
98+
```bash
99+
cd bin
100+
SGX_DEBUG=1 sgx-gdb -ex="enable sgx_emmt" -ex=r --args ./app
101+
```
102+
103+
This will show peak memory usage after the enclave exits:
104+
105+
```
106+
[+] Init Enclave Successful 3077026240004098!
107+
[+] ecall_sample success...
108+
[+] Enclave returned: Hello from enclave: Hello, world!
109+
Enclave: "/path/to/sgx-sdk-rs/samples/hello-rust/bin/enclave.signed.so"
110+
[Peak stack used]: 5 KB
111+
[Peak heap used]: 4 KB
112+
[Peak reserved memory used]: 0 KB
113+
```
114+
70115
## Understanding the Code
71116

72117
- **app/**: Contains the untrusted host application that loads and communicates with the enclave

0 commit comments

Comments
 (0)