incubator-teaclave-sgx-sdk
incubator-teaclave-sgx-sdk copied to clipboard
Derive Debug trait for SGX types
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.
i remember last time i failed on large arrays. just created a new branch to continue ...
I believe Debug is only implemented for [T: n], where n <= 32. So, yes, some types need manual implementation for Debug trait.
check https://github.com/apache/incubator-teaclave-sgx-sdk/commit/3c1edf464a6353f14fd0f665a1206494bea6c5a6
@volcano0dr how do you think about it? https://github.com/apache/incubator-teaclave-sgx-sdk/commit/3c1edf464a6353f14fd0f665a1206494bea6c5a6
It's OK.
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.