Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset b060ca9 in mainline


Ignore:
Timestamp:
2010-05-20T16:01:00Z (11 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
b10e6e31
Parents:
9e56e65
Message:

add verbose ASSERT macro
cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/debug.h

    r9e56e65 rb060ca9  
    3939#include <arch/debug.h>
    4040
    41 #define CALLER ((uintptr_t) __builtin_return_address(0))
     41#define CALLER  ((uintptr_t) __builtin_return_address(0))
     42
    4243
    4344#ifndef HERE
     45
    4446/** Current Instruction Pointer address */
    45 #       define HERE ((uintptr_t *) 0)
    46 #endif
     47#define HERE ((uintptr_t *) 0)
     48
     49#endif /* HERE */
     50
     51
     52#ifdef CONFIG_DEBUG
    4753
    4854/** Debugging ASSERT macro
     
    5561 *
    5662 */
    57 #ifdef CONFIG_DEBUG
    58 #       define ASSERT(expr) \
    59                 if (!(expr)) { \
    60                         panic("Assertion failed (%s), caller=%p.", #expr, CALLER); \
    61                 }
    62 #else
    63 #       define ASSERT(expr)
    64 #endif
     63#define ASSERT(expr) \
     64        if (!(expr)) { \
     65                panic("Assertion failed (%s), caller=%p.", #expr, CALLER); \
     66        }
     67
     68/** Debugging verbose ASSERT macro
     69 *
     70 * If CONFIG_DEBUG is set, the ASSERT() macro
     71 * evaluates expr and if it is false raises
     72 * kernel panic. The panic message contains also
     73 * the supplied message.
     74 *
     75 * @param expr Expression which is expected to be true.
     76 * @param msg  Additional message to show (string).
     77 *
     78 */
     79#define ASSERT_VERBOSE(expr, msg) \
     80        if (!(expr)) { \
     81                panic("Assertion failed (%s, %s), caller=%p.", #expr, msg, CALLER); \
     82        }
     83
     84#else /* CONFIG_DEBUG */
     85
     86#define ASSERT(expr)
     87#define ASSERT_VERBOSE(expr, msg)
     88
     89#endif /* CONFIG_DEBUG */
     90
     91
     92#ifdef CONFIG_LOG
    6593
    6694/** Extensive logging output macro
     
    7199 *
    72100 */
    73 
    74 #ifdef CONFIG_LOG
    75 #       define LOG(format, ...) \
    76                 printf("%s() at %s:%u: " format "\n", __func__, __FILE__, \
    77                     __LINE__, ##__VA_ARGS__);
    78 #else
    79 #       define LOG(format, ...)
    80 #endif
     101#define LOG(format, ...) \
     102        printf("%s() at %s:%u: " format "\n", __func__, __FILE__, \
     103            __LINE__, ##__VA_ARGS__);
    81104
    82105/** Extensive logging execute macro
     
    87110 *
    88111 */
     112#define LOG_EXEC(fnc) \
     113        { \
     114                printf("%s() at %s:%u: " #fnc "\n", __func__, __FILE__, \
     115                    __LINE__); \
     116                fnc; \
     117        }
     118       
     119#else /* CONFOG_LOG */
    89120
    90 #ifdef CONFIG_LOG
    91 #       define LOG_EXEC(fnc) \
    92                 { \
    93                         printf("%s() at %s:%u: " #fnc "\n", __func__, __FILE__, \
    94                             __LINE__); \
    95                         fnc; \
    96                 }
    97 #else
    98 #       define LOG_EXEC(fnc) fnc
    99 #endif
     121#define LOG(format, ...)
     122#define LOG_EXEC(fnc) fnc
    100123
     124#endif /* CONFOG_LOG */
    101125
    102126#endif
Note: See TracChangeset for help on using the changeset viewer.