incubator-teaclave-sgx-sdk icon indicating copy to clipboard operation
incubator-teaclave-sgx-sdk copied to clipboard

Derive Debug trait for SGX types

Open tatetian opened this issue 5 years ago • 6 comments

Background

When debugging, one usually needs to inspect the value of an object. For exactly this purpose, Rust offers the ability to implement or automatically derive Debug traits for user-defined types. Rust programmers have taken this godsend feature for granted.

Problem

However, the SGX-related types defined in sgx_types crate do not have Debug trait implemented or derived. This makes it really cumbersome to debug values of SGX types. This absence of Debug trait for basic types also deviates the practice in Rust std crate, where (almost) all types support Debug traits. Moreover, due to Rust's the orphan rule, it is impossible for the users of Rust SGX SDK to manually implement Debug trait for SGX types defined in sgx_types crate.

Feature Request

For the reasons above, I hope that Debug trait can be implemented (most can be derived automatically) for all SGX types defined in sgx_types. Thanks a lot.

tatetian avatar Apr 24 '20 03:04 tatetian

i remember last time i failed on large arrays. just created a new branch to continue ...

dingelish avatar Apr 24 '20 04:04 dingelish

I believe Debug is only implemented for [T: n], where n <= 32. So, yes, some types need manual implementation for Debug trait.

tatetian avatar Apr 24 '20 05:04 tatetian

check https://github.com/apache/incubator-teaclave-sgx-sdk/commit/3c1edf464a6353f14fd0f665a1206494bea6c5a6

dingelish avatar Apr 26 '20 01:04 dingelish

@volcano0dr how do you think about it? https://github.com/apache/incubator-teaclave-sgx-sdk/commit/3c1edf464a6353f14fd0f665a1206494bea6c5a6

dingelish avatar Apr 26 '20 03:04 dingelish

It's OK.

volcano0dr avatar Apr 27 '20 13:04 volcano0dr

Thanks for the quick coding! The commit looks good.

I got a question: why the implementation for Debug trait needs to be feature gated? I suppose that it is useful enough to be always enabled.

tatetian avatar Apr 27 '20 14:04 tatetian