intel / linux-sgx

Intel SGX for Linux*
https://www.intel.com/content/www/us/en/developer/tools/software-guard-extensions/linux-overview.html
Other
1.33k stars 545 forks source link

Unable to debug in hardware mode #601

Open Arslan8 opened 4 years ago

Arslan8 commented 4 years ago

Hi, I am trying to debug libsgx_urts, however sgx-gdb is unable to find the symbols. Here are my build instructions:

apt-get remove libsgx-launch* libsgx-urts*  libsgx-epid*  libsgx-quote-ex*  libsgx-dcap-ql* && apt-get install libsgx-launch-dbgsym  libsgx-urts-dbgsym libsgx-epid-dbgsym  libsgx-quote-ex-dbgsym  libsgx-dcap-ql-dbgsym 

I have checked my gdb and it does look for the files in "/usr/lib/dbg" and dpk -L does show the .debug file.

/usr/lib/debug/.build-id/14/4d4abb30e140eb8889caaf1a3a2878fd29e35c.debug

However, as you can see in the backtrace the debug symbols are still missing:

#0  ioctl () at ../sysdeps/unix/syscall-template.S:78
#1  0x00007ffff7f840f4 in enclave_create () from /usr/lib/x86_64-linux-gnu/libsgx_enclave_common.so.1
#2  0x00007ffff7f981a7 in EnclaveCreatorHW::create_enclave(_secs_t*, unsigned long*, void**, bool) () from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#3  0x00007ffff7f91626 in CLoader::build_secs(_attributes_t*, unsigned char (*) [64], unsigned short, _sgx_misc_attribute_t*) () from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#4  0x00007ffff7f91efc in CLoader::build_image(SGXLaunchToken*, _attributes_t*, unsigned char (*) [64], unsigned short, _le_prd_css_file_t*, _sgx_misc_attribute_t*) ()
   from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#5  0x00007ffff7f92ba6 in CLoader::load_enclave(SGXLaunchToken*, int, _metadata_t const*, unsigned char (*) [64], unsigned short, _le_prd_css_file_t*, _sgx_misc_attribute_t*) ()
   from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#6  0x00007ffff7f92c27 in CLoader::load_enclave_ex(SGXLaunchToken*, bool, _metadata_t const*, unsigned char (*) [64], unsigned short, _le_prd_css_file_t*, _sgx_misc_attribute_t*) ()
   from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#7  0x00007ffff7f96dcf in _create_enclave_from_buffer_ex(bool, unsigned char*, unsigned long, _se_file_t&, _le_prd_css_file_t*, unsigned long*, _sgx_misc_attribute_t*, unsigned int, void const**) ()
   from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#8  0x00007ffff7f97708 in _create_enclave_ex(bool, int, _se_file_t&, _le_prd_css_file_t*, unsigned char (*) [1024], int*, unsigned long*, _sgx_misc_attribute_t*, unsigned int, void const**) ()
   from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#9  0x00007ffff7f9781c in __sgx_create_enclave_ex.part.18 () from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#10 0x00007ffff7f9793d in sgx_create_enclave () from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#11 0x0000555555557202 in initialize_enclave () at App/App.cpp:169
#12 0x0000555555557256 in main (argc=1, argv=0x7fffffffdb58) at App/App.cpp:198

Any leads what might be going wrong here? I am using sdk 2.9

xxu36 commented 4 years ago

The symbols of urts were there, otherwise we shall see ??? as the function names in the bt. Something like the following:

#0  0x00007ffff7fb3fa0 in enclave_create () from /usr/lib/x86_64-linux-gnu/libsgx_enclave_common.so.1
#1  0x00007ffff7fc81a7 in ?? () from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#2  0x00007ffff7fc1626 in ?? () from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#3  0x00007ffff7fc1efc in ?? () from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#4  0x00007ffff7fc2ba6 in ?? () from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#5  0x00007ffff7fc2c27 in ?? () from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#6  0x00007ffff7fc6dcf in ?? () from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#7  0x00007ffff7fc7708 in ?? () from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#8  0x00007ffff7fc781c in ?? () from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#9  0x00007ffff7fc793d in sgx_create_enclave () from /usr/lib/x86_64-linux-gnu/libsgx_urts.so
#10 0x00005555555571f6 in initialize_enclave () at App/App.cpp:161
#11 0x0000555555557252 in main (argc=1, argv=0x7fffffffe078) at App/App.cpp:188
Arslan8 commented 4 years ago

@xxu36 thanks for the response.. I am a little confused now, why doesn't it point to the line number in the file? is this something related to SGX libraries?

xxu36 commented 4 years ago

I think the answer is yes. The released packages are using release build instead of debug build, so the line numbers are not available. If you build it from source code and build it in debug mode, you can see the line number.