Intel® Software Guard Extensions (Intel® SGX)
Discussion board focused on hardware-based isolation and memory encryption to provide extended code protection in solutions.

Intel SGX Debug (sgx-gdb) in Ubuntu 18.04.2 LTS

Khandaker__Mustakimu
2,304 Views

Hi

I have successfully built and enabled Intel SGX in my Ubuntu 18.4.2 LTS machine. Kernel version 4.15.0-46-generic. Everything works perfectly except the sgx-gdb which sgx enclave debugger. I have the sgx-sdk in my build and while I am using it with a breakpoint in the enclave, it is not caught. Rather it shows the following messages:

Function "notify_gdb_to_update" not defined.
Function "sgx_debug_load_state_add_element" not defined.
Function "sgx_debug_unload_state_remove_element" not defined.
Function "urts_add_tcs" not defined.
Function "random_stack_notify_gdb" not defined.
Python Exception <class 'gdb.error'> No symbol "g_debug_enclave_info_list" in current context.: 
Details following:
Reading symbols from app...done.
(gdb) br Enclave/Enclave.cpp:29
No source file named Enclave/Enclave.cpp.
Make breakpoint pending on future shared library load? (y or ) y
Breakpoint 1 (Enclave/Enclave.cpp:29) pending.
(gdb) r
Starting program: /home/mustakim/SGX-Iago/linux-sgx/SampleCode/SampleEnclave/app 
detect urts is loaded, initializing
Function "notify_gdb_to_update" not defined.
Function "sgx_debug_load_state_add_element" not defined.
Function "sgx_debug_unload_state_remove_element" not defined.
Function "urts_add_tcs" not defined.
Function "random_stack_notify_gdb" not defined.
Python Exception <class 'gdb.error'> No symbol "g_debug_enclave_info_list" in current context.: 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[CEnclavePool /home/mustakim/SGX-Iago/linux-sgx/psw/urts/enclave.cpp:566] enter CEnclavePool constructor
[parse_dyn /home/mustakim/SGX-Iago/linux-sgx/psw/urts/parser/elfparser.cpp:154] dynamic tag = 10, ptr = 0
[parse_dyn /home/mustakim/SGX-Iago/linux-sgx/psw/urts/parser/elfparser.cpp:154] dynamic tag = 1a, ptr = 243940
[parse_dyn /home/mustakim/SGX-Iago/linux-sgx/psw/urts/parser/elfparser.cpp:154] dynamic tag = 1c, ptr = 40
....
[enclave_create sgx_enclave_common.cpp:220] 
 secs->attibutes.flags = 6, secs->attributes.xfrm = 7 
[build_secs /home/mustakim/SGX-Iago/linux-sgx/psw/urts/loader.cpp:477] enclave start address = 0x7ffff4000000, size = 0x1000000
[reg_sig_handler sig_handler.cpp:189] signal handler is registered
[__create_enclave /home/mustakim/SGX-Iago/linux-sgx/psw/urts/urts_com.h:336] add tcs 0x7ffff43b9000
[__create_enclave /home/mustakim/SGX-Iago/linux-sgx/psw/urts/urts_com.h:336] add tcs 0x7ffff442d000
[__create_enclave /home/mustakim/SGX-Iago/linux-sgx/psw/urts/urts_com.h:336] add tcs 0x7ffff44a1000
[__create_enclave /home/mustakim/SGX-Iago/linux-sgx/psw/urts/urts_com.h:336] add tcs 0x7ffff4515000
[__create_enclave /home/mustakim/SGX-Iago/linux-sgx/psw/urts/urts_com.h:336] add tcs 0x7ffff4589000
[__create_enclave /home/mustakim/SGX-Iago/linux-sgx/psw/urts/urts_com.h:336] add tcs 0x7ffff45fd000
[__create_enclave /home/mustakim/SGX-Iago/linux-sgx/psw/urts/urts_com.h:336] add tcs 0x7ffff4671000
[__create_enclave /home/mustakim/SGX-Iago/linux-sgx/psw/urts/urts_com.h:336] add tcs 0x7ffff46e5000
[__create_enclave /home/mustakim/SGX-Iago/linux-sgx/psw/urts/urts_com.h:336] add tcs 0x7ffff4759000
[__create_enclave /home/mustakim/SGX-Iago/linux-sgx/psw/urts/urts_com.h:336] add tcs 0x7ffff47cd000
[__create_enclave /home/mustakim/SGX-Iago/linux-sgx/psw/urts/urts_com.h:346] Debug enclave. Checking if VTune is profiling or SGX_DBG_OPTIN is set
[__create_enclave /home/mustakim/SGX-Iago/linux-sgx/psw/urts/urts_com.h:392] VTune is not profiling and SGX_DBG_OPTIN is not set. TCS Debug OPTIN bit not set and API to do module mapping not invoked
Checksum(0x0x7fffffffdb10, 100) = 0xfffd4143
[New Thread 0x7ffff5f5c700 (LWP 23915)]
[New Thread 0x7ffff3fff700 (LWP 23916)]
[New Thread 0x7ffff37fe700 (LWP 23917)]
[Thread 0x7ffff3fff700 (LWP 23916) exited]
[Thread 0x7ffff5f5c700 (LWP 23915) exited]
[New Thread 0x7ffff2ffd700 (LWP 23918)]
[Thread 0x7ffff37fe700 (LWP 23917) exited]
Info: executing thread synchronization, please wait...  
[Thread 0x7ffff2ffd700 (LWP 23918) exited]
[New Thread 0x7ffff2ffd700 (LWP 23919)]
[New Thread 0x7ffff37fe700 (LWP 23920)]
[New Thread 0x7ffff3fff700 (LWP 23921)]
[New Thread 0x7ffff5f5c700 (LWP 23922)]
[New Thread 0x7ffff27fc700 (LWP 23923)]
[Thread 0x7ffff27fc700 (LWP 23923) exited]
[Thread 0x7ffff3fff700 (LWP 23921) exited]
[Thread 0x7ffff5f5c700 (LWP 23922) exited]
[Thread 0x7ffff37fe700 (LWP 23920) exited]
[Thread 0x7ffff2ffd700 (LWP 23919) exited]
Info: SampleEnclave successfully returned.
Enter a character before exit ...

