linuxkm: add DEBUG_VECTOR_REGISTER_ACCESS (debug feature switch), ASSERT_SAVED_VECTOR_REGISTERS, and ASSERT_RESTORED_VECTOR_REGISTERS macros, and move the fallback no-op definitions of the SAVE_VECTOR_REGISTERS and RESTORE_VECTOR_REGISTERS to types.h. also fixed several ASCII TAB characters in types.h.

This commit is contained in:
Daniel Pouzzner
2021-10-18 23:45:02 -05:00
parent e0395c6441
commit 85a8c06062
4 changed files with 38 additions and 25 deletions

View File

@@ -186,6 +186,12 @@ static struct log mynewt_log;
#endif /* DEBUG_WOLFSSL */
#ifdef DEBUG_VECTOR_REGISTER_ACCESS
THREAD_LS_T int wc_svr_count = 0;
THREAD_LS_T const char *wc_svr_last_file = NULL;
THREAD_LS_T int wc_svr_last_line = -1;
#endif
/* allow this to be set to NULL, so logs can be redirected to default output */
int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb f)

View File

@@ -639,6 +639,7 @@ static int wolfssl_pb_print(const char* msg, ...)
va_end(args);
PRINT_HEAP_CHECKPOINT();
TEST_SLEEP();
ASSERT_RESTORED_VECTOR_REGISTERS(exit(1););
}
#else
/* redirect to printf */
@@ -648,6 +649,7 @@ static int wolfssl_pb_print(const char* msg, ...)
return err_sys("post-test check failed", -1); \
} \
PRINT_HEAP_CHECKPOINT(); \
ASSERT_RESTORED_VECTOR_REGISTERS(exit(1);); \
}
/* stub the sleep macro */
#define TEST_SLEEP()

View File

@@ -1179,8 +1179,28 @@ decouple library dependencies with standard string, memory and so on.
#define PRAGMA_CLANG_DIAG_POP
#endif
#ifdef DEBUG_VECTOR_REGISTER_ACCESS
WOLFSSL_API extern THREAD_LS_T int wc_svr_count;
WOLFSSL_API extern THREAD_LS_T const char *wc_svr_last_file;
WOLFSSL_API extern THREAD_LS_T int wc_svr_last_line;
#define SAVE_VECTOR_REGISTERS(...) { ++wc_svr_count; if (wc_svr_count > 5) {fprintf(stderr, "%s @ L%d : incr : wc_svr_count %d (last op %s L%d)\n", __FILE__, __LINE__, wc_svr_count, wc_svr_last_file, wc_svr_last_line);} wc_svr_last_file = __FILE__; wc_svr_last_line = __LINE__; }
#define ASSERT_SAVED_VECTOR_REGISTERS(fail_clause) {if (wc_svr_count <= 0) {fprintf(stderr, "ASSERT_SAVED_VECTOR_REGISTERS : %s @ L%d : wc_svr_count %d (last op %s L%d)\n", __FILE__, __LINE__, wc_svr_count, wc_svr_last_file, wc_svr_last_line); { fail_clause }}}
#define ASSERT_RESTORED_VECTOR_REGISTERS(fail_clause) {if (wc_svr_count != 0) {fprintf(stderr, "ASSERT_RESTORED_VECTOR_REGISTERS : %s @ L%d : wc_svr_count %d (last op %s L%d)\n", __FILE__, __LINE__, wc_svr_count, wc_svr_last_file, wc_svr_last_line); { fail_clause }}}
#define RESTORE_VECTOR_REGISTERS(...) {--wc_svr_count; if (wc_svr_count > 4) {fprintf(stderr, "%s @ L%d : decr : wc_svr_count %d (last op %s L%d)\n", __FILE__, __LINE__, wc_svr_count, wc_svr_last_file, wc_svr_last_line);} wc_svr_last_file = __FILE__; wc_svr_last_line = __LINE__; }
#else
#ifndef SAVE_VECTOR_REGISTERS
#define SAVE_VECTOR_REGISTERS(...) do{}while(0)
#endif
#ifndef ASSERT_SAVED_VECTOR_REGISTERS
#define ASSERT_SAVED_VECTOR_REGISTERS(...) do{}while(0)
#endif
#ifndef ASSERT_RESTORED_VECTOR_REGISTERS
#define ASSERT_RESTORED_VECTOR_REGISTERS(...) do{}while(0)
#endif
#ifndef RESTORE_VECTOR_REGISTERS
#define RESTORE_VECTOR_REGISTERS() do{}while(0)
#endif
#endif
#ifdef __cplusplus
} /* extern "C" */

View File

@@ -161,12 +161,6 @@
#ifndef WOLFSSL_NO_ASM
#define WOLFSSL_NO_ASM
#endif
#ifndef SAVE_VECTOR_REGISTERS
#define SAVE_VECTOR_REGISTERS(...) ({})
#endif
#ifndef RESTORE_VECTOR_REGISTERS
#define RESTORE_VECTOR_REGISTERS() ({})
#endif
#endif
_Pragma("GCC diagnostic pop");
@@ -617,15 +611,6 @@
#endif /* BUILDING_WOLFSSL */
#else /* ! WOLFSSL_LINUXKM */
#ifndef SAVE_VECTOR_REGISTERS
#define SAVE_VECTOR_REGISTERS(...) do{}while(0)
#endif
#ifndef RESTORE_VECTOR_REGISTERS
#define RESTORE_VECTOR_REGISTERS() do{}while(0)
#endif
#endif /* WOLFSSL_LINUXKM */
/* THREADING/MUTEX SECTION */