Skip to content

Commit

Permalink
improve debugging with ego-gdb
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasten committed Apr 24, 2024
1 parent d9415aa commit 4638e77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ project(ego VERSION 1.5.0)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
# disable optimizations to improve debugging with gdb
set(PREMAIN_DEBUG_FLAGS -gcflags=all='-N -l')
else()
set(TRIMPATH -trimpath)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
Expand Down Expand Up @@ -39,7 +42,7 @@ target_link_libraries(ego-enclave-lib PRIVATE openenclave::oe_includes)
add_custom_command(
OUTPUT premain.a
DEPENDS ego/premain/main.go ego/premain/core/core.go
COMMAND ertgo build -buildmode=c-archive -o ${CMAKE_BINARY_DIR} ${TRIMPATH}
COMMAND ertgo build -buildmode=c-archive -o ${CMAKE_BINARY_DIR} ${TRIMPATH} ${PREMAIN_DEBUG_FLAGS}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/ego/premain)
add_custom_target(premainbuild DEPENDS premain.a)

Expand Down
5 changes: 4 additions & 1 deletion docs/docs/workflows/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ An EGo executable can be run as a normal host process without an enclave. Thus,

## Inside an enclave

EGo comes with `ego-gdb` that augments `gdb` with enclave support. The `console` interface is the same as `gdb`:
EGo comes with `ego-gdb` that augments `gdb` with enclave support.
For a better debugging experience with it, compile your app without optimizations by passing `-gcflags=all="-N -l"` to `ego-go build`.

The `console` interface of `ego-gdb` is the same as `gdb`:

```bash
ego-gdb --args ./helloworld
Expand Down

0 comments on commit 4638e77

Please sign in to comment.