Skip to content

Commit

Permalink
linuxkm: add support for WOLFSSL_DEBUG_BACKTRACE_ERROR_CODES using du…
Browse files Browse the repository at this point in the history
…mp_stack().
  • Loading branch information
douzzer committed Aug 20, 2024
1 parent e43a982 commit a7998a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions linuxkm/linuxkm_wc_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,10 @@
#endif
#endif

#ifdef WOLFSSL_DEBUG_BACKTRACE_ERROR_CODES
typeof(dump_stack) *dump_stack;
#endif

const void *_last_slot;
};

Expand Down Expand Up @@ -777,6 +781,10 @@
#endif
#endif

#ifdef WOLFSSL_DEBUG_BACKTRACE_ERROR_CODES
#define dump_stack (wolfssl_linuxkm_get_pie_redirect_table()->dump_stack)
#endif

#endif /* __PIE__ */

#endif /* USE_WOLFSSL_LINUXKM_PIE_REDIRECT_TABLE */
Expand Down
4 changes: 4 additions & 0 deletions linuxkm/module_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@ static int set_up_wolfssl_linuxkm_pie_redirect_table(void) {
#endif
#endif

#ifdef WOLFSSL_DEBUG_BACKTRACE_ERROR_CODES
wolfssl_linuxkm_pie_redirect_table.dump_stack = dump_stack;
#endif

/* runtime assert that the table has no null slots after initialization. */
{
unsigned long *i;
Expand Down
9 changes: 9 additions & 0 deletions wolfcrypt/src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,14 @@ void WOLFSSL_ERROR_MSG(const char* msg)

#ifdef WOLFSSL_DEBUG_BACKTRACE_ERROR_CODES

#ifdef WOLFSSL_LINUXKM

void wc_backtrace_render(void) {
dump_stack();
}

#else /* !WOLFSSL_LINUXKM */

#include <backtrace-supported.h>

#if BACKTRACE_SUPPORTED != 1
Expand Down Expand Up @@ -1848,5 +1856,6 @@ void wc_backtrace_render(void) {

wc_UnLockMutex(&backtrace_mutex);
}
#endif /* !WOLFSSL_LINUXKM */

#endif /* WOLFSSL_DEBUG_BACKTRACE_ERROR_CODES */

0 comments on commit a7998a2

Please sign in to comment.