Ignore:
File:
1 edited

Legend:

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

    r31198c12 rb83ba81  
    3737
    3838#include <panic.h>
    39 #include <symtab.h>
     39#include <arch/debug.h>
    4040
    41 #define CALLER  ((uintptr_t) __builtin_return_address(0))
     41#define CALLER ((uintptr_t) __builtin_return_address(0))
    4242
    43 #ifdef CONFIG_DEBUG
     43#ifndef HERE
     44/** Current Instruction Pointer address */
     45#       define HERE ((uintptr_t *) 0)
     46#endif
    4447
    4548/** Debugging ASSERT macro
     
    5255 *
    5356 */
    54 #define ASSERT(expr) \
    55         do { \
    56                 if (!(expr)) \
    57                         panic("Assertion failed (%s)", #expr); \
    58         } while (0)
    59 
    60 /** Debugging verbose ASSERT macro
    61  *
    62  * If CONFIG_DEBUG is set, the ASSERT() macro
    63  * evaluates expr and if it is false raises
    64  * kernel panic. The panic message contains also
    65  * the supplied message.
    66  *
    67  * @param expr Expression which is expected to be true.
    68  * @param msg  Additional message to show (string).
    69  *
    70  */
    71 #define ASSERT_VERBOSE(expr, msg) \
    72         do { \
    73                 if (!(expr)) \
    74                         panic("Assertion failed (%s, %s)", #expr, msg); \
    75         } while (0)
    76 
    77 #else /* CONFIG_DEBUG */
    78 
    79 #define ASSERT(expr)
    80 #define ASSERT_VERBOSE(expr, msg)
    81 
    82 #endif /* CONFIG_DEBUG */
    83 
    84 #ifdef CONFIG_LOG
     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
    8565
    8666/** Extensive logging output macro
     
    9171 *
    9272 */
    93 #define LOG(format, ...) \
    94         do { \
    95                 printf("%s->%s() at %s:%u: " format "\n", symtab_fmt_name_lookup(CALLER), \
    96                     __func__, __FILE__, __LINE__, ##__VA_ARGS__); \
    97         } while (0)
     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
    9881
    9982/** Extensive logging execute macro
     
    10487 *
    10588 */
    106 #define LOG_EXEC(fnc) \
    107         do { \
    108                 printf("%s->%s() at %s:%u: " #fnc "\n", symtab_fmt_name_lookup(CALLER), \
    109                     __func__, __FILE__, __LINE__); \
    110                 fnc; \
    111         } while (0)
    11289
    113 #else /* CONFIG_LOG */
     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
    114100
    115 #define LOG(format, ...)
    116 #define LOG_EXEC(fnc)     fnc
    117 
    118 #endif /* CONFOG_LOG */
    119101
    120102#endif
Note: See TracChangeset for help on using the changeset viewer.