[Inferior 1 (process 23911) exited normally]

 

0 Kudos
2 Replies
Nguyen__Minh
Beginner
2,304 Views

Hi,

Did you try the deb_sgx_enclave_common_dev_pkg for SGX PSW installation? I encountered the same problem while using psw_install_pkg.

When sgx_dbg works, you won't see the "not define" warning

Minh

0 Kudos
Benny_F_
Beginner
2,304 Views

Hello,

I seem to have a related problem under Ubuntu 18.04.1 LTS. I use the SDK in version 2.5. I installed libsgx-enclave-common_2.5.101.50123-bionic1_amd64.deb, libsgx-enclave-common-dbgsym_2.5.101.50123-bionic1_amd64.ddeb  and libsgx-enclave-common-dev_2.5.101.50123-bionic1_amd64.deb     

In the following, you see the output that I get when I want to debug an unchanged version of the SampleEnclave. I can successfully build and run it. I'm also sure that I build it in debug mode.

<machine>:~/sgxsdk/SampleCode/SampleEnclave$ ~/sgxsdk/bin/sgx-gdb ./app
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Source directories searched: /home/<user>/sgxsdk/lib64/gdb-sgx-plugin:$cdir:$cwd
Setting environment variable "LD_PRELOAD" to null value.
Reading symbols from ./app...done.
(gdb) br Enclave/Enclave.cpp:46
No source file named Enclave/Enclave.cpp.
Make breakpoint pending on future shared library load? (y or ) y
Haltepunkt 1 (Enclave/Enclave.cpp:46) anstehend.
(gdb) r
Starting program: /home/<user>/sgxsdk/SampleCode/SampleEnclave/app 
detect urts is loaded, initializing
Function "random_stack_notify_gdb" not defined.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Error parsing enclave file.  Check format of file.
Checksum(0x0x7fffffffdc90, 100) = 0xfffd4143
[New Thread 0x7ffff5f94700 (LWP 3658)]
[New Thread 0x7ffff3fff700 (LWP 3659)]
[Thread 0x7ffff5f94700 (LWP 3658) exited]
[New Thread 0x7ffff37fe700 (LWP 3660)]
[Thread 0x7ffff3fff700 (LWP 3659) exited]
[New Thread 0x7ffff2ffd700 (LWP 3661)]
[Thread 0x7ffff37fe700 (LWP 3660) exited]
Info: executing thread synchronization, please wait...  
[Thread 0x7ffff2ffd700 (LWP 3661) exited]
[New Thread 0x7ffff2ffd700 (LWP 3662)]
[New Thread 0x7ffff37fe700 (LWP 3663)]
[New Thread 0x7ffff3fff700 (LWP 3664)]
[New Thread 0x7ffff5f94700 (LWP 3665)]
[New Thread 0x7ffff27fc700 (LWP 3666)]
[Thread 0x7ffff3fff700 (LWP 3664) exited]
[Thread 0x7ffff2ffd700 (LWP 3662) exited]
[Thread 0x7ffff27fc700 (LWP 3666) exited]
[Thread 0x7ffff37fe700 (LWP 3663) exited]
[Thread 0x7ffff5f94700 (LWP 3665) exited]
Error parsing enclave file.  Check format of file.
Info: SampleEnclave successfully returned.
Enter a character before exit ...

[Inferior 1 (process 3653) exited normally]
(gdb) quit

I also tried it in eclipse by setting the sgx-gdb debugger in den Debugger tab. It simply jumps over the breakpoint inside of he enclave without any message.

0 Kudos
Reply