Move cypto debug definitions to debug.h with other susbsystem-level debug

This commit is contained in:
Gregory Nutt
2014-07-03 07:58:43 -06:00
parent bb3dcccd98
commit edb5f312ca
5 changed files with 151 additions and 152 deletions
+2 -16
View File
@@ -44,11 +44,11 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <semaphore.h>
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <semaphore.h>
#include <crypto/crypto.h>
#include <crypto/crypto.h>
#include <arch/board/board.h> #include <arch/board/board.h>
#include <nuttx/arch.h> #include <nuttx/arch.h>
@@ -63,20 +63,6 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
#define CONFIG_DEBUG_CRYPTO
#ifdef CONFIG_DEBUG_CRYPTO
# define cryptdbg lldbg
# ifdef CONFIG_DEBUG_VERBOSE
# define cryptvdbg lldbg
# else
# define cryptvdbg(x...)
# endif
#else
# define cryptdbg(x...)
# define cryptvdbg(x...)
#endif
#define AES_BLOCK_SIZE 16 #define AES_BLOCK_SIZE 16
/**************************************************************************** /****************************************************************************
+2 -2
View File
@@ -76,9 +76,9 @@ void up_cryptoinitialize(void)
#if defined(CONFIG_CRYPTO_ALGTEST) #if defined(CONFIG_CRYPTO_ALGTEST)
res = crypto_test(); res = crypto_test();
if (res) if (res)
cryptdbg("crypto test failed\n"); cryptlldbg("crypto test failed\n");
else else
cryptvdbg("crypto test OK\n"); cryptllvdbg("crypto test OK\n");
#endif #endif
return res; return res;
+2 -2
View File
@@ -78,7 +78,7 @@ static int do_test_aes(FAR struct cipher_testvec* test, int mode, int encrypt)
#define AES_CYPHER_TEST_ENCRYPT(mode, mode_str, count, template) \ #define AES_CYPHER_TEST_ENCRYPT(mode, mode_str, count, template) \
for (i = 0; i < count; i++) { \ for (i = 0; i < count; i++) { \
if (do_test_aes(template + i, mode, CYPHER_ENCRYPT)) { \ if (do_test_aes(template + i, mode, CYPHER_ENCRYPT)) { \
cryptdbg("Failed " mode_str " encrypt test #%i\n", i); \ cryptlldbg("Failed " mode_str " encrypt test #%i\n", i); \
return -1; \ return -1; \
} \ } \
} }
@@ -86,7 +86,7 @@ static int do_test_aes(FAR struct cipher_testvec* test, int mode, int encrypt)
#define AES_CYPHER_TEST_DECRYPT(mode, mode_str, count, template) \ #define AES_CYPHER_TEST_DECRYPT(mode, mode_str, count, template) \
for (i = 0; i < count; i++) { \ for (i = 0; i < count; i++) { \
if (do_test_aes(template + i, mode, CYPHER_DECRYPT)) { \ if (do_test_aes(template + i, mode, CYPHER_DECRYPT)) { \
cryptdbg("Failed " mode_str " decrypt test #%i\n", i); \ cryptlldbg("Failed " mode_str " decrypt test #%i\n", i); \
return -1; \ return -1; \
} \ } \
} }
+2 -14
View File
@@ -60,24 +60,12 @@
#define CYPHER_ENCRYPT 1 #define CYPHER_ENCRYPT 1
#define CYPHER_DECRYPT 0 #define CYPHER_DECRYPT 0
#ifdef CONFIG_DEBUG_CRYPTO
# define cryptdbg lldbg
# ifdef CONFIG_DEBUG_VERBOSE
# define cryptvdbg lldbg
# else
# define cryptvdbg(x...)
# endif
#else
# define cryptdbg(x...)
# define cryptvdbg(x...)
#endif
#ifndef __ASSEMBLY__
/************************************************************************************ /************************************************************************************
* Public Data * Public Data
************************************************************************************/ ************************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN #undef EXTERN
#if defined(__cplusplus) #if defined(__cplusplus)
#define EXTERN extern "C" #define EXTERN extern "C"
+143 -118
View File
@@ -56,9 +56,9 @@
* that the output is not buffered. The first character indicates the * that the output is not buffered. The first character indicates the
* system system (e.g., n=network, f=filesystm, etc.). If the first * system system (e.g., n=network, f=filesystm, etc.). If the first
* character is missing (i.e., dbg()), then it is common. The common * character is missing (i.e., dbg()), then it is common. The common
* dbg() macro is enabled by CONFIG_DEBUG. Subystem debug requires an * dbg() macro is enabled by CONFIG_DEBUG. Subsystem debug requires an
* additional configuration setting to enable it (e.g., CONFIG_DEBUG_NET * additional configuration setting to enable it (e.g., CONFIG_DEBUG_NET
* for the network, CONFIG_DEBUG_FS for the file syste, etc). * for the network, CONFIG_DEBUG_FS for the file system, etc).
* *
* In general, error messages and output of importance use [a-z]dbg(). * In general, error messages and output of importance use [a-z]dbg().
* [a-z]dbg() is implementation dependent but usually uses file descriptors. * [a-z]dbg() is implementation dependent but usually uses file descriptors.
@@ -66,7 +66,7 @@
* directed stdout). Therefore [a-z]dbg() should not be used in interrupt * directed stdout). Therefore [a-z]dbg() should not be used in interrupt
* handlers. * handlers.
* *
* [a-z]vdbg() -- Identifcal to [a-z]dbg() except that it also requires that * [a-z]vdbg() -- Identical to [a-z]dbg() except that it also requires that
* CONFIG_DEBUG_VERBOSE be defined. This is intended for general debug * CONFIG_DEBUG_VERBOSE be defined. This is intended for general debug
* output that you would normally want to suppress. * output that you would normally want to suppress.
* *
@@ -81,7 +81,7 @@
* in low-level code where it is inappropriate to use file descriptors. For * in low-level code where it is inappropriate to use file descriptors. For
* example, only [a-z]lldbg() should be used in interrupt handlers. * example, only [a-z]lldbg() should be used in interrupt handlers.
* *
* [a-z]llvdbg() -- Identifcal to [a-z]lldbg() except that it also requires that * [a-z]llvdbg() -- Identical to [a-z]lldbg() except that it also requires that
* CONFIG_DEBUG_VERBOSE be defined. This is intended for general debug * CONFIG_DEBUG_VERBOSE be defined. This is intended for general debug
* output that you would normally want to suppress. * output that you would normally want to suppress.
*/ */
@@ -224,6 +224,18 @@
# define fllvdbg(x...) # define fllvdbg(x...)
#endif #endif
#ifdef CONFIG_DEBUG_CRYPTO
# define cryptdbg(format, ...) dbg(format, ##__VA_ARGS__)
# define cryptlldbg(format, ...) lldbg(format, ##__VA_ARGS__)
# define cryptvdbg(format, ...) vdbg(format, ##__VA_ARGS__)
# define cryptllvdbg(format, ...) llvdbg(format, ##__VA_ARGS__)
#else
# define cryptdbg(x...)
# define cryptlldbg(x...)
# define cryptvdbg(x...)
# define cryptllvdbg(x...)
#endif
#ifdef CONFIG_DEBUG_INPUT #ifdef CONFIG_DEBUG_INPUT
# define idbg(format, ...) dbg(format, ##__VA_ARGS__) # define idbg(format, ...) dbg(format, ##__VA_ARGS__)
# define illdbg(format, ...) lldbg(format, ##__VA_ARGS__) # define illdbg(format, ...) lldbg(format, ##__VA_ARGS__)
@@ -302,179 +314,191 @@
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
# ifndef CONFIG_ARCH_LOWPUTC # ifndef CONFIG_ARCH_LOWPUTC
# define lldbg (void) # define lldbg (void)
# endif # endif
# ifndef CONFIG_DEBUG_VERBOSE # ifndef CONFIG_DEBUG_VERBOSE
# define vdbg (void) # define vdbg (void)
# define llvdbg (void) # define llvdbg (void)
# else # else
# ifndef CONFIG_ARCH_LOWPUTC # ifndef CONFIG_ARCH_LOWPUTC
# define llvdbg (void) # define llvdbg (void)
# endif # endif
# endif # endif
#else #else
# define dbg (void) # define dbg (void)
# define lldbg (void) # define lldbg (void)
# define vdbg (void) # define vdbg (void)
# define llvdbg (void) # define llvdbg (void)
#endif #endif
/* Subsystem specific debug */ /* Subsystem specific debug */
#ifdef CONFIG_DEBUG_MM #ifdef CONFIG_DEBUG_MM
# define mdbg dbg # define mdbg dbg
# define mlldbg lldbg # define mlldbg lldbg
# define mvdbg vdbg # define mvdbg vdbg
# define mllvdbg llvdbg # define mllvdbg llvdbg
#else #else
# define mdbg (void) # define mdbg (void)
# define mlldbg (void) # define mlldbg (void)
# define mvdbg (void) # define mvdbg (void)
# define mllvdbg (void) # define mllvdbg (void)
#endif #endif
#ifdef CONFIG_DEBUG_SCHED #ifdef CONFIG_DEBUG_SCHED
# define sdbg dbg # define sdbg dbg
# define slldbg lldbg # define slldbg lldbg
# define svdbg vdbg # define svdbg vdbg
# define sllvdbg llvdbg # define sllvdbg llvdbg
#else #else
# define sdbg (void) # define sdbg (void)
# define slldbg (void) # define slldbg (void)
# define svdbg (void) # define svdbg (void)
# define sllvdbg (void) # define sllvdbg (void)
#endif #endif
#ifdef CONFIG_DEBUG_PAGING #ifdef CONFIG_DEBUG_PAGING
# define pgdbg dbg # define pgdbg dbg
# define pglldbg lldbg # define pglldbg lldbg
# define pgvdbg vdbg # define pgvdbg vdbg
# define pgllvdbg llvdbg # define pgllvdbg llvdbg
#else #else
# define pgdbg (void) # define pgdbg (void)
# define pglldbg (void) # define pglldbg (void)
# define pgvdbg (void) # define pgvdbg (void)
# define pgllvdbg (void) # define pgllvdbg (void)
#endif #endif
#ifdef CONFIG_DEBUG_DMA #ifdef CONFIG_DEBUG_DMA
# define dmadbg dbg # define dmadbg dbg
# define dmalldbg lldbg # define dmalldbg lldbg
# define dmavdbg vdbg # define dmavdbg vdbg
# define dmallvdbg llvdbg # define dmallvdbg llvdbg
#else #else
# define dmadbg (void) # define dmadbg (void)
# define dmalldbg (void) # define dmalldbg (void)
# define dmavdbg (void) # define dmavdbg (void)
# define dmallvdbg (void) # define dmallvdbg (void)
#endif #endif
#ifdef CONFIG_DEBUG_NET #ifdef CONFIG_DEBUG_NET
# define ndbg dbg # define ndbg dbg
# define nlldbg lldbg # define nlldbg lldbg
# define nvdbg vdbg # define nvdbg vdbg
# define nllvdbg llvdbg # define nllvdbg llvdbg
#else #else
# define ndbg (void) # define ndbg (void)
# define nlldbg (void) # define nlldbg (void)
# define nvdbg (void) # define nvdbg (void)
# define nllvdbg (void) # define nllvdbg (void)
#endif #endif
#ifdef CONFIG_DEBUG_USB #ifdef CONFIG_DEBUG_USB
# define udbg dbg # define udbg dbg
# define ulldbg lldbg # define ulldbg lldbg
# define uvdbg vdbg # define uvdbg vdbg
# define ullvdbg llvdbg # define ullvdbg llvdbg
#else #else
# define udbg (void) # define udbg (void)
# define ulldbg (void) # define ulldbg (void)
# define uvdbg (void) # define uvdbg (void)
# define ullvdbg (void) # define ullvdbg (void)
#endif #endif
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
# define fdbg dbg # define fdbg dbg
# define flldbg lldbg # define flldbg lldbg
# define fvdbg vdbg # define fvdbg vdbg
# define fllvdbg llvdbg # define fllvdbg llvdbg
#else #else
# define fdbg (void) # define fdbg (void)
# define flldbg (void) # define flldbg (void)
# define fvdbg (void) # define fvdbg (void)
# define fllvdbg (void) # define fllvdbg (void)
#endif
#ifdef CONFIG_DEBUG_CRYPTO
# define cryptdbg dbg
# define cryptlldbg lldbg
# define cryptvdbg vdbg
# define cryptllvdbg llvdbg
#else
# define cryptdbg (void)
# define cryptlldbg (void)
# define cryptvdbg (void)
# define cryptllvdbg (void)
#endif #endif
#ifdef CONFIG_DEBUG_INPUT #ifdef CONFIG_DEBUG_INPUT
# define idbg dbg # define idbg dbg
# define illdbg lldbg # define illdbg lldbg
# define ivdbg vdbg # define ivdbg vdbg
# define illvdbg llvdbg # define illvdbg llvdbg
#else #else
# define idbg (void) # define idbg (void)
# define illdbg (void) # define illdbg (void)
# define ivdbg (void) # define ivdbg (void)
# define illvdbg (void) # define illvdbg (void)
#endif #endif
#ifdef CONFIG_DEBUG_ANALOG #ifdef CONFIG_DEBUG_ANALOG
# define adbg dbg # define adbg dbg
# define alldbg lldbg # define alldbg lldbg
# define avdbg vdbg # define avdbg vdbg
# define allvdbg llvdbg # define allvdbg llvdbg
#else #else
# define adbg (void) # define adbg (void)
# define alldbg (void) # define alldbg (void)
# define avdbg (void) # define avdbg (void)
# define allvdbg (void) # define allvdbg (void)
#endif #endif
#ifdef CONFIG_DEBUG_GRAPHICS #ifdef CONFIG_DEBUG_GRAPHICS
# define gdbg dbg # define gdbg dbg
# define glldbg lldbg # define glldbg lldbg
# define gvdbg vdbg # define gvdbg vdbg
# define gllvdbg llvdbg # define gllvdbg llvdbg
#else #else
# define gdbg (void) # define gdbg (void)
# define glldbg (void) # define glldbg (void)
# define gvdbg (void) # define gvdbg (void)
# define gllvdbg (void) # define gllvdbg (void)
#endif #endif
#ifdef CONFIG_DEBUG_BINFMT #ifdef CONFIG_DEBUG_BINFMT
# define bdbg dbg # define bdbg dbg
# define blldbg lldbg # define blldbg lldbg
# define bvdbg vdbg # define bvdbg vdbg
# define bllvdbg llvdbg # define bllvdbg llvdbg
#else #else
# define bdbg (void) # define bdbg (void)
# define blldbg (void) # define blldbg (void)
# define bvdbg (void) # define bvdbg (void)
# define bllvdbg (void) # define bllvdbg (void)
#endif #endif
#ifdef CONFIG_DEBUG_LIB #ifdef CONFIG_DEBUG_LIB
# define ldbg dbg # define ldbg dbg
# define llldbg lldbg # define llldbg lldbg
# define lvdbg vdbg # define lvdbg vdbg
# define lllvdbg llvdbg # define lllvdbg llvdbg
#else #else
# define ldbg (void) # define ldbg (void)
# define llldbg (void) # define llldbg (void)
# define lvdbg (void) # define lvdbg (void)
# define lllvdbg (void) # define lllvdbg (void)
#endif #endif
#ifdef CONFIG_DEBUG_AUDIO #ifdef CONFIG_DEBUG_AUDIO
# define auddbg dbg # define auddbg dbg
# define audlldbg lldbg # define audlldbg lldbg
# define audvdbg vdbg # define audvdbg vdbg
# define audllvdbg llvdbg # define audllvdbg llvdbg
#else #else
# define auddbg (void) # define auddbg (void)
# define audlldbg (void) # define audlldbg (void)
# define audvdbg (void) # define audvdbg (void)
# define audllvdbg (void) # define audllvdbg (void)
#endif #endif
#endif /* CONFIG_CPP_HAVE_VARARGS */ #endif /* CONFIG_CPP_HAVE_VARARGS */
@@ -610,9 +634,10 @@ extern "C"
/* Dump a buffer of data */ /* Dump a buffer of data */
void lib_dumpbuffer(FAR const char *msg, FAR const uint8_t *buffer, unsigned int buflen); void lib_dumpbuffer(FAR const char *msg, FAR const uint8_t *buffer,
unsigned int buflen);
/* The system logging interfaces are pnormally accessed via the macros /* The system logging interfaces are normally accessed via the macros
* provided above. If the cross-compiler's C pre-processor supports a * provided above. If the cross-compiler's C pre-processor supports a
* variable number of macro arguments, then those macros below will map all * variable number of macro arguments, then those macros below will map all
* debug statements to the logging interfaces declared in syslog.h. * debug statements to the logging interfaces declared in syslog.h.