Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

headers: Add macro to print error code as string #366

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pdxjohnny
Copy link
Member

  • Adds a PRINT_SGX_STATUS macro to sgx_error.h which prints
    the sgx_status_t as a string.

* Adds a PRINT_SGX_STATUS macro to sgx_error.h which prints
  the sgx_status_t as a string.
@pdxjohnny
Copy link
Member Author

pdxjohnny commented Jan 23, 2019

Generated with:

(
echo -e '#define PRINT_SGX_STATUS(FILE_STRUCT, STATUS_T) \\\n    switch (STATUS_T) {\\';
for error in $(grep -E '=.*SGX_MK_ERROR' /opt/intel/sgxsdk/include/sgx_error.h | awk '{print $1}' | sed 's/=//g'); do
  printf '    case %s:\\\n        fprintf(FILE_STRUCT, "Error: %s\\n");\\\n        break;\\\n' $error $error;
done;
echo -e '    }'
)

@pdxjohnny
Copy link
Member Author

maybe this would be better as something similar to perror called sgx_perror or something. Where it acts just as perror does but for sgx_status_t errors

@sergefdrv
Copy link

Might be even better to make it similar to strerror, for fine control of output. Think of advanced logging mechanism.

@pdxjohnny
Copy link
Member Author

Ya that is probably a better option, I think that's what was started in #346 perhaps that PR should be one PR introducing the strerror and another adding the logging to various places.

@pdxjohnny
Copy link
Member Author

Something similar is going on in the examples

static sgx_errlist_t sgx_errlist[] = {
{
SGX_ERROR_UNEXPECTED,
"Unexpected error occurred.",
NULL
},
{
SGX_ERROR_INVALID_PARAMETER,
"Invalid parameter.",
NULL
},
{
SGX_ERROR_OUT_OF_MEMORY,
"Out of memory.",
NULL
},

@Icaro-Lima
Copy link
Contributor

Hello, I was disinclined to continue working on my pull request after the comment from the Intel member himself saying that maybe it did not help much. And I still maintain my position, I think it is very important and avoids many lines of unnecessary codes that will be inserted in each enclave.

@pdxjohnny
Copy link
Member Author

I agree. As I posted above something similar was done in the sample enclave code. If its useful there then it is of course useful and instead of duplicating that functionality it should be a part of the SDK.

@LuminousXLB
Copy link

I believe that it's a really useful patch.
FYI, here's how I did the same thing.

https://pastebin.com/PT4Ds8WQ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants