Add debug messaging system to wolfPKCS11#100
Merged
Merged
Conversation
- Add DEBUG_WOLFPKCS11 compile flag support for conditional debug compilation - Implement wolfPKCS11_Debugging_On() and wolfPKCS11_Debugging_Off() functions - Add WOLFPKCS11_ENTER/LEAVE/MSG debug macros with printf output - Instrument public functions in wolfpkcs11.c, crypto.c, and slot.c - Add debug control function declarations to public API (pkcs11.h) - Include debug test program demonstrating functionality - Follow wolfSSL logging patterns for consistency Debug system provides function enter/exit tracing and parameter logging for public PKCS#11 functions when enabled with --enable-debug configure option. Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
- Replace direct printf calls with WOLFPKCS11_MSG macro - Add user-customizable macro support with #ifndef guards - Instrument all public PKCS#11 functions across crypto.c, slot.c, and wolfpkcs11.c - Ensure consistent debug logging pattern with enter/exit tracing and parameter details Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
SparkiDev
reviewed
Jun 19, 2025
… printf in slot.c, move debug_test.c to tests - Add varargs support to WOLFPKCS11_MSG macro for printf-style formatting - Replace all direct printf calls in slot.c with WOLFPKCS11_MSG macro calls - Convert all snprintf + WOLFPKCS11_MSG patterns to direct WOLFPKCS11_MSG calls - Move debug_test.c from root to tests directory as official test - Update tests/README.md to document debug_test.c purpose Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
…_MSG macro - Replace ##__VA_ARGS__ with standard __VA_ARGS__ for MSVC compatibility - Complete conversion of all snprintf + WOLFPKCS11_MSG patterns to direct varargs calls - Fixes 90 compilation errors in Windows CI build Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
- Add debug_test to tests/include.am for proper build and test integration - Return code 77 (skip test) when DEBUG_WOLFPKCS11 is not defined - Implement stdout capture mechanism to verify debug output is generated - Test passes/fails based on whether debug messages are actually produced - Follows wolfPKCS11 test framework patterns and conventions Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
- Change main() to main(void) to fix strict-prototypes warning - Remove unused debug_output_detected variable - Addresses CI build failures caused by -Werror treating warnings as errors Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
- Move variable declarations inside DEBUG_WOLFPKCS11 ifdef to avoid unused variable errors in non-debug builds - Ensure debug_test links against libwolfpkcs11.la in both static and dynamic builds Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
Member
|
I think this might be ready for review now. If it is approved, it might be a good idea to squash on merge. |
dgarske
requested changes
Jun 20, 2025
Member
dgarske
left a comment
There was a problem hiding this comment.
That's very noisy when wolfPKCS11_Debugging_On();, but that's probably okay.
- Add standard wolfSSL GPL license header to debug_test.c with 2025 copyright - Fix function brace style (braces on their own lines) - Fix mixed variable declarations (move declarations to top of blocks) - Fix line length violations (break long lines under 80 chars) - Update copyright year in crypto.c from 2023 to 2025 Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
dgarske
requested changes
Jun 20, 2025
- Replace printf with WOLFPKCS11_MSG in wolfPKCS11_Debugging_On() - Replace printf with WOLFPKCS11_MSG in wolfPKCS11_Debugging_Off() - Ensures consistent debug output formatting across all debug functions Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
- Add ## before __VA_ARGS__ to handle empty argument lists - Fixes compilation errors in wolfPKCS11_Debugging_On() and wolfPKCS11_Debugging_Off() - Resolves CI build failures reported by andrew@wolfssl.com Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
- Add no-op versions of wolfPKCS11_Debugging_On() and wolfPKCS11_Debugging_Off() - Functions now exist in both debug and non-debug modes - Addresses andrew@wolfssl.com feedback for consistent API availability Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
- Move wolfPKCS11_Debugging_On() and wolfPKCS11_Debugging_Off() declarations outside #ifdef DEBUG_WOLFPKCS11 block - Functions are now available in both debug and non-debug builds - Addresses feedback from andrew@wolfssl.com Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
- Add new 'debug' job to unit-test.yml with --enable-debug configuration - Ensures debug messaging system is tested in CI - Addresses request from andrew@wolfssl.com Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
dgarske
approved these changes
Jun 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Debug Messaging System to wolfPKCS11
Summary
This PR implements a comprehensive debug messaging system for wolfPKCS11 that provides function enter/exit tracing and parameter logging for public PKCS#11 functions.
Changes Made
Debug Infrastructure
DEBUG_WOLFPKCS11flag support with--enable-debugconfigure optionwolfPKCS11_Debugging_On()andwolfPKCS11_Debugging_Off()functionsWOLFPKCS11_ENTER(),WOLFPKCS11_LEAVE(), andWOLFPKCS11_MSG()macrosDEBUG_WOLFPKCS11is not definedInstrumented Functions
C_GetFunctionList(),C_Initialize(),C_Finalize(),C_GetInfo()C_CreateObject(),C_DestroyObject()with parameter loggingC_GetSlotList(),C_GetSlotInfo(),C_Login()with parameter loggingPublic API
wolfpkcs11/pkcs11.hDEBUG_WOLFPKCS11flagWP11_APIvisibility macro for proper symbol exportTesting
debug_test.cdemonstration program showing debug functionalityDesign Decisions
Following wolfSSL Patterns
wolfcrypt/src/logging.cPrintf Output
printf()by default as requested"WOLFPKCS11 ENTER: function_name"and"WOLFPKCS11 LEAVE: function_name, returning X"C_CreateObject()andC_Login()Conditional Compilation
#ifdef DEBUG_WOLFPKCS11guardsUsage
Build with Debug
Runtime Control
Example Output
Testing
Link to Devin run
https://app.devin.ai/sessions/0600d82de3fc4c0393b0e846643b337a
Requested by
andrew@wolfssl.com